[-] MO : applied unachieved patch on blockbestsellers
This commit is contained in:
@@ -54,12 +54,12 @@ class DbPDOCore extends Db
|
|||||||
try {
|
try {
|
||||||
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5);
|
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
throw new PrestaShopDatabaseException(sprintf(Tools::displayError('Link to database cannot be established: %s'), $e->getMessage()));
|
die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// UTF-8 support
|
// UTF-8 support
|
||||||
if ($this->link->exec('SET NAMES \'utf8\'') === false)
|
if ($this->link->exec('SET NAMES \'utf8\'') === false)
|
||||||
throw new PrestaShopDatabaseException(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
|
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.'));
|
||||||
|
|
||||||
return $this->link;
|
return $this->link;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class BlockBestSellers extends Module
|
|||||||
$output = '<h2>'.$this->displayName.'</h2>';
|
$output = '<h2>'.$this->displayName.'</h2>';
|
||||||
if (Tools::isSubmit('submitBestSellers'))
|
if (Tools::isSubmit('submitBestSellers'))
|
||||||
{
|
{
|
||||||
Configuration::updateValue('PS_BLOCK_BESTSELLERS_DISPLAY', (int)(Tools::getValue('always_display')));
|
Configuration::updateValue('PS_BLOCK_BESTSELLERS_DISPLAY', (int)Tools::getValue('always_display'));
|
||||||
$output .= '<div class="conf confirm">'.$this->l('Settings updated').'</div>';
|
$output .= '<div class="conf confirm">'.$this->l('Settings updated').'</div>';
|
||||||
}
|
}
|
||||||
return $output.$this->displayForm();
|
return $output.$this->displayForm();
|
||||||
@@ -92,31 +92,31 @@ class BlockBestSellers extends Module
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
</form>';
|
</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookRightColumn($params)
|
public function hookHeader($params)
|
||||||
{
|
{
|
||||||
if (Configuration::get('PS_CATALOG_MODE'))
|
if (Configuration::get('PS_CATALOG_MODE'))
|
||||||
return;
|
return;
|
||||||
|
$this->context->controller->addCSS($this->_path.'blockbestsellers.css', 'all');
|
||||||
|
}
|
||||||
|
|
||||||
$currency = new Currency($params['cookie']->id_currency);
|
public function hookHome($params)
|
||||||
|
{
|
||||||
if (Product::getTaxCalculationMethod((int)$this->context->customer->id) == PS_TAX_EXC)
|
$best_sellers = $this->getBestSellers($params);
|
||||||
$usetax = false;
|
if ($best_sellers === false)
|
||||||
else
|
|
||||||
$usetax = true;
|
|
||||||
|
|
||||||
$bestsellers = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5);
|
|
||||||
|
|
||||||
if (!$bestsellers && !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
|
|
||||||
return;
|
return;
|
||||||
$best_sellers = array();
|
|
||||||
|
|
||||||
if ($bestsellers)
|
$this->smarty->assign(array(
|
||||||
foreach ($bestsellers as $bestseller)
|
'best_sellers' => $best_sellers,
|
||||||
{
|
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
|
||||||
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product']), $usetax), $currency);
|
return $this->display(__FILE__, 'blockbestsellers-home.tpl');
|
||||||
$best_sellers[] = $bestseller;
|
}
|
||||||
}
|
|
||||||
|
public function hookRightColumn($params)
|
||||||
|
{
|
||||||
|
$best_sellers = $this->getBestSellers($params);
|
||||||
|
if ($best_sellers === false)
|
||||||
|
return;
|
||||||
|
|
||||||
$this->smarty->assign(array(
|
$this->smarty->assign(array(
|
||||||
'best_sellers' => $best_sellers,
|
'best_sellers' => $best_sellers,
|
||||||
@@ -130,35 +130,20 @@ class BlockBestSellers extends Module
|
|||||||
{
|
{
|
||||||
return $this->hookRightColumn($params);
|
return $this->hookRightColumn($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hookHeader($params)
|
|
||||||
{
|
|
||||||
if (Configuration::get('PS_CATALOG_MODE'))
|
|
||||||
return;
|
|
||||||
$this->context->controller->addCSS(($this->_path).'blockbestsellers.css', 'all');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hookHome($params)
|
protected function getBestSellers($params)
|
||||||
{
|
{
|
||||||
if (Configuration::get('PS_CATALOG_MODE'))
|
if (Configuration::get('PS_CATALOG_MODE'))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
if (!($result = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5)))
|
||||||
|
return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false);
|
||||||
|
|
||||||
|
$bestsellers = array();
|
||||||
$currency = new Currency($params['cookie']->id_currency);
|
$currency = new Currency($params['cookie']->id_currency);
|
||||||
$bestsellers = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 4);
|
$usetax = (Product::getTaxCalculationMethod((int)$this->context->customer->id) != PS_TAX_EXC);
|
||||||
if (!$bestsellers && !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY'))
|
foreach ($result as &$row)
|
||||||
return;
|
$row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency);
|
||||||
$best_sellers = array();
|
return $result;
|
||||||
|
|
||||||
if ($bestsellers)
|
|
||||||
foreach ($bestsellers as $bestseller)
|
|
||||||
{
|
|
||||||
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency);
|
|
||||||
$best_sellers[] = $bestseller;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->smarty->assign(array(
|
|
||||||
'best_sellers' => $best_sellers,
|
|
||||||
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
|
|
||||||
return $this->display(__FILE__, 'blockbestsellers-home.tpl');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user