Skip to content

Commit 4e9ef8d

Browse files
Merge branch 'main' of github.com:magento-commerce/facebook-for-magento2 into 1.0.0-release
2 parents 17bc7bf + 28d8cea commit 4e9ef8d

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
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

app/code/Meta/Conversion/view/frontend/templates/pixel/view_content.phtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ if ($block->getFacebookPixelID()) {
1111
{
1212
"*": {
1313
"Meta_Conversion/js/metaPixelTracker" : {
14-
"url" : "<?= $block->escapeJs($trackerUrl); ?>",
15-
"payload": <?= $block->escapeJs(json_encode([
14+
"url" : "<?= $block->escapeUrl($trackerUrl); ?>",
15+
"payload": <?= /* @noEscape */ json_encode([
1616
"eventName" => $block->getEventToObserveName(),
1717
"productId" => $block->getProductId()
18-
])) ?>,
19-
"browserEventData": <?= $block->escapeJs(json_encode([
18+
]) ?>,
19+
"browserEventData": <?= /* @noEscape */ json_encode([
2020
'fbAgentVersion' => $block->getFacebookAgentVersion(),
2121
'fbPixelId' => $block->getFacebookPixelID(),
2222
'source' => $block->getSource(),
@@ -31,7 +31,7 @@ if ($block->getFacebookPixelID()) {
3131
'value' => $block->getValue() ?? '',
3232
'currency' => $block->getCurrency() ?? ''
3333
]
34-
])) ?>
34+
]) ?>
3535
}
3636
}
3737
}

0 commit comments

Comments
 (0)