Skip to content

Commit 410d421

Browse files
Merge remote-tracking branch 'mainline/2.3.3-develop' into MC-18977
2 parents fe43246 + 7063e2a commit 410d421

File tree

16 files changed

+135
-158
lines changed

16 files changed

+135
-158
lines changed

app/code/Magento/Catalog/Controller/Product/Compare/Add.php

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,72 @@
66
*/
77
namespace Magento\Catalog\Controller\Product\Compare;
88

9-
use Magento\Catalog\Model\Product\Attribute\Source\Status;
9+
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability;
1011
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
12+
use Magento\Framework\Data\Form\FormKey\Validator;
1113
use Magento\Framework\Exception\NoSuchEntityException;
14+
use Magento\Framework\View\Result\PageFactory;
1215

1316
/**
1417
* Add item to compare list action.
18+
*
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1520
*/
1621
class Add extends \Magento\Catalog\Controller\Product\Compare implements HttpPostActionInterface
1722
{
23+
/**
24+
* @var AddToCompareAvailability
25+
*/
26+
private $compareAvailability;
27+
28+
/**
29+
* @param \Magento\Framework\App\Action\Context $context
30+
* @param \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory
31+
* @param \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory $itemCollectionFactory
32+
* @param \Magento\Customer\Model\Session $customerSession
33+
* @param \Magento\Customer\Model\Visitor $customerVisitor
34+
* @param \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList
35+
* @param \Magento\Catalog\Model\Session $catalogSession
36+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
37+
* @param Validator $formKeyValidator
38+
* @param PageFactory $resultPageFactory
39+
* @param ProductRepositoryInterface $productRepository
40+
* @param AddToCompareAvailability|null $compareAvailability
41+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
42+
*/
43+
public function __construct(
44+
\Magento\Framework\App\Action\Context $context,
45+
\Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory,
46+
\Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory $itemCollectionFactory,
47+
\Magento\Customer\Model\Session $customerSession,
48+
\Magento\Customer\Model\Visitor $customerVisitor,
49+
\Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList,
50+
\Magento\Catalog\Model\Session $catalogSession,
51+
\Magento\Store\Model\StoreManagerInterface $storeManager,
52+
Validator $formKeyValidator,
53+
PageFactory $resultPageFactory,
54+
ProductRepositoryInterface $productRepository,
55+
AddToCompareAvailability $compareAvailability = null
56+
) {
57+
parent::__construct(
58+
$context,
59+
$compareItemFactory,
60+
$itemCollectionFactory,
61+
$customerSession,
62+
$customerVisitor,
63+
$catalogProductCompareList,
64+
$catalogSession,
65+
$storeManager,
66+
$formKeyValidator,
67+
$resultPageFactory,
68+
$productRepository
69+
);
70+
71+
$this->compareAvailability = $compareAvailability
72+
?: $this->_objectManager->get(AddToCompareAvailability::class);
73+
}
74+
1875
/**
1976
* Add item to compare list.
2077
*
@@ -37,7 +94,7 @@ public function execute()
3794
$product = null;
3895
}
3996

40-
if ($product && (int)$product->getStatus() !== Status::STATUS_DISABLED) {
97+
if ($product && $this->compareAvailability->isAvailableForCompare($product)) {
4198
$this->_catalogProductCompareList->addProduct($product);
4299
$productName = $this->_objectManager->get(
43100
\Magento\Framework\Escaper::class

app/code/Magento/Catalog/Controller/Product/Compare/Remove.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
namespace Magento\Catalog\Controller\Product\Compare;
88

9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
910
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1011
use Magento\Framework\Exception\NoSuchEntityException;
1112

@@ -17,12 +18,13 @@ class Remove extends \Magento\Catalog\Controller\Product\Compare implements Http
1718
/**
1819
* Remove item from compare list.
1920
*
21+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
2022
* @return \Magento\Framework\Controller\ResultInterface
2123
*/
2224
public function execute()
2325
{
2426
$productId = (int)$this->getRequest()->getParam('product');
25-
if ($productId) {
27+
if ($this->_formKeyValidator->validate($this->getRequest()) && $productId) {
2628
$storeId = $this->_storeManager->getStore()->getId();
2729
try {
2830
/** @var \Magento\Catalog\Model\Product $product */
@@ -31,7 +33,7 @@ public function execute()
3133
$product = null;
3234
}
3335

34-
if ($product && $product->isSalable()) {
36+
if ($product && (int)$product->getStatus() !== Status::STATUS_DISABLED) {
3537
/** @var $item \Magento\Catalog\Model\Product\Compare\Item */
3638
$item = $this->_compareItemFactory->create();
3739
if ($this->_customerSession->isLoggedIn()) {

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,43 @@
1818
<testCaseId value="MAGETWO-98644"/>
1919
<useCaseId value="MAGETWO-98522"/>
2020
<group value="Catalog"/>
21-
<skip>
22-
<issueId value="MC-15930"/>
23-
</skip>
2421
</annotations>
2522
<before>
2623
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
27-
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 0" stepKey="displayOutOfStockNo"/>
24+
<magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockDisable.path}} {{CatalogInventoryOptionsShowOutOfStockDisable.value}}" stepKey="setConfigShowOutOfStockFalse"/>
2825
<magentoCLI command="cache:flush" stepKey="flushCache"/>
2926
<createData entity="SimpleSubCategory" stepKey="category"/>
3027
<createData entity="SimpleProduct4" stepKey="product">
3128
<requiredEntity createDataKey="category"/>
3229
</createData>
3330
</before>
3431
<after>
35-
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 0" stepKey="displayOutOfStockNo2"/>
32+
<magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockDisable.path}} {{CatalogInventoryOptionsShowOutOfStockDisable.value}}" stepKey="setConfigShowOutOfStockFalse"/>
3633
<magentoCLI command="cache:flush" stepKey="flushCache"/>
3734
<deleteData createDataKey="product" stepKey="deleteProduct"/>
3835
<deleteData createDataKey="category" stepKey="deleteCategory"/>
3936
<actionGroup ref="logout" stepKey="logout"/>
4037
</after>
4138
<!--Open product page-->
4239
<comment userInput="Open product page" stepKey="openProdPage"/>
43-
<amOnPage url="{{StorefrontProductPage.url($$product.name$$)}}" stepKey="goToSimpleProductPage"/>
40+
<amOnPage url="{{StorefrontProductPage.url($$product.custom_attributes[url_key]$$)}}" stepKey="goToSimpleProductPage"/>
4441
<waitForPageLoad stepKey="waitForSimpleProductPage"/>
4542
<!--'Add to compare' link is not available-->
4643
<comment userInput="'Add to compare' link is not available" stepKey="addToCompareLinkAvailability"/>
4744
<dontSeeElement selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="dontSeeAddToCompareLink"/>
4845
<!--Turn on 'out on stock' config-->
4946
<comment userInput="Turn on 'out of stock' config" stepKey="onOutOfStockConfig"/>
50-
<magentoCLI command="config:set cataloginventory/options/show_out_of_stock 1" stepKey="displayOutOfStockYes"/>
47+
<magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockEnable.path}} {{CatalogInventoryOptionsShowOutOfStockEnable.value}}" stepKey="setConfigShowOutOfStockTrue"/>
5148
<!--Clear cache and reindex-->
5249
<comment userInput="Clear cache and reindex" stepKey="cleanCache"/>
5350
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
5451
<magentoCLI command="cache:flush" stepKey="flushCache"/>
5552
<!--Open product page-->
5653
<comment userInput="Open product page" stepKey="openProductPage"/>
57-
<amOnPage url="{{StorefrontProductPage.url($$product.name$$)}}" stepKey="goToSimpleProductPage2"/>
54+
<amOnPage url="{{StorefrontProductPage.url($$product.custom_attributes[url_key]$$)}}" stepKey="goToSimpleProductPage2"/>
5855
<waitForPageLoad stepKey="waitForSimpleProductPage2"/>
5956
<!--Click on 'Add to Compare' link-->
57+
<waitForElementVisible selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="seeAddToCompareLink"/>
6058
<comment userInput="Click on 'Add to Compare' link" stepKey="clickOnAddToCompareLink"/>
6159
<click selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="clickOnAddToCompare"/>
6260
<waitForPageLoad stepKey="waitForProdAddToCmpList"/>

app/code/Magento/Catalog/ViewModel/Product/Checker/AddToCompareAvailability.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\View\Element\Block\ArgumentInterface;
1111
use Magento\Catalog\Api\Data\ProductInterface;
1212
use Magento\CatalogInventory\Api\StockConfigurationInterface;
13+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1314

1415
/**
1516
* Check is available add to compare.
@@ -37,7 +38,11 @@ public function __construct(StockConfigurationInterface $stockConfiguration)
3738
*/
3839
public function isAvailableForCompare(ProductInterface $product): bool
3940
{
40-
return $this->isInStock($product) || $this->stockConfiguration->isShowOutOfStock();
41+
if ((int)$product->getStatus() !== Status::STATUS_DISABLED) {
42+
return $this->isInStock($product) || $this->stockConfiguration->isShowOutOfStock();
43+
}
44+
45+
return false;
4146
}
4247

4348
/**
@@ -53,6 +58,6 @@ private function isInStock(ProductInterface $product): bool
5358
return $product->isSalable();
5459
}
5560

56-
return isset($quantityAndStockStatus['is_in_stock']) && $quantityAndStockStatus['is_in_stock'];
61+
return $quantityAndStockStatus['is_in_stock'] ?? false;
5762
}
5863
}

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutJsValidationTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<test name="StorefrontOnePageCheckoutJsValidationTest">
1212
<annotations>
1313
<features value="Checkout"/>
14+
<stories value="Checkout"/>
1415
<title value="Js validation error messages must be absent for required fields after checkout start."/>
1516
<description value="Js validation error messages must be absent for required fields after checkout start."/>
1617
<severity value="MAJOR" />

app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,4 @@ public function getShippingLabel()
111111
}
112112
return $label;
113113
}
114-
115-
/**
116-
* Get update totals url.
117-
*
118-
* @return string
119-
*/
120-
public function getUpdateTotalsUrl(): string
121-
{
122-
return $this->getUrl(
123-
'sales/*/updateQty',
124-
[
125-
'order_id' => $this->getSource()->getOrderId(),
126-
'invoice_id' => $this->getRequest()->getParam('invoice_id', null),
127-
]
128-
);
129-
}
130114
}

app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ protected function _prepareLayout()
5656
$this->addChild(
5757
'update_button',
5858
\Magento\Backend\Block\Widget\Button::class,
59-
['label' => __('Update Qty\'s'), 'class' => 'update-button secondary', 'onclick' => $onclick]
60-
);
61-
$this->addChild(
62-
'update_totals_button',
63-
\Magento\Backend\Block\Widget\Button::class,
64-
['label' => __('Update Totals'), 'class' => 'update-totals-button secondary', 'onclick' => $onclick]
59+
['label' => __('Update Qty\'s'), 'class' => 'update-button', 'onclick' => $onclick]
6560
);
6661

6762
if ($this->getCreditmemo()->canRefund()) {
@@ -181,16 +176,6 @@ public function getUpdateButtonHtml()
181176
return $this->getChildHtml('update_button');
182177
}
183178

184-
/**
185-
* Get update totals button html
186-
*
187-
* @return string
188-
*/
189-
public function getUpdateTotalsButtonHtml(): string
190-
{
191-
return $this->getChildHtml('update_totals_button');
192-
}
193-
194179
/**
195180
* Get update url
196181
*

app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<testCaseId value="MC-18159"/>
1919
<useCaseId value="MC-17003"/>
2020
<group value="sales"/>
21+
<skip>
22+
<issueId value="MC-17003"/>
23+
</skip>
2124
</annotations>
2225
<before>
2326
<!--Create product-->

app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
<span class="title"><?= $block->escapeHtml(__('Refund Totals')) ?></span>
101101
</div>
102102
<?= $block->getChildHtml('creditmemo_totals') ?>
103-
<div class="totals-actions"><?= $block->getUpdateTotalsButtonHtml() ?></div>
104103
<div class="order-totals-actions">
105104
<div class="field choice admin__field admin__field-option field-append-comments">
106105
<input id="notify_customer"
@@ -140,9 +139,8 @@ require(['jquery'], function(jQuery){
140139

141140
//<![CDATA[
142141
var submitButtons = jQuery('.submit-button');
143-
var updateButtons = jQuery('.update-button,.update-totals-button');
144-
var fields = jQuery('.qty-input,.order-subtotal-table input[type="text"]');
145-
142+
var updateButtons = jQuery('.update-button');
143+
var fields = jQuery('.qty-input');
146144
function enableButtons(buttons) {
147145
buttons.removeClass('disabled').prop('disabled', false);
148146
}

app/code/Magento/Theme/Test/Mftf/Test/AdminWatermarkUploadTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<description value="Watermark images should be able to be uploaded in the admin"/>
1717
<severity value="MAJOR"/>
1818
<testCaseId value="MC-5796"/>
19+
<skip>
20+
<issueId value="MC-18496"/>
21+
</skip>
1922
<group value="Watermark"/>
2023
</annotations>
2124
<before>

0 commit comments

Comments
 (0)