Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Fix: 1.7.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
luciobenini committed Jan 18, 2021
1 parent 961bc02 commit 8619660
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions classes/GoogleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

class GoogleProvider extends Provider
{
protected $country;
protected $context;
protected $carrier;
protected $locale;

public function __construct()
{
$this->country = Country::getIsoById((int)Configuration::get('PS_COUNTRY_DEFAULT'));
$this->context = Context::getContext();
$this->carrier = new Carrier((int)Configuration::get('PITTICA_TROVAPREZZI_CARRIER'));
$this->locale = Tools::getContextLocale($this->context);
}

public function getElementRoot()
{
return 'rss';
Expand All @@ -39,28 +52,24 @@ public function renderAttributes($xml)

public function renderItem($xml, $offer)
{
$context = Context::getContext();
$carrier = new Carrier((int)Configuration::get('PITTICA_TROVAPREZZI_CARRIER'));
$locale = Tools::getContextLocale($context);

$xml->writeElement('title', $offer->name);
$xml->writeElement('description', $offer->description);
$xml->writeElement('description', !empty($offer->description) ? $offer->description : $offer->name);
$xml->writeElement('link', $offer->link);
$xml->writeElement('g:id', $offer->id_product . ($offer->id_product_attribute ? ('-' . $offer->id_product_attribute) : ''));
$xml->writeElement('g:image_link', $offer->image_1);
$xml->writeElement('g:price', $locale->formatPrice($offer->original_price, $context->currency->iso_code));
$xml->writeElement('g:price', $this->locale->formatPrice($offer->original_price, $this->context->currency->iso_code));

if ($offer->original_price != $offer->price) {
$xml->writeElement('g:sale_price', $locale->formatPrice($offer->price, $context->currency->iso_code));
$xml->writeElement('g:sale_price', $this->locale->formatPrice($offer->price, $this->context->currency->iso_code));
}

$xml->writeElement('g:gtin', !empty($offer->ean_code) ? $offer->ean_code : $offer->part_number);
$xml->writeElement('g:brand', $offer->brand);
$xml->writeElement('g:availability', $offer->stock);
$xml->writeElement('g:availability', $offer->stock > 0 ? 'in stock' : 'out of stock');
$xml->startElement('g:shipping');
$xml->writeElement('g:country', Country::getIsoById((int)Configuration::get('PS_COUNTRY_DEFAULT')));
$xml->writeElement('g:service', $carrier->name);
$xml->writeElement('g:price', $locale->formatPrice($offer->shipping_cost, $context->currency->iso_code));
$xml->writeElement('g:country', $this->country);
$xml->writeElement('g:service', $this->carrier->name);
$xml->writeElement('g:price', $this->locale->formatPrice($offer->shipping_cost, $this->context->currency->iso_code));
$xml->endElement();

if (!empty($offer->image_2)) {
Expand All @@ -81,7 +90,7 @@ public function renderBody($xml)
$meta = Meta::getHomeMetas((int)Configuration::get('PS_LANG_DEFAULT'), 'index');

$xml->writeElement('title', Configuration::get('PS_SHOP_NAME'));
$xml->writeElement('link', Context::getContext()->link->getBaseLink());
$xml->writeElement('link', $this->context->link->getBaseLink());
$xml->writeElement('description', $meta['meta_description']);

$offers = TrovaprezziOffer::getOffers();
Expand Down
2 changes: 1 addition & 1 deletion pitticatrovaprezzi.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct()
{
$this->name = 'pitticatrovaprezzi';
$this->tab = 'front_office_features';
$this->version = '1.2.0';
$this->version = '1.2.1';
$this->author = 'Pittica';
$this->need_instance = 1;
$this->bootstrap = 1;
Expand Down

0 comments on commit 8619660

Please sign in to comment.