Skip to content

Commit

Permalink
Merge branch '2.4-develop' into 26314-map-swatches-improvements-for-p…
Browse files Browse the repository at this point in the history
…roduct-list
  • Loading branch information
Vaha committed Jan 17, 2020
2 parents b3abb06 + 3e4db87 commit 9d9086f
Show file tree
Hide file tree
Showing 189 changed files with 7,300 additions and 1,030 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<argument name="submenuUiId" value="{{AdminMenuReportsBusinessIntelligenceAdvancedReporting.dataUiId}}"/>
</actionGroup>
<switchToNextTab stepKey="switchToNewTab"/>
<waitForPageLoad stepKey="waitForAdvancedReportingPageLoad"/>
<seeInCurrentUrl url="advancedreporting.rjmetrics.com/report" stepKey="seeAssertAdvancedReportingPageUrl"/>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@
<severity value="MAJOR"/>
<group value="backend"/>
<group value="mtf_migrated"/>
<skip>
<issueId value="MC-17140"/>
</skip>
</annotations>
<before>
<magentoCLI command="config:set {{MinifyJavaScriptFilesEnableConfigData.path}} {{MinifyJavaScriptFilesEnableConfigData.value}}" stepKey="enableJsMinification"/>
<magentoCLI command="cache:clean config" stepKey="cleanCache"/>
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
</before>
<after>
<magentoCLI command="config:set {{MinifyJavaScriptFilesDisableConfigData.path}} {{MinifyJavaScriptFilesDisableConfigData.value}}" stepKey="disableJsMinification"/>
<actionGroup ref="logout" stepKey="logout"/>
</after>

<see userInput="Dashboard" selector="{{AdminHeaderSection.pageTitle}}" stepKey="seeDashboardTitle"/>
<waitForPageLoad stepKey="waitForPageLoadOnDashboard"/>
<actionGroup ref="AssertAdminSuccessLoginActionGroup" stepKey="loggedInSuccessfully"/>
<actionGroup ref="AssertAdminPageIsNot404ActionGroup" stepKey="dontSee404Page"/>
</test>
Expand Down
42 changes: 30 additions & 12 deletions app/code/Magento/Bundle/view/base/web/js/price-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ define([
controlContainer: 'dd', // should be eliminated
priceFormat: {},
isFixedPrice: false,
optionTierPricesBlocksSelector: '#option-tier-prices-{1} [data-role="selection-tier-prices"]'
optionTierPricesBlocksSelector: '#option-tier-prices-{1} [data-role="selection-tier-prices"]',
isOptionsInitialized: false
};

$.widget('mage.priceBundle', {
Expand All @@ -53,20 +54,37 @@ define([
priceBox = $(this.options.priceBoxSelector, form),
qty = $(this.options.qtyFieldSelector, form);

if (priceBox.data('magePriceBox') &&
priceBox.priceBox('option') &&
priceBox.priceBox('option').priceConfig
) {
if (priceBox.priceBox('option').priceConfig.optionTemplate) {
this._setOption('optionTemplate', priceBox.priceBox('option').priceConfig.optionTemplate);
this._updatePriceBox();
priceBox.on('price-box-initialized', this._updatePriceBox.bind(this));
options.on('change', this._onBundleOptionChanged.bind(this));
qty.on('change', this._onQtyFieldChanged.bind(this));
},

/**
* Update price box config with bundle option prices
* @private
*/
_updatePriceBox: function () {
var form = this.element,
options = $(this.options.productBundleSelector, form),
priceBox = $(this.options.priceBoxSelector, form);

if (!this.options.isOptionsInitialized) {
if (priceBox.data('magePriceBox') &&
priceBox.priceBox('option') &&
priceBox.priceBox('option').priceConfig
) {
if (priceBox.priceBox('option').priceConfig.optionTemplate) { //eslint-disable-line max-depth
this._setOption('optionTemplate', priceBox.priceBox('option').priceConfig.optionTemplate);
}
this._setOption('priceFormat', priceBox.priceBox('option').priceConfig.priceFormat);
priceBox.priceBox('setDefault', this.options.optionConfig.prices);
this.options.isOptionsInitialized = true;
}
this._setOption('priceFormat', priceBox.priceBox('option').priceConfig.priceFormat);
priceBox.priceBox('setDefault', this.options.optionConfig.prices);
this._applyOptionNodeFix(options);
}
this._applyOptionNodeFix(options);

options.on('change', this._onBundleOptionChanged.bind(this));
qty.on('change', this._onQtyFieldChanged.bind(this));
return this;
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function getFinalPrice();

/**
* Set the final price: usually it calculated as minimal price of the product
*
* Can be different depends on type of product
*
* @param string $finalPrice
Expand All @@ -39,6 +40,7 @@ public function setFinalPrice($finalPrice);

/**
* Retrieve max price of a product
*
* E.g. for product with custom options is price with the most expensive custom option
*
* @return string
Expand All @@ -57,6 +59,7 @@ public function setMaxPrice($maxPrice);

/**
* Retrieve the minimal price of the product or variation
*
* The minimal price is for example, the lowest price of all variations for complex product
*
* @return string
Expand All @@ -66,7 +69,7 @@ public function getMinimalPrice();

/**
* Set max regular price
* Max regular price is the same, as maximum price, except of excluding calculating special price and catalogules
* Max regular price is the same, as maximum price, except of excluding calculating special price and catalog rules
* in it
*
* @param string $maxRegularPrice
Expand Down Expand Up @@ -130,6 +133,7 @@ public function setMinimalPrice($minimalPrice);

/**
* Regular price - is price of product without discounts and special price with taxes and fixed product tax
*
* Usually this price is corresponding to price in admin panel of product
*
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
use Magento\Eav\Api\Data\AttributeGroupInterfaceFactory;
use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Eav\Api\Data\AttributeSetInterface;
use Magento\Eav\Model\Cache\Type as CacheType;
use Magento\Framework\Api\ExtensionAttributesFactory;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
Expand All @@ -29,7 +31,7 @@
use Psr\Log\LoggerInterface;

/**
* Class AddAttributeToTemplate
* Assign attribute to attribute set.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
Expand Down Expand Up @@ -80,6 +82,11 @@ class AddAttributeToTemplate extends Product implements HttpPostActionInterface
*/
protected $extensionAttributesFactory;

/**
* @var CacheInterface
*/
private $cache;

/**
* Constructor
*
Expand All @@ -94,8 +101,8 @@ class AddAttributeToTemplate extends Product implements HttpPostActionInterface
* @param AttributeManagementInterface $attributeManagement
* @param LoggerInterface $logger
* @param ExtensionAttributesFactory $extensionAttributesFactory
* @param CacheInterface|null $cache
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.LongVariable)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function __construct(
Expand All @@ -109,7 +116,8 @@ public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder = null,
AttributeManagementInterface $attributeManagement = null,
LoggerInterface $logger = null,
ExtensionAttributesFactory $extensionAttributesFactory = null
ExtensionAttributesFactory $extensionAttributesFactory = null,
CacheInterface $cache = null
) {
parent::__construct($context, $productBuilder);
$this->resultJsonFactory = $resultJsonFactory;
Expand All @@ -129,6 +137,7 @@ public function __construct(
->get(LoggerInterface::class);
$this->extensionAttributesFactory = $extensionAttributesFactory ?: ObjectManager::getInstance()
->get(ExtensionAttributesFactory::class);
$this->cache = $cache ?? ObjectManager::getInstance()->get(CacheInterface::class);
}

/**
Expand Down Expand Up @@ -203,6 +212,7 @@ function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) {
);
}
);
$this->cache->clean([CacheType::CACHE_TAG]);
} catch (LocalizedException $e) {
$response->setError(true);
$response->setMessage($e->getMessage());
Expand All @@ -223,7 +233,7 @@ function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) {
*/
private function getBasicAttributeSearchCriteriaBuilder()
{
$attributeIds = (array) $this->getRequest()->getParam('attributeIds', []);
$attributeIds = (array)$this->getRequest()->getParam('attributeIds', []);

if (empty($attributeIds['selected'])) {
throw new LocalizedException(__('Attributes were missing and must be specified.'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ protected function populateFlatTables(array $stores)
}
$category['store_id'] = $store->getId();
$data[] = $this->prepareValuesToInsert(
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge($category, $attributesData[$category[$linkField]])
);
}
Expand Down Expand Up @@ -183,7 +184,7 @@ private function getActualStoreTablesForCategoryFlat(): array
foreach ($this->storeManager->getStores() as $store) {
$actualStoreTables[] = sprintf(
'%s_store_%s',
$this->connection->getTableName('catalog_category_flat'),
$this->connection->getTableName($this->getTableName('catalog_category_flat')),
$store->getId()
);
}
Expand All @@ -199,7 +200,7 @@ private function getActualStoreTablesForCategoryFlat(): array
private function deleteAbandonedStoreCategoryFlatTables(): void
{
$existentTables = $this->connection->getTables(
$this->connection->getTableName('catalog_category_flat_store_%')
$this->connection->getTableName($this->getTableName('catalog_category_flat_store_%'))
);
$actualStoreTables = $this->getActualStoreTablesForCategoryFlat();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function _updateRelationProducts($storeId, $productIds = null)
['t' => $this->_productIndexerHelper->getTable($relation->getTable())],
['entity_table.entity_id', $relation->getChildFieldName(), new \Zend_Db_Expr('1')]
)->join(
['entity_table' => $this->_connection->getTableName('catalog_product_entity')],
['entity_table' => $this->_productIndexerHelper->getTable('catalog_product_entity')],
"entity_table.{$metadata->getLinkField()} = t.{$relation->getParentFieldName()}",
[]
)->join(
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Catalog/Model/Product/Type/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function _applyTierPrice($product, $qty, $finalPrice)

$tierPrice = $product->getTierPrice($qty);
if (is_numeric($tierPrice)) {
$finalPrice = min($finalPrice, $tierPrice);
$finalPrice = min($finalPrice, (float) $tierPrice);
}
return $finalPrice;
}
Expand Down Expand Up @@ -645,7 +645,7 @@ public function calculateSpecialPrice(
) {
if ($specialPrice !== null && $specialPrice != false) {
if ($this->_localeDate->isScopeDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
$finalPrice = min($finalPrice, $specialPrice);
$finalPrice = min($finalPrice, (float) $specialPrice);
}
}
return $finalPrice;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="AdminExpandProductAttributesTabActionGroup">
<annotations>
<description>Expands the 'Attributes' tab on the Admin Product page.</description>
</annotations>

<scrollTo selector="{{AdminProductAttributeSection.attributeSectionHeader}}" stepKey="scrollToAttributesTab"/>
<conditionalClick selector="{{AdminProductAttributeSection.attributeSectionHeader}}" dependentSelector="{{AdminProductAttributeSection.attributeSection}}" visible="false" stepKey="expandAttributesTab"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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="AssertStorefrontAttributeOptionPresentInLayeredNavigationActionGroup">
<annotations>
<description>Clicks on the attribute label. Checks for attribute option presence.</description>
</annotations>
<arguments>
<argument name="attributeLabel" type="string" defaultValue="{{ProductAttributeFrontendLabel.label}}"/>
<argument name="attributeOptionLabel" type="string" defaultValue="{{Option1Store0.label}}"/>
<argument name="attributeOptionPosition" type="string" defaultValue="1"/>
</arguments>

<waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionsTitle(attributeLabel)}}" stepKey="waitForAttributeVisible"/>
<conditionalClick selector="{{StorefrontCategorySidebarSection.filterOptionsTitle(attributeLabel)}}" dependentSelector="{{StorefrontCategorySidebarSection.activeFilterOptions}}" visible="false" stepKey="clickToExpandAttribute"/>
<waitForElementVisible selector="{{StorefrontCategorySidebarSection.activeFilterOptions}}" stepKey="waitForAttributeOptionsVisible"/>
<see selector="{{StorefrontCategorySidebarSection.activeFilterOptionItemByPosition(attributeOptionPosition)}}" userInput="{{attributeOptionLabel}}" stepKey="assertAttributeOptionInLayeredNavigation"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
<element name="optionQty" type="text" selector=".filter-options-content .item .count"/>
<element name="filterOptionByLabel" type="button" selector=" div.filter-options-item div[option-label='{{optionLabel}}']" parameterized="true"/>
<element name="removeFilter" type="button" selector="div.filter-current .remove"/>
<element name="activeFilterOptions" type="text" selector=".filter-options-item.active .items"/>
<element name="activeFilterOptionItemByPosition" type="text" selector=".filter-options-item.active .items li:nth-child({{itemPosition}}) a" parameterized="true"/>
</section>
<section name="StorefrontCategorySidebarMobileSection">
<element name="shopByButton" type="button" selector="//div[contains(@class, 'filter-title')]/strong[contains(text(), 'Shop By')]"/>
</section>
</sections>
</sections>
Loading

0 comments on commit 9d9086f

Please sign in to comment.