Skip to content

Commit e045216

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MAGETWO-72172' into EPAM-PR-56
2 parents 0fbfc49 + c1f141d commit e045216

File tree

5 files changed

+148
-4
lines changed

5 files changed

+148
-4
lines changed

app/code/Magento/Catalog/Helper/Product.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/**
1515
* Catalog category helper
1616
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1718
*/
1819
class Product extends \Magento\Framework\Url\Helper\Data
1920
{
@@ -268,6 +269,8 @@ public function getThumbnailUrl($product)
268269
}
269270

270271
/**
272+
* Retrieve email to friend url
273+
*
271274
* @param ModelProduct $product
272275
* @return string
273276
*/
@@ -282,6 +285,8 @@ public function getEmailToFriendUrl($product)
282285
}
283286

284287
/**
288+
* Get statuses
289+
*
285290
* @return array
286291
*/
287292
public function getStatuses()
@@ -476,6 +481,7 @@ public function initProduct($productId, $controller, $params = null)
476481

477482
/**
478483
* Prepares product options by buyRequest: retrieves values and assigns them as default.
484+
*
479485
* Also parses and adds product management related values - e.g. qty
480486
*
481487
* @param ModelProduct $product
@@ -493,6 +499,7 @@ public function prepareProductOptions($product, $buyRequest)
493499

494500
/**
495501
* Process $buyRequest and sets its options before saving configuration to some product item.
502+
*
496503
* This method is used to attach additional parameters to processed buyRequest.
497504
*
498505
* $params holds parameters of what operation must be performed:
@@ -541,8 +548,6 @@ public function addParamsToBuyRequest($buyRequest, $params)
541548
/**
542549
* Set flag that shows if Magento has to check product to be saleable (enabled and/or inStock)
543550
*
544-
* For instance, during order creation in the backend admin has ability to add any products to order
545-
*
546551
* @param bool $skipSaleableCheck
547552
* @return Product
548553
*/
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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="NoOptionAvailableToConfigureDisabledProductTest">
12+
<annotations>
13+
<title value="Disabled variation of configurable product can't be added to shopping cart via admin"/>
14+
<description value="Disabled variation of configurable product can't be added to shopping cart via admin"/>
15+
<severity value="AVERAGE"/>
16+
<testCaseId value="MC-17373"/>
17+
<useCaseId value="MAGETWO-72172"/>
18+
<group value="ConfigurableProduct"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
22+
<!--Create category-->
23+
<comment userInput="Create category" stepKey="commentCreateCategory"/>
24+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
25+
<!-- Create the configurable product based on the data in the data folder -->
26+
<comment userInput="Create the configurable product based on the data in the data folder" stepKey="createConfigurableProduct"/>
27+
<createData entity="ApiConfigurableProduct" stepKey="createConfigProduct">
28+
<requiredEntity createDataKey="createCategory"/>
29+
</createData>
30+
<!-- Create the configurable product with two options based on the default attribute set -->
31+
<comment userInput="Create the configurable product with two options based on the default attribute set" stepKey="configurableProductWithTwoOptions"/>
32+
<createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/>
33+
<createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1">
34+
<requiredEntity createDataKey="createConfigProductAttribute"/>
35+
</createData>
36+
<createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2">
37+
<requiredEntity createDataKey="createConfigProductAttribute"/>
38+
</createData>
39+
<createData entity="productAttributeOption3" stepKey="createConfigProductAttributeOption3">
40+
<requiredEntity createDataKey="createConfigProductAttribute"/>
41+
</createData>
42+
<createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet">
43+
<requiredEntity createDataKey="createConfigProductAttribute"/>
44+
</createData>
45+
<getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1">
46+
<requiredEntity createDataKey="createConfigProductAttribute"/>
47+
</getData>
48+
<getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2">
49+
<requiredEntity createDataKey="createConfigProductAttribute"/>
50+
</getData>
51+
<getData entity="ProductAttributeOptionGetter" index="3" stepKey="getConfigAttributeOption3">
52+
<requiredEntity createDataKey="createConfigProductAttribute"/>
53+
</getData>
54+
<!-- Create the 2 children that will be a part of the configurable product -->
55+
<comment userInput="Create the 2 children that will be a part of the configurable product" stepKey="createTwoChildrenProducts"/>
56+
<createData entity="ApiSimpleProductWithPrice50" stepKey="createConfigChildProduct1">
57+
<requiredEntity createDataKey="createConfigProductAttribute"/>
58+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
59+
</createData>
60+
<createData entity="ApiSimpleProductWithPrice60" stepKey="createConfigChildProduct2">
61+
<requiredEntity createDataKey="createConfigProductAttribute"/>
62+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
63+
</createData>
64+
<createData entity="ApiSimpleProductWithPrice70" stepKey="createConfigChildProduct3">
65+
<requiredEntity createDataKey="createConfigProductAttribute"/>
66+
<requiredEntity createDataKey="getConfigAttributeOption3"/>
67+
</createData>
68+
<!-- Assign two products to the configurable product -->
69+
<comment userInput="Assign two products to the configurable product" stepKey="assignToConfigurableProduct"/>
70+
<createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption">
71+
<requiredEntity createDataKey="createConfigProduct"/>
72+
<requiredEntity createDataKey="createConfigProductAttribute"/>
73+
<requiredEntity createDataKey="getConfigAttributeOption1"/>
74+
<requiredEntity createDataKey="getConfigAttributeOption2"/>
75+
<requiredEntity createDataKey="getConfigAttributeOption3"/>
76+
</createData>
77+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1">
78+
<requiredEntity createDataKey="createConfigProduct"/>
79+
<requiredEntity createDataKey="createConfigChildProduct1"/>
80+
</createData>
81+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2">
82+
<requiredEntity createDataKey="createConfigProduct"/>
83+
<requiredEntity createDataKey="createConfigChildProduct2"/>
84+
</createData>
85+
<createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild3">
86+
<requiredEntity createDataKey="createConfigProduct"/>
87+
<requiredEntity createDataKey="createConfigChildProduct3"/>
88+
</createData>
89+
<!--Create Customer-->
90+
<comment userInput="Create customer" stepKey="commentCreateCustomer"/>
91+
<createData entity="Simple_US_Customer_CA" stepKey="createCustomer"/>
92+
</before>
93+
<after>
94+
<!--Delete created data-->
95+
<comment userInput="Delete created data" stepKey="deleteData"/>
96+
<deleteData createDataKey="createCategory" stepKey="deleteCategory2"/>
97+
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/>
98+
<deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/>
99+
<deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/>
100+
<deleteData createDataKey="createConfigChildProduct3" stepKey="deleteConfigChildProduct3"/>
101+
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/>
102+
<deleteData createDataKey="createCustomer" stepKey="deleteCreatedCustomer"/>
103+
<actionGroup ref="logout" stepKey="logout"/>
104+
</after>
105+
<!--Disable child product -->
106+
<comment userInput="Disable child product" stepKey="disableChildProduct"/>
107+
<amOnPage url="{{AdminProductEditPage.url($$createConfigChildProduct1.id$$)}}" stepKey="goToEditPage"/>
108+
<waitForPageLoad stepKey="waitForChildProductPageLoad"/>
109+
<click selector="{{AdminProductFormSection.enableProductLabel}}" stepKey="disableProduct"/>
110+
<actionGroup ref="saveProductForm" stepKey="saveProductForm"/>
111+
<!--Go to created customer page-->
112+
<comment userInput="Go to created customer page" stepKey="goToCreatedCustomerPage"/>
113+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="createNewOrder">
114+
<argument name="customer" value="$$createCustomer$$"/>
115+
</actionGroup>
116+
<click selector="{{AdminOrderFormItemsSection.addProducts}}" stepKey="clickToAddProduct"/>
117+
<waitForPageLoad stepKey="waitForProductsOpened"/>
118+
<!--Find created configurable product and click on "Configure" link-->
119+
<comment userInput="Find created configurable product and click on Configure link" stepKey="goToConfigurableLink"/>
120+
<click selector="{{AdminOrderFormConfigureProductSection.configure($$createConfigProduct.id$$)}}" stepKey="clickOnConfigure"/>
121+
<!--Click on attribute drop-down and check no option 1 is available-->
122+
<comment userInput="Click on attribute drop-down and check no option 1 is available" stepKey="commentNoOptionIsAvailable"/>
123+
<waitForElement selector="{{AdminOrderFormConfigureProductSection.selectOption}}" stepKey="waitForShippingSectionLoaded"/>
124+
<click selector="{{AdminOrderFormConfigureProductSection.selectOption}}" stepKey="clickToSelectOption"/>
125+
<dontSee userInput="$$createConfigProductAttributeOption1.option[store_labels][1][label]$$" stepKey="dontSeeOption1"/>
126+
</test>
127+
</tests>

app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Sales\Controller\Adminhtml\Order;
79

810
use Magento\Backend\App\Action;
@@ -14,6 +16,7 @@
1416
*
1517
* @author Magento Core Team <[email protected]>
1618
* @SuppressWarnings(PHPMD.NumberOfChildren)
19+
* @SuppressWarnings(PHPMD.AllPurposeAction)
1720
*/
1821
abstract class Create extends \Magento\Backend\App\Action
1922
{
@@ -38,6 +41,7 @@ abstract class Create extends \Magento\Backend\App\Action
3841
* @param \Magento\Framework\Escaper $escaper
3942
* @param PageFactory $resultPageFactory
4043
* @param ForwardFactory $resultForwardFactory
44+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4145
*/
4246
public function __construct(
4347
Action\Context $context,
@@ -47,7 +51,6 @@ public function __construct(
4751
ForwardFactory $resultForwardFactory
4852
) {
4953
parent::__construct($context);
50-
$productHelper->setSkipSaleableCheck(true);
5154
$this->escaper = $escaper;
5255
$this->resultPageFactory = $resultPageFactory;
5356
$this->resultForwardFactory = $resultForwardFactory;
@@ -362,6 +365,8 @@ protected function _processFiles($items)
362365
}
363366

364367
/**
368+
* Reload quote
369+
*
365370
* @return $this
366371
*/
367372
protected function _reloadQuote()

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormConfigureProductSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminOrderFormConfigureProductSection">
12-
<element name="optionSelect" type="select" selector="//div[contains(@class,'product-options')]/div/div/select[../../label[text() = '{{option}}']]" parameterized="true"/>
12+
<element name="configure" type="button" selector="//a[@product_id='{{productId}}']" parameterized="true"/>
13+
<element name="optionSelect" type="select" selector="//div[contains(@class,'product-options')]//select[//label[text() = '{{option}}']]" parameterized="true"/>
1314
<element name="quantity" type="input" selector="#product_composite_configure_input_qty"/>
1415
<element name="ok" type="button" selector=".modal-header .page-actions button[data-role='action']" timeout="30"/>
1516
<element name="selectOption" type="select" selector="//form[@id='product_composite_configure_form']//select"/>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
<field key="qty">2</field>
7878
</createData>
7979
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
80+
81+
<!--Go to bundle product page and save it to force "in stock" status-->
82+
<actionGroup ref="goToProductPageViaID" stepKey="goToBundleProductPage">
83+
<argument name="productId" value="$product.id$"/>
84+
</actionGroup>
85+
<actionGroup ref="saveProductForm" stepKey="saveBundleProduct"/>
8086
</before>
8187

8288
<!--Create new customer order-->

0 commit comments

Comments
 (0)