Skip to content

Commit c00880b

Browse files
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into MAGETWO-48223
2 parents 4da6c42 + 357713e commit c00880b

File tree

31 files changed

+747
-50
lines changed

31 files changed

+747
-50
lines changed

app/code/Magento/Catalog/Block/Product/Widget/NewWidget.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class NewWidget extends \Magento\Catalog\Block\Product\NewProduct implements \Ma
3232

3333
/**
3434
* Name of request parameter for page number value
35+
*
36+
* @deprecated
3537
*/
3638
const PAGE_VAR_NAME = 'np';
3739

@@ -88,7 +90,7 @@ protected function _getRecentlyAddedProductsCollection()
8890
*/
8991
public function getCurrentPage()
9092
{
91-
return abs((int)$this->getRequest()->getParam(self::PAGE_VAR_NAME));
93+
return abs((int)$this->getRequest()->getParam($this->getData('page_var_name')));
9294
}
9395

9496
/**
@@ -103,7 +105,8 @@ public function getCacheKeyInfo()
103105
[
104106
$this->getDisplayType(),
105107
$this->getProductsPerPage(),
106-
intval($this->getRequest()->getParam(self::PAGE_VAR_NAME))
108+
intval($this->getRequest()->getParam($this->getData('page_var_name'), 1)),
109+
serialize($this->getRequest()->getParams())
107110
]
108111
);
109112
}
@@ -187,7 +190,7 @@ public function getPagerHtml()
187190
$this->_pager->setUseContainer(true)
188191
->setShowAmounts(true)
189192
->setShowPerPage(false)
190-
->setPageVarName(self::PAGE_VAR_NAME)
193+
->setPageVarName($this->getData('page_var_name'))
191194
->setLimit($this->getProductsPerPage())
192195
->setTotalLimit($this->getProductsCount())
193196
->setCollection($this->getProductCollection());

app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributeSets.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
class SuggestAttributeSets extends \Magento\Backend\App\Action
1010
{
11+
/**
12+
* Authorization level of a basic admin session
13+
*
14+
* @see _isAllowed()
15+
*/
16+
const ADMIN_RESOURCE = 'Magento_Catalog::sets';
17+
1118
/**
1219
* @var \Magento\Framework\Controller\Result\JsonFactory
1320
*/

app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66
*/
77
namespace Magento\Catalog\Controller\Adminhtml\Product;
88

9-
class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product
9+
class SuggestAttributes extends \Magento\Backend\App\Action
1010
{
11+
/**
12+
* Authorization level of a basic admin session
13+
*
14+
* @see _isAllowed()
15+
*/
16+
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
17+
1118
/**
1219
* @var \Magento\Framework\Controller\Result\JsonFactory
1320
*/
@@ -20,17 +27,15 @@ class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product
2027

2128
/**
2229
* @param \Magento\Backend\App\Action\Context $context
23-
* @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder
2430
* @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
2531
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
2632
*/
2733
public function __construct(
2834
\Magento\Backend\App\Action\Context $context,
29-
\Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder,
3035
\Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
3136
\Magento\Framework\View\LayoutFactory $layoutFactory
3237
) {
33-
parent::__construct($context, $productBuilder);
38+
parent::__construct($context);
3439
$this->resultJsonFactory = $resultJsonFactory;
3540
$this->layoutFactory = $layoutFactory;
3641
}

app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ public function testGetProductPriceHtml()
144144
*/
145145
public function testGetCurrentPage($pageNumber, $expectedResult)
146146
{
147+
$this->block->setData('page_var_name', 'page_number');
148+
147149
$this->requestMock->expects($this->any())
148150
->method('getParam')
149-
->with(\Magento\Catalog\Block\Product\Widget\NewWidget::PAGE_VAR_NAME)
151+
->with('page_number')
150152
->willReturn($pageNumber);
151153

152154
$this->assertEquals($expectedResult, $this->block->getCurrentPage());

app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,8 @@
234234
<argument name="data" xsi:type="array">
235235
<item name="options" xsi:type="object">Magento\Store\Model\ResourceModel\Website\Collection</item>
236236
<item name="config" xsi:type="array">
237-
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
238237
<item name="add_field" xsi:type="boolean">true</item>
239-
<item name="dataType" xsi:type="string">select</item>
238+
<item name="dataType" xsi:type="string">text</item>
240239
<item name="label" xsi:type="string" translate="true">Websites</item>
241240
<item name="sortOrder" xsi:type="number">100</item>
242241
</item>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,11 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
695695
[],
696696
[
697697
'related_skus',
698+
'related_position',
698699
'crosssell_skus',
700+
'crosssell_position',
699701
'upsell_skus',
702+
'upsell_position'
700703
],
701704
['additional_images', 'additional_image_labels', 'hide_from_product_page']
702705
);
@@ -1113,6 +1116,8 @@ protected function addMultirowData($dataRow, $multiRawData)
11131116
asort($associations);
11141117
$dataRow[$colPrefix . 'skus'] =
11151118
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, array_keys($associations));
1119+
$dataRow[$colPrefix . 'position'] =
1120+
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, array_values($associations));
11161121
}
11171122
}
11181123
$dataRow = $this->rowCustomizer->addData($dataRow, $productId);

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

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
294294
'max_sale_qty' => 'max_cart_qty',
295295
'notify_stock_qty' => 'notify_on_stock_below',
296296
'_related_sku' => 'related_skus',
297+
'_related_position' => 'related_position',
297298
'_crosssell_sku' => 'crosssell_skus',
299+
'_crosssell_position' => 'crosssell_position',
298300
'_upsell_sku' => 'upsell_skus',
301+
'_upsell_position' => 'upsell_position',
299302
'meta_keyword' => 'meta_keywords',
300303
];
301304

@@ -1102,13 +1105,27 @@ protected function _saveLinks()
11021105

11031106
$sku = $rowData[self::COL_SKU];
11041107

1108+
$productId = $this->skuProcessor->getNewSku($sku)[$this->getProductEntityLinkField()];
1109+
$productLinkKeys = [];
1110+
$select = $this->_connection->select()->from(
1111+
$resource->getTable('catalog_product_link'),
1112+
['id' => 'link_id', 'linked_id' => 'linked_product_id', 'link_type_id' => 'link_type_id']
1113+
)->where(
1114+
'product_id = :product_id'
1115+
);
1116+
$bind = [':product_id' => $productId];
1117+
foreach ($this->_connection->fetchAll($select, $bind) as $linkData) {
1118+
$linkKey = "{$productId}-{$linkData['linked_id']}-{$linkData['link_type_id']}";
1119+
$productLinkKeys[$linkKey] = $linkData['id'];
1120+
}
11051121
foreach ($this->_linkNameToId as $linkName => $linkId) {
1106-
$productId = $this->skuProcessor->getNewSku($sku)[$this->getProductEntityLinkField()];
11071122
$productIds[] = $productId;
11081123
if (isset($rowData[$linkName . 'sku'])) {
11091124
$linkSkus = explode($this->getMultipleValueSeparator(), $rowData[$linkName . 'sku']);
1110-
1111-
foreach ($linkSkus as $linkedSku) {
1125+
$linkPositions = !empty($rowData[$linkName . 'position'])
1126+
? explode($this->getMultipleValueSeparator(), $rowData[$linkName . 'position'])
1127+
: [];
1128+
foreach ($linkSkus as $linkedKey => $linkedSku) {
11121129
$linkedSku = trim($linkedSku);
11131130
if ((!is_null(
11141131
$this->skuProcessor->getNewSku($linkedSku)
@@ -1143,19 +1160,21 @@ protected function _saveLinks()
11431160
}
11441161

11451162
$linkKey = "{$productId}-{$linkedId}-{$linkId}";
1146-
1163+
if(empty($productLinkKeys[$linkKey])) {
1164+
$productLinkKeys[$linkKey] = $nextLinkId;
1165+
}
11471166
if (!isset($linkRows[$linkKey])) {
11481167
$linkRows[$linkKey] = [
1149-
'link_id' => $nextLinkId,
1168+
'link_id' => $productLinkKeys[$linkKey],
11501169
'product_id' => $productId,
11511170
'linked_product_id' => $linkedId,
11521171
'link_type_id' => $linkId,
11531172
];
1154-
if (!empty($rowData[$linkName . 'position'])) {
1173+
if (!empty($linkPositions[$linkedKey])) {
11551174
$positionRows[] = [
1156-
'link_id' => $nextLinkId,
1175+
'link_id' => $productLinkKeys[$linkKey],
11571176
'product_link_attribute_id' => $positionAttrId[$linkId],
1158-
'value' => $rowData[$linkName . 'position'],
1177+
'value' => $linkPositions[$linkedKey],
11591178
];
11601179
}
11611180
$nextLinkId++;
@@ -1176,7 +1195,10 @@ protected function _saveLinks()
11761195
}
11771196
if ($positionRows) {
11781197
// process linked product positions
1179-
$this->_connection->insertOnDuplicate($resource->getAttributeTypeTable('int'), $positionRows, ['value']);
1198+
$this->_connection->insertOnDuplicate(
1199+
$resource->getAttributeTypeTable('int'),
1200+
$positionRows, ['value']
1201+
);
11801202
}
11811203
}
11821204
return $this;

app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class AfterImportDataObserver implements ObserverInterface
5151
/** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry */
5252
protected $productCategories;
5353

54+
/** @var UrlFinderInterface */
55+
protected $urlFinder;
56+
5457
/** @var \Magento\Store\Model\StoreManagerInterface */
5558
protected $storeManager;
5659

@@ -353,14 +356,10 @@ protected function currentUrlRewritesRegenerate()
353356
if ($category === false) {
354357
continue;
355358
}
356-
if ($currentUrlRewrite->getIsAutogenerated()) {
357-
$urlRewrite = $this->generateForAutogenerated($currentUrlRewrite, $category);
358-
} else {
359-
$urlRewrite = $this->generateForCustom($currentUrlRewrite, $category);
360-
}
361-
if ($urlRewrite) {
362-
$urlRewrites[] = $urlRewrite;
363-
}
359+
$url = $currentUrlRewrite->getIsAutogenerated()
360+
? $this->generateForAutogenerated($currentUrlRewrite, $category)
361+
: $this->generateForCustom($currentUrlRewrite, $category);
362+
$urlRewrites = array_merge($urlRewrites, $url);
364363
}
365364

366365
$this->product = null;

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem
2222

2323
/**
2424
* Name of request parameter for page number value
25+
*
26+
* @deprecated
2527
*/
2628
const PAGE_VAR_NAME = 'np';
2729

@@ -142,9 +144,10 @@ public function getCacheKeyInfo()
142144
$this->_storeManager->getStore()->getId(),
143145
$this->_design->getDesignTheme()->getId(),
144146
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
145-
intval($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1)),
147+
intval($this->getRequest()->getParam($this->getData('page_var_name'), 1)),
146148
$this->getProductsPerPage(),
147-
$conditions
149+
$conditions,
150+
serialize($this->getRequest()->getParams())
148151
];
149152
}
150153

@@ -208,7 +211,7 @@ public function createCollection()
208211
$collection = $this->_addProductAttributesAndPrices($collection)
209212
->addStoreFilter()
210213
->setPageSize($this->getPageSize())
211-
->setCurPage($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1));
214+
->setCurPage($this->getRequest()->getParam($this->getData('page_var_name'), 1));
212215

213216
$conditions = $this->getConditions();
214217
$conditions->collectValidatedAttributes($collection);
@@ -305,7 +308,7 @@ public function getPagerHtml()
305308
$this->pager->setUseContainer(true)
306309
->setShowAmounts(true)
307310
->setShowPerPage(false)
308-
->setPageVarName(self::PAGE_VAR_NAME)
311+
->setPageVarName($this->getData('page_var_name'))
309312
->setLimit($this->getProductsPerPage())
310313
->setTotalLimit($this->getProductsCount())
311314
->setCollection($this->getProductCollection());

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,21 @@ public function testGetCacheKeyInfo()
126126
$this->httpContext->expects($this->once())->method('getValue')->willReturn('context_group');
127127
$this->productsList->setData('conditions', 'some_serialized_conditions');
128128

129-
$this->request->expects($this->once())->method('getParam')->with('np')->willReturn(1);
130-
131-
$cacheKey = ['CATALOG_PRODUCTS_LIST_WIDGET', 1, 'blank', 'context_group', 1, 5, 'some_serialized_conditions'];
129+
$this->productsList->setData('page_var_name', 'page_number');
130+
$this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1);
131+
132+
$this->request->expects($this->once())->method('getParams')->willReturn('request_params');
133+
134+
$cacheKey = [
135+
'CATALOG_PRODUCTS_LIST_WIDGET',
136+
1,
137+
'blank',
138+
'context_group',
139+
1,
140+
5,
141+
'some_serialized_conditions',
142+
serialize('request_params')
143+
];
132144
$this->assertEquals($cacheKey, $this->productsList->getCacheKeyInfo());
133145
}
134146

@@ -264,7 +276,6 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
264276
$this->rule->expects($this->once())->method('loadPost')->willReturnSelf();
265277
$this->rule->expects($this->once())->method('getConditions')->willReturn($conditions);
266278

267-
268279
if ($productsPerPage) {
269280
$this->productsList->setData('products_per_page', $productsPerPage);
270281
} else {

app/code/Magento/Review/Model/Review.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public function getEntityIdByCode($entityCode)
374374
public function getIdentities()
375375
{
376376
$tags = [];
377-
if ($this->isApproved() && $this->getEntityPkValue()) {
377+
if ($this->getEntityPkValue()) {
378378
$tags[] = Product::CACHE_TAG . '_' . $this->getEntityPkValue();
379379
}
380380
return $tags;

app/code/Magento/Review/Test/Unit/Model/ReviewTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,16 @@ public function testGetIdentities()
278278
$this->assertEmpty($this->review->getIdentities());
279279

280280
$productId = 1;
281+
$this->review->setEntityPkValue($productId);
282+
$this->review->setStatusId(Review::STATUS_PENDING);
283+
$this->assertEquals([Product::CACHE_TAG . '_' . $productId], $this->review->getIdentities());
284+
281285
$this->review->setEntityPkValue($productId);
282286
$this->review->setStatusId(Review::STATUS_APPROVED);
283287
$this->assertEquals([Product::CACHE_TAG . '_' . $productId], $this->review->getIdentities());
288+
289+
$this->review->setEntityPkValue($productId);
290+
$this->review->setStatusId(Review::STATUS_NOT_APPROVED);
291+
$this->assertEquals([Product::CACHE_TAG . '_' . $productId], $this->review->getIdentities());
284292
}
285293
}

app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function getHtmlOutput()
3939
*/
4040
protected function getSwatchAttributesData()
4141
{
42+
$result = [];
4243
$swatchAttributeData = parent::getSwatchAttributesData();
4344
foreach ($swatchAttributeData as $attributeId => $item) {
4445
if (!empty($item['used_in_product_listing'])) {

app/code/Magento/Swatches/Model/Plugin/EavAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ protected function prepareOptionIds(array $optionsArray)
174174
{
175175
if (isset($optionsArray['value']) && is_array($optionsArray['value'])) {
176176
foreach (array_keys($optionsArray['value']) as $optionId) {
177-
if ($optionsArray['delete'][$optionId] == 1) {
177+
if (isset($optionsArray['delete']) && $optionsArray['delete'][$optionId] == 1) {
178178
unset($optionsArray['value'][$optionId]);
179179
}
180180
}

0 commit comments

Comments
 (0)