Page 1 of 1

Need of SKU in Open Graph and/or JSON-LD

Posted: Wed Aug 31, 2022 12:20 am
by lecarlb
Hello,

If adding products to Facebook and other places, they will automatically add, update or delete products if the product schema is correct. My only issue is "id" or sku.

After running a scan, Facebook can detect both Open Graph and JSON-LD. They say the only error is missing id. I looked at both header tag modules and there isn't anything indicating id or sku in the codes.

It looks less time consuming to add sku code to open graph. Is this an easy tweak? Has anyone encountered and fixed this issue?

Thank you.

Re: Need of SKU in Open Graph and/or JSON-LD

Posted: Tue Oct 24, 2023 11:03 pm
by burt
This update (coming in 1.0.8.21) will be of interest to you, as this update (which you can add into any recentish version of Phoenix, just two lines of code in two files) will allow the product schema header tag module and the opengraph header tag module to be amended via HOOK.

Of course, it does mean that a hook needs to be created but that is fairly straightforward, see next post.

Re: Need of SKU in Open Graph and/or JSON-LD

Posted: Tue Oct 24, 2023 11:11 pm
by burt
Example Hook, which adds in "opening hours" (eg if you had a bricks & mortar shop). Such a setting probably doesn't exist in "open graph" but this hook is meant as an example, you can set your own data as appropriate).

This hook would be saved as /includes/hooks/shop/product_info/hours.php;

Code: Select all

class hook_shop_product_info_hours {
  
  public function listen_injectHtOpenGraph($data) {
    $data['data']['product:openingHours'] = 'Mo,Tu,We,Th 09:00-12:00';
  }

  public function listen_injectHtProductSchema($schema_product) {
    $schema_product['product_schema']['openingHours'] = 'Mo,Tu,We,Th 09:00-12:00'; 
  }
  
}
Once uploaded, assuming you have turned on the header tag modules, and importantly updated them as shown in the github link above...you can "view source" and you should see the extra entries as should Facebook etc