Skip to content

Commit 5e16608

Browse files
authored
Merge pull request #113 from magento-api/merged-prs
Combined PRs
2 parents e7ab10a + 86bca45 commit 5e16608

File tree

48 files changed

+1412
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1412
-275
lines changed

app/code/Magento/Backup/Model/Fs/Collection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ protected function _generateRow($filename)
110110
$row[$key] = $value;
111111
}
112112
$row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
113-
$row['id'] = $row['time'] . '_' . $row['type'];
113+
if (isset($row['display_name']) && $row['display_name'] == '') {
114+
$row['display_name'] = 'WebSetupWizard';
115+
}
116+
$row['id'] = $row['time'] . '_' . $row['type'] . (isset($row['display_name']) ? $row['display_name'] : '');
114117
return $row;
115118
}
116119
}

app/code/Magento/CatalogImportExport/Model/Export/Product.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
8585
*/
8686
protected $_indexValueAttributes = [
8787
'status',
88-
'gift_message_available',
8988
];
9089

9190
/**

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
196196
protected $_indexValueAttributes = [
197197
'status',
198198
'tax_class_id',
199-
'gift_message_available',
200199
];
201200

202201
/**

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99
namespace Magento\CatalogWidget\Block\Product;
1010

11+
use Magento\Framework\DataObject\IdentityInterface;
12+
use Magento\Widget\Block\BlockInterface;
13+
1114
/**
1215
* Catalog Products List widget block
1316
* Class ProductsList
1417
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1518
*/
16-
class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implements \Magento\Widget\Block\BlockInterface
19+
class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implements BlockInterface, IdentityInterface
1720
{
1821
/**
1922
* Default value for products count that will be shown
@@ -327,7 +330,16 @@ public function getPagerHtml()
327330
*/
328331
public function getIdentities()
329332
{
330-
return [\Magento\Catalog\Model\Product::CACHE_TAG];
333+
$identities = [];
334+
if ($this->getProductCollection()) {
335+
foreach ($this->getProductCollection() as $product) {
336+
if ($product instanceof IdentityInterface) {
337+
$identities = array_merge($identities, $product->getIdentities());
338+
}
339+
}
340+
}
341+
342+
return $identities ?: [\Magento\Catalog\Model\Product::CACHE_TAG];
331343
}
332344

333345
/**

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,10 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
261261
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
262262
$this->productsList->setData('conditions_encoded', 'some_serialized_conditions');
263263

264-
$conditions = $this->getMockBuilder('\Magento\Rule\Model\Condition\Combine')
265-
->setMethods(['collectValidatedAttributes'])
266-
->disableOriginalConstructor()
267-
->getMock();
268-
$conditions->expects($this->once())->method('collectValidatedAttributes')
269-
->with($collection)
270-
->willReturnSelf();
271-
272264
$this->builder->expects($this->once())->method('attachConditionToCollection')
273-
->with($collection, $conditions)
265+
->with($collection, $this->getConditionsForCollection($collection))
274266
->willReturnSelf();
275267

276-
$this->rule->expects($this->once())->method('loadPost')->willReturnSelf();
277-
$this->rule->expects($this->once())->method('getConditions')->willReturn($conditions);
278-
279268
if ($productsPerPage) {
280269
$this->productsList->setData('products_per_page', $productsPerPage);
281270
} else {
@@ -333,7 +322,44 @@ public function testShowPager()
333322

334323
public function testGetIdentities()
335324
{
336-
$this->assertEquals([\Magento\Catalog\Model\Product::CACHE_TAG], $this->productsList->getIdentities());
325+
$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Collection')
326+
->setMethods([
327+
'addAttributeToSelect',
328+
'getIterator',
329+
])->disableOriginalConstructor()
330+
->getMock();
331+
332+
$product = $this->getMock('Magento\Framework\DataObject\IdentityInterface', ['getIdentities']);
333+
$notProduct = $this->getMock('NotProduct', ['getIdentities']);
334+
$product->expects($this->once())->method('getIdentities')->willReturn(['product_identity']);
335+
$collection->expects($this->once())->method('getIterator')->willReturn(
336+
new \ArrayIterator([$product, $notProduct])
337+
);
338+
$this->productsList->setData('product_collection', $collection);
339+
340+
$this->assertEquals(
341+
['product_identity'],
342+
$this->productsList->getIdentities()
343+
);
344+
}
345+
346+
/**
347+
* @param $collection
348+
* @return \PHPUnit_Framework_MockObject_MockObject
349+
*/
350+
private function getConditionsForCollection($collection)
351+
{
352+
$conditions = $this->getMockBuilder('\Magento\Rule\Model\Condition\Combine')
353+
->setMethods(['collectValidatedAttributes'])
354+
->disableOriginalConstructor()
355+
->getMock();
356+
$conditions->expects($this->once())->method('collectValidatedAttributes')
357+
->with($collection)
358+
->willReturnSelf();
359+
360+
$this->rule->expects($this->once())->method('loadPost')->willReturnSelf();
361+
$this->rule->expects($this->once())->method('getConditions')->willReturn($conditions);
362+
return $conditions;
337363
}
338364

339365
public function testGetTitle()
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Block\Adminhtml\Order\Create;
7+
8+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
9+
10+
class Sidebar
11+
{
12+
/**
13+
* Get item qty
14+
*
15+
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
16+
* @param \Closure $proceed
17+
* @param \Magento\Framework\DataObject $item
18+
* @return string
19+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
20+
*/
21+
public function aroundGetItemQty(
22+
\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject,
23+
\Closure $proceed,
24+
\Magento\Framework\DataObject $item
25+
) {
26+
if ($item->getProduct()->getTypeId() == Configurable::TYPE_CODE) {
27+
return '';
28+
}
29+
return $proceed($item);
30+
}
31+
32+
/**
33+
* Check whether product configuration is required before adding to order
34+
*
35+
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
36+
* @param \Closure $proceed
37+
* @param string $productType
38+
* @return bool
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
40+
*/
41+
public function aroundIsConfigurationRequired(
42+
\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject,
43+
\Closure $proceed,
44+
$productType
45+
) {
46+
if ($productType == Configurable::TYPE_CODE) {
47+
return true;
48+
}
49+
return $proceed($productType);
50+
}
51+
}

app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ class VariationHandler
2929
/** @var \Magento\Catalog\Model\ProductFactory */
3030
protected $productFactory;
3131

32-
/** @var \Magento\CatalogInventory\Api\StockConfigurationInterface */
32+
/**
33+
* @var \Magento\CatalogInventory\Api\StockConfigurationInterface
34+
* @deprecated
35+
*/
3336
protected $stockConfiguration;
3437

3538
/**
@@ -168,14 +171,10 @@ protected function fillSimpleProductData(
168171

169172
$keysFilter = ['item_id', 'product_id', 'stock_id', 'type_id', 'website_id'];
170173
$postData['stock_data'] = array_diff_key((array)$parentProduct->getStockData(), array_flip($keysFilter));
171-
$postData['stock_data']['manage_stock'] = $postData['quantity_and_stock_status']['qty'] === '' ? 0 : 1;
172174
if (!isset($postData['stock_data']['is_in_stock'])) {
173175
$stockStatus = $parentProduct->getQuantityAndStockStatus();
174176
$postData['stock_data']['is_in_stock'] = $stockStatus['is_in_stock'];
175177
}
176-
$configDefaultValue = $this->stockConfiguration->getManageStock($product->getStoreId());
177-
$postData['stock_data']['use_config_manage_stock'] = $postData['stock_data']['manage_stock'] ==
178-
$configDefaultValue ? 1 : 0;
179178
$postData = $this->processMediaGallery($product, $postData);
180179
$postData['status'] = isset($postData['status'])
181180
? $postData['status']

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/VariationHandlerTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,6 @@ public function testGenerateSimpleProducts()
254254
$parentProductMock->expects($this->once())
255255
->method('getQuantityAndStockStatus')
256256
->willReturn(['is_in_stock' => 1]);
257-
$newSimpleProductMock->expects($this->once())->method('getStoreId')->willReturn('store_id');
258-
$this->stockConfiguration->expects($this->once())
259-
->method('getManageStock')
260-
->with('store_id')
261-
->willReturn(1);
262257
$newSimpleProductMock->expects($this->once())->method('addData')->willReturnSelf();
263258
$parentProductMock->expects($this->once())->method('getWebsiteIds')->willReturn('website_id');
264259
$newSimpleProductMock->expects($this->once())->method('setWebsiteIds')->with('website_id')->willReturnSelf();

app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<type name="Magento\Catalog\Model\Product\Validator">
1717
<plugin name="configurable" type="Magento\ConfigurableProduct\Model\Product\Validator\Plugin" sortOrder="50" />
1818
</type>
19+
<type name="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar">
20+
<plugin name="configurable" type="Magento\ConfigurableProduct\Block\Adminhtml\Order\Create\Sidebar" sortOrder="200"/>
21+
</type>
1922
<type name="Magento\ConfigurableProduct\Block\Adminhtml\Product\Attribute\Edit\Tab\Variations\Main">
2023
<arguments>
2124
<argument name="inputTypeFactory" xsi:type="object">Magento\Catalog\Model\System\Config\Source\InputtypeFactory</argument>

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ define([
8181
options: options,
8282
images: images,
8383
sku: sku,
84+
name: sku,
8485
quantity: quantity,
8586
price: price,
8687
productId: productId,
@@ -91,6 +92,7 @@ define([
9192
if (productId) {
9293
variation.sku = product.sku;
9394
variation.weight = product.weight;
95+
variation.name = product.name;
9496
gridExisting.push(this.prepareRowForGrid(variation));
9597
} else {
9698
gridNew.push(this.prepareRowForGrid(variation));

0 commit comments

Comments
 (0)