Skip to content

Commit d921385

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-2615' into PR_Tier4_June24
2 parents 71370a9 + 4a4ef64 commit d921385

File tree

4 files changed

+156
-3
lines changed

4 files changed

+156
-3
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2023 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ***********************************************************************
17+
*/
18+
-->
19+
20+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
22+
<actionGroup name="AdminFillCatalogProductsListWidgetSkuActionGroup">
23+
<annotations>
24+
<description>Fill catalog products list widget sku.</description>
25+
</annotations>
26+
27+
<arguments>
28+
<argument name="sku" type="string" defaultValue=""/>
29+
</arguments>
30+
31+
<waitForElementVisible selector="{{WidgetSection.AddParam}}" stepKey="waitForAddParamElement"/>
32+
<click selector="{{WidgetSection.AddParam}}" stepKey="clickOnAddParamElement"/>
33+
<waitForElementVisible selector="{{WidgetSection.ConditionsDropdown}}"
34+
stepKey="waitForConditionsDropdownVisible"/>
35+
<selectOption selector="{{WidgetSection.ConditionsDropdown}}" userInput="SKU" stepKey="selectSkuAsCondition"/>
36+
<waitForElementVisible selector="{{WidgetSection.RuleParam}}" stepKey="waitForRuleParamElementVisible"/>
37+
<click selector="{{WidgetSection.RuleParam}}" stepKey="clickToAddRuleParam"/>
38+
<fillField selector=".rule-param-edit input" userInput="{{sku}}" stepKey="fillSkuField"/>
39+
<click selector="{{AdminNewWidgetSection.applyParameter}}" stepKey="clickApplyButton"/>
40+
</actionGroup>
41+
</actionGroups>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/************************************************************************
4+
*
5+
* Copyright 2023 Adobe
6+
* All Rights Reserved.
7+
*
8+
* NOTICE: All information contained herein is, and remains
9+
* the property of Adobe and its suppliers, if any. The intellectual
10+
* and technical concepts contained herein are proprietary to Adobe
11+
* and its suppliers and are protected by all applicable intellectual
12+
* property laws, including trade secret and copyright laws.
13+
* Dissemination of this information or reproduction of this material
14+
* is strictly forbidden unless prior written permission is obtained
15+
* from Adobe.
16+
* ***********************************************************************
17+
*/
18+
-->
19+
20+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
22+
<test name="StorefrontBundleAddToCartFromWidget">
23+
<annotations>
24+
<features value="Bundle"/>
25+
<stories value="Bundle product details page"/>
26+
<title value="Customer should be able to add a bundle product to the cart from widget"/>
27+
<description value="Customer should be able to add a bundle product to the cart from widget"/>
28+
<severity value="CRITICAL"/>
29+
<testCaseId value="AC-10867"/>
30+
<useCaseId value="ACP2E-2615"/>
31+
<group value="WYSIWYGDisabled"/>
32+
<group value="Bundle"/>
33+
</annotations>
34+
<before>
35+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
36+
<createData entity="SimpleProduct2" stepKey="simpleProduct1"/>
37+
</before>
38+
<after>
39+
<actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteBundleProductBySku">
40+
<argument name="sku" value="{{BundleProductWithSlashSku.sku}}"/>
41+
</actionGroup>
42+
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>
43+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
44+
</after>
45+
46+
<!-- Start creating a bundle product -->
47+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductList"/>
48+
<actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct">
49+
<argument name="product" value="BundleProduct"/>
50+
</actionGroup>
51+
<actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillNameAndSku">
52+
<argument name="product" value="BundleProductWithSlashSku"/>
53+
</actionGroup>
54+
55+
<!-- Add Option One, a "Drop-down" type option -->
56+
<actionGroup ref="AddBundleOptionWithOneProductActionGroup" stepKey="addBundleOptionWithOneProduct">
57+
<argument name="x" value="0"/>
58+
<argument name="n" value="1"/>
59+
<argument name="prodOneSku" value="$$simpleProduct1.sku$$"/>
60+
<argument name="prodTwoSku" value=""/>
61+
<argument name="optionTitle" value="Option One"/>
62+
<argument name="inputType" value="select"/>
63+
</actionGroup>
64+
65+
<!-- Save product, edit Homepage CMS page and add products widget -->
66+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/>
67+
<amOnPage url="{{AdminCmsPageEditPage.url(CmsHomePageContent.page_id)}}" stepKey="navigateToEditCmsHomePage"/>
68+
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickContentTab" />
69+
<actionGroup ref="AdminInsertWidgetToCmsPageContentActionGroup" stepKey="insertWidgetToCmsPageContentActionGroup">
70+
<argument name="widgetType" value="Catalog Products List"/>
71+
</actionGroup>
72+
<actionGroup ref="AdminFillCatalogProductsListWidgetSkuActionGroup" stepKey="selectProductForListing">
73+
<argument name="sku" value="{{BundleProductWithSlashSku.sku}}"/>
74+
</actionGroup>
75+
<actionGroup ref="AdminClickInsertWidgetActionGroup" stepKey="clickInsertWidgetButton2"/>
76+
<actionGroup ref="SaveCmsPageActionGroup" stepKey="clickSaveButton"/>
77+
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the page." stepKey="seeSuccess"/>
78+
79+
<!-- Go to storefront homepage and add to cart -->
80+
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/>
81+
<actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverProduct"/>
82+
<actionGroup ref="StorefrontClickAddToCartButtonActionGroup" stepKey="addToCart"/>
83+
<waitForPageLoad stepKey="waitForProductAdded"/>
84+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="seeSuccessMessage"/>
85+
</test>
86+
</tests>

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1616
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
1717
use Magento\Catalog\Pricing\Price\FinalPrice;
18+
use Magento\Catalog\ViewModel\Product\OptionsData;
1819
use Magento\CatalogWidget\Model\Rule;
1920
use Magento\Framework\App\ActionInterface;
2021
use Magento\Framework\App\Http\Context as HttpContext;
@@ -130,6 +131,11 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
130131
*/
131132
private $categoryRepository;
132133

134+
/**
135+
* @var OptionsData
136+
*/
137+
private OptionsData $optionsData;
138+
133139
/**
134140
* @param Context $context
135141
* @param CollectionFactory $productCollectionFactory
@@ -143,6 +149,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
143149
* @param LayoutFactory|null $layoutFactory
144150
* @param EncoderInterface|null $urlEncoder
145151
* @param CategoryRepositoryInterface|null $categoryRepository
152+
* @param OptionsData|null $optionsData
146153
*
147154
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
148155
*/
@@ -158,7 +165,8 @@ public function __construct(
158165
Json $json = null,
159166
LayoutFactory $layoutFactory = null,
160167
EncoderInterface $urlEncoder = null,
161-
CategoryRepositoryInterface $categoryRepository = null
168+
CategoryRepositoryInterface $categoryRepository = null,
169+
OptionsData $optionsData = null
162170
) {
163171
$this->productCollectionFactory = $productCollectionFactory;
164172
$this->catalogProductVisibility = $catalogProductVisibility;
@@ -171,6 +179,7 @@ public function __construct(
171179
$this->urlEncoder = $urlEncoder ?: ObjectManager::getInstance()->get(EncoderInterface::class);
172180
$this->categoryRepository = $categoryRepository ?? ObjectManager::getInstance()
173181
->get(CategoryRepositoryInterface::class);
182+
$this->optionsData = $optionsData ?: ObjectManager::getInstance()->get(OptionsData::class);
174183
parent::__construct(
175184
$context,
176185
$data
@@ -306,6 +315,17 @@ public function getAddToCartPostParams(Product $product)
306315
];
307316
}
308317

318+
/**
319+
* Return product options
320+
*
321+
* @param Product $product
322+
* @return array
323+
*/
324+
public function getOptionsData(Product $product): array
325+
{
326+
return $this->optionsData->getOptionsData($product);
327+
}
328+
309329
/**
310330
* @inheritdoc
311331
*/

app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ use Magento\Wishlist\Helper\Data;
7474
<?php if ($_item->isSaleable()): ?>
7575
<?php $postParams = $block->getAddToCartPostParams($_item); ?>
7676
<form data-role="tocart-form" data-product-sku="<?= $escaper->escapeHtml($_item->getSku()) ?>" action="<?= $escaper->escapeUrl($postParams['action']) ?>" method="post">
77+
<?php $options = $block->getOptionsData($_item); ?>
78+
<?php foreach ($options as $optionItem): ?>
79+
<input type="hidden"
80+
name="<?= $escaper->escapeHtml($optionItem['name']) ?>"
81+
value="<?= $escaper->escapeHtml($optionItem['value']) ?>">
82+
<?php endforeach; ?>
7783
<input type="hidden" name="product" value="<?= $escaper->escapeHtmlAttr($postParams['data']['product']) ?>">
7884
<input type="hidden" name="<?= /* @noEscape */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @noEscape */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>">
7985
<?= $block->getBlockHtml('formkey') ?>
@@ -107,13 +113,13 @@ use Magento\Wishlist\Helper\Data;
107113
<div class="actions-secondary" data-role="add-to-links">
108114
<?php if ($this->helper(Data::class)->isAllow() && $showWishlist): ?>
109115
<a href="#"
110-
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
116+
data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $escaper->escapeHtmlAttr(__('Add to Wish List')) ?>">
111117
<span><?= $escaper->escapeHtml(__('Add to Wish List')) ?></span>
112118
</a>
113119
<?php endif; ?>
114120
<?php if ($block->getAddToCompareUrl() && $showCompare): ?>
115121
<?php $compareHelper = $this->helper(Compare::class);?>
116-
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>">
122+
<a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $escaper->escapeHtmlAttr(__('Add to Compare')) ?>">
117123
<span><?= $escaper->escapeHtml(__('Add to Compare')) ?></span>
118124
</a>
119125
<?php endif; ?>

0 commit comments

Comments
 (0)