Skip to content

Commit 3c92edc

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/2.3-develop' into MC-13926
2 parents b99e90e + 7951d9a commit 3c92edc

File tree

60 files changed

+553
-503
lines changed

Some content is hidden

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

60 files changed

+553
-503
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
77

8-
use Magento\Customer\Api\Data\GroupInterface;
9-
108
/**
119
* Products mass update inventory tab
1210
*
@@ -31,29 +29,20 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
3129
*/
3230
protected $disabledFields = [];
3331

34-
/**
35-
* @var \Magento\Framework\Serialize\SerializerInterface
36-
*/
37-
private $serializer;
38-
3932
/**
4033
* @param \Magento\Backend\Block\Template\Context $context
4134
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
4235
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
4336
* @param array $data
44-
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
4537
*/
4638
public function __construct(
4739
\Magento\Backend\Block\Template\Context $context,
4840
\Magento\CatalogInventory\Model\Source\Backorders $backorders,
4941
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
50-
array $data = [],
51-
\Magento\Framework\Serialize\SerializerInterface $serializer = null
42+
array $data = []
5243
) {
5344
$this->_backorders = $backorders;
5445
$this->stockConfiguration = $stockConfiguration;
55-
$this->serializer = $serializer ?? \Magento\Framework\App\ObjectManager::getInstance()
56-
->get(\Magento\Framework\Serialize\SerializerInterface::class);
5746
parent::__construct($context, $data);
5847
}
5948

@@ -85,9 +74,7 @@ public function getFieldSuffix()
8574
*/
8675
public function getStoreId()
8776
{
88-
$storeId = (int)$this->getRequest()->getParam('store');
89-
90-
return $storeId;
77+
return (int)$this->getRequest()->getParam('store');
9178
}
9279

9380
/**
@@ -101,22 +88,6 @@ public function getDefaultConfigValue($field)
10188
return $this->stockConfiguration->getDefaultConfigValue($field);
10289
}
10390

104-
/**
105-
* Returns min_sale_qty configuration for the ALL Customer Group
106-
*
107-
* @return float
108-
*/
109-
public function getDefaultMinSaleQty()
110-
{
111-
$default = $this->stockConfiguration->getDefaultConfigValue('min_sale_qty');
112-
if (!is_numeric($default)) {
113-
$default = $this->serializer->unserialize($default);
114-
$default = $default[GroupInterface::CUST_GROUP_ALL] ?? 1;
115-
}
116-
117-
return (float) $default;
118-
}
119-
12091
/**
12192
* Tab settings
12293
*

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
7272

7373
const CACHE_TAG = 'cat_c';
7474

75-
/**
76-
* Category Store Id
77-
*/
78-
const STORE_ID = 'store_id';
79-
8075
/**#@-*/
8176
protected $_eventPrefix = 'catalog_category';
8277

@@ -573,8 +568,8 @@ public function getStoreIds()
573568
*/
574569
public function getStoreId()
575570
{
576-
if ($this->hasData(self::STORE_ID)) {
577-
return (int)$this->_getData(self::STORE_ID);
571+
if ($this->hasData('store_id')) {
572+
return (int)$this->_getData('store_id');
578573
}
579574
return (int)$this->_storeManager->getStore()->getId();
580575
}
@@ -590,7 +585,7 @@ public function setStoreId($storeId)
590585
if (!is_numeric($storeId)) {
591586
$storeId = $this->_storeManager->getStore($storeId)->getId();
592587
}
593-
$this->setData(self::STORE_ID, $storeId);
588+
$this->setData('store_id', $storeId);
594589
$this->getResource()->setStoreId($storeId);
595590
return $this;
596591
}
@@ -1124,10 +1119,15 @@ public function reindex()
11241119
}
11251120
}
11261121
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
1127-
if (!$productIndexer->isScheduled()
1128-
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
1129-
) {
1130-
$productIndexer->reindexList($this->getPathIds());
1122+
1123+
if (!empty($this->getAffectedProductIds())
1124+
|| $this->dataHasChangedFor('is_anchor')
1125+
|| $this->dataHasChangedFor('is_active')) {
1126+
if (!$productIndexer->isScheduled()) {
1127+
$productIndexer->reindexList($this->getPathIds());
1128+
} else {
1129+
$productIndexer->invalidate();
1130+
}
11311131
}
11321132
}
11331133

@@ -1152,9 +1152,17 @@ public function getIdentities()
11521152
$identities = [
11531153
self::CACHE_TAG . '_' . $this->getId(),
11541154
];
1155+
11551156
if ($this->hasDataChanges()) {
11561157
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
11571158
}
1159+
1160+
if ($this->dataHasChangedFor('is_anchor') || $this->dataHasChangedFor('is_active')) {
1161+
foreach ($this->getPathIds() as $id) {
1162+
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $id;
1163+
}
1164+
}
1165+
11581166
if (!$this->getId() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
11591167
$identities[] = self::CACHE_TAG;
11601168
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
7171
*/
7272
const STORE_ID = 'store_id';
7373

74-
/**
75-
* Product Url path.
76-
*/
77-
const URL_PATH = 'url_path';
78-
7974
/**
8075
* @var string
8176
*/

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function copy(Product $product)
8383
? $matches[1] . '-' . ($matches[2] + 1)
8484
: $urlKey . '-1';
8585
$duplicate->setUrlKey($urlKey);
86-
$duplicate->setData(Product::URL_PATH, null);
86+
$duplicate->setData('url_path', null);
8787
try {
8888
$duplicate->save();
8989
$isDuplicateSaved = true;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,7 @@
304304
<argument name="website"/>
305305
<argument name="product"/>
306306
</arguments>
307-
<amOnPage url="{{AdminCatalogProductPage.url}}" stepKey="navigateToProductPage"/>
308-
<waitForPageLoad stepKey="waitForProductsList"/>
309-
<click stepKey="openProduct" selector="{{AdminProductGridActionSection.productName(product.name)}}"/>
307+
<click stepKey="openProduct" selector="{{AdminProductGridActionSection.productName(product.sku)}}"/>
310308
<waitForPageLoad stepKey="waitForProductPage"/>
311309
<scrollTo selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="ScrollToWebsites"/>
312310
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openWebsitesList"/>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<section name="AdminProductSEOSection">
1212
<element name="sectionHeader" type="button" selector="div[data-index='search-engine-optimization']" timeout="30"/>
1313
<element name="urlKeyInput" type="input" selector="input[name='product[url_key]']"/>
14+
<element name="useDefaultUrl" type="checkbox" selector="input[name='use_default[url_key]']"/>
1415
</section>
1516
</sections>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@
3838

3939
<element name="description" type="input" selector="#description"/>
4040
</section>
41+
<section name="AdminUpdateAttributesWebsiteSection">
42+
<element name="website" type="button" selector="#attributes_update_tabs_websites"/>
43+
<element name="addProductToWebsite" type="checkbox" selector="#add-products-to-website-content .website-checkbox"/>
44+
</section>
4145
</sections>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="ProductAvailableAfterEnablingSubCategoriesTest">
12+
<annotations>
13+
<features value="Catalog"/>
14+
<title value="Check that parent categories are showing products after enabling subcategories after fully reindex"/>
15+
<description value="Check that parent categories are showing products after enabling subcategories after fully reindex"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-97370"/>
18+
<useCaseId value="MAGETWO-96846"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<createData entity="ApiCategory" stepKey="createCategory"/>
23+
<createData entity="SubCategoryWithParent" stepKey="simpleSubCategory">
24+
<requiredEntity createDataKey="createCategory"/>
25+
<field key="is_active">false</field>
26+
</createData>
27+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
28+
<requiredEntity createDataKey="simpleSubCategory"/>
29+
</createData>
30+
31+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
32+
</before>
33+
<after>
34+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
35+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
36+
<actionGroup ref="logout" stepKey="logout"/>
37+
</after>
38+
39+
<amOnPage url="$$createCategory.name$$.html" stepKey="goToCategoryStorefront2"/>
40+
<waitForPageLoad stepKey="waitForCategoryStorefront"/>
41+
<dontSeeElement selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct.name$$)}}" stepKey="dontSeeCreatedProduct"/>
42+
<amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/>
43+
<waitForPageLoad stepKey="waitForCategoryPageLoadAddProducts"/>
44+
<click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandAll"/>
45+
<click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$simpleSubCategory.name$$)}}" stepKey="clickOnCreatedSimpleSubCategoryBeforeDelete"/>
46+
<waitForPageLoad stepKey="AdminCategoryEditPageLoad"/>
47+
<click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="EnableCategory"/>
48+
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategoryWithProducts"/>
49+
<waitForPageLoad stepKey="waitForCategorySaved"/>
50+
<see userInput="You saved the category." stepKey="seeSuccessMessage"/>
51+
<amOnPage url="$$createCategory.name$$.html" stepKey="goToCategoryStorefront"/>
52+
<waitForPageLoad stepKey="waitForCategoryStorefrontPage"/>
53+
<seeElement selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct.name$$)}}" stepKey="seeCreatedProduct"/>
54+
</test>
55+
</tests>

app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
5353
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
5454

55+
<!-- Reset Product filter -->
56+
57+
<actionGroup ref="ClearProductsFilterActionGroup" stepKey="clearProductsFilter"/>
58+
5559
<!-- Delete Store View EN -->
5660

5761
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView1">

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
77

8-
use Magento\Customer\Api\Data\GroupInterface;
9-
108
/**
119
* Class InventoryTest
1210
*/
@@ -70,8 +68,7 @@ protected function setUp()
7068
[
7169
'context' => $this->contextMock,
7270
'backorders' => $this->backordersMock,
73-
'stockConfiguration' => $this->stockConfigurationMock,
74-
'serializer' => new \Magento\Framework\Serialize\Serializer\Json(),
71+
'stockConfiguration' => $this->stockConfigurationMock
7572
]
7673
);
7774
}
@@ -129,32 +126,6 @@ public function testGetDefaultConfigValue()
129126
$this->assertEquals('return-value', $this->inventory->getDefaultConfigValue('field-name'));
130127
}
131128

132-
/**
133-
* @dataProvider getDefaultMinSaleQtyDataProvider
134-
* @param string $expected
135-
* @param string $default
136-
*/
137-
public function testGetDefaultMinSaleQty($expected, $default)
138-
{
139-
$this->stockConfigurationMock->method('getDefaultConfigValue')->willReturn($default);
140-
$this->assertEquals($expected, $this->inventory->getDefaultMinSaleQty());
141-
}
142-
143-
public function getDefaultMinSaleQtyDataProvider()
144-
{
145-
return [
146-
'single-default-value' => [
147-
22, '22'
148-
],
149-
'no-default-for-all-group' => [
150-
1, json_encode(['12' => '111'])
151-
],
152-
'default-for-all-group' => [
153-
5, json_encode(['12' => '111', GroupInterface::CUST_GROUP_ALL => '5'])
154-
]
155-
];
156-
}
157-
158129
/**
159130
* Run test getTabLabel method
160131
*

0 commit comments

Comments
 (0)