From 7e724b183b0e6f025295424a5896830b944853a0 Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Tue, 27 Oct 2020 18:21:35 +0200 Subject: [PATCH 1/6] Fix for SKU without options --- .../Magento/Catalog/Model/Product/Type/AbstractType.php | 6 +----- .../ConfigurableProduct/Model/Product/Type/Configurable.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index eb4a71cb90a8c..3d41d0c2b4143 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -801,11 +801,7 @@ public function canUseQtyDecimals() */ public function getSku($product) { - $sku = $product->getData('sku'); - if ($product->getCustomOption('option_ids')) { - $sku = $this->getOptionSku($product, $sku); - } - return $sku; + return $product->getData('sku'); } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index c2ae381b345c6..656c16450f359 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -1155,7 +1155,7 @@ public function getSku($product) if ($optionProduct) { $simpleSku = $simpleOption->getProduct()->getSku(); } - $sku = parent::getOptionSku($product, $simpleSku); + $sku = $simpleSku; } else { $sku = parent::getSku($product); } From 907b60bb2f442b0c88f43d5ee54f9775dc3e4287 Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Mon, 2 Nov 2020 19:08:48 +0200 Subject: [PATCH 2/6] The fix has been changed - in progress --- .../Model/Product/Type/AbstractType.php | 6 +++++- .../Model/Product/Type/Configurable.php | 2 +- .../Quote/Api/Data/CartItemInterface.php | 21 +++++++++++++++++-- app/code/Magento/Quote/Model/Quote/Item.php | 18 ++++++++++++++++ app/code/Magento/Quote/etc/db_schema.xml | 3 ++- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index 3d41d0c2b4143..eb4a71cb90a8c 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -801,7 +801,11 @@ public function canUseQtyDecimals() */ public function getSku($product) { - return $product->getData('sku'); + $sku = $product->getData('sku'); + if ($product->getCustomOption('option_ids')) { + $sku = $this->getOptionSku($product, $sku); + } + return $sku; } /** diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 656c16450f359..c2ae381b345c6 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -1155,7 +1155,7 @@ public function getSku($product) if ($optionProduct) { $simpleSku = $simpleOption->getProduct()->getSku(); } - $sku = $simpleSku; + $sku = parent::getOptionSku($product, $simpleSku); } else { $sku = parent::getSku($product); } diff --git a/app/code/Magento/Quote/Api/Data/CartItemInterface.php b/app/code/Magento/Quote/Api/Data/CartItemInterface.php index 1c651045aa58d..fdfbcae002d27 100644 --- a/app/code/Magento/Quote/Api/Data/CartItemInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartItemInterface.php @@ -19,6 +19,8 @@ interface CartItemInterface extends \Magento\Framework\Api\ExtensibleDataInterfa const KEY_SKU = 'sku'; + const KEY_ORIGINAL_PRODUCT_SKU = 'original_product_sku'; + const KEY_QTY = 'qty'; const KEY_NAME = 'name'; @@ -49,20 +51,35 @@ public function getItemId(); public function setItemId($itemId); /** - * Returns the product SKU. + * Returns the product options SKU. * * @return string|null Product SKU. Otherwise, null. */ public function getSku(); /** - * Sets the product SKU. + * Sets the product options SKU. * * @param string $sku * @return $this */ public function setSku($sku); + /** + * Returns the product SKU. + * + * @return string|null Product SKU. Otherwise, null. + */ + public function getOriginalProductSku(); + + /** + * Sets the product SKU. + * + * @param string $sku + * @return $this + */ + public function setOriginalProductSku(string $sku); + /** * Returns the product quantity. * diff --git a/app/code/Magento/Quote/Model/Quote/Item.php b/app/code/Magento/Quote/Model/Quote/Item.php index 22554380ca61e..23a0bf641225a 100644 --- a/app/code/Magento/Quote/Model/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Item.php @@ -9,6 +9,7 @@ use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Api\ExtensionAttributesFactory; +use Magento\Quote\Api\Data\CartItemInterface; /** * Sales Quote Item Model @@ -431,6 +432,7 @@ public function setProduct($product) ->setProductId($product->getId()) ->setProductType($product->getTypeId()) ->setSku($this->getProduct()->getSku()) + ->setOriginalProductSku($this->getProduct()->getData('sku')) ->setName($product->getName()) ->setWeight($this->getProduct()->getWeight()) ->setTaxClassId($product->getTaxClassId()) @@ -1075,4 +1077,20 @@ public function setExtensionAttributes(\Magento\Quote\Api\Data\CartItemExtension { return $this->_setExtensionAttributes($extensionAttributes); } + + /** + * @inheritDoc + */ + public function getOriginalProductSku() + { + return $this->getData(self::KEY_ORIGINAL_PRODUCT_SKU); + } + + /** + * @inheritDoc + */ + public function setOriginalProductSku(string $sku) + { + return $this->setData(self::KEY_ORIGINAL_PRODUCT_SKU, $sku); + } } diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml index ff183e3150894..f2ad16b707b0f 100644 --- a/app/code/Magento/Quote/etc/db_schema.xml +++ b/app/code/Magento/Quote/etc/db_schema.xml @@ -230,7 +230,8 @@ comment="Parent Item ID"/> - + + From e912dd075b503bf19c41a044b6e1a414973b6bed Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Thu, 5 Nov 2020 18:02:16 +0200 Subject: [PATCH 3/6] Original SKU has been added to api response at quote and passed to the order. --- app/code/Magento/Quote/etc/fieldset.xml | 3 +++ .../Sales/Api/Data/OrderItemInterface.php | 19 +++++++++++++++++++ .../Adminhtml/Items/Column/DefaultColumn.php | 10 ++++++++++ app/code/Magento/Sales/Model/Order/Item.php | 16 ++++++++++++++++ app/code/Magento/Sales/etc/db_schema.xml | 1 + .../templates/items/column/name.phtml | 2 +- 6 files changed, 50 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/etc/fieldset.xml b/app/code/Magento/Quote/etc/fieldset.xml index 85ee20c7f8520..078639f8fecb5 100644 --- a/app/code/Magento/Quote/etc/fieldset.xml +++ b/app/code/Magento/Quote/etc/fieldset.xml @@ -195,6 +195,9 @@ + + + diff --git a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php index 2aee648ef7c9f..a26b326708ea7 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php @@ -67,6 +67,10 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf * SKU. */ const SKU = 'sku'; + /* + * Original product SKU. + */ + const ORIGINAL_PRODUCT_SKU = 'original_product_sku'; /* * Name. */ @@ -954,6 +958,13 @@ public function getRowWeight(); */ public function getSku(); + /** + * Gets the original product SKU for the order item. + * + * @return string + */ + public function getOriginalProductSku(); + /** * Gets the store ID for the order item. * @@ -1155,6 +1166,14 @@ public function setIsVirtual($isVirtual); */ public function setSku($sku); + /** + * Sets the SKU for the order item. + * + * @param string + * @return $this + */ + public function setOriginalProductSku($sku); + /** * Sets the name for the order item. * diff --git a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php b/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php index 81f670de91805..48f02501054c0 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php @@ -114,6 +114,16 @@ public function getSku() return $this->getItem()->getSku(); } + /** + * Get original product sku + * + * @return string + */ + public function getOriginalProductSku(): string + { + return $this->getItem()->getOriginalProductSku(); + } + /** * Calculate total amount for the item * diff --git a/app/code/Magento/Sales/Model/Order/Item.php b/app/code/Magento/Sales/Model/Order/Item.php index bc55b2229770d..6321e110eec5e 100644 --- a/app/code/Magento/Sales/Model/Order/Item.php +++ b/app/code/Magento/Sales/Model/Order/Item.php @@ -2415,4 +2415,20 @@ public function isProcessingAvailable() { return $this->getQtyToShip() > $this->getQtyToCancel(); } + + /** + * @inheritDoc + */ + public function getOriginalProductSku() + { + return $this->getData(OrderItemInterface::ORIGINAL_PRODUCT_SKU); + } + + /** + * @inheritDoc + */ + public function setOriginalProductSku($sku) + { + return $this->setData(OrderItemInterface::ORIGINAL_PRODUCT_SKU, $sku); + } } diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml index ab524a0f552f6..71f831bee0a6b 100644 --- a/app/code/Magento/Sales/etc/db_schema.xml +++ b/app/code/Magento/Sales/etc/db_schema.xml @@ -481,6 +481,7 @@ + diff --git a/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml b/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml index a3904ac09c6b4..5ccc4faff5ed7 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml @@ -23,7 +23,7 @@ $catalogHelper = $block->getData('catalogHelper');
escapeHtml(__('SKU'))?>: - ', $catalogHelper->splitSku($block->escapeHtml($block->getSku()))) ?> + ', $catalogHelper->splitSku($block->escapeHtml($block->getOriginalProductSku()))) ?>
getOrderOptions()): ?> From 1ccf13ed10935a4fe29c3fcb754941a3bec56d3c Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Fri, 6 Nov 2020 17:34:50 +0200 Subject: [PATCH 4/6] Code refactoring, tests updates --- app/code/Magento/Quote/Api/Data/CartItemInterface.php | 2 +- app/code/Magento/Quote/Model/Quote/Item.php | 3 +-- app/code/Magento/Sales/Api/Data/OrderItemInterface.php | 4 ++-- .../Sales/Block/Adminhtml/Items/Column/DefaultColumn.php | 2 +- .../Sales/view/adminhtml/templates/items/column/name.phtml | 3 ++- .../testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php | 1 + .../Magento/Downloadable/Api/CartItemRepositoryTest.php | 1 + .../testsuite/Magento/Quote/Api/CartItemRepositoryTest.php | 1 + .../Magento/Quote/Api/GuestCartItemRepositoryTest.php | 1 + .../testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php | 2 +- 10 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Quote/Api/Data/CartItemInterface.php b/app/code/Magento/Quote/Api/Data/CartItemInterface.php index fdfbcae002d27..20702d82dab28 100644 --- a/app/code/Magento/Quote/Api/Data/CartItemInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartItemInterface.php @@ -78,7 +78,7 @@ public function getOriginalProductSku(); * @param string $sku * @return $this */ - public function setOriginalProductSku(string $sku); + public function setOriginalProductSku($sku); /** * Returns the product quantity. diff --git a/app/code/Magento/Quote/Model/Quote/Item.php b/app/code/Magento/Quote/Model/Quote/Item.php index 23a0bf641225a..a3e223b13175f 100644 --- a/app/code/Magento/Quote/Model/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Item.php @@ -9,7 +9,6 @@ use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Api\ExtensionAttributesFactory; -use Magento\Quote\Api\Data\CartItemInterface; /** * Sales Quote Item Model @@ -1089,7 +1088,7 @@ public function getOriginalProductSku() /** * @inheritDoc */ - public function setOriginalProductSku(string $sku) + public function setOriginalProductSku($sku) { return $this->setData(self::KEY_ORIGINAL_PRODUCT_SKU, $sku); } diff --git a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php index a26b326708ea7..2a44b03283908 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php @@ -393,7 +393,7 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf const BASE_WEEE_TAX_ROW_DISPOSITION = 'base_weee_tax_row_disposition'; /** - * Parent Item + * Parent order Item */ const PARENT_ITEM = 'parent_item'; @@ -1169,7 +1169,7 @@ public function setSku($sku); /** * Sets the SKU for the order item. * - * @param string + * @param string $sku * @return $this */ public function setOriginalProductSku($sku); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php b/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php index 48f02501054c0..4a03799713e09 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php @@ -119,7 +119,7 @@ public function getSku() * * @return string */ - public function getOriginalProductSku(): string + public function getOriginalProductSku() { return $this->getItem()->getOriginalProductSku(); } diff --git a/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml b/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml index 5ccc4faff5ed7..e28699b6443a6 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/items/column/name.phtml @@ -23,7 +23,8 @@ $catalogHelper = $block->getData('catalogHelper');
escapeHtml(__('SKU'))?>: - ', $catalogHelper->splitSku($block->escapeHtml($block->getOriginalProductSku()))) ?> + ', $catalogHelper->splitSku($block->escapeHtml($block->getOriginalProductSku()))) ?>
getOrderOptions()): ?> diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php index e3680c573750d..586c3fec3302a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CartItemRepositoryTest.php @@ -65,6 +65,7 @@ public function testAddProductToCartWithCustomOptions() [ 'item_id' => $item->getItemId(), 'sku' => $item->getSku(), + 'original_product_sku' => $item->getOriginalProductSku(), 'qty' => $item->getQty(), 'name' => $item->getName(), 'price' => $item->getPrice(), diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php index 8af1d2a02d4e6..1c6896627521a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/CartItemRepositoryTest.php @@ -247,6 +247,7 @@ public function testGetList() $expectedResult = [[ 'item_id' => $item->getItemId(), 'sku' => $item->getSku(), + 'original_product_sku' => $item->getOriginalProductSku(), 'name' => $item->getName(), 'price' => $item->getPrice(), 'qty' => $item->getQty(), diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php index bf5421b5ca2be..5a89643618143 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartItemRepositoryTest.php @@ -45,6 +45,7 @@ public function testGetList() $data = [ 'item_id' => (int)$item->getItemId(), 'sku' => $item->getSku(), + 'original_product_sku' => $item->getOriginalProductSku(), 'name' => $item->getName(), 'price' => (float)$item->getPrice(), 'qty' => (float)$item->getQty(), diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php index 373ad64ba39d4..29ed18c506eac 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartItemRepositoryTest.php @@ -61,6 +61,7 @@ public function testGetList() $data = [ 'item_id' => $item->getItemId(), 'sku' => $item->getSku(), + 'original_product_sku' => $item->getOriginalProductSku(), 'name' => $item->getName(), 'price' => $item->getPrice(), 'qty' => $item->getQty(), diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php index 25795f2cdd747..800282471d283 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php @@ -56,7 +56,7 @@ public function testGet() //check that nullable fields were marked as optional and were not sent foreach ($response as $fieldName => $value) { - if ($fieldName == 'sku') { + if ($fieldName == 'sku' || $fieldName == 'original_product_sku') { continue; } $this->assertNotNull($value); From b0176bf1128ab566ab2b252b49b3bce49e7e62ac Mon Sep 17 00:00:00 2001 From: "taras.gamanov" Date: Tue, 17 Nov 2020 12:45:54 +0200 Subject: [PATCH 5/6] MFTF coverage for the fix --- .../Test/AdminVerifyProductSKUInOrderTest.xml | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminVerifyProductSKUInOrderTest.xml diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminVerifyProductSKUInOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminVerifyProductSKUInOrderTest.xml new file mode 100644 index 0000000000000..625122ac4c02d --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminVerifyProductSKUInOrderTest.xml @@ -0,0 +1,131 @@ + + + + + + + + + + <description value="Verify that order contains real SKU of products and not options sku"/> + <severity value="MAJOR"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <!-- Create simple with options product --> + <createData entity="SimpleProduct" stepKey="createSimpleProductWithCustomOptions"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <updateData createDataKey="createSimpleProductWithCustomOptions" entity="productWithDropdownOption" stepKey="updateProductWithCustomOption"/> + <!-- Create configurable product --> + <createData entity="BaseConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <updateData createDataKey="createConfigProduct" entity="productWithOptionRadiobutton" stepKey="updateConfigurableProductWithCustomOption"/> + <createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <createData entity="ApiSimpleOne" stepKey="createConfigFirstChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createConfigSecondChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddFirstChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigFirstChildProduct"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddSecondChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigSecondChildProduct"/> + </createData> + <!-- Create the customer --> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <!-- Reindex and flush the cache to display products on the category page --> + <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> + <argument name="indices" value=""/> + </actionGroup> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> + <argument name="tags" value=""/> + </actionGroup> + </before> + <after> + <!-- Delete created data --> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndexPage"/> + <actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="resetProductGridToDefaultView"/> + <actionGroup ref="DeleteProductsIfTheyExistActionGroup" stepKey="deleteAllProducts"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + <!-- Login to Storefront as Customer --> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$$createCustomer$$" /> + </actionGroup> + <!-- Place the order --> + <!-- Add simple with options to cart --> + <amOnPage url="{{StorefrontProductPage.url($$createSimpleProductWithCustomOptions.custom_attributes[url_key]$$)}}" stepKey="goSimpleProductPage"/> + <waitForPageLoad stepKey="waitForSecondProductPageLoad"/> + <actionGroup ref="StorefrontProductPageSelectDropDownOptionValueActionGroup" stepKey="selectFirstOption"> + <argument name="attributeLabel" value="{{ProductOptionValueDropdown.title}}"/> + <argument name="optionLabel" value="{{ProductOptionValueWithSkuDropdown1.title}}"/> + </actionGroup> + <!-- Add the product to the shopping cart --> + <actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addSimpleProductToCart"> + <argument name="productName" value="$$createSimpleProductWithCustomOptions.name$$"/> + </actionGroup> + <!-- Add configurable with options to cart --> + <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goConfigurableProductPage"> + <argument name="productUrl" value="$$createConfigProduct.custom_attributes[url_key]$$"/> + </actionGroup> + <actionGroup ref="StorefrontAddProductWithSelectedConfigurableAndCustomOptionsToCartActionGroup" stepKey="addConfigurableToCart"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="option" value="$$getConfigAttributeSecondOption.label$$"/> + <argument name="customizableOption" value="{{ProductOptionValueRadioButtons1.title}}"/> + </actionGroup> + <!-- Place the Order --> + <actionGroup ref="StorefrontOpenCheckoutPageActionGroup" stepKey="onCheckout"/> + <actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="clickNextButton"/> + <click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="placeOrder"/> + <waitForPageLoad stepKey="waitForSuccess"/> + <!--Open Order View Page--> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminOrdersPageOpenActionGroup" stepKey="openOrdersGridPage"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="openOrderViewPage"/> + <!--Check if order has correct products sku--> + <actionGroup ref="SeeProductInItemsOrderedActionGroup" stepKey="verifySimpleProductSku"> + <argument name="product" value="SimpleProduct"/> + </actionGroup> + <actionGroup ref="SeeProductInItemsOrderedActionGroup" stepKey="verifyConfigurableProductSku"> + <argument name="product" value="BaseConfigurableProduct"/> + </actionGroup> + </test> +</tests> From bb31fb1eec4c59154daff9fdc2a50d748017c1b4 Mon Sep 17 00:00:00 2001 From: "taras.gamanov" <engcom-vendorworker-hotel@adobe.com> Date: Wed, 30 Dec 2020 12:21:43 +0200 Subject: [PATCH 6/6] Refactoring --- .../testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php index 800282471d283..6de927058d193 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php @@ -56,7 +56,7 @@ public function testGet() //check that nullable fields were marked as optional and were not sent foreach ($response as $fieldName => $value) { - if ($fieldName == 'sku' || $fieldName == 'original_product_sku') { + if ($fieldName === 'sku' || $fieldName === 'original_product_sku') { continue; } $this->assertNotNull($value);