Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
@@ -36,7 +36,7 @@ class BlockBestSellers extends Module
|
||||
{
|
||||
$this->name = 'blockbestsellers';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = '1.1';
|
||||
$this->version = '1.2';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -51,14 +51,53 @@ class BlockBestSellers extends Module
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() ||
|
||||
!$this->registerHook('rightColumn') ||
|
||||
!$this->registerHook('header') ||
|
||||
!$this->registerHook('updateOrderStatus') ||
|
||||
!ProductSale::fillProductSales())
|
||||
$this->_clearCache('blockbestsellers.tpl');
|
||||
$this->_clearCache('blockbestsellers-home.tpl');
|
||||
|
||||
if (!parent::install()
|
||||
|| !$this->registerHook('rightColumn')
|
||||
|| !$this->registerHook('header')
|
||||
|| !$this->registerHook('actionOrderStatusPostUpdate')
|
||||
|| !$this->registerHook('addproduct')
|
||||
|| !$this->registerHook('updateproduct')
|
||||
|| !$this->registerHook('deleteproduct')
|
||||
|| !ProductSale::fillProductSales()
|
||||
)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$this->_clearCache('blockbestsellers.tpl');
|
||||
$this->_clearCache('blockbestsellers-home.tpl');
|
||||
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
public function hookAddProduct($params)
|
||||
{
|
||||
$this->_clearCache('blockbestsellers.tpl');
|
||||
$this->_clearCache('blockbestsellers-home.tpl');
|
||||
}
|
||||
|
||||
public function hookUpdateProduct($params)
|
||||
{
|
||||
$this->_clearCache('blockbestsellers.tpl');
|
||||
$this->_clearCache('blockbestsellers-home.tpl');
|
||||
}
|
||||
|
||||
public function hookDeleteProduct($params)
|
||||
{
|
||||
$this->_clearCache('blockbestsellers.tpl');
|
||||
$this->_clearCache('blockbestsellers-home.tpl');
|
||||
}
|
||||
|
||||
public function hookActionOrderStatusPostUpdate($params)
|
||||
{
|
||||
$this->_clearCache('blockbestsellers.tpl');
|
||||
$this->_clearCache('blockbestsellers-home.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in administration -> module -> configure
|
||||
@@ -102,28 +141,34 @@ class BlockBestSellers extends Module
|
||||
|
||||
public function hookHome($params)
|
||||
{
|
||||
$best_sellers = $this->getBestSellers($params);
|
||||
if ($best_sellers === false)
|
||||
return;
|
||||
if (!$this->isCached('blockbestsellers-home.tpl', $this->getCacheId('blockbestsellers-home')))
|
||||
{
|
||||
$best_sellers = $this->getBestSellers($params);
|
||||
if ($best_sellers === false)
|
||||
return;
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'best_sellers' => $best_sellers,
|
||||
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
|
||||
return $this->display(__FILE__, 'blockbestsellers-home.tpl');
|
||||
$this->smarty->assign(array(
|
||||
'best_sellers' => $best_sellers,
|
||||
'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
|
||||
}
|
||||
return $this->display(__FILE__, 'blockbestsellers-home.tpl', $this->getCacheId('blockbestsellers-home'));
|
||||
}
|
||||
|
||||
public function hookRightColumn($params)
|
||||
{
|
||||
$best_sellers = $this->getBestSellers($params);
|
||||
if ($best_sellers === false)
|
||||
return;
|
||||
if (!$this->isCached('blockbestsellers.tpl', $this->getCacheId('blockbestsellers')))
|
||||
{
|
||||
$best_sellers = $this->getBestSellers($params);
|
||||
if ($best_sellers === false)
|
||||
return;
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'best_sellers' => $best_sellers,
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
'smallSize' => Image::getSize(ImageType::getFormatedName('small'))
|
||||
));
|
||||
return $this->display(__FILE__, 'blockbestsellers.tpl');
|
||||
$this->smarty->assign(array(
|
||||
'best_sellers' => $best_sellers,
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
'smallSize' => Image::getSize(ImageType::getFormatedName('small'))
|
||||
));
|
||||
}
|
||||
return $this->display(__FILE__, 'blockbestsellers.tpl', $this->getCacheId('blockbestsellers'));
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params)
|
||||
@@ -136,7 +181,7 @@ class BlockBestSellers extends Module
|
||||
if (Configuration::get('PS_CATALOG_MODE'))
|
||||
return false;
|
||||
|
||||
if (!($result = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5)))
|
||||
if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, 5)))
|
||||
return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false);
|
||||
|
||||
$bestsellers = array();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blockbestsellers</name>
|
||||
<displayName><![CDATA[Top-seller block]]></displayName>
|
||||
<version><![CDATA[1.1]]></version>
|
||||
<version><![CDATA[1.2]]></version>
|
||||
<description><![CDATA[Add a block displaying your store's top-selling products.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_2($object)
|
||||
{
|
||||
return ($object->registerHook('addproduct') && $object->registerHook('updateproduct') && $object->registerHook('deleteproduct') && $object->registerHook('actionOrderStatusPostUpdate'));
|
||||
}
|
||||
@@ -38,6 +38,7 @@ class BlockCMSModel extends ObjectModel
|
||||
|
||||
const LEFT_COLUMN = 0;
|
||||
const RIGHT_COLUMN = 1;
|
||||
const FOOTER = 2;
|
||||
|
||||
/**
|
||||
* @see ObjectModel::$definition
|
||||
|
||||
@@ -39,7 +39,7 @@ class BlockCms extends Module
|
||||
{
|
||||
$this->name = 'blockcms';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = '1.1.1';
|
||||
$this->version = '1.2';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -52,14 +52,23 @@ class BlockCms extends Module
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() ||
|
||||
!$this->registerHooks() ||
|
||||
!BlockCMSModel::createTables() ||
|
||||
!Configuration::updateValue('FOOTER_CMS', '') ||
|
||||
!Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) ||
|
||||
!Configuration::updateValue('FOOTER_POWEREDBY', 1))
|
||||
if (!parent::install()
|
||||
|| !$this->registerHook('leftColumn')
|
||||
|| !$this->registerHook('rightColumn')
|
||||
|| !$this->registerHook('header')
|
||||
|| !$this->registerHook('footer')
|
||||
|| !$this->registerHook('actionObjectCmsUpdateAfter')
|
||||
|| !$this->registerHook('actionObjectCmsDeleteAfter')
|
||||
|| !$this->registerHook('actionShopDataDuplication')
|
||||
|| !BlockCMSModel::createTables()
|
||||
|| !Configuration::updateValue('FOOTER_CMS', '')
|
||||
|| !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1)
|
||||
|| !Configuration::updateValue('FOOTER_POWEREDBY', 1)
|
||||
)
|
||||
return false;
|
||||
|
||||
$this->_clearCache('blockcms.tpl');
|
||||
|
||||
// Install fixtures for blockcms
|
||||
$default = Db::getInstance()->insert('cms_block', array(
|
||||
'id_cms_category' => 1,
|
||||
@@ -101,23 +110,16 @@ class BlockCms extends Module
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$this->_clearCache('blockcms.tpl');
|
||||
if (!parent::uninstall() ||
|
||||
!BlockCMSModel::DropTables() ||
|
||||
!Configuration::deleteByName('FOOTER_CMS') ||
|
||||
!Configuration::deleteByName('FOOTER_BLOCK_ACTIVATION') ||
|
||||
!Configuration::deleteByName('FOOTER_POWEREDBY'))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function registerHooks()
|
||||
{
|
||||
return (
|
||||
$this->registerHook('leftColumn') && $this->registerHook('rightColumn') &&
|
||||
$this->registerHook('header') && $this->registerHook('footer') && $this->registerHook('actionShopDataDuplication'));
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
$current_index = AdminController::$currentIndex;
|
||||
@@ -541,6 +543,8 @@ class BlockCms extends Module
|
||||
if ($this->_postValidation() == false)
|
||||
return false;
|
||||
|
||||
$this->_clearCache('blockcms.tpl');
|
||||
|
||||
$this->_errors = array();
|
||||
if (Tools::isSubmit('submitBlockCMS'))
|
||||
{
|
||||
@@ -661,42 +665,33 @@ class BlockCms extends Module
|
||||
|
||||
public function displayBlockCMS($column)
|
||||
{
|
||||
$cms_titles = BlockCMSModel::getCMSTitles($column);
|
||||
if (!$this->isCached('blockcms.tpl', $this->getCacheId($column)))
|
||||
{
|
||||
$cms_titles = BlockCMSModel::getCMSTitles($column);
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'block' => 1,
|
||||
'cms_titles' => $cms_titles,
|
||||
'contact_url' => (_PS_VERSION_ >= 1.5) ? 'contact' : 'contact-form'
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, 'blockcms.tpl');
|
||||
$this->smarty->assign(array(
|
||||
'block' => 1,
|
||||
'cms_titles' => $cms_titles,
|
||||
'contact_url' => (_PS_VERSION_ >= 1.5) ? 'contact' : 'contact-form'
|
||||
));
|
||||
}
|
||||
return $this->display(__FILE__, 'blockcms.tpl', $this->getCacheId($column));
|
||||
}
|
||||
|
||||
private function _prepareHook()
|
||||
|
||||
protected function getCacheId($name = null)
|
||||
{
|
||||
$block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION');
|
||||
|
||||
if (!$block_activation)
|
||||
return false;
|
||||
|
||||
$cms_titles = BlockCMSModel::getCMSTitlesFooter();
|
||||
$display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER');
|
||||
$display_poweredby = Configuration::get('FOOTER_POWEREDBY');
|
||||
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$this->context->language->id);
|
||||
|
||||
$this->smarty->assign(
|
||||
array(
|
||||
'block' => 0,
|
||||
'contact_url' => 'contact',
|
||||
'cmslinks' => $cms_titles,
|
||||
'display_stores_footer' => $display_footer,
|
||||
'display_poweredby' => ((int)$display_poweredby === 1 || $display_poweredby === false),
|
||||
'footer_text' => $footer_text
|
||||
)
|
||||
);
|
||||
return true;
|
||||
return parent::getCacheId('blockcms|'.$name);
|
||||
}
|
||||
|
||||
public function hookActionObjectCmsUpdateAfter()
|
||||
{
|
||||
$this->_clearCache('blockcms.tpl');
|
||||
}
|
||||
|
||||
public function hookActionObjectCmsDeleteAfter()
|
||||
{
|
||||
$this->_clearCache('blockcms.tpl');
|
||||
}
|
||||
|
||||
public function hookHeader($params)
|
||||
{
|
||||
@@ -715,9 +710,28 @@ class BlockCms extends Module
|
||||
|
||||
public function hookFooter()
|
||||
{
|
||||
if (!$this->_prepareHook())
|
||||
return ;
|
||||
return $this->display(__FILE__, 'blockcms.tpl');
|
||||
if (!($block_activation = Configuration::get('FOOTER_BLOCK_ACTIVATION')))
|
||||
return;
|
||||
|
||||
if (!$this->isCached('blockcms.tpl', $this->getCacheId(BlockCMSModel::FOOTER)))
|
||||
{
|
||||
$cms_titles = BlockCMSModel::getCMSTitlesFooter();
|
||||
$display_footer = Configuration::get('PS_STORES_DISPLAY_FOOTER');
|
||||
$display_poweredby = Configuration::get('FOOTER_POWEREDBY');
|
||||
$footer_text = Configuration::get('FOOTER_CMS_TEXT_'.(int)$this->context->language->id);
|
||||
|
||||
$this->smarty->assign(
|
||||
array(
|
||||
'block' => 0,
|
||||
'contact_url' => 'contact',
|
||||
'cmslinks' => $cms_titles,
|
||||
'display_stores_footer' => $display_footer,
|
||||
'display_poweredby' => ((int)$display_poweredby === 1 || $display_poweredby === false),
|
||||
'footer_text' => $footer_text
|
||||
)
|
||||
);
|
||||
}
|
||||
return $this->display(__FILE__, 'blockcms.tpl', $this->getCacheId(BlockCMSModel::FOOTER));
|
||||
}
|
||||
|
||||
protected function updatePositionsDnd()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blockcms</name>
|
||||
<displayName><![CDATA[CMS Block]]></displayName>
|
||||
<version><![CDATA[1.1.1]]></version>
|
||||
<version><![CDATA[1.2]]></version>
|
||||
<description><![CDATA[Adds a block with several CMS links.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_2($object)
|
||||
{
|
||||
return ($object->registerHook('actionObjectCmsUpdateAfter') && $object->registerHook('actionObjectCmsDeleteAfter'));
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class BlockNewProducts extends Module
|
||||
{
|
||||
$this->name = 'blocknewproducts';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = 0.9;
|
||||
$this->version = 1.0;
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -45,9 +45,23 @@ class BlockNewProducts extends Module
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (parent::install() == false || $this->registerHook('rightColumn') == false || $this->registerHook('header') == false || Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false)
|
||||
return false;
|
||||
return true;
|
||||
if (!parent::install()
|
||||
|| !$this->registerHook('rightColumn')
|
||||
|| !$this->registerHook('header')
|
||||
|| !$this->registerHook('addproduct')
|
||||
|| !$this->registerHook('updateproduct')
|
||||
|| !$this->registerHook('deleteproduct')
|
||||
|| !Configuration::updateValue('NEW_PRODUCTS_NBR', 5)
|
||||
)
|
||||
return false;
|
||||
$this->_clearCache('blocknewproducts.tpl');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$this->_clearCache('blocknewproducts.tpl');
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
@@ -95,16 +109,25 @@ class BlockNewProducts extends Module
|
||||
|
||||
public function hookRightColumn($params)
|
||||
{
|
||||
$newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)(Configuration::get('NEW_PRODUCTS_NBR')));
|
||||
if (!$newProducts && !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))
|
||||
if (!Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))
|
||||
return;
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'new_products' => $newProducts,
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
));
|
||||
if (!$this->isCached('blocknewproducts.tpl', $this->getCacheId()))
|
||||
{
|
||||
if (!($newProducts = Product::getNewProducts((int)($params['cookie']->id_lang), 0, (int)Configuration::get('NEW_PRODUCTS_NBR'))))
|
||||
return;
|
||||
|
||||
return $this->display(__FILE__, 'blocknewproducts.tpl');
|
||||
$this->smarty->assign(array(
|
||||
'new_products' => $newProducts,
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
));
|
||||
}
|
||||
return $this->display(__FILE__, 'blocknewproducts.tpl', $this->getCacheId());
|
||||
}
|
||||
|
||||
protected function getCacheId($name = null)
|
||||
{
|
||||
return parent::getCacheId('blocknewproducts|'.date('Ymd'));
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params)
|
||||
@@ -117,6 +140,18 @@ class BlockNewProducts extends Module
|
||||
$this->context->controller->addCSS(($this->_path).'blocknewproducts.css', 'all');
|
||||
}
|
||||
|
||||
}
|
||||
public function hookAddProduct($params)
|
||||
{
|
||||
$this->_clearCache('blocknewproducts.tpl');
|
||||
}
|
||||
|
||||
public function hookUpdateProduct($params)
|
||||
{
|
||||
$this->_clearCache('blocknewproducts.tpl');
|
||||
}
|
||||
|
||||
public function hookDeleteProduct($params)
|
||||
{
|
||||
$this->_clearCache('blocknewproducts.tpl');
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blocknewproducts</name>
|
||||
<displayName><![CDATA[New products block]]></displayName>
|
||||
<version><![CDATA[0.9]]></version>
|
||||
<version><![CDATA[1.0]]></version>
|
||||
<description><![CDATA[Displays a block featuring your store's newest products.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_0($object)
|
||||
{
|
||||
return ($object->registerHook('addproduct') && $object->registerHook('updateproduct') && $object->registerHook('deleteproduct'));
|
||||
}
|
||||
@@ -36,7 +36,7 @@ class BlockSpecials extends Module
|
||||
{
|
||||
$this->name = 'blockspecials';
|
||||
$this->tab = 'pricing_promotion';
|
||||
$this->version = '0.8';
|
||||
$this->version = '1.0';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -48,7 +48,23 @@ class BlockSpecials extends Module
|
||||
|
||||
public function install()
|
||||
{
|
||||
return (parent::install() AND $this->registerHook('rightColumn') AND $this->registerHook('header'));
|
||||
if (!Configuration::get('BLOCKSPECIALS_NB_CACHES'))
|
||||
Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', 20);
|
||||
$this->_clearCache('blockspecials.tpl');
|
||||
|
||||
return (parent::install()
|
||||
&& $this->registerHook('rightColumn')
|
||||
&& $this->registerHook('header')
|
||||
&& $this->registerHook('addproduct')
|
||||
&& $this->registerHook('updateproduct')
|
||||
&& $this->registerHook('deleteproduct')
|
||||
);
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$this->_clearCache('blockspecials.tpl');
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
@@ -56,7 +72,8 @@ class BlockSpecials extends Module
|
||||
$output = '<h2>'.$this->displayName.'</h2>';
|
||||
if (Tools::isSubmit('submitSpecials'))
|
||||
{
|
||||
Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)(Tools::getValue('always_display')));
|
||||
Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)Tools::getValue('always_display'));
|
||||
Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', (int)Tools::getValue('BLOCKSPECIALS_NB_CACHES'));
|
||||
$output .= '<div class="conf confirm">'.$this->l('Settings updated').'</div>';
|
||||
}
|
||||
return $output.$this->displayForm();
|
||||
@@ -76,6 +93,11 @@ class BlockSpecials extends Module
|
||||
<label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
|
||||
<p class="clear">'.$this->l('Show the block even if no product is available.').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('Number of cache files.').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="BLOCKSPECIALS_NB_CACHES" value="'.(int)Configuration::get('BLOCKSPECIALS_NB_CACHES').'" />
|
||||
<p class="clear">'.$this->l('Specials are displayed randomly on the front end, but since it takes a lot of ressources, it is better to cache the results. Cache is reset everyday. 0 will disable the cache.').'</p>
|
||||
</div>
|
||||
<center><input type="submit" name="submitSpecials" value="'.$this->l('Save').'" class="button" /></center>
|
||||
</fieldset>
|
||||
</form>';
|
||||
@@ -84,18 +106,24 @@ class BlockSpecials extends Module
|
||||
public function hookRightColumn($params)
|
||||
{
|
||||
if (Configuration::get('PS_CATALOG_MODE'))
|
||||
return ;
|
||||
|
||||
if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
|
||||
return;
|
||||
|
||||
// We need to create multiple caches because the products are sorted randomly
|
||||
$random = date('Ymd').'|'.round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1)));
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'special' => $special,
|
||||
'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
));
|
||||
if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random)))
|
||||
{
|
||||
if (!($special = Product::getRandomSpecial((int)$params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
|
||||
return;
|
||||
|
||||
return $this->display(__FILE__, 'blockspecials.tpl');
|
||||
$this->smarty->assign(array(
|
||||
'special' => $special,
|
||||
'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
|
||||
'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
|
||||
));
|
||||
}
|
||||
|
||||
return $this->display(__FILE__, 'blockspecials.tpl', $this->getCacheId('blockspecials|'.$random));
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params)
|
||||
@@ -109,5 +137,19 @@ class BlockSpecials extends Module
|
||||
return ;
|
||||
$this->context->controller->addCSS(($this->_path).'blockspecials.css', 'all');
|
||||
}
|
||||
}
|
||||
|
||||
public function hookAddProduct($params)
|
||||
{
|
||||
$this->_clearCache('blockspecials.tpl');
|
||||
}
|
||||
|
||||
public function hookUpdateProduct($params)
|
||||
{
|
||||
$this->_clearCache('blockspecials.tpl');
|
||||
}
|
||||
|
||||
public function hookDeleteProduct($params)
|
||||
{
|
||||
$this->_clearCache('blockspecials.tpl');
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<module>
|
||||
<name>blockspecials</name>
|
||||
<displayName><![CDATA[Specials block]]></displayName>
|
||||
<version><![CDATA[0.8]]></version>
|
||||
<version><![CDATA[1.0]]></version>
|
||||
<description><![CDATA[Adds a block displaying current product specials.]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[pricing_promotion]]></tab>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_0($object)
|
||||
{
|
||||
Configuration::updateValue('BLOCKSPECIALS_NB_CACHES', 20);
|
||||
return ($object->registerHook('addproduct') && $object->registerHook('updateproduct') && $object->registerHook('deleteproduct'));
|
||||
}
|
||||
@@ -32,7 +32,7 @@ $('document').ready(function()
|
||||
var parent = $(this).parent().parent();
|
||||
|
||||
$.ajax({
|
||||
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'], true)|escape:'html'}",
|
||||
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'], true)|addslashes}",
|
||||
type: "POST",
|
||||
data: {
|
||||
'id_product': idFavoriteProduct,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>homefeatured</name>
|
||||
<displayName><![CDATA[Featured products on the homepage.]]></displayName>
|
||||
<version><![CDATA[0.9]]></version>
|
||||
<description><![CDATA[Displays featured products in the middle of your homepage.]]></description>
|
||||
<displayName><![CDATA[Produits phares sur la page d'accueil]]></displayName>
|
||||
<version><![CDATA[1.0]]></version>
|
||||
<description><![CDATA[Affiche les produits phares au centre de votre page d'accueil]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
|
||||
@@ -36,7 +36,7 @@ class HomeFeatured extends Module
|
||||
{
|
||||
$this->name = 'homefeatured';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = '0.9';
|
||||
$this->version = '1.0';
|
||||
$this->author = 'PrestaShop';
|
||||
$this->need_instance = 0;
|
||||
|
||||
@@ -48,17 +48,32 @@ class HomeFeatured extends Module
|
||||
|
||||
function install()
|
||||
{
|
||||
if (!Configuration::updateValue('HOME_FEATURED_NBR', 8) || !parent::install() || !$this->registerHook('displayHome') || !$this->registerHook('header'))
|
||||
$this->_clearCache('homefeatured.tpl');
|
||||
Configuration::updateValue('HOME_FEATURED_NBR', 8);
|
||||
|
||||
if (!parent::install()
|
||||
|| !$this->registerHook('displayHome')
|
||||
|| !$this->registerHook('header')
|
||||
|| !$this->registerHook('addproduct')
|
||||
|| !$this->registerHook('updateproduct')
|
||||
|| !$this->registerHook('deleteproduct')
|
||||
)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$this->_clearCache('homefeatured.tpl');
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$output = '<h2>'.$this->displayName.'</h2>';
|
||||
if (Tools::isSubmit('submitHomeFeatured'))
|
||||
{
|
||||
$nbr = (int)(Tools::getValue('nbr'));
|
||||
$nbr = (int)Tools::getValue('nbr');
|
||||
if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))
|
||||
$errors[] = $this->l('An invalid number of products has been specified.');
|
||||
else
|
||||
@@ -101,16 +116,33 @@ class HomeFeatured extends Module
|
||||
|
||||
public function hookDisplayHome($params)
|
||||
{
|
||||
$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
|
||||
$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
|
||||
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
|
||||
if (!$this->isCached('homefeatured.tpl', $this->getCacheId('homefeatured')))
|
||||
{
|
||||
$category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
|
||||
$nb = (int)Configuration::get('HOME_FEATURED_NBR');
|
||||
$products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10));
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'products' => $products,
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, 'homefeatured.tpl');
|
||||
$this->smarty->assign(array(
|
||||
'products' => $products,
|
||||
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
|
||||
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
|
||||
));
|
||||
}
|
||||
return $this->display(__FILE__, 'homefeatured.tpl', $this->getCacheId('homefeatured'));
|
||||
}
|
||||
}
|
||||
|
||||
public function hookAddProduct($params)
|
||||
{
|
||||
$this->_clearCache('homefeatured.tpl');
|
||||
}
|
||||
|
||||
public function hookUpdateProduct($params)
|
||||
{
|
||||
$this->_clearCache('homefeatured.tpl');
|
||||
}
|
||||
|
||||
public function hookDeleteProduct($params)
|
||||
{
|
||||
$this->_clearCache('homefeatured.tpl');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_1_0($object)
|
||||
{
|
||||
return ($object->registerHook('addproduct') && $object->registerHook('updateproduct') && $object->registerHook('deleteproduct'));
|
||||
}
|
||||
@@ -35,7 +35,7 @@ $('document').ready(function()
|
||||
var parent = $(this).parent().parent();
|
||||
|
||||
$.ajax({
|
||||
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'remove'])|escape:'html'}",
|
||||
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'remove'])|addslashes}",
|
||||
type: "POST",
|
||||
data: {
|
||||
'id_product': id_product_mail_alert,
|
||||
|
||||
Reference in New Issue
Block a user