Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add the og:image to category page #1

Open
qmuhannad opened this issue Aug 9, 2018 · 1 comment
Open

How to add the og:image to category page #1

qmuhannad opened this issue Aug 9, 2018 · 1 comment

Comments

@qmuhannad
Copy link

qmuhannad commented Aug 9, 2018

Hi folks,
I am trying to include link of a category on facebook. The open graph object debugger shows that all category fields are correct but the og:image. This extension is missing adding the product.group option. I have tried to edit the block file (MagePal/FbOpenGraphMetaTags/Block/Tags.php) code in the getTags() function as follows but failed to get results:

public function getTags(){
$this->tags['og:url'] = $this->helper('core/url')->getCurrentUrl();
$this->tags['og:site_name'] = Mage::app()->getStore()->getName();
$this->tags['og:type'] = 'website';
$this->tags['og:title'] = $this->getLayout()->getBlock('head')->getTitle();
$this->tags['og:description'] = $this->getLayout()->getBlock('head')->getDescription();

//If on the product page
if($product = Mage::registry('current_product')){
$this->tags['og:type'] = 'product';
$this->tags['og:title'] = $product->getName();
$this->tags['og:description'] = $product->getShortDescription() ? $product->getShortDescription() : $this->tags['og:description'];
$this->tags['og:image'] = $this->helper('catalog/image')->init($product, 'image')->resize(500,500);
}
//If on the category page
elseif($category = Mage::registry('current_category')){
$this->tags['og:type'] = 'product.group';
$this->tags['og:title'] = $category->getName();
$this->tags['og:description'] = 'Helloooooooo';
$this->tags['og:image'] = 'https://images.askmen.com/1080x540/2016/01/14-045822-what_to_wear_in_your_tinder_pics.jpg';
}
foreach($this->getConfigValueArray() as $key => $value){
if(array_key_exists($key, $this->systemConfigTranslation)){
$this->tags[$this->systemConfigTranslation[$key]] = $value;
}
}

    return $this->tags;
}

I hope if anyone could help me to solve this issue!

@srenon
Copy link
Contributor

srenon commented Aug 9, 2018

When you view source in a browser on the category page, do the new OG tags show up?

If, NO, did you clear Magento caches?

if, YES ... take a look at https://stackoverflow.com/questions/5776567/facebook-open-graph-not-clearing-cache and then https://developers.facebook.com/tools/debug/sharing/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants