Add failling price

This commit is contained in:
Michael RICOIS 2017-05-17 16:12:12 +02:00
parent bb739811fe
commit fd6ec8139c
6 changed files with 25 additions and 4 deletions

View File

@ -3,6 +3,7 @@
class Product extends ProductCore
{
public $home_edito;
public $failling_price;
public static $products_flashsale;
public static $definition = array(
@ -35,6 +36,7 @@ class Product extends ProductCore
'on_sale' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'online_only' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'home_edito' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'failling_price' => array('type' => self::TYPE_BOOL, 'shop' => true, 'validate' => 'isBool'),
'ecotax' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice'),
'minimal_quantity' => array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'),
'price' => array('type' => self::TYPE_FLOAT, 'shop' => true, 'validate' => 'isPrice', 'required' => true),
@ -187,11 +189,11 @@ class Product extends ProductCore
return $this;
}
public static function getProductsInFlashsales()
public static function getProductsInFlashsales()
{
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT fsp.`id_product`
FROM '._DB_PREFIX_.'flash_sale_products fsp
SELECT fsp.`id_product`
FROM '._DB_PREFIX_.'flash_sale_products fsp
INNER JOIN '._DB_PREFIX_.'flash_sale fs ON (fs.id_flash_sale = fsp.id_flash_sale AND fs.active = 1)'
);

View File

@ -46,6 +46,10 @@ class AdminProductsController extends AdminProductsControllerCore
if ($this->checkMultishopBox('home_edito', $this->context)) {
$object->home_edito = (int)Tools::getValue('home_edito');
}
if ($this->checkMultishopBox('failling_price', $this->context)) {
$object->failling_price= (int)Tools::getValue('failling_price');
}
}
if ($this->isTabSubmitted('Prices')) {
$object->on_sale = (int)Tools::getValue('on_sale');

View File

@ -281,6 +281,11 @@
<input type="checkbox" name="home_edito" id="home_edito" value="1" {if $product->home_edito}checked="checked"{/if} >
{l s='Remonté sur l\'accueil à côté des éditos'}</label>
</div>
<div class="checkbox">
<label for="failling_price">
<input type="checkbox" name="failling_price" id="failling_price" value="1" {if $product->failling_price}checked="checked"{/if} >
{l s='Afficher comme prix récent'}</label>
</div>
</div>
</div>
<div class="form-group">

View File

@ -38,6 +38,12 @@
{l s='Nouveau'}
</span>
</span>
{elseif isset($product.failling_price) && $product.failling_price == 1}
<span class="product-failling-bloclabel">
<span class="product-failling-label">
{l s='Prix en baisse'}
</span>
</span>
{/if}
<a class="product-img" href="{$product.link|escape:'html':'UTF-8'}" title="{$product.name|escape:'html':'UTF-8'}" itemprop="url">

View File

@ -83,8 +83,10 @@
<div id="image-block" class="col-md-4 col-sm-6">
{if $percentReduction}
<span class="price-percent-reduction">{if $isFlash}{l s='Vente Flash'}{else}{l s='Promo'}{/if} | -{$percentReduction}%</span>
{elseif isset($product.new) && $product.new == 1}
{elseif isset($product.new) && $product.new == 1}
<span class="product-new-label">{l s='Nouveau'}</span>
{elseif isset($product.failling_price) && $product.failling_price == 1}
<span class="product-failling-label">{l s='Nouveau'}</span>
{/if}
<!-- Image principale-->
{if $have_image}

2
update-20160517.sql Normal file
View File

@ -0,0 +1,2 @@
ALTER TABLE `ps_product` ADD `failling_price` TINYINT(1) NOT NULL DEFAULT '0' AFTER `home_edito`;
ALTER TABLE `ps_product_shop` ADD `failling_price` TINYINT(1) NOT NULL DEFAULT '0' AFTER `home_edito`;