Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #13251: Translate attribute label with default translation helper function (by @cmuench)
 - #12765: #12717 - Catalog Products List widget is not displayed on Storefront (by @RostislavS)
 - #13417: [Backport 2.3] #12936 out-of-stock options for configurable product visible as sellable (by @coderimus)


Fixed GitHub Issues:
 - #12717: Catalog Products List widget is not displayed on Storefront (reported by @alena-marchenko) has been fixed in #12765 by @RostislavS in 2.3-develop branch
   Related commits:
     1. d30696e
     2. 55a3ded
  • Loading branch information
magento-engcom-team authored Feb 7, 2018
2 parents 7bc49cd + b40e0af commit 1dcb55d
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 46 deletions.
10 changes: 10 additions & 0 deletions app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ public function afterSave()
return parent::afterSave();
}

/**
* Is attribute enabled for flat indexing
*
* @return bool
*/
public function isEnabledInFlat()
{
return $this->_isEnabledInFlat();
}

/**
* Is attribute enabled for flat indexing
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class EavTest extends AbstractModifierTest
* @var ObjectManager
*/
protected $objectManager;

/**
* @var Eav
*/
Expand Down Expand Up @@ -324,7 +324,7 @@ protected function setUp()
$this->eavAttributeMock->expects($this->any())
->method('load')
->willReturnSelf();

$this->eav =$this->getModel();
$this->objectManager->setBackwardCompatibleProperty(
$this->eav,
Expand Down Expand Up @@ -490,6 +490,10 @@ public function testSetupAttributeMetaDefaultAttribute($productId, $productRequi
->method('getNote')
->willReturn($note);

$this->productAttributeMock->expects($this->any())
->method('getDefaultFrontendLabel')
->willReturn(new Phrase('mylabel'));

$attributeMock = $this->getMockBuilder(AttributeInterface::class)
->setMethods(['getValue'])
->disableOriginalConstructor()
Expand Down Expand Up @@ -561,7 +565,7 @@ private function defaultNullProdNotNewAndRequired()
'required' => true,
'notice' => null,
'default' => null,
'label' => null,
'label' => new Phrase('mylabel'),
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
Expand All @@ -588,7 +592,7 @@ private function defaultNullProdNotNewAndNotRequired()
'required' => false,
'notice' => null,
'default' => null,
'label' => null,
'label' => new Phrase('mylabel'),
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
Expand All @@ -615,7 +619,7 @@ private function defaultNullProdNewAndNotRequired()
'required' => false,
'notice' => null,
'default' => 'required_value',
'label' => null,
'label' => new Phrase('mylabel'),
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
Expand All @@ -642,7 +646,7 @@ private function defaultNullProdNewAndRequired()
'required' => false,
'notice' => null,
'default' => 'required_value',
'label' => null,
'label' => new Phrase('mylabel'),
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
Expand All @@ -669,7 +673,7 @@ private function defaultNullProdNewAndRequiredAndFilledNotice()
'required' => false,
'notice' => __('example notice'),
'default' => 'required_value',
'label' => null,
'label' => new Phrase('mylabel'),
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC
'required' => $attribute->getIsRequired(),
'notice' => $attribute->getNote() === null ? null : __($attribute->getNote()),
'default' => (!$this->isProductExists()) ? $attribute->getDefaultValue() : null,
'label' => $attribute->getDefaultFrontendLabel(),
'label' => __($attribute->getDefaultFrontendLabel()),
'code' => $attribute->getAttributeCode(),
'source' => $groupCode,
'scopeLabel' => $this->getScopeLabel($attribute),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
namespace Magento\CatalogInventory\Model\ResourceModel\Stock;

use Magento\CatalogInventory\Model\Stock;
use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\CatalogInventory\Model\Stock;
use Magento\Framework\App\ObjectManager;

/**
Expand Down Expand Up @@ -46,19 +46,23 @@ class Status extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param \Magento\Store\Model\WebsiteFactory $websiteFactory
* @param \Magento\Eav\Model\Config $eavConfig
* @param string $connectionName
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Store\Model\WebsiteFactory $websiteFactory,
\Magento\Eav\Model\Config $eavConfig,
$connectionName = null
$connectionName = null,
$stockConfiguration = null
) {
parent::__construct($context, $connectionName);

$this->_storeManager = $storeManager;
$this->_websiteFactory = $websiteFactory;
$this->eavConfig = $eavConfig;
$this->stockConfiguration = $stockConfiguration ?: ObjectManager::getInstance()
->get(StockConfigurationInterface::class);
}

/**
Expand Down Expand Up @@ -204,7 +208,7 @@ public function getProductCollection($lastEntityId = 0, $limit = 1000)
*/
public function addStockStatusToSelect(\Magento\Framework\DB\Select $select, \Magento\Store\Model\Website $website)
{
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
$websiteId = $this->getWebsiteId($website->getId());
$select->joinLeft(
['stock_status' => $this->getMainTable()],
'e.entity_id = stock_status.product_id AND stock_status.website_id=' . $websiteId,
Expand All @@ -221,7 +225,7 @@ public function addStockStatusToSelect(\Magento\Framework\DB\Select $select, \Ma
*/
public function addStockDataToCollection($collection, $isFilterInStock)
{
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
$websiteId = $this->getWebsiteId();
$joinCondition = $this->getConnection()->quoteInto(
'e.entity_id = stock_status_index.product_id' . ' AND stock_status_index.website_id = ?',
$websiteId
Expand Down Expand Up @@ -255,7 +259,7 @@ public function addStockDataToCollection($collection, $isFilterInStock)
*/
public function addIsInStockFilterToCollection($collection)
{
$websiteId = $this->getStockConfiguration()->getDefaultScopeId();
$websiteId = $this->getWebsiteId();
$joinCondition = $this->getConnection()->quoteInto(
'e.entity_id = stock_status_index.product_id' . ' AND stock_status_index.website_id = ?',
$websiteId
Expand All @@ -277,6 +281,19 @@ public function addIsInStockFilterToCollection($collection)
return $this;
}

/**
* @param \Magento\Store\Model\Website $websiteId
* @return int
*/
private function getWebsiteId($websiteId = null)
{
if (null === $websiteId) {
$websiteId = $this->stockConfiguration->getDefaultScopeId();
}

return $websiteId;
}

/**
* Retrieve Product(s) status for store
* Return array where key is a product_id, value - status
Expand Down Expand Up @@ -335,18 +352,4 @@ public function getProductStatus($productIds, $storeId = null)
}
return $statuses;
}

/**
* @return StockConfigurationInterface
*
* @deprecated 100.1.0
*/
private function getStockConfiguration()
{
if ($this->stockConfiguration === null) {
$this->stockConfiguration = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\CatalogInventory\Api\StockConfigurationInterface::class);
}
return $this->stockConfiguration;
}
}
17 changes: 15 additions & 2 deletions app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,21 @@ public function addToCollection($collection)
$attribute = $this->getAttributeObject();

if ($collection->isEnabledFlat()) {
$alias = array_keys($collection->getSelect()->getPart('from'))[0];
$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode();
if ($attribute->isEnabledInFlat()) {
$alias = array_keys($collection->getSelect()->getPart('from'))[0];
$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode();
} else {
$alias = 'at_' . $attribute->getAttributeCode();
if (!in_array($alias, array_keys($collection->getSelect()->getPart('from')))) {
$collection->joinAttribute(
$attribute->getAttributeCode(),
'catalog_product/'.$attribute->getAttributeCode(),
'entity_id'
);
}

$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.value';
}
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\ConfigurableProduct\Model\Product\Type;

use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\ConfigurableProduct\Model\Product\Type\Collection\SalableProcessor;
use Magento\Catalog\Model\Config;
use Magento\Catalog\Model\Product\Gallery\ReadHandler as GalleryReadHandler;
use Magento\ConfigurableProduct\Model\Product\Type\Collection\SalableProcessor;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Catalog\Model\Product\Gallery\ReadHandler as GalleryReadHandler;

/**
* Configurable product type implementation
Expand Down Expand Up @@ -266,7 +267,6 @@ public function __construct(
$productRepository,
$serializer
);

}

/**
Expand Down Expand Up @@ -682,7 +682,7 @@ private function saveConfigurableOptions(ProductInterface $product)
->setProductId($product->getData($metadata->getLinkField()))
->save();
}
/** @var $configurableAttributesCollection \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection */
/** @var $configurableAttributesCollection \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection */
$configurableAttributesCollection = $this->_attributeCollectionFactory->create();
$configurableAttributesCollection->setProductFilter($product);
$configurableAttributesCollection->addFieldToFilter(
Expand Down Expand Up @@ -1276,6 +1276,8 @@ public function getSalableUsedProducts(\Magento\Catalog\Model\Product $product,
* Load collection on sub-products for specified configurable product
*
* Load collection of sub-products, apply result to specified configurable product and store result to cache
* Please note $salableOnly parameter is used for backwards compatibility because of deprecated method
* getSalableUsedProducts
* Number of loaded sub-products depends on $salableOnly parameter
* $salableOnly = true - result array contains only salable sub-products
* $salableOnly = false - result array contains all sub-products
Expand All @@ -1292,7 +1294,7 @@ private function loadUsedProducts(\Magento\Catalog\Model\Product $product, $cach
if (!$product->hasData($dataFieldName)) {
$usedProducts = $this->readUsedProductsCacheData($cacheKey);
if ($usedProducts === null) {
$collection = $this->getConfiguredUsedProductCollection($product);
$collection = $this->getConfiguredUsedProductCollection($product, false);
if ($salableOnly) {
$collection = $this->salableProcessor->process($collection);
}
Expand Down Expand Up @@ -1386,13 +1388,18 @@ private function getUsedProductsCacheKey($keyParts)
* Retrieve related products collection with additional configuration
*
* @param \Magento\Catalog\Model\Product $product
* @param bool $skipStockFilter
* @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection
*/
private function getConfiguredUsedProductCollection(\Magento\Catalog\Model\Product $product)
{
private function getConfiguredUsedProductCollection(
\Magento\Catalog\Model\Product $product,
$skipStockFilter = true
) {
$collection = $this->getUsedProductCollection($product);
if ($skipStockFilter) {
$collection->setFlag('has_stock_status_filter', true);
}
$collection
->setFlag('has_stock_status_filter', true)
->addAttributeToSelect($this->getCatalogConfig()->getProductAttributes())
->addFilterByRequiredOptions()
->setStoreId($product->getStoreId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
use Magento\Catalog\Api\Data\ProductExtensionInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Config;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Customer\Model\Session;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\CollectionFactory;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection;
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\ConfigurableProduct\Model\Product\Type\Collection\SalableProcessor;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable\AttributeFactory;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\CollectionFactory;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection as ProductCollection;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\ConfigurableFactory;
use Magento\Customer\Model\Session;
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection as ProductCollection;
use Magento\ConfigurableProduct\Model\Product\Type\Collection\SalableProcessor;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;

/**
* @SuppressWarnings(PHPMD.LongVariable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Setup\Module\I18n\Dictionary;

use Magento\Framework\Component\ComponentRegistrar;
use Magento\Setup\Module\I18n\Dictionary\Generator;
use Magento\Setup\Module\I18n\ServiceLocator;

class GeneratorTest extends \PHPUnit\Framework\TestCase
Expand Down Expand Up @@ -46,6 +47,7 @@ protected function setUp()
$paths = $reflection->getProperty('paths');
$paths->setAccessible(true);
$this->backupRegistrar = $paths->getValue();
$paths->setValue(['module' => [], 'theme' => []]);
$paths->setAccessible(false);

$this->testDir = realpath(__DIR__ . '/_files');
Expand Down

0 comments on commit 1dcb55d

Please sign in to comment.