[SOLVED] Open Graph – image only supported?

ThemeBurn SupportForumsOpenCart ThemesPavilion OpenCart Theme[SOLVED] Open Graph – image only supported?

This topic has been marked as not resolved.

Hi TB,
i’ve just noticed today, that only og:image graph object is being generated with Pavilion Theme v1.2.1.
Therefor, when someone posts a product URL to FB, only image is being “autorendered”.
How about other graph objects – og:title, og:url, og:description?

Here’s the TB Pavilion code, that clearly shows, there’s only og:image there:
../webroot/tb_themes/pavilion/catalog/plugin/ProductPlugin.php


public function setFacebookMeta(TB_ViewDataBag $themeData)
{
$fb_meta = '';
$product_id = (int) $this->manager->getOcRequest()->get['product_id'];
$product_info = $this->getOcModel('catalog/product')->getProduct($product_id);
if ($product_info) {
if ($product_info['image']) {
$width = $this->manager->getOcConfig()->get('config_image_thumb_width');
$height = $this->manager->getOcConfig()->get('config_image_thumb_height');
$thumb = $this->getModel()->resizeImage($product_info['image'], $width, $height);
} else {
$thumb = $themeData->res_url . '/image/no_image.jpg';
}
$fb_meta = '';
}

$themeData->fbMeta = $fb_meta;
}

Could you please add other objects as well?
When?

thanx
Martin

February 19, 2015 at 10:53 pm #38483

You can replace the whole function with this version:

    public function setFacebookMeta(TB_ViewDataBag $themeData)
    {
        $fb_meta = '';
        $product_id = (int) $this->manager->getOcRequest()->get['product_id'];
        $product_info = $this->getOcModel('catalog/product')->getProduct($product_id);
        if ($product_info) {
            if ($product_info['image']) {
                $width = $this->manager->getOcConfig()->get('config_image_thumb_width');
                $height = $this->manager->getOcConfig()->get('config_image_thumb_height');
                $thumb = $this->getModel()->resizeImage($product_info['image'], $width, $height);
            } else {
                $thumb = $themeData->res_url . '/image/no_image.jpg';
            }
            $fb_meta  = '<meta property="og:image" content="' . $thumb . '" />' . "\n";
            $fb_meta .= '<meta property="og:title" content="' . $product_info['name'] . '" />' . "\n";
            $fb_meta .= '<meta property="og:description" content="' . substr(htmlspecialchars(strip_tags(html_entity_decode($product_info['description'], ENT_COMPAT, 'UTF-8'))), 0, 300) . '" />' . "\n";
            $fb_meta .= '<meta property="og:url" content="' . $this->manager->getOcUrl()->link('product/product', 'product_id=' . $product_info['product_id']) . '" />' . "\n";
        }

        $themeData->fbMeta = $fb_meta;
    }

We will include it in our next update as well.

BR,
ThemeBurn team

February 23, 2015 at 5:21 pm #38628

Wonderful!
Many thanxs…

BR
m.

February 25, 2015 at 2:24 pm #38700

Glad we’ve helped :)

BR,
ThemeBurn team

March 2, 2015 at 3:50 pm #38831
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.