Skip to content

Commit

Permalink
Merge branch '2.4-develop' into 25963-grid-export-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
novikor authored Feb 6, 2020
2 parents 4483911 + 7322e87 commit 0d3e478
Show file tree
Hide file tree
Showing 82 changed files with 1,520 additions and 306 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
<seeInCurrentUrl url="{{AdminLoginPage.url}}" stepKey="seeAdminLoginUrl"/>
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
</test>
</tests>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ define([
*/
onError: function () {
self.showError($t('Payment ' + self.getTitle() + ' can\'t be initialized'));
self.reInitPayPal();
}
}, self.paypalButtonSelector);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCardinalCommerceSettingsHiddenTest">
<annotations>
<stories value="Cardinal Commerce Settings"/>
<features value="CardinalCommerce"/>
<title value="CardinalCommerce settings hidden" />
<description value="CardinalCommerce config shouldn't be visible if the 3D secure is disabled for Authorize.Net."/>
Expand Down
32 changes: 26 additions & 6 deletions app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
namespace Magento\Catalog\Block\Ui;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\ProductRenderFactory;
use Magento\Catalog\Model\ProductRepository;
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\Hydrator;
use Magento\Framework\Registry;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Url;
use Magento\Framework\View\Element\Template;
use Magento\Store\Model\Store;
use Magento\Catalog\Model\ProductRenderFactory;
use Magento\Catalog\Model\ProductRepository;
use Magento\Framework\EntityManager\Hydrator;
use Magento\Store\Model\StoreManager;

/**
Expand All @@ -25,6 +27,7 @@
*
* @api
* @since 101.1.0
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ProductViewCounter extends Template
{
Expand Down Expand Up @@ -68,6 +71,13 @@ class ProductViewCounter extends Template
*/
private $registry;

/**
* Core store config
*
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param Template\Context $context
* @param ProductRepository $productRepository
Expand All @@ -78,6 +88,8 @@ class ProductViewCounter extends Template
* @param SerializerInterface $serialize
* @param Url $url
* @param Registry $registry
* @param ScopeConfigInterface|null $scopeConfig
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Template\Context $context,
Expand All @@ -88,7 +100,8 @@ public function __construct(
Hydrator $hydrator,
SerializerInterface $serialize,
Url $url,
Registry $registry
Registry $registry,
?ScopeConfigInterface $scopeConfig = null
) {
parent::__construct($context);
$this->productRepository = $productRepository;
Expand All @@ -99,6 +112,7 @@ public function __construct(
$this->serialize = $serialize;
$this->url = $url;
$this->registry = $registry;
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
}

/**
Expand All @@ -116,14 +130,19 @@ public function getCurrentProductData()
{
/** @var ProductInterface $product */
$product = $this->registry->registry('product');
$productsScope = $this->scopeConfig->getValue(
'catalog/recently_products/scope',
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE
);
/** @var Store $store */
$store = $this->storeManager->getStore();

if (!$product || !$product->getId()) {
return $this->serialize->serialize([
'items' => [],
'store' => $store->getId(),
'currency' => $store->getCurrentCurrency()->getCode()
'currency' => $store->getCurrentCurrency()->getCode(),
'productCurrentScope' => $productsScope
]);
}

Expand All @@ -140,7 +159,8 @@ public function getCurrentProductData()
$product->getId() => $data
],
'store' => $store->getId(),
'currency' => $store->getCurrentCurrency()->getCode()
'currency' => $store->getCurrentCurrency()->getCode(),
'productCurrentScope' => $productsScope
];

return $this->serialize->serialize($currentProductData);
Expand Down
28 changes: 26 additions & 2 deletions app/code/Magento/Catalog/CustomerData/CompareProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
namespace Magento\Catalog\CustomerData;

use Magento\Customer\CustomerData\SectionSourceInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;

/**
* Catalog Product Compare Widget
*/
class CompareProducts implements SectionSourceInterface
{
/**
Expand All @@ -24,23 +30,33 @@ class CompareProducts implements SectionSourceInterface
*/
private $outputHelper;

/**
* Core store config
*
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param \Magento\Catalog\Helper\Product\Compare $helper
* @param \Magento\Catalog\Model\Product\Url $productUrl
* @param \Magento\Catalog\Helper\Output $outputHelper
* @param ScopeConfigInterface|null $scopeConfig
*/
public function __construct(
\Magento\Catalog\Helper\Product\Compare $helper,
\Magento\Catalog\Model\Product\Url $productUrl,
\Magento\Catalog\Helper\Output $outputHelper
\Magento\Catalog\Helper\Output $outputHelper,
?ScopeConfigInterface $scopeConfig = null
) {
$this->helper = $helper;
$this->productUrl = $productUrl;
$this->outputHelper = $outputHelper;
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getSectionData()
{
Expand All @@ -54,18 +70,26 @@ public function getSectionData()
}

/**
* Get the list of compared product items
*
* @return array
* @throws LocalizedException
*/
protected function getItems()
{
$items = [];
$productsScope = $this->scopeConfig->getValue(
'catalog/recently_products/scope',
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE
);
/** @var \Magento\Catalog\Model\Product $item */
foreach ($this->helper->getItemCollection() as $item) {
$items[] = [
'id' => $item->getId(),
'product_url' => $this->productUrl->getUrl($item),
'name' => $this->outputHelper->productAttribute($item, $item->getName(), 'name'),
'remove_url' => $this->helper->getPostDataRemove($item),
'productScope' => $productsScope
];
}
return $items;
Expand Down
57 changes: 47 additions & 10 deletions app/code/Magento/Catalog/Model/ResourceModel/Product/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\Catalog\Model\ResourceModel\Product;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;

/**
Expand All @@ -14,6 +15,32 @@
*/
class Action extends \Magento\Catalog\Model\ResourceModel\AbstractResource
{
/**
* @var \Magento\Framework\Stdlib\DateTime\DateTime
*/
private $dateTime;

/**
* @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Factory $modelFactory
* @param \Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface $uniqueValidator
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
* @param array $data
*/
public function __construct(
\Magento\Eav\Model\Entity\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Factory $modelFactory,
\Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface $uniqueValidator,
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
$data = []
) {
parent::__construct($context, $storeManager, $modelFactory, $data, $uniqueValidator);

$this->dateTime = $dateTime;
}

/**
* Initialize connection
*
Expand Down Expand Up @@ -43,6 +70,7 @@ public function updateAttributes($entityIds, $attrData, $storeId)
$object = new \Magento\Framework\DataObject();
$object->setStoreId($storeId);

$attrData[ProductInterface::UPDATED_AT] = $this->dateTime->gmtDate();
$this->getConnection()->beginTransaction();
try {
foreach ($attrData as $attrCode => $value) {
Expand Down Expand Up @@ -95,7 +123,7 @@ protected function _saveAttributeValue($object, $attribute, $value)
* for default store id
* In this case we clear all not default values
*/
if ($this->_storeManager->hasSingleStore()) {
if ($this->_storeManager->hasSingleStore() && !$attribute->isStatic()) {
$storeId = $this->getDefaultStoreId();
$connection->delete(
$table,
Expand All @@ -107,17 +135,24 @@ protected function _saveAttributeValue($object, $attribute, $value)
);
}

$data = new \Magento\Framework\DataObject(
[
'attribute_id' => $attribute->getAttributeId(),
'store_id' => $storeId,
$this->getLinkField() => $entityId,
'value' => $this->_prepareValueForSave($value, $attribute),
]
);
$data = $attribute->isStatic()
? new \Magento\Framework\DataObject(
[
$this->getLinkField() => $entityId,
$attribute->getAttributeCode() => $this->_prepareValueForSave($value, $attribute),
]
)
: new \Magento\Framework\DataObject(
[
'attribute_id' => $attribute->getAttributeId(),
'store_id' => $storeId,
$this->getLinkField() => $entityId,
'value' => $this->_prepareValueForSave($value, $attribute),
]
);
$bind = $this->_prepareDataForTable($data, $table);

if ($attribute->isScopeStore()) {
if ($attribute->isScopeStore() || $attribute->isStatic()) {
/**
* Update attribute value for store
*/
Expand All @@ -143,6 +178,8 @@ protected function _saveAttributeValue($object, $attribute, $value)
}

/**
* Resolve entity id
*
* @param int $entityId
* @return int
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="ProductAttributeWithoutValueInCompareListTest">
<annotations>
<features value="Catalog"/>
<stories value="Product Comparison"/>
<title value="Product attribute without value in compare list test"/>
<description
value="The product attribute that has no value should output 'N/A' on the product comparison page."/>
<description value="The product attribute that has no value should output 'N/A' on the product comparison page."/>
<severity value="MINOR"/>
<group value="Catalog"/>
</annotations>
Expand All @@ -22,7 +22,7 @@
<createData entity="textProductAttribute" stepKey="createProductAttribute"/>
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$$createAttributeSet.attribute_set_id$$/"
stepKey="onAttributeSetEdit"/>
stepKey="onAttributeSetEdit"/>
<actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup">
<argument name="group" value="Product Details"/>
<argument name="attribute" value="$$createProductAttribute.attribute_code$$"/>
Expand Down Expand Up @@ -69,11 +69,11 @@
</actionGroup>
<!--See attribute default value in the comparison list-->
<see userInput="$createProductAttribute.defaultValue$"
selector="{{StorefrontProductCompareMainSection.ProductAttributeByCodeAndProductName(ProductAttributeFrontendLabel.label, $createProductCustom.name$)}}"
stepKey="assertAttributeValueForProductCustom"/>
selector="{{StorefrontProductCompareMainSection.ProductAttributeByCodeAndProductName(ProductAttributeFrontendLabel.label, $createProductCustom.name$)}}"
stepKey="assertAttributeValueForProductCustom"/>
<!--See N/A if attribute has no value in the comparison list-->
<see userInput="N/A"
selector="{{StorefrontProductCompareMainSection.ProductAttributeByCodeAndProductName(ProductAttributeFrontendLabel.label, $createProductDefault.name$)}}"
stepKey="assertNAForProductDefault"/>
selector="{{StorefrontProductCompareMainSection.ProductAttributeByCodeAndProductName(ProductAttributeFrontendLabel.label, $createProductDefault.name$)}}"
stepKey="assertNAForProductDefault"/>
</test>
</tests>
Loading

0 comments on commit 0d3e478

Please sign in to comment.