Skip to content

Commit 703c029

Browse files
author
Oleksandr Iegorov
committed
Merge branch '2.4-develop' of github.com:magento-commerce/magento2ce into ACP2E-716
2 parents 0523cb7 + c45e170 commit 703c029

File tree

7 files changed

+169
-5
lines changed

7 files changed

+169
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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="StorefrontSelectionOfOutOfStockChildProductsOfConfigurableProductDisabledTest">
12+
<annotations>
13+
<features value="CatalogInventory"/>
14+
<stories value="Storefront selection of out of stock child products of configurable product"/>
15+
<title value="Storefront selection of out of stock child products of configurable Product disabled"/>
16+
<description value="Storefront selection of out of stock child products of configurable are disabled on storefront when display of out of stock options are enabled"/>
17+
<severity value="MAJOR"/>
18+
<group value="catalogInventory"/>
19+
</annotations>
20+
21+
<before>
22+
<!--Set Display out of stock product-->
23+
<magentoCLI stepKey="setDisplayOutOfStockProduct" command="config:set cataloginventory/options/show_out_of_stock 1" />
24+
<!-- Create category -->
25+
<createData entity="SimpleSubCategory" stepKey="simplecategory"/>
26+
<!-- Create configurable product with two options -->
27+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
28+
<requiredEntity createDataKey="simplecategory"/>
29+
</createData>
30+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
31+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
32+
<requiredEntity createDataKey="createConfigProductAttribute"/>
33+
</createData>
34+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
35+
<requiredEntity createDataKey="createConfigProductAttribute"/>
36+
</createData>
37+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
38+
<requiredEntity createDataKey="createConfigProductAttribute"/>
39+
</createData>
40+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
41+
<requiredEntity createDataKey="createConfigProductAttribute"/>
42+
</getData>
43+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
44+
<requiredEntity createDataKey="createConfigProductAttribute"/>
45+
</getData>
46+
<!-- Create child products -->
47+
<createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1">
48+
<requiredEntity createDataKey="createConfigProductAttribute"/>
49+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
50+
</createData>
51+
<createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2">
52+
<requiredEntity createDataKey="createConfigProductAttribute"/>
53+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
54+
</createData>
55+
<createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption">
56+
<requiredEntity createDataKey="createConfigProduct"/>
57+
<requiredEntity createDataKey="createConfigProductAttribute"/>
58+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
59+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
60+
</createData>
61+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1">
62+
<requiredEntity createDataKey="createConfigProduct"/>
63+
<requiredEntity createDataKey="createConfigChildProduct1"/>
64+
</createData>
65+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2">
66+
<requiredEntity createDataKey="createConfigProduct"/>
67+
<requiredEntity createDataKey="createConfigChildProduct2"/>
68+
</createData>
69+
<magentoCron groups="index" stepKey="reindex"/>
70+
</before>
71+
72+
<after>
73+
<magentoCLI stepKey="setDisplayOutOfStockProduct" command="config:set cataloginventory/options/show_out_of_stock 0" />
74+
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
75+
<deleteData createDataKey="simplecategory" stepKey="deleteSimpleCategory"/>
76+
<deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
77+
<deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
78+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
79+
<magentoCron groups="index" stepKey="reindexInvalidatedIndices"/>
80+
</after>
81+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/>
82+
<amOnPage url="{{AdminProductEditPage.url($$createConfigChildProduct1.id$$)}}" stepKey="openProductEditPageToSetStatus"/>
83+
<selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="Out of Stock" stepKey="selectOutOfStockStatus"/>
84+
<actionGroup ref="AdminFormSaveAndCloseActionGroup" stepKey="saveProductWithSetOutOfStockStatus"/>
85+
<!-- Go to configurable product page -->
86+
<amOnPage url="/{{ApiConfigurableProduct.urlKey}}2.html" stepKey="goToConfigProductPage"/>
87+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
88+
<!-- Assert the out of stock child product option is disabled on storefront -->
89+
<seeElement selector="#product-options-wrapper .super-attribute-select option:disabled" stepKey="assertConfigAttributeOption1Disabled"/>
90+
</test>
91+
</tests>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ private function deleteObsoleteRewrites(Product $product): void
144144
}
145145
$storesToRemove = array_unique($storesToRemove);
146146
}
147+
$storesToRemove = array_filter($storesToRemove);
147148
if ($storesToRemove) {
148149
$this->urlPersist->deleteByData(
149150
[

app/code/Magento/Reports/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function prepareActiveCartItems()
121121

122122
$quoteItemsSelect->reset()
123123
->from(['main_table' => $this->getTable('quote_item')], '')
124-
->columns('main_table.product_id')
124+
->columns(['main_table.product_id', 'main_table.name'])
125125
->columns(['carts' => new \Zend_Db_Expr('COUNT(main_table.item_id)')])
126126
->columns('quote.base_to_global_rate')
127127
->joinInner(

app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,27 @@ define([
498498
$widget._EmulateSelected($widget._getSelectedAttributes());
499499
},
500500

501+
disableSwatchForOutOfStockProducts: function () {
502+
let $widget = this, container = this.element;
503+
504+
$.each(this.options.jsonConfig.attributes, function () {
505+
let item = this;
506+
507+
if ($widget.options.jsonConfig.canDisplayShowOutOfStockStatus) {
508+
let salableProducts = $widget.options.jsonConfig.salable[item.id],
509+
swatchOptions = container.find('.swatch-option');
510+
511+
swatchOptions.each(function (key, value) {
512+
let optionId = $(value).data('option-id');
513+
514+
if (!salableProducts.hasOwnProperty(optionId)) {
515+
$(value).attr('disabled', true).addClass('disabled');
516+
}
517+
});
518+
}
519+
});
520+
},
521+
501522
/**
502523
* Render swatch options by part of config
503524
*
@@ -888,6 +909,7 @@ define([
888909
.attr('disabled', true)
889910
.addClass('disabled')
890911
.attr('tabindex', '-1');
912+
this.disableSwatchForOutOfStockProducts();
891913
},
892914

893915
/**

dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListProduct/SortingTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ public function testProductListOutOfStockSortOrderWithElasticsearch(
407407
string $direction,
408408
array $expected
409409
): void {
410-
$this->markTestSkipped('MC-40449: ListProduct\SortingTest failure on 2.4-develop');
411410
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expected);
412411
}
413412

@@ -429,7 +428,6 @@ public function testProductListOutOfStockSortOrderWithMysql(
429428
string $direction,
430429
array $expected
431430
): void {
432-
$this->markTestSkipped('MC-40449: ListProduct\SortingTest failure on 2.4-develop');
433431
$this->assertProductListSortOrderWithConfig($sortBy, $direction, $expected);
434432
}
435433

@@ -449,7 +447,7 @@ public function productListWithOutOfStockSortOrderDataProvider(): array
449447
'default_order_price_desc' => [
450448
'sort' => 'price',
451449
'direction' => Collection::SORT_ORDER_DESC,
452-
'expectation' => ['configurable', 'simple3', 'simple2', 'simple1'],
450+
'expectation' => ['simple3', 'simple2', 'simple1', 'configurable'],
453451
],
454452
];
455453
}

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/ProductProcessUrlRewriteSavingObserverTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@
99
use Magento\Catalog\Model\Product;
1010
use Magento\Catalog\Model\Product\Visibility;
1111
use Magento\Catalog\Model\ProductFactory;
12+
use Magento\Catalog\Test\Fixture\Product as ProductFixture;
1213
use Magento\Framework\ObjectManagerInterface;
1314
use Magento\Store\Model\Store;
1415
use Magento\Store\Model\StoreManagerInterface;
16+
use Magento\Store\Test\Fixture\Group as GroupFixture;
17+
use Magento\Store\Test\Fixture\Store as StoreFixture;
18+
use Magento\Store\Test\Fixture\Website as WebsiteFixture;
19+
use Magento\TestFramework\Fixture\DataFixture;
20+
use Magento\TestFramework\Fixture\DataFixtureStorage;
21+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
1522
use Magento\TestFramework\Helper\Bootstrap;
1623
use Magento\UrlRewrite\Model\UrlFinderInterface;
1724
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
@@ -38,6 +45,11 @@ class ProductProcessUrlRewriteSavingObserverTest extends TestCase
3845
*/
3946
private $productRepository;
4047

48+
/**
49+
* @var DataFixtureStorage
50+
*/
51+
private $fixtures;
52+
4153
/**
4254
* Set up
4355
*/
@@ -46,6 +58,7 @@ protected function setUp(): void
4658
$this->objectManager = Bootstrap::getObjectManager();
4759
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
4860
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
61+
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
4962
}
5063

5164
/**
@@ -634,4 +647,44 @@ public function testChangeVisibilityLocalScope()
634647
$this->assertContainsEquals($row, $actual);
635648
}
636649
}
650+
651+
#[
652+
DataFixture(WebsiteFixture::class, as: 'website'),
653+
DataFixture(GroupFixture::class, ['website_id' => '$website.id$'], 'store_group'),
654+
DataFixture(StoreFixture::class, ['store_group_id' => '$store_group.id$'], 'store'),
655+
DataFixture(ProductFixture::class, ['sku' => 'simple1', 'website_ids' => [1,'$website.id$'], 'product']),
656+
]
657+
public function testRemoveProductFromAllWebsites(): void
658+
{
659+
$testStore1 = $this->storeManager->getStore('default');
660+
$testStore2 = $this->fixtures->get('store');
661+
662+
$productFilter = [UrlRewrite::ENTITY_TYPE => 'product'];
663+
664+
/** @var Product $product*/
665+
$product = $this->productRepository->get('simple1');
666+
$product->setWebsiteIds([])
667+
->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE);
668+
$this->productRepository->save($product);
669+
$unexpected = [
670+
[
671+
'request_path' => 'simple1.html',
672+
'target_path' => 'catalog/product/view/id/' . $product->getId(),
673+
'is_auto_generated' => 1,
674+
'redirect_type' => 0,
675+
'store_id' => $testStore1->getId(),
676+
],
677+
[
678+
'request_path' => 'simple1.html',
679+
'target_path' => 'catalog/product/view/id/' . $product->getId(),
680+
'is_auto_generated' => 1,
681+
'redirect_type' => 0,
682+
'store_id' => $testStore2->getId(),
683+
],
684+
];
685+
$actual = $this->getActualResults($productFilter);
686+
foreach ($unexpected as $row) {
687+
$this->assertNotContains($row, $actual);
688+
}
689+
}
637690
}

dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Product/GridTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class GridTest extends \Magento\Reports\Block\Adminhtml\Shopcart\GridTestAbstrac
2222
*/
2323
public function testGridContent()
2424
{
25-
$this->markTestSkipped('MC-40448: Product\GridTest failure on 2.4-develop');
2625
/** @var \Magento\Framework\View\LayoutInterface $layout */
2726
$layout = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class);
2827
/** @var Grid $grid */

0 commit comments

Comments
 (0)