Skip to content

Commit 206ea48

Browse files
committed
MAGETWO-91433: ProductListing: Grid view is getting changed to List view when user adding product from wishlist section.
1 parent 2da9d00 commit 206ea48

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

app/code/Magento/Wishlist/Model/Product/AttributeValueProvider.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\Wishlist\Model\Product;
99

1010
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
11-
use Magento\Framework\Exception\NoSuchEntityException;
1211

1312
/**
1413
* Provides existing attribute value for a product entity.
@@ -36,7 +35,6 @@ public function __construct(
3635
* @param string $attributeCode
3736
* @param int|null $storeId
3837
* @return null|string
39-
* @throws NoSuchEntityException
4038
*/
4139
public function getRawAttributeValue(int $productId, string $attributeCode, int $storeId = null):? string
4240
{
@@ -46,12 +44,13 @@ public function getRawAttributeValue(int $productId, string $attributeCode, int
4644
->addStoreFilter($storeId)
4745
->addAttributeToSelect($attributeCode);
4846

49-
$data = $collection->getConnection()->fetchRow($collection->getSelect());
50-
51-
if (!array_key_exists($attributeCode, $data)) {
52-
throw new NoSuchEntityException(__('An attribute value of "%1" does not exist.', $attributeCode));
47+
if ($collection->isEnabledFlat()) {
48+
$data = $collection->getConnection()->fetchRow($collection->getSelect());
49+
$attributeValue = $data[$attributeCode] ?? null;
50+
} else {
51+
$attributeValue = $collection->getFirstItem()->getData($attributeCode);
5352
}
5453

55-
return $data[$attributeCode];
54+
return $attributeValue;
5655
}
5756
}

0 commit comments

Comments
 (0)