Skip to content

Commit

Permalink
[EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
 - merged latest code from mainline branch
  • Loading branch information
magento-engcom-team authored Feb 12, 2019
2 parents 27c46aa + 4e11084 commit 48cfb71
Show file tree
Hide file tree
Showing 56 changed files with 1,092 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,38 @@ public function build(Filter $filter): string
$conditionValue = $this->mapConditionValue($conditionType, $filter->getValue());

// NOTE: store scope was ignored intentionally to perform search across all stores
$attributeSelect = $this->resourceConnection->getConnection()
->select()
->from(
[$tableAlias => $attribute->getBackendTable()],
$tableAlias . '.' . $attribute->getEntityIdField()
)->where(
$this->resourceConnection->getConnection()->prepareSqlCondition(
$tableAlias . '.' . $attribute->getIdFieldName(),
['eq' => $attribute->getAttributeId()]
)
)->where(
$this->resourceConnection->getConnection()->prepareSqlCondition(
$tableAlias . '.value',
[$conditionType => $conditionValue]
)
);
if ($conditionType == 'is_null') {
$entityResourceModel = $attribute->getEntity();
$attributeSelect = $this->resourceConnection->getConnection()
->select()
->from(
[Collection::MAIN_TABLE_ALIAS => $entityResourceModel->getEntityTable()],
Collection::MAIN_TABLE_ALIAS . '.' . $entityResourceModel->getEntityIdField()
)->joinLeft(
[$tableAlias => $attribute->getBackendTable()],
$tableAlias . '.' . $attribute->getEntityIdField() . '=' . Collection::MAIN_TABLE_ALIAS .
'.' . $entityResourceModel->getEntityIdField() . ' AND ' . $tableAlias . '.' .
$attribute->getIdFieldName() . '=' . $attribute->getAttributeId(),
''
)->where($tableAlias . '.value is null');
} else {
$attributeSelect = $this->resourceConnection->getConnection()
->select()
->from(
[$tableAlias => $attribute->getBackendTable()],
$tableAlias . '.' . $attribute->getEntityIdField()
)->where(
$this->resourceConnection->getConnection()->prepareSqlCondition(
$tableAlias . '.' . $attribute->getIdFieldName(),
['eq' => $attribute->getAttributeId()]
)
)->where(
$this->resourceConnection->getConnection()->prepareSqlCondition(
$tableAlias . '.value',
[$conditionType => $conditionValue]
)
);
}

return $this->resourceConnection
->getConnection()
Expand All @@ -86,6 +102,8 @@ public function build(Filter $filter): string
}

/**
* Get attribute entity by its code
*
* @param string $field
* @return Attribute
* @throws \Magento\Framework\Exception\LocalizedException
Expand Down
29 changes: 15 additions & 14 deletions app/code/Magento/Catalog/Model/Product/Attribute/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,28 @@ private function customizeAttributeCode($meta)
*/
private function customizeFrontendLabels($meta)
{
$labelConfigs = [];

foreach ($this->storeRepository->getList() as $store) {
$storeId = $store->getId();

if (!$storeId) {
continue;
}

$meta['manage-titles']['children'] = [
'frontend_label[' . $storeId . ']' => $this->arrayManager->set(
'arguments/data/config',
[],
[
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'label' => $store->getName(),
'dataType' => Text::NAME,
'dataScope' => 'frontend_label[' . $storeId . ']'
]
),
];
$labelConfigs['frontend_label[' . $storeId . ']'] = $this->arrayManager->set(
'arguments/data/config',
[],
[
'formElement' => Input::NAME,
'componentType' => Field::NAME,
'label' => $store->getName(),
'dataType' => Text::NAME,
'dataScope' => 'frontend_label[' . $storeId . ']'
]
);
}
$meta['manage-titles']['children'] = $labelConfigs;

return $meta;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ public function afterSave()
) {
$this->_indexerEavProcessor->markIndexerAsInvalid();
}

$this->_source = null;

return parent::afterSave();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,41 @@
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="navigateToAttributeEditPage3" />
<waitForPageLoad stepKey="waitForPageLoad3" />
</actionGroup>

<actionGroup name="AdminCreateAttributeFromProductPage">
<arguments>
<argument name="attributeName" type="string"/>
<argument name="attributeType" type="string" defaultValue="TextField"/>
</arguments>
<click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickAddAttributeBtn"/>
<see userInput="Select Attribute" stepKey="checkNewAttributePopUpAppeared"/>
<click selector="{{AdminProductFormAttributeSection.createNewAttribute}}" stepKey="clickCreateNewAttribute"/>
<fillField selector="{{AdminProductFormNewAttributeSection.attributeLabel}}" userInput="{{attributeName}}" stepKey="fillAttributeLabel"/>
<selectOption selector="{{AdminProductFormNewAttributeSection.attributeType}}" userInput="{{attributeType}}" stepKey="selectAttributeType"/>
<click selector="{{AdminProductFormNewAttributeSection.saveAttribute}}" stepKey="saveAttribute"/>
</actionGroup>

<actionGroup name="AdminCreateAttributeWithValueWithTwoStoreViesFromProductPage" extends="AdminCreateAttributeFromProductPage">
<remove keyForRemoval="saveAttribute"/>
<arguments>
<argument name="firstStoreViewName" type="string"/>
<argument name="secondStoreViewName" type="string"/>
</arguments>
<click selector="{{AdminProductFormNewAttributeSection.addValue}}" stepKey="addValue" after="selectAttributeType"/>
<seeElement selector="{{AdminProductFormNewAttributeSection.optionViewName(firstStoreViewName))}}" stepKey="seeFirstStoreView"/>
<seeElement selector="{{AdminProductFormNewAttributeSection.optionViewName(firstStoreViewName))}}" stepKey="seeSecondStoreView"/>
<fillField selector="{{AdminProductFormNewAttributeSection.optionValue('1'))}}" userInput="default" stepKey="fillDefaultStoreView"/>
<fillField selector="{{AdminProductFormNewAttributeSection.optionValue('2'))}}" userInput="admin" stepKey="fillAdminStoreView"/>
<fillField selector="{{AdminProductFormNewAttributeSection.optionValue('3'))}}" userInput="view1" stepKey="fillFirstStoreView"/>
<fillField selector="{{AdminProductFormNewAttributeSection.optionValue('4'))}}" userInput="view2" stepKey="fillSecondStoreView"/>

<!--Check store view in Manage Titles section-->
<click selector="{{AdminProductFormNewAttributeSection.manageTitlesHeader}}" stepKey="openManageTitlesSection"/>
<seeElement selector="{{AdminProductFormNewAttributeSection.manageTitlesViewName(customStoreEN.name)}}" stepKey="seeFirstStoreViewName"/>
<seeElement selector="{{AdminProductFormNewAttributeSection.manageTitlesViewName(customStoreFR.name)}}" stepKey="seeSecondStoreViewName"/>
<click selector="{{AdminProductFormNewAttributeSection.saveAttribute}}" stepKey="saveAttribute1"/>
</actionGroup>

<actionGroup name="changeUseForPromoRuleConditionsProductAttribute">
<arguments>
<argument name="option" type="string"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">

<actionGroup name="CompareTwoProductsOrder">
<arguments>
<argument name="product_1"/>
<argument name="product_2"/>
</arguments>
<amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/>
<waitForPageLoad stepKey="waitForPageLoad5"/>
<grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByNumber('1')}}" userInput="alt" stepKey="grabFirstProductName1_1"/>
<assertEquals expected="{{product_1.name}}" actual="($grabFirstProductName1_1)" message="notExpectedOrder" stepKey="compare1"/>
<grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByNumber('2')}}" userInput="alt" stepKey="grabFirstProductName2_2"/>
<assertEquals expected="{{product_2.name}}" actual="($grabFirstProductName2_2)" message="notExpectedOrder" stepKey="compare2"/>
</actionGroup>
</actionGroups>
21 changes: 21 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@
<data key="used_for_sort_by">true</data>
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
</entity>
<entity name="productYesNoAttribute" type="ProductAttribute">
<data key="attribute_code" unique="suffix">attribute</data>
<data key="frontend_input">boolean</data>
<data key="scope">global</data>
<data key="is_required">false</data>
<data key="is_unique">false</data>
<data key="is_searchable">true</data>
<data key="is_visible">true</data>
<data key="is_visible_in_advanced_search">true</data>
<data key="is_visible_on_front">true</data>
<data key="is_filterable">true</data>
<data key="is_filterable_in_search">true</data>
<data key="used_in_product_listing">true</data>
<data key="is_used_for_promo_rules">true</data>
<data key="is_comparable">true</data>
<data key="is_used_in_grid">true</data>
<data key="is_visible_in_grid">true</data>
<data key="is_filterable_in_grid">true</data>
<data key="used_for_sort_by">true</data>
<requiredEntity type="FrontendLabel">ProductAttributeFrontendLabel</requiredEntity>
</entity>
<entity name="productAttributeText" type="ProductAttribute">
<data key="attribute_code" unique="suffix">attribute</data>
<data key="frontend_input">text</data>
Expand Down
9 changes: 9 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@
<requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity>
<requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity>
</entity>
<entity name="ApiSimpleProductWithPrice50" type="product2" extends="ApiSimpleOne">
<data key="price">50</data>
</entity>
<entity name="ApiSimpleProductWithPrice60" type="product2" extends="ApiSimpleTwo">
<data key="price">60</data>
</entity>
<entity name="ApiSimpleProductWithPrice70" type="product2" extends="SimpleOne">
<data key="price">70</data>
</entity>
<entity name="ApiSimpleTwoHidden" type="product2">
<data key="sku" unique="suffix">api-simple-product-two</data>
<data key="type_id">simple</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<element name="productTierPricePercentageValuePriceInput" type="input" selector="[name='product[tier_price][{{var1}}][percentage_value]']" parameterized="true"/>
<element name="specialPrice" type="input" selector="input[name='product[special_price]']"/>
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary" timeout="5"/>
<element name="msrp" type="input" selector="//input[@name='product[msrp]']" timeout="30"/>
<element name="save" type="button" selector="#save-button"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminProductFormAttributeSection">
<element name="createNewAttribute" type="button" selector="//button[@data-index='add_new_attribute_button']" timeout="30"/>
</section>
<section name="AdminProductFormNewAttributeSection">
<element name="attributeLabel" type="button" selector="//input[@name='frontend_label[0]']" timeout="30"/>
<element name="attributeType" type="select" selector="//select[@name='frontend_input']" timeout="30"/>
<element name="addValue" type="button" selector="//button[@data-action='add_new_row']" timeout="30"/>
<element name="optionViewName" type="text" selector="//table[@data-index='attribute_options_select']//span[contains(text(), '{{arg}}')]" parameterized="true" timeout="30"/>
<element name="optionValue" type="input" selector="(//input[contains(@name, 'option[value]')])[{{arg}}]" timeout="30" parameterized="true"/>
<element name="manageTitlesHeader" type="button" selector="//div[@class='fieldset-wrapper-title']//span[contains(text(), 'Manage Titles')]" timeout="30/"/>
<element name="manageTitlesViewName" type="text" selector="//div[@data-index='manage-titles']//span[contains(text(), '{{arg}}')]" timeout="30" parameterized="true"/>
<element name="saveAttribute" type="button" selector="button#save" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,9 @@
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary"/>
<element name="useDefaultPrice" type="checkbox" selector="//input[@name='product[special_price]']/parent::div/following-sibling::div/input[@name='use_default[special_price]']"/>
</section>
<section name="AdminProductAttributeSection">
<element name="attributeSectionHeader" type="button" selector="//div[@data-index='attributes']" timeout="30"/>
<element name="dropDownAttribute" type="select" selector="//select[@name='product[{{arg}}]']" parameterized="true" timeout="30"/>
<element name="attributeSection" type="div" selector="//div[@data-index='attributes']/div[contains(@class, 'admin__collapsible-content _show')]" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<element name="ProductInfoByNumber" type="text" selector="//main//li[{{var1}}]//div[@class='product-item-info']" parameterized="true"/>
<element name="ProductAddToCompareByNumber" type="text" selector="//main//li[{{var1}}]//a[contains(@class, 'tocompare')]" parameterized="true"/>
<element name="listedProduct" type="block" selector="ol li:nth-child({{productPositionInList}}) img" parameterized="true"/>
<element name="ProductImageByNumber" type="button" selector="//main//li[{{var1}}]//img" parameterized="true"/>
<element name="categoryListView" type="button" selector="a[title='List']" timeout="30"/>

<element name="ProductTitleByName" type="button" selector="//main//li//a[contains(text(), '{{var1}}')]" parameterized="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<element name="productOptionSelect" type="select" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//select" parameterized="true"/>
<element name="asLowAs" type="input" selector="span[class='price-wrapper '] "/>
<element name="specialPriceValue" type="text" selector="//span[@class='special-price']//span[@class='price']"/>
<element name="mapPrice" type="text" selector="//div[@class='price-box price-final_price']//span[contains(@class, 'price-msrp_price')]"/>
<element name="clickForPriceLink" type="text" selector="//div[@class='price-box price-final_price']//a[contains(text(), 'Click for price')]"/>

<!-- The parameter is the nth custom option that you want to get -->
<element name="nthCustomOption" type="block" selector="//*[@id='product-options-wrapper']/*[@class='fieldset']/*[contains(@class, 'field')][{{customOptionNum}}]" parameterized="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCreateNewAttributeFromProductTest">
<annotations>
<features value="Catalog"/>
<title value="Check that New Attribute from Product is create"/>
<description value="Check that New Attribute from Product is create"/>
<severity value="MAJOR"/>
<testCaseId value="MC-12296"/>
<useCaseId value="MAGETWO-59055"/>
<group value="Catalog"/>
</annotations>
<before>
<actionGroup ref="LoginAsAdmin" stepKey="login"/>

<!--Create product-->
<createData entity="SimpleProduct2" stepKey="createProduct"/>
</before>
<after>
<!--Delete create data-->
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>

<!--Delete store views-->
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteFirstStoreView">
<argument name="customStore" value="customStoreEN"/>
</actionGroup>
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteSecondStoreView">
<argument name="customStore" value="customStoreFR"/>
</actionGroup>

<!--Delete Attribute-->
<actionGroup ref="deleteProductAttribute" stepKey="deleteAttribute">
<argument name="ProductAttribute" value="productDropDownAttribute"/>
</actionGroup>

<actionGroup ref="logout" stepKey="logout"/>
</after>

<!--Create 2 store views-->
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createFirstStoreView">
<argument name="customStore" value="customStoreEN"/>
</actionGroup>
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createSecondStoreView">
<argument name="customStore" value="customStoreFR"/>
</actionGroup>

<!--Go to created product page and create new attribute-->
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="openAdminEditPage"/>
<actionGroup ref="AdminCreateAttributeWithValueWithTwoStoreViesFromProductPage" stepKey="createAttribute">
<argument name="attributeName" value="{{productDropDownAttribute.attribute_code}}"/>
<argument name="attributeType" value="Dropdown"/>
<argument name="firstStoreViewName" value="{{customStoreEN.name}}"/>
<argument name="secondStoreViewName" value="{{customStoreFR.name}}"/>
</actionGroup>

<!--Check attribute existence in product page attribute section-->
<conditionalClick selector="{{AdminProductAttributeSection.attributeSectionHeader}}" dependentSelector="{{AdminProductAttributeSection.attributeSection}}" visible="false" stepKey="openAttributeSection"/>
<seeElement selector="{{AdminProductAttributeSection.dropDownAttribute(productDropDownAttribute.attribute_code)}}" stepKey="seeNewAttributeInProductPage"/>
</test>
</tests>
Loading

0 comments on commit 48cfb71

Please sign in to comment.