Skip to content

Commit d3f50f8

Browse files
author
Oleksii Korshenko
committed
MAGETWO-48781: Low catalog performance with Swatches
1 parent 3f7bc66 commit d3f50f8

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ protected function getSwatchProductImage(Product $childProduct, $imageType)
327327
*/
328328
protected function isProductHasImage(Product $product, $imageType)
329329
{
330-
return $product->getData($imageType) !== null && $product->getData($imageType) != SwatchData::EMPTY_IMAGE_VALUE;
330+
return $product->getData($imageType) !== null && $product->getData($imageType) != 'no_selection';
331331
}
332332

333333
/**

app/code/Magento/Swatches/Helper/Data.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
*/
2727
class Data extends \Magento\Framework\App\Helper\AbstractHelper
2828
{
29-
/**
30-
* When we init media gallery empty image types contain this value.
31-
*/
32-
const EMPTY_IMAGE_VALUE = 'no_selection';
33-
3429
/**
3530
* Default store ID
3631
*/
@@ -380,11 +375,11 @@ function ($value) {
380375
*/
381376
public function getProductMediaGallery (Product $product)
382377
{
383-
if (!in_array($product->getData('image'), [null, self::EMPTY_IMAGE_VALUE], true)) {
378+
if (!in_array($product->getData('image'), [null, 'no_selection'], true)) {
384379
$baseImage = $product->getData('image');
385380
} else {
386381
$productMediaAttributes = array_filter($product->getMediaAttributeValues(), function ($value) {
387-
return $value !== self::EMPTY_IMAGE_VALUE && $value !== null;
382+
return $value !== 'no_selection' && $value !== null;
388383
});
389384
foreach ($productMediaAttributes as $attributeCode => $value) {
390385
if ($attributeCode !== 'swatch_image') {
@@ -645,7 +640,7 @@ private function loadFirstVariation($attributeCode, ModelProduct $configurablePr
645640
$usedProducts = $configurableProduct->getTypeInstance()->getUsedProducts($configurableProduct);
646641

647642
foreach ($usedProducts as $simpleProduct) {
648-
if (!in_array($simpleProduct->getData($attributeCode), [null, self::EMPTY_IMAGE_VALUE], true)
643+
if (!in_array($simpleProduct->getData($attributeCode), [null, 'no_selection'], true)
649644
&& !array_diff_assoc($requiredAttributes, $simpleProduct->getData())
650645
) {
651646
return $simpleProduct;

0 commit comments

Comments
 (0)