Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 6128c5a

Browse files
[EngCom] Public Pull Requests - 2.3-develop
- merged latest code from mainline branch
2 parents fce11d6 + 3ef3885 commit 6128c5a

26 files changed

+1267
-573
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,10 +1119,15 @@ public function reindex()
11191119
}
11201120
}
11211121
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
1122-
if (!$productIndexer->isScheduled()
1123-
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
1124-
) {
1125-
$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+
}
11261131
}
11271132
}
11281133

@@ -1147,9 +1152,17 @@ public function getIdentities()
11471152
$identities = [
11481153
self::CACHE_TAG . '_' . $this->getId(),
11491154
];
1155+
11501156
if ($this->hasDataChanges()) {
11511157
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
11521158
}
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+
11531166
if (!$this->getId() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
11541167
$identities[] = self::CACHE_TAG;
11551168
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();

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/Model/CategoryTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,16 @@ public function testReindexFlatEnabled(
383383
public function reindexFlatDisabledTestDataProvider()
384384
{
385385
return [
386-
[false, null, null, null, 0],
387-
[true, null, null, null, 0],
388-
[false, [], null, null, 0],
389-
[false, ["1", "2"], null, null, 1],
390-
[false, null, 1, null, 1],
391-
[false, ["1", "2"], 0, 1, 1],
392-
[false, null, 1, 1, 0],
386+
[false, null, null, null, null, null, 0],
387+
[true, null, null, null, null, null, 0],
388+
[false, [], null, null, null, null, 0],
389+
[false, ["1", "2"], null, null, null, null, 1],
390+
[false, null, 1, null, null, null, 1],
391+
[false, ["1", "2"], 0, 1, null, null, 1],
392+
[false, null, 1, 1, null, null, 0],
393+
[false, ["1", "2"], null, null, 0, 1, 1],
394+
[false, ["1", "2"], null, null, 1, 0, 1],
395+
393396
];
394397
}
395398

@@ -407,11 +410,16 @@ public function testReindexFlatDisabled(
407410
$affectedIds,
408411
$isAnchorOrig,
409412
$isAnchor,
413+
$isActiveOrig,
414+
$isActive,
410415
$expectedProductReindexCall
411416
) {
412417
$this->category->setAffectedProductIds($affectedIds);
413418
$this->category->setData('is_anchor', $isAnchor);
414419
$this->category->setOrigData('is_anchor', $isAnchorOrig);
420+
$this->category->setData('is_active', $isActive);
421+
$this->category->setOrigData('is_active', $isActiveOrig);
422+
415423
$this->category->setAffectedProductIds($affectedIds);
416424

417425
$pathIds = ['path/1/2', 'path/2/3'];
@@ -422,7 +430,7 @@ public function testReindexFlatDisabled(
422430
->method('isFlatEnabled')
423431
->will($this->returnValue(false));
424432

425-
$this->productIndexer->expects($this->exactly(1))
433+
$this->productIndexer
426434
->method('isScheduled')
427435
->willReturn($productScheduled);
428436
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))

app/code/Magento/CatalogUrlRewrite/Observer/ProductToWebsiteChangeObserver.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Magento\UrlRewrite\Model\UrlPersistInterface;
1515
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1616

17+
/**
18+
* Observer to assign the products to website
19+
*/
1720
class ProductToWebsiteChangeObserver implements ObserverInterface
1821
{
1922
/**
@@ -69,12 +72,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6972
$this->request->getParam('store_id', Store::DEFAULT_STORE_ID)
7073
);
7174

72-
$this->urlPersist->deleteByData([
73-
UrlRewrite::ENTITY_ID => $product->getId(),
74-
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
75-
]);
76-
if ($product->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE) {
77-
$this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
75+
if (!empty($this->productUrlRewriteGenerator->generate($product))) {
76+
$this->urlPersist->deleteByData([
77+
UrlRewrite::ENTITY_ID => $product->getId(),
78+
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
79+
]);
80+
if ($product->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE) {
81+
$this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
82+
}
7883
}
7984
}
8085
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminUrlForProductRewrittenCorrectlyTest">
11+
<annotations>
12+
<features value="CatalogUrlRewrite"/>
13+
<title value="Check that URL for product rewritten correctly"/>
14+
<description value="Check that URL for product rewritten correctly"/>
15+
<severity value="MAJOR"/>
16+
<testCaseId value="MAGETWO-97224"/>
17+
<useCaseId value="MAGETWO-64191"/>
18+
<group value="CatalogUrlRewrite"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
24+
<!--Create product-->
25+
<createData entity="_defaultCategory" stepKey="category"/>
26+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
27+
<requiredEntity createDataKey="category"/>
28+
</createData>
29+
</before>
30+
<after>
31+
<!--Delete created data-->
32+
<deleteData createDataKey="createProduct" stepKey="deleteSimpleProduct"/>
33+
<deleteData createDataKey="category" stepKey="deleteCategory"/>
34+
35+
<actionGroup ref="logout" stepKey="logout"/>
36+
</after>
37+
38+
<!--Open Created product-->
39+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="amOnEditPage"/>
40+
<waitForPageLoad stepKey="waitForEditPage"/>
41+
42+
<!--Switch to Default Store view-->
43+
<actionGroup ref="SwitchToTheNewStoreView" stepKey="selectSecondStoreView">
44+
<argument name="storeViewName" value="Default Store View"/>
45+
</actionGroup>
46+
<waitForPageLoad stepKey="waitForStoreViewLoad"/>
47+
48+
<!--Set use default url-->
49+
<click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="clickOnSearchEngineOptimization"/>
50+
<waitForElementVisible selector="{{AdminProductSEOSection.useDefaultUrl}}" stepKey="waitForUseDefaultUrlCheckbox"/>
51+
<click selector="{{AdminProductSEOSection.useDefaultUrl}}" stepKey="clickUseDefaultUrlCheckbox"/>
52+
<fillField selector="{{AdminProductSEOSection.urlKeyInput}}" userInput="$$createProduct.sku$$-new" stepKey="changeUrlKey"/>
53+
<actionGroup ref="saveProductForm" stepKey="saveProduct"/>
54+
55+
<!--Select product and go toUpdate Attribute page-->
56+
<amOnPage url="{{ProductCatalogPage.url}}" stepKey="GoToCatalogPageChangingView"/>
57+
<waitForPageLoad stepKey="WaitForPageToLoadFullyChangingView"/>
58+
<actionGroup ref="filterProductGridByName" stepKey="filterBundleProductOptionsDownToName">
59+
<argument name="product" value="ApiSimpleProduct"/>
60+
</actionGroup>
61+
<click selector="{{AdminProductFiltersSection.allCheckbox}}" stepKey="ClickOnSelectAllCheckBoxChangingView"/>
62+
<click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickActionDropdown"/>
63+
<click selector="{{AdminProductGridSection.bulkActionOption('Update attributes')}}" stepKey="clickBulkUpdate"/>
64+
<waitForPageLoad stepKey="waitForUpdateAttributesPageLoad"/>
65+
<seeInCurrentUrl url="{{ProductAttributesEditPage.url}}" stepKey="seeInUrlAttributeUpdatePage"/>
66+
<click selector="{{AdminUpdateAttributesWebsiteSection.website}}" stepKey="clickWebsiteTab"/>
67+
<waitForAjaxLoad stepKey="waitForLoadWebSiteTab"/>
68+
<click selector="{{AdminUpdateAttributesWebsiteSection.addProductToWebsite}}" stepKey="checkAddProductToWebsiteCheckbox"/>
69+
<click selector="{{AdminUpdateAttributesSection.saveButton}}" stepKey="clickSave"/>
70+
<see selector="{{AdminProductMessagesSection.successMessage}}" userInput="A total of 1 record(s) were updated." stepKey="seeSaveSuccess"/>
71+
72+
<!--Got to Store front product page and check url-->
73+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.sku$$-new)}}" stepKey="navigateToSimpleProductPage"/>
74+
<seeInCurrentUrl url="{{StorefrontProductPage.url($$createProduct.sku$$-new)}}" stepKey="seeProductNewUrl"/>
75+
</test>
76+
</tests>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<!-- Go to checkout from minicart -->
1818
<actionGroup name="GoToCheckoutFromMinicartActionGroup">
1919
<waitForElementNotVisible selector="{{StorefrontMinicartSection.emptyCart}}" stepKey="waitUpdateQuantity" />
20+
<wait time="5" stepKey="waitMinicartRendering"/>
2021
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/>
2122
<click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/>
2223
</actionGroup>

0 commit comments

Comments
 (0)