Skip to content

Commit 8c83a6e

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into MAGETWO-73922
2 parents 504aeb6 + b1e26d5 commit 8c83a6e

File tree

47 files changed

+848
-808
lines changed

Some content is hidden

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

47 files changed

+848
-808
lines changed

app/code/Magento/Analytics/Model/Cryptographer.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ private function getInitializationVector()
124124
*/
125125
private function validateCipherMethod($cipherMethod)
126126
{
127-
$methods = openssl_get_cipher_methods();
127+
$methods = array_map(
128+
'strtolower',
129+
openssl_get_cipher_methods()
130+
);
131+
$cipherMethod = strtolower($cipherMethod);
132+
128133
return (false !== array_search($cipherMethod, $methods));
129134
}
130135
}

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,11 @@ public function getSku($product)
310310
$selectionIds = $this->serializer->unserialize($customOption->getValue());
311311
if (!empty($selectionIds)) {
312312
$selections = $this->getSelectionsByIds($selectionIds, $product);
313-
foreach ($selections->getItems() as $selection) {
314-
$skuParts[] = $selection->getSku();
313+
foreach ($selectionIds as $selectionId) {
314+
$entity = $selections->getItemByColumnValue('selection_id', $selectionId);
315+
if (isset($entity) && $entity->getEntityId()) {
316+
$skuParts[] = $entity->getSku();
317+
}
315318
}
316319
}
317320
}

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ public function testGetSkuWithoutType()
15951595
->disableOriginalConstructor()
15961596
->getMock();
15971597
$selectionItemMock = $this->getMockBuilder(\Magento\Framework\DataObject::class)
1598-
->setMethods(['getSku', '__wakeup'])
1598+
->setMethods(['getSku', 'getEntityId', '__wakeup'])
15991599
->disableOriginalConstructor()
16001600
->getMock();
16011601

@@ -1623,9 +1623,12 @@ public function testGetSkuWithoutType()
16231623
->will($this->returnValue($serializeIds));
16241624
$selectionMock = $this->getSelectionsByIdsMock($selectionIds, $productMock, 5, 6);
16251625
$selectionMock->expects(($this->any()))
1626-
->method('getItems')
1627-
->will($this->returnValue([$selectionItemMock]));
1628-
$selectionItemMock->expects($this->any())
1626+
->method('getItemByColumnValue')
1627+
->will($this->returnValue($selectionItemMock));
1628+
$selectionItemMock->expects($this->at(0))
1629+
->method('getEntityId')
1630+
->will($this->returnValue(1));
1631+
$selectionItemMock->expects($this->once())
16291632
->method('getSku')
16301633
->will($this->returnValue($itemSku));
16311634

app/code/Magento/Bundle/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@
140140
</argument>
141141
</arguments>
142142
</type>
143+
<type name="Magento\Sales\Model\Order\ProductOption">
144+
<arguments>
145+
<argument name="processorPool" xsi:type="array">
146+
<item name="bundle" xsi:type="object">Magento\Bundle\Model\ProductOptionProcessor</item>
147+
</argument>
148+
</arguments>
149+
</type>
143150
<type name="Magento\Bundle\Ui\DataProvider\Product\Listing\Collector\BundlePrice">
144151
<arguments>
145152
<argument name="excludeAdjustments" xsi:type="array">

app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,19 @@ private function getCategoryLinksPositions($entity)
106106
*/
107107
private function mergeCategoryLinks($newCategoryPositions, $oldCategoryPositions)
108108
{
109-
$result = [];
110109
if (empty($newCategoryPositions)) {
111-
return $result;
110+
return [];
112111
}
113112

113+
$categoryPositions = array_combine(array_column($oldCategoryPositions, 'category_id'), $oldCategoryPositions);
114114
foreach ($newCategoryPositions as $newCategoryPosition) {
115-
$key = array_search(
116-
$newCategoryPosition['category_id'],
117-
array_column($oldCategoryPositions, 'category_id')
118-
);
119-
120-
if ($key === false) {
121-
$result[] = $newCategoryPosition;
122-
} elseif (isset($oldCategoryPositions[$key])
123-
&& $oldCategoryPositions[$key]['position'] != $newCategoryPosition['position']
124-
) {
125-
$result[] = $newCategoryPositions[$key];
126-
unset($oldCategoryPositions[$key]);
115+
$categoryId = $newCategoryPosition['category_id'];
116+
if (!isset($categoryPositions[$categoryId])) {
117+
$categoryPositions[$categoryId] = ['category_id' => $categoryId];
127118
}
119+
$categoryPositions[$categoryId]['position'] = $newCategoryPosition['position'];
128120
}
129-
$result = array_merge($result, $oldCategoryPositions);
121+
$result = array_values($categoryPositions);
130122

131123
return $result;
132124
}

app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ abstract class AbstractAction
126126
*/
127127
private $queryGenerator;
128128

129+
/**
130+
* Current store id.
131+
* @var int
132+
*/
133+
private $currentStoreId = 0;
134+
129135
/**
130136
* @param ResourceConnection $resource
131137
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -167,6 +173,7 @@ protected function reindex()
167173
{
168174
foreach ($this->storeManager->getStores() as $store) {
169175
if ($this->getPathFromCategoryId($store->getRootCategoryId())) {
176+
$this->currentStoreId = $store->getId();
170177
$this->reindexRootCategory($store);
171178
$this->reindexAnchorCategories($store);
172179
$this->reindexNonAnchorCategories($store);
@@ -594,7 +601,7 @@ protected function getTemporaryTreeIndexTableName()
594601
if (empty($this->tempTreeIndexTableName)) {
595602
$this->tempTreeIndexTableName = $this->connection->getTableName('temp_catalog_category_tree_index')
596603
. '_'
597-
. substr(md5(time() . random_int(0, 999999999)), 0, 8);
604+
. substr(sha1(time() . random_int(0, 999999999)), 0, 8);
598605
}
599606

600607
return $this->tempTreeIndexTableName;
@@ -649,30 +656,47 @@ protected function makeTempCategoryTreeIndex()
649656
}
650657

651658
/**
652-
* Populate the temporary category tree index table
659+
* Populate the temporary category tree index table.
653660
*
654661
* @param string $temporaryName
662+
* @return void
655663
* @since 101.0.0
656664
*/
657665
protected function fillTempCategoryTreeIndex($temporaryName)
658666
{
659-
$offset = 0;
660-
$limit = 500;
661-
662-
$categoryTable = $this->getTable('catalog_category_entity');
663-
664-
$categoriesSelect = $this->connection->select()
665-
->from(
666-
['c' => $categoryTable],
667-
['entity_id', 'path']
668-
)->limit($limit, $offset);
669-
670-
$categories = $this->connection->fetchAll($categoriesSelect);
667+
$isActiveAttributeId = $this->config->getAttribute(
668+
\Magento\Catalog\Model\Category::ENTITY,
669+
'is_active'
670+
)->getId();
671+
$categoryMetadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\CategoryInterface::class);
672+
$categoryLinkField = $categoryMetadata->getLinkField();
673+
$selects = $this->prepareSelectsByRange(
674+
$this->connection->select()
675+
->from(
676+
['c' => $this->getTable('catalog_category_entity')],
677+
['entity_id', 'path']
678+
)->joinInner(
679+
['ccacd' => $this->getTable('catalog_category_entity_int')],
680+
'ccacd.' . $categoryLinkField . ' = c.' . $categoryLinkField
681+
. ' AND ccacd.store_id = 0' . ' AND ccacd.attribute_id = ' . $isActiveAttributeId,
682+
[]
683+
)->joinLeft(
684+
['ccacs' => $this->getTable('catalog_category_entity_int')],
685+
'ccacs.' . $categoryLinkField . ' = c.' . $categoryLinkField
686+
. ' AND ccacs.attribute_id = ccacd.attribute_id AND ccacs.store_id = '
687+
. $this->currentStoreId,
688+
[]
689+
)->where(
690+
$this->connection->getIfNullSql('ccacs.value', 'ccacd.value') . ' = ?',
691+
1
692+
),
693+
'entity_id'
694+
);
671695

672-
while ($categories) {
696+
foreach ($selects as $select) {
673697
$values = [];
674698

675-
foreach ($categories as $category) {
699+
foreach ($this->connection->fetchAll($select) as $category) {
676700
foreach (explode('/', $category['path']) as $parentId) {
677701
if ($parentId !== $category['entity_id']) {
678702
$values[] = [$parentId, $category['entity_id']];
@@ -683,15 +707,6 @@ protected function fillTempCategoryTreeIndex($temporaryName)
683707
if (count($values) > 0) {
684708
$this->connection->insertArray($temporaryName, ['parent_id', 'child_id'], $values);
685709
}
686-
687-
$offset += $limit;
688-
$categoriesSelect = $this->connection->select()
689-
->from(
690-
['c' => $categoryTable],
691-
['entity_id', 'path']
692-
)->limit($limit, $offset);
693-
694-
$categories = $this->connection->fetchAll($categoriesSelect);
695710
}
696711
}
697712

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ private function getCategoryLinkMetadata()
114114
private function processCategoryLinks($newCategoryPositions, &$oldCategoryPositions)
115115
{
116116
$result = ['changed' => [], 'updated' => []];
117+
118+
$oldCategoryPositions = array_values($oldCategoryPositions);
119+
$oldCategoryList = array_column($oldCategoryPositions, 'category_id');
117120
foreach ($newCategoryPositions as $newCategoryPosition) {
118-
$key = array_search(
119-
$newCategoryPosition['category_id'],
120-
array_column($oldCategoryPositions, 'category_id')
121-
);
121+
$key = array_search($newCategoryPosition['category_id'], $oldCategoryList);
122122

123123
if ($key === false) {
124124
$result['changed'][] = $newCategoryPosition;
125125
} elseif ($oldCategoryPositions[$key]['position'] != $newCategoryPosition['position']) {
126-
$result['updated'][] = $newCategoryPositions[$key];
126+
$result['updated'][] = $newCategoryPosition;
127127
unset($oldCategoryPositions[$key]);
128128
}
129129
}

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,27 @@
5151
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) have been deleted." stepKey="seeSuccessMessage"/>
5252
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial2"/>
5353
</actionGroup>
54+
55+
<!--Disabled a product by filtering grid and using change status action-->
56+
<actionGroup name="ChangeStatusProductUsingProductGridActionGroup">
57+
<arguments>
58+
<argument name="product"/>
59+
<argument name="status" defaultValue="Enable" type="string" />
60+
</arguments>
61+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/>
62+
<waitForPageLoad time="60" stepKey="waitForPageLoadInitial"/>
63+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/>
64+
<click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/>
65+
<fillField selector="{{AdminProductGridFilterSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillProductSkuFilter"/>
66+
<click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/>
67+
<see selector="{{AdminProductGridSection.productGridCell('1', 'SKU')}}" userInput="{{product.sku}}" stepKey="seeProductSkuInGrid"/>
68+
<click selector="{{AdminProductGridSection.multicheckDropdown}}" stepKey="openMulticheckDropdown"/>
69+
<click selector="{{AdminProductGridSection.multicheckOption('Select All')}}" stepKey="selectAllProductInFilteredGrid"/>
70+
71+
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickActionDropdown"/>
72+
<click selector="{{AdminProductGridSection.bulkActionOption('Change status')}}" stepKey="clickChangeStatusAction"/>
73+
<click selector="{{AdminProductGridSection.changeStatus('status')}}" stepKey="clickChangeStatusDisabled" parameterized="true"/>
74+
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) have been updated." stepKey="seeSuccessMessage"/>
75+
<conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial2"/>
76+
</actionGroup>
5477
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
<element name="productGridNameProduct" type="input" selector="//tbody//tr//td//div[contains(., '{{var1}}')]" parameterized="true" timeout="30"/>
2727
<element name="adminImgGridThumbnail" type="text" selector="img.admin__control-thumbnail[src*='/{{var1}}']" parameterized="true"/>
2828
<element name="selectRowBasedOnName" type="input" selector="//td/div[text()='{{var1}}']" parameterized="true"/>
29+
<element name="changeStatus" type="button" selector="//div[contains(@class,'admin__data-grid-header-row') and contains(@class, 'row')]//div[contains(@class, 'action-menu-item')]//ul/li/span[text() = '{{status}}']" parameterized="true"/>
2930
</section>
3031
</sections>

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AbstractModifierTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function setUp()
6767
'isLockedAttribute'
6868
])->getMockForAbstractClass();
6969
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
70-
->setMethods(['load', 'getId', 'getConfig'])
70+
->setMethods(['load', 'getId', 'getConfig', 'getBaseCurrency', 'getBaseCurrencyCode'])
7171
->getMockForAbstractClass();
7272
$this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class)
7373
->disableOriginalConstructor()

0 commit comments

Comments
 (0)