Skip to content

Commit f42be8a

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into ENGCOM-2271-magento-magento2-15366
2 parents 072498e + c19d876 commit f42be8a

File tree

20 files changed

+269
-56
lines changed

20 files changed

+269
-56
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ public function execute()
222222
$data['backend_model'] = $this->productHelper->getAttributeBackendModelByInputType(
223223
$data['frontend_input']
224224
);
225+
226+
if ($model->getIsUserDefined() === null) {
227+
$data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
228+
}
225229
}
226230

227231
$data += ['is_filterable' => 0, 'is_filterable_in_search' => 0];
228232

229-
if ($model->getIsUserDefined() === null || $model->getIsUserDefined() != 0) {
230-
$data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']);
231-
}
232-
233233
$defaultValueField = $model->getDefaultValueByInput($data['frontend_input']);
234234
if ($defaultValueField) {
235235
$data['default_value'] = $this->getRequest()->getParam($defaultValueField);

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ protected function _updateTemporaryTableByStoreValues(
341341
if (!empty($changedIds)) {
342342
$select->where($this->_connection->quoteInto('et.entity_id IN (?)', $changedIds));
343343
}
344+
345+
/*
346+
* According to \Magento\Framework\DB\SelectRendererInterface select rendering may be updated
347+
* so we need to trigger select renderer for correct update
348+
*/
349+
$select->assemble();
344350
$sql = $select->crossUpdateFromSelect(['et' => $temporaryFlatTableName]);
345351
$this->_connection->query($sql);
346352
}
@@ -355,6 +361,7 @@ protected function _updateTemporaryTableByStoreValues(
355361
if (!empty($changedIds)) {
356362
$select->where($this->_connection->quoteInto('et.entity_id IN (?)', $changedIds));
357363
}
364+
$select->assemble();
358365
$sql = $select->crossUpdateFromSelect(['et' => $temporaryFlatTableName]);
359366
$this->_connection->query($sql);
360367
}

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ public function changeParent(
920920
$childrenCount = $this->getChildrenCount($category->getId()) + 1;
921921
$table = $this->getEntityTable();
922922
$connection = $this->getConnection();
923-
$levelFiled = $connection->quoteIdentifier('level');
923+
$levelField = $connection->quoteIdentifier('level');
924924
$pathField = $connection->quoteIdentifier('path');
925925

926926
/**
@@ -960,7 +960,7 @@ public function changeParent(
960960
$newPath . '/'
961961
) . ')'
962962
),
963-
'level' => new \Zend_Db_Expr($levelFiled . ' + ' . $levelDisposition)
963+
'level' => new \Zend_Db_Expr($levelField . ' + ' . $levelDisposition)
964964
],
965965
[$pathField . ' LIKE ?' => $category->getPath() . '/%']
966966
);

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

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
352352
* @param \Magento\Framework\App\ResourceConnection $resource
353353
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
354354
* @param \Psr\Log\LoggerInterface $logger
355-
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
355+
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory
356356
* @param \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig
357357
* @param \Magento\Catalog\Model\ResourceModel\ProductFactory $productFactory
358358
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFactory
@@ -361,9 +361,10 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
361361
* @param \Magento\Catalog\Model\ResourceModel\Product\Option\CollectionFactory $optionColFactory
362362
* @param \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $attributeColFactory
363363
* @param Product\Type\Factory $_typeFactory
364-
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
365-
* @param \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface $rowCustomizer
364+
* @param ProductEntity\LinkTypeProvider $linkTypeProvider
365+
* @param RowCustomizerInterface $rowCustomizer
366366
* @param array $dateAttrCodes
367+
* @throws \Magento\Framework\Exception\LocalizedException
367368
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
368369
*/
369370
public function __construct(
@@ -517,10 +518,13 @@ protected function getMediaGallery(array $productIds)
517518
if (empty($productIds)) {
518519
return [];
519520
}
521+
522+
$productEntityJoinField = $this->getProductEntityLinkField();
523+
520524
$select = $this->_connection->select()->from(
521525
['mgvte' => $this->_resourceModel->getTableName('catalog_product_entity_media_gallery_value_to_entity')],
522526
[
523-
"mgvte.{$this->getProductEntityLinkField()}",
527+
"mgvte.$productEntityJoinField",
524528
'mgvte.value_id'
525529
]
526530
)->joinLeft(
@@ -532,22 +536,22 @@ protected function getMediaGallery(array $productIds)
532536
]
533537
)->joinLeft(
534538
['mgv' => $this->_resourceModel->getTableName('catalog_product_entity_media_gallery_value')],
535-
'(mg.value_id = mgv.value_id)',
539+
"(mg.value_id = mgv.value_id) and (mgvte.$productEntityJoinField = mgv.$productEntityJoinField)",
536540
[
537541
'mgv.label',
538542
'mgv.position',
539543
'mgv.disabled',
540544
'mgv.store_id'
541545
]
542546
)->where(
543-
"mgvte.{$this->getProductEntityLinkField()} IN (?)",
547+
"mgvte.$productEntityJoinField IN (?)",
544548
$productIds
545549
);
546550

547551
$rowMediaGallery = [];
548552
$stmt = $this->_connection->query($select);
549553
while ($mediaRow = $stmt->fetch()) {
550-
$rowMediaGallery[$mediaRow[$this->getProductEntityLinkField()]][] = [
554+
$rowMediaGallery[$mediaRow[$productEntityJoinField]][] = [
551555
'_media_attribute_id' => $mediaRow['attribute_id'],
552556
'_media_image' => $mediaRow['filename'],
553557
'_media_label' => $mediaRow['label'],
@@ -689,6 +693,8 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
689693
}
690694

691695
/**
696+
* Get header columns
697+
*
692698
* {@inheritdoc}
693699
*/
694700
public function _getHeaderColumns()
@@ -748,6 +754,8 @@ protected function _getExportMainAttrCodes()
748754
}
749755

750756
/**
757+
* Get entity collection
758+
*
751759
* {@inheritdoc}
752760
*/
753761
protected function _getEntityCollection($resetCollection = false)
@@ -818,9 +826,8 @@ protected function paginateCollection($page, $pageSize)
818826
}
819827

820828
/**
821-
* Export process
822-
*
823829
* @return string
830+
* @throws \Magento\Framework\Exception\LocalizedException
824831
*/
825832
public function export()
826833
{
@@ -854,7 +861,11 @@ public function export()
854861
}
855862

856863
/**
857-
* {@inheritdoc}
864+
* Apply filter to collection and add not skipped attributes to select.
865+
*
866+
* @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
867+
* @return \Magento\Eav\Model\Entity\Collection\AbstractCollection
868+
*
858869
* @since 100.2.0
859870
*/
860871
protected function _prepareEntityCollection(\Magento\Eav\Model\Entity\Collection\AbstractCollection $collection)
@@ -916,11 +927,10 @@ protected function getExportData()
916927
}
917928

918929
/**
919-
* Load products' data from the collection
920-
* and filter it (if needed).
930+
* Load products' data from the collection and filter it (if needed).
921931
*
922-
* @return array Keys are product IDs, values arrays with keys as store IDs
923-
* and values as store-specific versions of Product entity.
932+
* @return array Keys are product IDs, values arrays with keys as store ID
933+
* and values as store-specific versions of Product entity.
924934
*/
925935
protected function loadCollection(): array
926936
{

app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
<settings>
286286
<scopeLabel>[GLOBAL]</scopeLabel>
287287
<validation>
288-
<rule name="validate-number" xsi:type="boolean">true</rule>
288+
<rule name="validate-greater-than-zero" xsi:type="boolean">true</rule>
289289
</validation>
290290
<label translate="true">Maximum Qty Allowed in Shopping Cart</label>
291291
<dataScope>max_sale_qty</dataScope>

app/code/Magento/Checkout/view/frontend/web/js/view/progress-bar.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ define([
2424

2525
/** @inheritdoc */
2626
initialize: function () {
27+
var stepsValue;
28+
2729
this._super();
2830
$(window).hashchange(_.bind(stepNavigator.handleHash, stepNavigator));
2931

3032
if (!window.location.hash) {
31-
stepNavigator.setHash(stepNavigator.steps().sort(stepNavigator.sortItems)[0].code);
33+
stepsValue = stepNavigator.steps();
34+
35+
if (stepsValue.length) {
36+
stepNavigator.setHash(stepsValue.sort(stepNavigator.sortItems)[0].code);
37+
}
3238
}
3339

3440
stepNavigator.handleHash();

app/code/Magento/Customer/Model/Address.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ public function updateData(AddressInterface $address)
154154
// Need to explicitly set this due to discrepancy in the keys between model and data object
155155
$this->setIsDefaultBilling($address->isDefaultBilling());
156156
$this->setIsDefaultShipping($address->isDefaultShipping());
157-
if (!$this->getAttributeSetId()) {
158-
$this->setAttributeSetId(AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS);
159-
}
160157
$customAttributes = $address->getCustomAttributes();
161158
if ($customAttributes !== null) {
162159
foreach ($customAttributes as $attribute) {

app/code/Magento/Customer/Model/Customer.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,6 @@ public function updateData($customer)
358358
$this->setId($customerId);
359359
}
360360

361-
// Need to use attribute set or future updates can cause data loss
362-
if (!$this->getAttributeSetId()) {
363-
$this->setAttributeSetId(
364-
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER
365-
);
366-
}
367-
368361
return $this;
369362
}
370363

@@ -960,6 +953,16 @@ public function getSharedWebsiteIds()
960953
return $ids;
961954
}
962955

956+
/**
957+
* Retrieve attribute set id for customer.
958+
*
959+
* @return int
960+
*/
961+
public function getAttributeSetId()
962+
{
963+
return parent::getAttributeSetId() ?: CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER;
964+
}
965+
963966
/**
964967
* Set store to customer
965968
*

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,6 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
205205
$customerModel->setStoreId($this->storeManager->getStore()->getId());
206206
}
207207

208-
// Need to use attribute set or future updates can cause data loss
209-
if (!$customerModel->getAttributeSetId()) {
210-
$customerModel->setAttributeSetId(
211-
\Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER
212-
);
213-
}
214208
$this->populateCustomerWithSecureData($customerModel, $passwordHash);
215209

216210
// If customer email was changed, reset RpToken info

app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ public function testUpdateData()
307307
}
308308

309309
$expectedResult[$attribute->getAttributeCode()] = $attribute->getValue();
310-
$expectedResult['attribute_set_id'] =
311-
\Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER;
312310

313311
$this->assertEquals($this->_model->getData(), $expectedResult);
314312
}

0 commit comments

Comments
 (0)