Skip to content

Commit d110f47

Browse files
author
Hayder Sharhan
committed
Merge remote-tracking branch 'remotes/origin/develop' into bug-fixes
2 parents cf003c0 + f227f6a commit d110f47

File tree

54 files changed

+1264
-205
lines changed

Some content is hidden

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

54 files changed

+1264
-205
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/Model/Category/DataProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,11 @@ public function getDefaultMetaData($result)
384384
$result['use_config.default_sort_by']['default'] = true;
385385
$result['use_config.filter_price_range']['default'] = true;
386386
if ($this->request->getParam('store') && $this->request->getParam('id')) {
387+
$result['use_default.url_key']['checked'] = true;
387388
$result['use_default.url_key']['default'] = true;
388389
$result['use_default.url_key']['visible'] = true;
389390
} else {
391+
$result['use_default.url_key']['checked'] = false;
390392
$result['use_default.url_key']['default'] = false;
391393
$result['use_default.url_key']['visible'] = false;
392394
}

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/Catalog/view/adminhtml/web/js/components/url-key-handle-changes.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,36 @@
44
*/
55

66
define([
7-
'Magento_Ui/js/form/element/abstract'
8-
], function (Abstract) {
7+
'Magento_Ui/js/form/element/single-checkbox'
8+
], function (Checkbox) {
99
'use strict';
1010

11-
return Abstract.extend({
11+
return Checkbox.extend({
12+
defaults: {
13+
imports: {
14+
handleUseDefault: '${ $.parentName }.use_default.url_key:checked',
15+
urlKey: '${ $.provider }:data.url_key'
16+
},
17+
listens: {
18+
urlKey: 'handleChanges'
19+
},
20+
modules: {
21+
useDefault: '${ $.parentName }.use_default.url_key'
22+
}
23+
},
1224

1325
/**
14-
* Disable checkbox field, when 'url_key' field without changes
26+
* Disable checkbox field, when 'url_key' field without changes or 'use default' field is checked
1527
*/
1628
handleChanges: function (newValue) {
17-
if (newValue !== this.getInitialValue()) {
18-
this.disabled(false);
19-
} else {
20-
this.disabled(true);
21-
}
29+
this.disabled(newValue === this.valueMap['true'] || this.useDefault.checked);
2230
},
2331

2432
/**
25-
* Set real 'url_key' to 'url_key_create_redirect' when field is checked
33+
* Disable checkbox field, when 'url_key' field without changes or 'use default' field is checked
2634
*/
27-
onUpdate: function () {
28-
this._super();
29-
30-
if (this.value()) {
31-
this.value(this.initialValue);
32-
} else {
33-
this.value(0);
34-
}
35-
this._super();
35+
handleUseDefault: function (checkedUseDefault) {
36+
this.disabled(this.urlKey === this.valueMap['true'] || checkedUseDefault);
3637
}
3738
});
3839
});

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;

0 commit comments

Comments
 (0)