Skip to content

Commit 467a30f

Browse files
committed
Merge branch 'main' into 1.2.4-rc
2 parents 8869214 + 35c9aea commit 467a30f

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

app/code/Meta/Catalog/Helper/Product/Identifier.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,34 @@ public function __construct(SystemConfig $systemConfig, ProductRepository $produ
5656
}
5757

5858
/**
59-
* Get product's identifier (SKU or ID, depending on configuration)
59+
* Get product's identifier col name(SKU or entity ID, depending on configuration)
6060
*
61-
* @param ProductInterface $product
62-
* @return bool|int|string
61+
* @return string
6362
*/
64-
private function getProductIdentifier(ProductInterface $product)
63+
public function getProductIdentifierColName(): string
6564
{
6665
if ($this->identifierAttr === IdentifierConfig::PRODUCT_IDENTIFIER_SKU) {
67-
return $product->getSku();
66+
return 'sku';
6867
} elseif ($this->identifierAttr === IdentifierConfig::PRODUCT_IDENTIFIER_ID) {
69-
return $product->getId();
68+
return 'entity_id';
7069
}
71-
return false;
70+
return '';
7271
}
7372

7473
/**
75-
* Get product Retailer ID for Commerce
74+
* Get product Retailer ID for Commerce (SKU or ID, depending on configuration)
7675
*
7776
* @param ProductInterface $product
7877
* @return int|string|bool
7978
*/
8079
public function getMagentoProductRetailerId(ProductInterface $product)
8180
{
82-
return $this->getProductIdentifier($product);
81+
if ($this->identifierAttr === IdentifierConfig::PRODUCT_IDENTIFIER_SKU) {
82+
return $product->getSku();
83+
} elseif ($this->identifierAttr === IdentifierConfig::PRODUCT_IDENTIFIER_ID) {
84+
return $product->getId();
85+
}
86+
return false;
8387
}
8488

8589
/**

app/code/Meta/Catalog/Plugin/FacebookCatalogDeletePlugin.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ public function __construct(
8080
*/
8181
public function afterDelete(Product $subject, $result, $object)
8282
{
83+
$identifier = $this->identifier->getMagentoProductRetailerId($object);
84+
if ($identifier === false) {
85+
$this->fbeHelper->log('Deleted Product does not have meta identifier.');
86+
return $result;
87+
}
88+
8389
$catalogDelete = $this->catalogUpdateFactory->create()
8490
->setProductId($object->getId())
85-
->setSku($object->getSku())
91+
->setSku($identifier)
8692
->setMethod('delete');
8793
try {
8894
$this->catalogUpdateResourceModel->deleteUpdateProductEntries($identifier);

0 commit comments

Comments
 (0)