Skip to content

Commit 28d8cea

Browse files
authored
Merge pull request #163 from magento-commerce/fix/disabled-products
issue-resolution/disabled child product uploaded to Meta catalog
2 parents f712873 + c422b35 commit 28d8cea

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

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

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,26 @@ public function retrieve($offset = 1, $limit = self::LIMIT): array
114114
$configurableAttributes = $configurableType->getConfigurableAttributes($product);
115115

116116
foreach ($configurableType->getUsedProducts($product) as $childProduct) {
117-
/** @var Product $childProduct */
118-
$configurableSettings = ['item_group_id' => $product->getId()];
119-
foreach ($configurableAttributes as $attribute) {
120-
$productAttribute = $attribute->getProductAttribute();
121-
$attributeCode = $productAttribute->getAttributeCode();
122-
$attributeValue = $childProduct->getData($productAttribute->getAttributeCode());
123-
$attributeLabel = $productAttribute->getSource()->getOptionText($attributeValue);
124-
$configurableSettings[$attributeCode] = $attributeLabel;
117+
if ($childProduct->getStatus() == Status::STATUS_ENABLED) {
118+
/** @var Product $childProduct */
119+
$configurableSettings = ['item_group_id' => $product->getId()];
120+
foreach ($configurableAttributes as $attribute) {
121+
$productAttribute = $attribute->getProductAttribute();
122+
$attributeCode = $productAttribute->getAttributeCode();
123+
$attributeValue = $childProduct->getData($productAttribute->getAttributeCode());
124+
$attributeLabel = $productAttribute->getSource()->getOptionText($attributeValue);
125+
$configurableSettings[$attributeCode] = $attributeLabel;
126+
}
127+
// Assign parent product name to all child products' name (used as variant name is Meta catalog)
128+
// https://developers.facebook.com/docs/commerce-platform/catalog/variants
129+
$childProduct->setName($product->getName());
130+
$childProduct->setConfigurableSettings($configurableSettings);
131+
$childProduct->setParentProductUrl($product->getProductUrl());
132+
if (!$childProduct->getDescription()) {
133+
$childProduct->setDescription($product->getDescription());
134+
}
135+
$simpleProducts[] = $childProduct;
125136
}
126-
// Assign parent product name to all child products' name (used as variant name is Meta catalog)
127-
// https://developers.facebook.com/docs/commerce-platform/catalog/variants
128-
$childProduct->setName($product->getName());
129-
$childProduct->setConfigurableSettings($configurableSettings);
130-
$childProduct->setParentProductUrl($product->getProductUrl());
131-
if (!$childProduct->getDescription()) {
132-
$childProduct->setDescription($product->getDescription());
133-
}
134-
$simpleProducts[] = $childProduct;
135137
}
136138
}
137139

0 commit comments

Comments
 (0)