Jump to content

Customize Facebook Sharer


Recommended Posts

if you want to do this individually for each product you need solution that will give you possibility to define unique open graph tags for selected products.

manually, without module it will be a nightmare

Link to comment
Share on other sites

At the moment Facebook shows meta title as post title and meta description as post description.

 

I simple want that everytime that I share a product on Facebook it will display the Product Title (and not meta_title) as title of the Facebook post, the Short Description (and not meta_description) as description of the facebook post and featured image as thumbnail of the Facebook post.

 

But I want to do this for every products, without set open graph tags individually each time.

Link to comment
Share on other sites

okay i understand.

it is possible to achieve this with some minor modifications of one module that generates og tags in prestashop - It's a socialsharing module. And with one commercial addon. i Will describe possible solutions below:

 

(1) Modification of default prestashop module - please open socialsharing.php - there is a code:

$this->context->smarty->assign(array(
'price' => Tools::ps_round($product->getPrice(!Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer), null), _PS_PRICE_COMPUTE_PRECISION_),
'pretax_price' => Tools::ps_round($product->getPrice(false, null), _PS_PRICE_COMPUTE_PRECISION_),
'weight' => $product->weight,
'weight_unit' => Configuration::get('PS_WEIGHT_UNIT'),
'cover' => isset($product->id) ? Product::getCover((int)$product->id) : '',
'link_rewrite' => isset($product->link_rewrite) && $product->link_rewrite ? $product->link_rewrite : '',
));

change it to:

$this->context->smarty->assign(array(
'price' => Tools::ps_round($product->getPrice(!Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer), null), _PS_PRICE_COMPUTE_PRECISION_),
'pretax_price' => Tools::ps_round($product->getPrice(false, null), _PS_PRICE_COMPUTE_PRECISION_),
'weight' => $product->weight,
'weight_unit' => Configuration::get('PS_WEIGHT_UNIT'),
'cover' => isset($product->id) ? Product::getCover((int)$product->id) : '',
'link_rewrite' => isset($product->link_rewrite) && $product->link_rewrite ? $product->link_rewrite : '',
'thisproduct' => $product
));

in socialsharing_header.tpl change:

<meta property="og:title" content="{$meta_title|escape:'html':'UTF-8'}" />
<meta property="og:description" content="{$meta_description|escape:'html':'UTF-8'}" /> 

to:

<meta property="og:title" content="{$thisproduct->name|escape:'html':'UTF-8'}" />
<meta property="og:description" content="{$thisproduct->description_short|escape:'html':'UTF-8'}" />

(2) commercial module - no changes necessry

you can achieve the same with no changes, with mine open graph tags module.

it creates automatically new og:tags for:

- og title: it will use product name

- og description:  it will use product short description

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...