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

Support Gallery Images #57

Open sulfurio opened 6 years ago

sulfurio commented 6 years ago

Hello , the extension not loading gallery images , magento version 1.9.2 , extension version 2.4.1 this is the code that makes me think why it should be ever loaded if the $image = $product->getImage(); actually returns data ? !$image will go to 0 / $image is not '' and not 'no_selection' , so it means that if we have a base image we can't have gallery images ? am i wrong on this ?

private function getImageURL($product) {
    $image_url = null;
    $image = $product->getImage();
    if (!$image || $image === '' || $image === 'no_selection') {
      $product->load('media_gallery');
      $gal = $product->getMediaGalleryImages();
      if ($gal) {
        foreach ($gal as $gal_image) {
          if ($gal_image['url'] && $gal_image['url'] !== '') {
            $image_url = $gal_image['url'];
            break;
          }
        }
      }
    }
    if (!$image_url) {
      $image_url = FacebookAdsExtension::getBaseUrlMedia().'catalog/product'.$image;
    }
    return $image_url;
  }
dmitridr commented 6 years ago

Hey,

You're absolutely right, we don't actually import gallery images, as you can see the feed file generated here doesn't have a column for additional_image_urls. The only reason we query the gallery is if there is no primary image for the product.

The good news is this is gallery support is something that can be added pretty easily, all you'd need to do is add a column in the feed file in the link above, then load the gallery image urls into it the same way the primary image is set. You're welcome to send us a pull request!

If not, we can add this in future versions. We're a bit swamped now.

prakashsatani commented 4 years ago

Hi @dmitridr I have tried your solution and created feed. But when I upload/update feed in Facebook catalog the media gallery still not showing. Facebook Feed Url - https://stonecarat.com/media/facebook_adstoolbox_product_feed.tsv Facebook Shop Url - https://www.facebook.com/stonecarat8115745678/shop/