facebookarchive / facebook-for-magento

A first-party extension plugin built for Magento. This plugin will install a pixel on your site, upload your products into a catalog for use in FB ads, and (optionally) auto-create an FB shop with your products.
https://www.facebook.com/business/help/532749253576163
84 stars 57 forks source link

brand output in tsv -> Field Mapping from Brand? #68

Open wildrness opened 6 years ago

wildrness commented 6 years ago

where is the 'brand field pulled from?' our tsv is outputing with the name of the store in the brand field

dmitridr commented 6 years ago

Hello,

We try to pull from the custom attribute 'brand', then the custom attribute 'manufacturer', and if none of those exist, we use the name of the store. Here is the code :

https://github.com/facebookincubator/facebook-for-magento/blob/master/app/code/community/Facebook/AdsExtension/Model/FBProductFeed.php#L228-L233

If you need a different custom field to pull the brand from, the workaround is to edit that code directly (on your server) with the name of the attribute you want to use, we do not have an easier solution unfortunately.

wildrness commented 6 years ago

Thanks, that is really helpful, our issue was caused because our 'brand' attribute was slightly different from the norm, perhaps it would be prudent for future versions of the extension to enable field mapping, so attributes can be mapped if they are not as default.

dmitridr commented 6 years ago

This is a good suggestion, thank you. It is likely we will not get around to it in the near term, but I'll put the general approach below in case there's a dev out there that wants to tackle it. We welcome your pull requests!

(1) Add a DB field in core_config_data corresponding to the field mapping. (2) Add an option under Advanced Options to edit/save the mapping. Just a textarea would work. (3) Add a controller to handle saving / loading the mapping. (4) Load the new controller path into JS and call the controller via AJAX when the mapping is saved. (5) Load the DB field in fbproductfeed.php when getting the name of the brand (and other) fields.