From e53eb97cb6a7be8a704536e872edc3b23533a0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20Ozan=20Akg=C3=BCl?= Date: Mon, 16 Dec 2024 11:59:18 +0000 Subject: [PATCH] Fixes the item not found error by using filter in the product endpoint --- .../API/ProductCatalog/Products/Id/Request.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/includes/API/ProductCatalog/Products/Id/Request.php b/includes/API/ProductCatalog/Products/Id/Request.php index 60436be05..3b08663af 100644 --- a/includes/API/ProductCatalog/Products/Id/Request.php +++ b/includes/API/ProductCatalog/Products/Id/Request.php @@ -8,9 +8,9 @@ defined( 'ABSPATH' ) || exit; /** - * Request object for Product Catalog > Product Groups > Products > Update Graph Api. + * Request object for Product Catalog > Products > Get Graph Api. * - * @link https://developers.facebook.com/docs/marketing-api/reference/product-group/products/ + * @link https://developers.facebook.com/docs/marketing-api/reference/product-catalog/products/ */ class Request extends ApiRequest { @@ -19,7 +19,14 @@ class Request extends ApiRequest { * @param string $facebook_product_retailer_id Facebook Product Retailer ID. */ public function __construct( string $facebook_product_catalog_id, string $facebook_product_retailer_id ) { - $path = "catalog:{$facebook_product_catalog_id}:" . base64_encode( $facebook_product_retailer_id ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode - parent::__construct( "/{$path}/?fields=id,product_group{id}", 'GET' ); + $path = "/{$facebook_product_catalog_id}/products"; + parent::__construct( $path, 'GET' ); + + $this->set_params( + array( + 'filter' => '{"retailer_id": {"eq": "'.$facebook_product_retailer_id.'"}}', + 'fields' => 'id,product_group{id}', + ) + ); } }