forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request magento#3934 from magento-tsg/2.2-develop-pr84
[TSG] Backporting for 2.2 (pr84) (2.2-develop)
- Loading branch information
Showing
57 changed files
with
1,061 additions
and
187 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
app/code/Magento/Backend/Test/Mftf/Data/CountryOptionsConfigData.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> | ||
<entity name="DefaultAllowCountriesConfig" type="allow_countries_config"> | ||
<requiredEntity type="allow_countries_config_default">DefaultAllowCountries</requiredEntity> | ||
</entity> | ||
<entity name="DefaultAllowCountries" type="allow_countries_config_default"> | ||
<data key="value">0</data> | ||
</entity> | ||
|
||
<entity name="SetAllowCountriesConfigUS" type="allow_countries_config"> | ||
<data key="value">US</data> | ||
</entity> | ||
</entities> |
24 changes: 24 additions & 0 deletions
24
app/code/Magento/Backend/Test/Mftf/Metadata/country_options_config-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
--> | ||
<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd"> | ||
<operation name="AllowCountriesConfig" dataType="allow_countries_config" type="create" auth="adminFormKey" url="/admin/system_config/save/section/general/" method="POST" successRegex="/messages-message-success/"> | ||
<object key="groups" dataType="allow_countries_config"> | ||
<object key="country" dataType="allow_countries_config"> | ||
<object key="fields" dataType="allow_countries_config"> | ||
<object key="allow" dataType="allow_countries_config"> | ||
<field key="value">string</field> | ||
<object key="inherit" dataType="allow_countries_config_default"> | ||
<field key="value">integer</field> | ||
</object> | ||
</object> | ||
</object> | ||
</object> | ||
</object> | ||
</operation> | ||
</operations> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
app/code/Magento/Catalog/Model/Product/Type/FrontSpecialPrice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Product\Type; | ||
|
||
use Magento\Store\Model\Store; | ||
use Magento\Catalog\Model\ResourceModel\Product\Price\SpecialPrice; | ||
use Magento\Catalog\Api\Data\SpecialPriceInterface; | ||
use Magento\Store\Api\Data\WebsiteInterface; | ||
|
||
/** | ||
* Product special price model. | ||
* | ||
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse) | ||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) | ||
*/ | ||
class FrontSpecialPrice extends Price | ||
{ | ||
/** | ||
* @var SpecialPrice | ||
*/ | ||
private $specialPrice; | ||
|
||
/** | ||
* @param \Magento\CatalogRule\Model\ResourceModel\RuleFactory $ruleFactory | ||
* @param \Magento\Store\Model\StoreManagerInterface $storeManager | ||
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate | ||
* @param \Magento\Customer\Model\Session $customerSession | ||
* @param \Magento\Framework\Event\ManagerInterface $eventManager | ||
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency | ||
* @param \Magento\Customer\Api\GroupManagementInterface $groupManagement | ||
* @param \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory | ||
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config | ||
* @param SpecialPrice $specialPrice | ||
* @SuppressWarnings(PHPMD.ExcessiveParameterList) | ||
*/ | ||
public function __construct( | ||
\Magento\CatalogRule\Model\ResourceModel\RuleFactory $ruleFactory, | ||
\Magento\Store\Model\StoreManagerInterface $storeManager, | ||
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, | ||
\Magento\Customer\Model\Session $customerSession, | ||
\Magento\Framework\Event\ManagerInterface $eventManager, | ||
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, | ||
\Magento\Customer\Api\GroupManagementInterface $groupManagement, | ||
\Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory, | ||
\Magento\Framework\App\Config\ScopeConfigInterface $config, | ||
SpecialPrice $specialPrice | ||
) { | ||
$this->specialPrice = $specialPrice; | ||
parent::__construct( | ||
$ruleFactory, | ||
$storeManager, | ||
$localeDate, | ||
$customerSession, | ||
$eventManager, | ||
$priceCurrency, | ||
$groupManagement, | ||
$tierPriceFactory, | ||
$config | ||
); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function _applySpecialPrice($product, $finalPrice) | ||
{ | ||
if (!$product->getSpecialPrice()) { | ||
return $finalPrice; | ||
} | ||
|
||
$specialPrices = $this->getSpecialPrices($product); | ||
$specialPrice = !(empty($specialPrices)) ? min($specialPrices) : $product->getSpecialPrice(); | ||
|
||
$specialPrice = $this->calculateSpecialPrice( | ||
$finalPrice, | ||
$specialPrice, | ||
$product->getSpecialFromDate(), | ||
$product->getSpecialToDate(), | ||
WebsiteInterface::ADMIN_CODE | ||
); | ||
$product->setData('special_price', $specialPrice); | ||
|
||
return $specialPrice; | ||
} | ||
|
||
/** | ||
* Get special prices. | ||
* | ||
* @param mixed $product | ||
* @return array | ||
*/ | ||
private function getSpecialPrices($product): array | ||
{ | ||
$allSpecialPrices = $this->specialPrice->get([$product->getSku()]); | ||
$specialPrices = []; | ||
foreach ($allSpecialPrices as $price) { | ||
if ($this->isSuitableSpecialPrice($product, $price)) { | ||
$specialPrices[] = $price['value']; | ||
} | ||
} | ||
|
||
return $specialPrices; | ||
} | ||
|
||
/** | ||
* Price is suitable from default and current store + start and end date are equal. | ||
* | ||
* @param mixed $product | ||
* @param array $price | ||
* @return bool | ||
*/ | ||
private function isSuitableSpecialPrice($product, array $price): bool | ||
{ | ||
$priceStoreId = $price[Store::STORE_ID]; | ||
if (($priceStoreId == Store::DEFAULT_STORE_ID || $product->getStoreId() == $priceStoreId) | ||
&& $price[SpecialPriceInterface::PRICE_FROM] == $product->getSpecialFromDate() | ||
&& $price[SpecialPriceInterface::PRICE_TO] == $product->getSpecialToDate()) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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="AdminChangeProductAttributeSetTest"> | ||
<annotations> | ||
<features value="Catalog"/> | ||
<stories value="Update product"/> | ||
<title value="Attributes from the selected attribute set should be shown"/> | ||
<description value="Attributes from the selected attribute set should be shown"/> | ||
<severity value="CRITICAL"/> | ||
<testCaseId value="MC-15414"/> | ||
<useCaseId value="MAGETWO-98380"/> | ||
<group value="catalog"/> | ||
</annotations> | ||
<before> | ||
<!--Create category product, attribute, attribute set--> | ||
<createData entity="SimpleSubCategory" stepKey="createCategory"/> | ||
<createData entity="_defaultProduct" stepKey="createSimpleProduct"> | ||
<requiredEntity createDataKey="createCategory"/> | ||
</createData> | ||
<createData entity="ProductAttributeText" stepKey="createProductAttribute"/> | ||
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/> | ||
|
||
<actionGroup ref="LoginAsAdmin" stepKey="login"/> | ||
<!--Assign attribute to attribute set--> | ||
<amOnPage url="{{AdminProductAttributeSetEditPage.url($$createAttributeSet.attribute_set_id$$)}}" stepKey="openAttributeSetEdit"/> | ||
<actionGroup ref="AssignAttributeToGroup" stepKey="assignAttributeToGroup"> | ||
<argument name="group" value="Product Details"/> | ||
<argument name="attribute" value="$$createProductAttribute.attribute_code$$"/> | ||
</actionGroup> | ||
<actionGroup ref="SaveAttributeSet" stepKey="saveAttributeSet"/> | ||
</before> | ||
<after> | ||
<!--Delete created entities--> | ||
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> | ||
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/> | ||
<deleteData createDataKey="createProductAttribute" stepKey="deleteProductAttribute"/> | ||
<deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/> | ||
|
||
<actionGroup ref="logout" stepKey="logoutAdminUserAfterTest"/> | ||
</after> | ||
<!--Open created product--> | ||
<amOnPage url="{{AdminProductEditPage.url($$createSimpleProduct.id$$)}}" stepKey="openProductEditPage"/> | ||
<waitForPageLoad time="30" stepKey="waitForProductPageIsLoaded"/> | ||
<dontSeeElement selector="{{AdminProductFormSection.customAttributeInputField($$createProductAttribute.attribute_code$$)}}" stepKey="dontSeeCreatedAttribute"/> | ||
<!--Change product attribute set--> | ||
<actionGroup ref="AdminChangeProductAttributeSet" stepKey="changeProductAttributeSet"> | ||
<argument name="attributeSet" value="$$createAttributeSet$$"/> | ||
</actionGroup> | ||
<!--Check new attribute is visible on product edit page--> | ||
<seeElement selector="{{AdminProductFormSection.customAttributeInputField($$createProductAttribute.attribute_code$$)}}" stepKey="seeAttributeInForm"/> | ||
</test> | ||
</tests> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.