Skip to content

Commit eea5626

Browse files
committed
Merge branch 'MC-21828' into 2.3-develop-com-pr13
2 parents fd8db61 + 8c24a56 commit eea5626

File tree

68 files changed

+3481
-189
lines changed

Some content is hidden

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

68 files changed

+3481
-189
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Action.php

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\ResourceModel\Product;
77

8+
use Magento\Catalog\Api\Data\ProductInterface;
89
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
910

1011
/**
@@ -14,6 +15,32 @@
1415
*/
1516
class Action extends \Magento\Catalog\Model\ResourceModel\AbstractResource
1617
{
18+
/**
19+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
20+
*/
21+
private $dateTime;
22+
23+
/**
24+
* @param \Magento\Eav\Model\Entity\Context $context
25+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
26+
* @param \Magento\Catalog\Model\Factory $modelFactory
27+
* @param \Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface $uniqueValidator
28+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
29+
* @param array $data
30+
*/
31+
public function __construct(
32+
\Magento\Eav\Model\Entity\Context $context,
33+
\Magento\Store\Model\StoreManagerInterface $storeManager,
34+
\Magento\Catalog\Model\Factory $modelFactory,
35+
\Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface $uniqueValidator,
36+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
37+
$data = []
38+
) {
39+
parent::__construct($context, $storeManager, $modelFactory, $data, $uniqueValidator);
40+
41+
$this->dateTime = $dateTime;
42+
}
43+
1744
/**
1845
* Initialize connection
1946
*
@@ -43,6 +70,7 @@ public function updateAttributes($entityIds, $attrData, $storeId)
4370
$object = new \Magento\Framework\DataObject();
4471
$object->setStoreId($storeId);
4572

73+
$attrData[ProductInterface::UPDATED_AT] = $this->dateTime->gmtDate();
4674
$this->getConnection()->beginTransaction();
4775
try {
4876
foreach ($attrData as $attrCode => $value) {
@@ -95,7 +123,7 @@ protected function _saveAttributeValue($object, $attribute, $value)
95123
* for default store id
96124
* In this case we clear all not default values
97125
*/
98-
if ($this->_storeManager->hasSingleStore()) {
126+
if ($this->_storeManager->hasSingleStore() && !$attribute->isStatic()) {
99127
$storeId = $this->getDefaultStoreId();
100128
$connection->delete(
101129
$table,
@@ -107,17 +135,24 @@ protected function _saveAttributeValue($object, $attribute, $value)
107135
);
108136
}
109137

110-
$data = new \Magento\Framework\DataObject(
111-
[
112-
'attribute_id' => $attribute->getAttributeId(),
113-
'store_id' => $storeId,
114-
$this->getLinkField() => $entityId,
115-
'value' => $this->_prepareValueForSave($value, $attribute),
116-
]
117-
);
138+
$data = $attribute->isStatic()
139+
? new \Magento\Framework\DataObject(
140+
[
141+
$this->getLinkField() => $entityId,
142+
$attribute->getAttributeCode() => $this->_prepareValueForSave($value, $attribute),
143+
]
144+
)
145+
: new \Magento\Framework\DataObject(
146+
[
147+
'attribute_id' => $attribute->getAttributeId(),
148+
'store_id' => $storeId,
149+
$this->getLinkField() => $entityId,
150+
'value' => $this->_prepareValueForSave($value, $attribute),
151+
]
152+
);
118153
$bind = $this->_prepareDataForTable($data, $table);
119154

120-
if ($attribute->isScopeStore()) {
155+
if ($attribute->isScopeStore() || $attribute->isStatic()) {
121156
/**
122157
* Update attribute value for store
123158
*/
@@ -143,6 +178,8 @@ protected function _saveAttributeValue($object, $attribute, $value)
143178
}
144179

145180
/**
181+
* Resolve entity id
182+
*
146183
* @param int $entityId
147184
* @return int
148185
*/

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,9 @@ private function getChildrenCategories(int $categoryId): array
21212121
if (in_array($category['parent_id'], $categoryIds)
21222122
&& in_array($category['parent_id'], $anchorCategory)) {
21232123
$categoryIds[] = (int)$category[$linkField];
2124-
if ($category['is_anchor'] == 1) {
2124+
// Storefront approach is to treat non-anchor children of anchor category as anchors.
2125+
// Adding their's IDs to $anchorCategory for consistency.
2126+
if ($category['is_anchor'] == 1 || in_array($category['parent_id'], $anchorCategory)) {
21252127
$anchorCategory[] = (int)$category[$linkField];
21262128
}
21272129
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Ui\Component\Listing\Columns;
9+
10+
/**
11+
* Attribute set listing column component
12+
*/
13+
class AttributeSetId extends \Magento\Ui\Component\Listing\Columns\Column
14+
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
protected function applySorting()
19+
{
20+
$sorting = $this->getContext()->getRequestParam('sorting');
21+
$isSortable = $this->getData('config/sortable');
22+
if ($isSortable !== false
23+
&& !empty($sorting['field'])
24+
&& !empty($sorting['direction'])
25+
&& $sorting['field'] === $this->getName()
26+
) {
27+
$collection = $this->getContext()->getDataProvider()->getCollection();
28+
$collection->joinField(
29+
'attribute_set',
30+
'eav_attribute_set',
31+
'attribute_set_name',
32+
'attribute_set_id=attribute_set_id',
33+
null,
34+
'left'
35+
);
36+
$collection->getSelect()->order('attribute_set_name ' . $sorting['direction']);
37+
}
38+
}
39+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<label translate="true">Type</label>
145145
</settings>
146146
</column>
147-
<column name="attribute_set_id" component="Magento_Ui/js/grid/columns/select" sortOrder="50">
147+
<column name="attribute_set_id" class="Magento\Catalog\Ui\Component\Listing\Columns\AttributeSetId" component="Magento_Ui/js/grid/columns/select" sortOrder="50">
148148
<settings>
149149
<options class="Magento\Catalog\Model\Product\AttributeSet\Options"/>
150150
<filter>select</filter>

app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<arguments>
2222
<argument name="css_class" xsi:type="string">product</argument>
2323
<argument name="add_base_attribute" xsi:type="string">itemprop="name"</argument>
24+
<argument name="translate" xsi:type="boolean">false</argument>
2425
</arguments>
2526
</referenceBlock>
2627
<referenceBlock name="root">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,7 @@ public function validateRow(array $rowData, $rowNum)
25212521
$this->addRowError(
25222522
ValidatorInterface::ERROR_DUPLICATE_URL_KEY,
25232523
$rowNum,
2524-
$rowData[self::COL_NAME],
2524+
$urlKey,
25252525
$message,
25262526
$errorLevel
25272527
)

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
namespace Magento\CatalogImportExport\Model\Import\Product;
88

9-
use Magento\CatalogImportExport\Model\Import\Product;
10-
use Magento\Framework\App\ResourceConnection;
11-
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
129
use Magento\Catalog\Api\Data\ProductInterface;
1310
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection as ProductOptionValueCollection;
1411
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\CollectionFactory as ProductOptionValueCollectionFactory;
15-
use Magento\Store\Model\Store;
12+
use Magento\CatalogImportExport\Model\Import\Product;
13+
use Magento\Framework\App\ResourceConnection;
1614
use Magento\ImportExport\Model\Import;
15+
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
16+
use Magento\Store\Model\Store;
1717

1818
/**
1919
* Entity class which provide possibility to import product custom options
@@ -110,6 +110,13 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
110110
'file' => ['sku', 'file_extension', 'image_size_x', 'image_size_y'],
111111
];
112112

113+
/**
114+
* Invalid rows list
115+
*
116+
* @var array
117+
*/
118+
private $_invalidRows;
119+
113120
/**
114121
* Keep product id value for every row which will be imported
115122
*
@@ -433,7 +440,7 @@ protected function _initMessageTemplates()
433440
self::ERROR_INVALID_TYPE,
434441
__(
435442
'Value for \'type\' sub attribute in \'custom_options\' attribute contains incorrect value, acceptable values are: %1',
436-
'\''.implode('\', \'', array_keys($this->_specificTypes)).'\''
443+
'\'' . implode('\', \'', array_keys($this->_specificTypes)) . '\''
437444
)
438445
);
439446
$this->_productEntity->addMessageTemplate(self::ERROR_EMPTY_TITLE, __('Please enter a value for title.'));
@@ -1251,7 +1258,9 @@ protected function _importData()
12511258
$childCount = [];
12521259
$optionsToRemove = [];
12531260
foreach ($bunch as $rowNumber => $rowData) {
1254-
if (isset($optionId, $valueId) && empty($rowData[PRODUCT::COL_STORE_VIEW_CODE])) {
1261+
if (isset($optionId, $valueId) &&
1262+
(empty($rowData[PRODUCT::COL_STORE_VIEW_CODE]) || empty($rowData['custom_options']))
1263+
) {
12551264
$nextOptionId = $optionId;
12561265
$nextValueId = $valueId;
12571266
}
@@ -1548,8 +1557,8 @@ protected function _collectOptionTitle(array $rowData, $prevOptionId, array &$ti
15481557
if (!empty($rowData[self::COLUMN_TITLE])) {
15491558
if (!isset($titles[$prevOptionId][$defaultStoreId])) {
15501559
if (isset($this->lastOptionTitle[$prevOptionId])) {
1551-
$titles[$prevOptionId] = $this->lastOptionTitle[$prevOptionId];
1552-
unset($this->lastOptionTitle);
1560+
$titles[$prevOptionId] = $this->lastOptionTitle[$prevOptionId];
1561+
unset($this->lastOptionTitle);
15531562
} else {
15541563
$titles[$prevOptionId][$defaultStoreId] = $rowData[self::COLUMN_TITLE];
15551564
}

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,11 @@ function (
255255
return attribute.label;
256256
}
257257

258-
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
259-
value: attribute.value
260-
});
258+
if (typeof this.source.get('customAttributes') !== 'undefined') {
259+
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
260+
value: attribute.value
261+
});
262+
}
261263

262264
return resultAttribute && resultAttribute.label || attribute.value;
263265
}

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ define([
6565
return attribute.label;
6666
}
6767

68-
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
69-
value: attribute.value
70-
});
68+
if (typeof this.source.get('customAttributes') !== 'undefined') {
69+
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
70+
value: attribute.value
71+
});
72+
}
7173

7274
return resultAttribute && resultAttribute.label || attribute.value;
7375
},

app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ define([
4242
return attribute.label;
4343
}
4444

45-
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
46-
value: attribute.value
47-
});
45+
if (typeof this.source.get('customAttributes') !== 'undefined') {
46+
resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], {
47+
value: attribute.value
48+
});
49+
}
4850

4951
return resultAttribute && resultAttribute.label || attribute.value;
5052
}

0 commit comments

Comments
 (0)