Google products feed and get main product id
9 years 6 months ago #269309
by kyratn
Google products feed and get main product id was created by kyratn
Hi,
I am using google products plugin to feed facebook catalog. All works fine with only 1 issue.
As plugin do not support variants i need to get main product id.
Using this code gives id per product variant:
How can i echo main product id?
facebook looks like this:
3 items purchased
content_ids: ["5226,5219,5224"]
5226 and 5224 are variants of same product.
I hope you see the issue.
Thanks
I am using google products plugin to feed facebook catalog. All works fine with only 1 issue.
As plugin do not support variants i need to get main product id.
Using this code gives id per product variant:
Code:
$ids = array();
foreach($this->order->products as $product){
$ids[]=$product->product_id;
}
echo implode(',',$ids);
How can i echo main product id?
facebook looks like this:
3 items purchased
content_ids: ["5226,5219,5224"]
5226 and 5224 are variants of same product.
I hope you see the issue.
Thanks
Please Log in or Create an account to join the conversation.
9 years 6 months ago #269329
by nicolas
Replied by nicolas on topic Google products feed and get main product id
Hi,
This code will get the id of the main product based on the id of the variant.
This code will get the id of the main product based on the id of the variant.
Code:
$class = hikashop_get('class.product');
$productData = $class->get($product->product_id);
echo $productData->product_parent_id;
The following user(s) said Thank You: kyratn
Please Log in or Create an account to join the conversation.
9 years 6 months ago #269366
by kyratn
Replied by kyratn on topic Google products feed and get main product id
Hi,
Thank you. I see my mistake.
For some reason i was looking for"main" product id and not parent.
Thanks again and have a great weekend!
Thank you. I see my mistake.
For some reason i was looking for"main" product id and not parent.
Thanks again and have a great weekend!
Please Log in or Create an account to join the conversation.
Time to create page: 0.054 seconds