Skip to content

Commit

Permalink
Fixes the item not found error by using filter in the product endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
halilozanakgul committed Dec 16, 2024
1 parent 20397ef commit e53eb97
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions includes/API/ProductCatalog/Products/Id/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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}',
)
);
}
}

0 comments on commit e53eb97

Please sign in to comment.