[Skip to main content](#vessel-content)

#   Google products feed and get main product id

##

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

9 years 6 months ago [\#269309](#269309) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  *[Google products feed and get main product id](/forum/4-how-to/890203-google-products-feed-and-get-main-product-id#269309 "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&#95;ids: &#91;&quot;5226,5219,5224&quot;&#93;  5226 and 5224 are variants of same product.  I hope you see the issue.  Thanks")* was created by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")*

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:
Code:

$ids = array(); foreach($this-&gt;order-&gt;products as $product){ $ids[]=$product-&gt;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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg5MDIwMy1nb29nbGUtcHJvZHVjdHMtZmVlZC1hbmQtZ2V0LW1haW4tcHJvZHVjdC1pZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86583
- Thank you received: 14323
-
-

9 years 6 months ago [\#269329](#269329) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Google products feed and get main product id](/forum/4-how-to/890203-google-products-feed-and-get-main-product-id#269329 "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&#95;ids: &#91;&quot;5226,5219,5224&quot;&#93;  5226 and 5224 are variants of same product.  I hope you see the issue.  Thanks")*

Hi,

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-&gt;get($product-&gt;product_id); echo $productData-&gt;product_parent_id;

The following user(s) said Thank You: [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg5MDIwMy1nb29nbGUtcHJvZHVjdHMtZmVlZC1hbmQtZ2V0LW1haW4tcHJvZHVjdC1pZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")**
- [![kyratn's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/gallery/redswirl.jpg)](/forum/user/38342-kyratn "View kyratn's Profile") Topic Author
- [ Offline](/forum/user/38342-kyratn)

Less More

- Posts: 1119
- Thank you received: 114
-
- [](http://kyra.lt)
-

9 years 6 months ago [\#269366](#269366) by [kyratn](/forum/user/38342-kyratn "View kyratn's Profile")  Replied by *[kyratn](/forum/user/38342-kyratn "View kyratn's Profile")* on topic *[Google products feed and get main product id](/forum/4-how-to/890203-google-products-feed-and-get-main-product-id#269366 "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&#95;ids: &#91;&quot;5226,5219,5224&quot;&#93;  5226 and 5224 are variants of same product.  I hope you see the issue.  Thanks")*

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!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg5MDIwMy1nb29nbGUtcHJvZHVjdHMtZmVlZC1hbmQtZ2V0LW1haW4tcHJvZHVjdC1pZD90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.050 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
