Skip to content

Commit 48a2884

Browse files
Merge branch 2.2-develop into ENGCOM-3968-magento-magento2-18472
2 parents df7c4ff + 6d856c4 commit 48a2884

File tree

84 files changed

+1381
-291
lines changed

Some content is hidden

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

84 files changed

+1381
-291
lines changed

app/code/Magento/Catalog/Block/Product/View/Attributes.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Framework\Pricing\PriceCurrencyInterface;
1717

1818
/**
19+
* Attributes attributes block
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -56,6 +58,8 @@ public function __construct(
5658
}
5759

5860
/**
61+
* Returns a Product.
62+
*
5963
* @return Product
6064
*/
6165
public function getProduct()
@@ -67,6 +71,8 @@ public function getProduct()
6771
}
6872

6973
/**
74+
* Additional data.
75+
*
7076
* $excludeAttr is optional array of attribute codes to
7177
* exclude them from additional data array
7278
*
@@ -89,7 +95,7 @@ public function getAdditionalData(array $excludeAttr = [])
8995
$value = $this->priceCurrency->convertAndFormat($value);
9096
}
9197

92-
if (is_string($value) && strlen($value)) {
98+
if (is_string($value) && strlen(trim($value))) {
9399
$data[$attribute->getAttributeCode()] = [
94100
'label' => __($attribute->getStoreLabel()),
95101
'value' => $value,

app/code/Magento/Catalog/Block/Product/View/Options.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/**
8-
* Product options block
9-
*
10-
* @author Magento Core Team <[email protected]>
11-
*/
127
namespace Magento\Catalog\Block\Product\View;
138

149
use Magento\Catalog\Model\Product;
10+
use Magento\Catalog\Model\Product\Option\Value;
1511

1612
/**
13+
* Product options block
14+
*
15+
* @author Magento Core Team <[email protected]>
1716
* @api
1817
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1918
* @since 100.0.2
@@ -121,6 +120,8 @@ public function setProduct(Product $product = null)
121120
}
122121

123122
/**
123+
* Get group of option.
124+
*
124125
* @param string $type
125126
* @return string
126127
*/
@@ -142,6 +143,8 @@ public function getOptions()
142143
}
143144

144145
/**
146+
* Check if block has options.
147+
*
145148
* @return bool
146149
*/
147150
public function hasOptions()
@@ -160,7 +163,10 @@ public function hasOptions()
160163
*/
161164
protected function _getPriceConfiguration($option)
162165
{
163-
$optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false);
166+
$optionPrice = $option->getPrice(true);
167+
if ($option->getPriceType() !== Value::TYPE_PERCENT) {
168+
$optionPrice = $this->pricingHelper->currency($optionPrice, false, false);
169+
}
164170
$data = [
165171
'prices' => [
166172
'oldPrice' => [
@@ -195,7 +201,7 @@ protected function _getPriceConfiguration($option)
195201
],
196202
],
197203
'type' => $option->getPriceType(),
198-
'name' => $option->getTitle()
204+
'name' => $option->getTitle(),
199205
];
200206
return $data;
201207
}
@@ -231,7 +237,7 @@ public function getJsonConfig()
231237
//pass the return array encapsulated in an object for the other modules to be able to alter it eg: weee
232238
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['configObj' => $configObj]);
233239

234-
$config=$configObj->getConfig();
240+
$config = $configObj->getConfig();
235241

236242
return $this->_jsonEncoder->encode($config);
237243
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private function isUniqueAdminValues(array $optionsValues, array $deletedOptions
158158
{
159159
$adminValues = [];
160160
foreach ($optionsValues as $optionKey => $values) {
161-
if (!(isset($deletedOptions[$optionKey]) and $deletedOptions[$optionKey] === '1')) {
161+
if (!(isset($deletedOptions[$optionKey]) && $deletedOptions[$optionKey] === '1')) {
162162
$adminValues[] = reset($values);
163163
}
164164
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
2020

2121
/**
22+
* Product helper
23+
*
2224
* @api
2325
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2426
* @since 100.0.2
@@ -104,7 +106,7 @@ class Helper
104106
* @param \Magento\Backend\Helper\Js $jsHelper
105107
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
106108
* @param CustomOptionFactory|null $customOptionFactory
107-
* @param ProductLinkFactory |null $productLinkFactory
109+
* @param ProductLinkFactory|null $productLinkFactory
108110
* @param ProductRepositoryInterface|null $productRepository
109111
* @param LinkTypeProvider|null $linkTypeProvider
110112
* @param AttributeFilter|null $attributeFilter
@@ -365,6 +367,8 @@ private function overwriteValue($optionId, $option, $overwriteOptions)
365367
}
366368

367369
/**
370+
* Get link resolver instance
371+
*
368372
* @return LinkResolver
369373
* @deprecated 101.0.0
370374
*/
@@ -377,6 +381,8 @@ private function getLinkResolver()
377381
}
378382

379383
/**
384+
* Get DateTimeFilter instance
385+
*
380386
* @return \Magento\Framework\Stdlib\DateTime\Filter\DateTime
381387
* @deprecated 101.0.0
382388
*/
@@ -391,6 +397,7 @@ private function getDateTimeFilter()
391397

392398
/**
393399
* Remove ids of non selected websites from $websiteIds array and return filtered data
400+
*
394401
* $websiteIds parameter expects array with website ids as keys and 1 (selected) or 0 (non selected) as values
395402
* Only one id (default website ID) will be set to $websiteIds array when the single store mode is turned on
396403
*
@@ -463,6 +470,7 @@ private function fillProductOptions(Product $product, array $productOptions)
463470
private function convertSpecialFromDateStringToObject($productData)
464471
{
465472
if (isset($productData['special_from_date']) && $productData['special_from_date'] != '') {
473+
$productData['special_from_date'] = $this->getDateTimeFilter()->filter($productData['special_from_date']);
466474
$productData['special_from_date'] = new \DateTime($productData['special_from_date']);
467475
}
468476

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,10 +1130,15 @@ public function reindex()
11301130
}
11311131
}
11321132
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
1133-
if (!$productIndexer->isScheduled()
1134-
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
1135-
) {
1136-
$productIndexer->reindexList($this->getPathIds());
1133+
1134+
if (!empty($this->getAffectedProductIds())
1135+
|| $this->dataHasChangedFor('is_anchor')
1136+
|| $this->dataHasChangedFor('is_active')) {
1137+
if (!$productIndexer->isScheduled()) {
1138+
$productIndexer->reindexList($this->getPathIds());
1139+
} else {
1140+
$productIndexer->invalidate();
1141+
}
11371142
}
11381143
}
11391144

@@ -1165,16 +1170,14 @@ public function getIdentities()
11651170
$identities[] = self::CACHE_TAG . '_' . $this->getId();
11661171
}
11671172

1168-
if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
1169-
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
1170-
}
1171-
1173+
$identities = $this->getCategoryRelationIdentities($identities);
1174+
11721175
if ($this->isObjectNew()) {
11731176
$identities[] = self::CACHE_TAG;
11741177
}
11751178
}
11761179

1177-
return $identities;
1180+
return array_unique($identities);
11781181
}
11791182

11801183
/**
@@ -1460,5 +1463,25 @@ public function setExtensionAttributes(\Magento\Catalog\Api\Data\CategoryExtensi
14601463
return $this->_setExtensionAttributes($extensionAttributes);
14611464
}
14621465

1466+
/**
1467+
* Return category relation identities.
1468+
*
1469+
* @param array $identities
1470+
* @return array
1471+
*/
1472+
private function getCategoryRelationIdentities(array $identities): array
1473+
{
1474+
if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
1475+
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
1476+
if ($this->dataHasChangedFor('is_anchor') || $this->dataHasChangedFor('is_active')) {
1477+
foreach ($this->getPathIds() as $id) {
1478+
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $id;
1479+
}
1480+
}
1481+
}
1482+
1483+
return $identities;
1484+
}
1485+
14631486
//@codeCoverageIgnoreEnd
14641487
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
<see userInput="{{category.name}}" selector="{{StorefrontCategoryMainSection.categoryTitle}}" stepKey="assertCategoryName"/>
2020
<see userInput="{{productCount}}" selector="{{StorefrontCategoryMainSection.productCount}} span" stepKey="assertProductCount"/>
2121
</actionGroup>
22+
<!--Check category is empty-->
23+
<actionGroup name="StorefrontCheckEmptyCategoryActionGroup" extends="StorefrontCheckCategoryActionGroup">
24+
<remove keyForRemoval="assertProductCount"/>
25+
<amOnPage url="{{StorefrontCategoryPage.url(category.name)}}" before="checkUrl" stepKey="goToCategoryStorefront"/>
26+
<see selector="{{StorefrontCategoryMainSection.categoryEmptyMessage}}" userInput="We can't find products matching the selection." stepKey="seeCategoryEmpty"/>
27+
</actionGroup>
2228

2329
<!-- Check simple product on the category page -->
2430
<actionGroup name="StorefrontCheckCategorySimpleProduct">
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
10+
<page name="AdminProductUpdateAttributesPage" url="catalog/product_action_attribute/edit/" area="admin" module="Magento_Catalog">
11+
<section name="AdminUpdateAttributesHeaderSection"/>
12+
<section name="AdminUpdateAttributesWebsiteSection"/>
13+
</page>
14+
</pages>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductFiltersSection">
1212
<element name="FiltersButton" type="button" selector="#container > div > div.admin__data-grid-header > div:nth-child(1) > div.data-grid-filters-actions-wrap > div > button"/>
1313
<element name="clearFiltersButton" type="button" selector="//div[@class='admin__data-grid-header']//button[@class='action-tertiary action-clear']" timeout="10"/>
1414
<element name="NameInput" type="input" selector="input[name=name]"/>
1515
<element name="SkuInput" type="input" selector="input[name=sku]"/>
1616
<element name="Apply" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/>
17+
<element name="allCheckbox" type="checkbox" selector="div[data-role='grid-wrapper'] label[data-bind='attr: {for: ko.uid}']" timeout="30"/>
1718
</section>
1819
</sections>

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>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="AdminUpdateAttributesHeaderSection">
11+
<element name="saveButton" type="button" selector="button[data-ui-id='page-actions-toolbar-save-button']" timeout="30"/>
12+
</section>
13+
<section name="AdminUpdateAttributesWebsiteSection">
14+
<element name="website" type="button" selector="#attributes_update_tabs_websites"/>
15+
<element name="addProductToWebsite" type="checkbox" selector="#add-products-to-website-content .website-checkbox"/>
16+
</section>
17+
</sections>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
<element name="categoryPageProductImagePlaceholderSmall" type="text" selector=".products-grid img[src*='placeholder/small_image.jpg']"/>
2323
<element name="categoryPageProductImage" type="text" selector=".products-grid img[src*='/{{var1}}']" parameterized="true"/>
2424
<element name="categoryPageProductName" type="text" selector=".products.list.items.product-items li:nth-of-type({{line}}) .product-item-link" timeout="30" parameterized="true"/>
25+
<element name="categoryEmptyMessage" type="text" selector=".column.main .message.info.empty"/>
2526
</section>
2627
</sections>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontProductAvailableAfterEnablingSubCategoriesTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Show category products on storefront"/>
14+
<title value="Check that parent categories are showing products after enabling subcategories"/>
15+
<description value="Check that parent categories are showing products after enabling subcategories"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-13914"/>
18+
<useCaseId value="MAGETWO-96489"/>
19+
<group value="Catalog"/>
20+
</annotations>
21+
<before>
22+
<createData entity="_defaultCategory" stepKey="createCategory"/>
23+
<createData entity="SubCategoryWithParent" stepKey="createSubCategory">
24+
<requiredEntity createDataKey="createCategory"/>
25+
<field key="is_active">false</field>
26+
</createData>
27+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
28+
<requiredEntity createDataKey="createSubCategory"/>
29+
</createData>
30+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
31+
</before>
32+
<after>
33+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
34+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
35+
<actionGroup ref="logout" stepKey="logout"/>
36+
</after>
37+
<!--Check anchor category is empty-->
38+
<actionGroup ref="StorefrontCheckEmptyCategoryActionGroup" stepKey="checkEmptyAnchorCategory">
39+
<argument name="category" value="$$createCategory$$"/>
40+
<argument name="productCount" value="0"/>
41+
</actionGroup>
42+
<!--Enable subcategory-->
43+
<actionGroup ref="AdminNavigateToCategoryInTree" stepKey="openCreatedSubCategory">
44+
<argument name="category" value="$$createSubCategory$$"/>
45+
</actionGroup>
46+
<click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="enableCategory"/>
47+
<actionGroup ref="saveCategoryForm" stepKey="saveCategory"/>
48+
<!--Check created product in anchor category on storefront-->
49+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="goToCategoryStorefront"/>
50+
<actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="seeCreatedProduct">
51+
<argument name="product" value="$$createSimpleProduct$$"/>
52+
</actionGroup>
53+
</test>
54+
</tests>

0 commit comments

Comments
 (0)