As of writing this article, there is no module that allows you to create a Facebook Product Catalog in combination with Drupal 8 or 9 and Drupal Commerce 2.x. That's why I'm open-sourcing my custom solution today.
But first, what is a Facebook Catalog?
A Facebook Catalog is a container that holds information about your products, like images, links, descriptions, prices, and much more. After you create a catalog and add your products, you can create ads and connect to Facebook and Instagram to show people items from your catalog.
Facebook will pick the best option for each specific consumer based on their interests and behavior. Dynamic Product Ads can show potential customers products they have previously seen or added to cart on your website.
For all this to work first make sure that you have Facebook Pixel installed on your website. My colleague Andor and I created a Facebook Pixel module for Drupal 8.
To find out more about the module go to the Simple Facebook Pixel project page. It's essential to properly set up the pixel. If not, you won’t be able to get your dynamic ads to work properly.
The simplest way to add products to a catalog is to expose all your products in an XML file that is publicly available on your website. Given how simple this is, I guess that people who need this functionality are also using custom solutions and that's why we don't have any publicly available modules.
My module is NOT plug-and-play. The module is working on one of my sites, but it probably won't work on your site without some modification, unless you have exactly the same fields as I have.
Also, for bigger catalogs with thousands of products, the module might need some refactoring to avoid a time out on the server. Using a batch process to generate and store the XML file somewhere in the cache is probably the way to go.
Commerce Product Catalog is available in the following repository:
About the Author
Goran Nikolovski is a senior web developer who loves working with Drupal, React, and React Native. He is the founder of this website and he enjoys sharing his knowledge. Need help with anything? Get in touch.