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

SKU in Title #16

Closed dimitraros closed 6 years ago

dimitraros commented 6 years ago

Hi, i have a lot of products with the same title and when I try to tag a product, i can't find the one i want, because in every search, Facebook shows me only 10 results. Therefore, i tried adding the Sku in the title with the following format: Title | Sku

i added just after line 190 in FacebookProductFeed.php (buildProductEntry function): $sku = $product->getSku(); $titlenew = $title.' | '.$sku;

and then changed line 195 to: $items[self::ATTR_TITLE] = $this->buildProductAttr(self::ATTR_TITLE, $titlenew);

I fetched the products and i can see the new format in Facebook Catalog (with the | separator), but the encoding is wrong and the letters are not readable. All my product titles are in Greek and they were all readable in FB before my code changes. What is wrong with my code that changes the encoding?

dmitridr commented 6 years ago

Hello,

If you have set up the extension with us a long time ago, it's possible your product feed is set up to auto-detect the correct encoding. My guess is the addition of the | to all products messed that up somehow. The other possibility is that the $sku has some different incompatible encoding.

Here is what I would recommend trying:

e.g. $sku = mb_convert_encoding($sku, "UTF-8", "auto");

Hope that helps.

dimitraros commented 6 years ago

Hi dmitridr

thanks for the reply. I can confirm that both the $title and the $sku variables have no encoding problems ($title.$sku works great but as you can understand i need something that makes more sense), so the problems occurs when i try to insert something in between (eg ' | ' or ' '). I tried to use the mb_convert_encoding function:

$titlenew = $title.mb_convert_encoding(' | ', 'UTF-8').$sku; or $titlenew = $title.' | '.$sku; $titlenew = mb_convert_encoding($titlenew, 'UTF-8');

but no luck, i still get the non readable characters.

dmitridr commented 6 years ago

Very strange. Even when using ' ' ? I wonder why that happens. There are a couple more things to try that I can think of:

dmitridr commented 6 years ago

Closing this, as it has been a while with no resolution or reply. We cannot reproduce this bug, unfortunately.