Skip to content

Commit 0f5dfa4

Browse files
authored
Refactor conditionals to check for attribute (#285)
* Refactor conditionals to check for attribute * Address Static Tests * Refactor to minimize db calls
1 parent f3a8fa6 commit 0f5dfa4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/code/Meta/Catalog/Model/Product/Feed/ProductRetriever/Configurable.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function getProductType()
8383
* @inheritDoc
8484
*
8585
* @throws LocalizedException
86+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8687
*/
8788
public function retrieve($offset = 1, $limit = self::LIMIT): array
8889
{
@@ -137,10 +138,14 @@ public function retrieve($offset = 1, $limit = self::LIMIT): array
137138
if (!$childProduct->getWeight()) {
138139
$childProduct->setWeight($product->getWeight());
139140
}
140-
if (!$childProduct->getAttributeText('material')) {
141+
142+
$material = $childProduct->getResource()->getAttribute('material');
143+
if ($material && !$material->getSource()->getOptionText($childProduct->getData('material'))) {
141144
$childProduct->setData('material', $product->getData('material'));
142145
}
143-
if (!$childProduct->getAttributeText('pattern')) {
146+
147+
$pattern = $childProduct->getResource()->getAttribute('pattern');
148+
if ($pattern && !$pattern->getSource()->getOptionText($childProduct->getData('pattern'))) {
144149
$childProduct->setData('pattern', $product->getData('pattern'));
145150
}
146151
$simpleProducts[] = $childProduct;

0 commit comments

Comments
 (0)