Merge branch 'ticket/r13147-product-fidelity' into 'master'

Ticket/r13147 product fidelity

See merge request !1
This commit is contained in:
Michael 2017-05-31 11:50:17 +02:00
commit ead411f255
6 changed files with 307 additions and 70 deletions

View File

@ -67,49 +67,27 @@ class HTMLTemplateOffredefideliteCore extends HTMLTemplate
// print_r($this->offredefidelite->selecteds);
// die();
}
/**
* Returns the template's HTML content
* @return string HTML content
*/
public function getItemsProducts2()
{
// if(Tools::getValue('id_product'))
// $id_product=Tools::getValue('id_product');
// $id_shop = $this->context->shop->id;
$id_lang = Context::getContext()->language->id;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and p.id_category_default = cl.id_category)
LEFT JOIN '._DB_PREFIX_.'category c ON (cl.id_category = c.id_category)
WHERE c.id_category!=12
and c.id_category!=13
and c.id_category!=14
and c.id_category!=15
and c.id_category!=16
and c.id_category!=17
ORDER BY c.position asc,pl.name asc');
}
public function getItemsProducts()
{
$id_lang = Context::getContext()->language->id;
$sql='
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
$id_category = Configuration::get('PS_CATEGORY_FIDELITY');
$sql = '
SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default
FROM '._DB_PREFIX_.'category_product cp
LEFT JOIN '._DB_PREFIX_.'category c ON (cp.id_category = c.id_category)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and c.id_category = cl.id_category)
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product)
WHERE cp.id_category=3
or cp.id_category=4
WHERE c.id_category = '.(int)$id_category.'
AND p.active = 1
ORDER BY cl.name desc,cp.position asc,pl.name asc';
$products= Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
// echo $sql;
// print_r($products);
return $products;
}
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return $products;
}
public function getContent()
{
// $country = new Country((int)$this->order->id_address_invoice);
@ -128,7 +106,7 @@ class HTMLTemplateOffredefideliteCore extends HTMLTemplate
'days' => $days
));
$this->smarty->assign('generationProduits',self::getItemsProducts());
$this->smarty->assign('productFidelity', self::getItemsProducts());
// print_r($this->offredefidelite);
// die();
$this->smarty->assign(

View File

@ -94,42 +94,73 @@ class OffrefideliteControllerCore extends FrontController
($active ? ' AND hss.`active` = 1' : ' ').
' AND hss.`en_avant` = 1
ORDER BY hss.position');
}
public function getItemsProducts2()
{
// if(Tools::getValue('id_product'))
// $id_product=Tools::getValue('id_product');
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and p.id_category_default = cl.id_category)
LEFT JOIN '._DB_PREFIX_.'category c ON (cl.id_category = c.id_category)
WHERE c.id_category = 31
AND active = 1
ORDER BY c.position asc,pl.name asc');
}
}
public function getItemsProducts()
{
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
$sql='
$id_lang = $this->context->language->id;
$id_category = Configuration::get('PS_CATEGORY_FIDELITY');
$sql = '
SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default
FROM '._DB_PREFIX_.'category_product cp
LEFT JOIN '._DB_PREFIX_.'category c ON (cp.id_category = c.id_category)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and c.id_category = cl.id_category)
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product)
WHERE c.id_category = 31
WHERE c.id_category = '.(int)$id_category.'
AND p.active = 1
ORDER BY cl.name desc,cp.position asc,pl.name asc';
$products= Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return $products;
}
}
public function getItemsProductsChoice($choice)
{
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
if ($choice == 2) {
$id_category = Configuration::get('PS_CATEGORY_FIDELITYCHOICE2');
} else {
$id_category = Configuration::get('PS_CATEGORY_FIDELITYCHOICE1');
}
$sql = '
SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default
FROM '._DB_PREFIX_.'category_product cp
LEFT JOIN '._DB_PREFIX_.'category c ON (cp.id_category = c.id_category)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and c.id_category = cl.id_category)
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product)
WHERE c.id_category = '.(int)$id_category.'
AND p.active = 1
ORDER BY cl.name desc,cp.position asc,pl.name asc';
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return $products;
}
public function getItemsProductsChoice2()
{
$id_shop = $this->context->shop->id;
$id_lang = $this->context->language->id;
$id_category = Configuration::get('PS_CATEGORY_FIDELITYCHOICE2');
$sql = '
SELECT distinct(p.`id_product`), pl.name, pl.link_rewrite,cl.name as categoryName,c.id_category,p.id_category_default
FROM '._DB_PREFIX_.'category_product cp
LEFT JOIN '._DB_PREFIX_.'category c ON (cp.id_category = c.id_category)
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_lang = '.(int)$id_lang.' and c.id_category = cl.id_category)
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product)
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_lang = '.(int)$id_lang.' and p.id_product = pl.id_product)
WHERE c.id_category = '.(int)$id_category.'
AND p.active = 1
ORDER BY cl.name desc,cp.position asc,pl.name asc';
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return $products;
}
public function initContent()
{
@ -154,7 +185,9 @@ class OffrefideliteControllerCore extends FrontController
$this->emailOffreFidelite();
}
$this->context->smarty->assign('generationProduits',$this->getItemsProducts());
$this->context->smarty->assign('productFidelity',$this->getItemsProducts());
$this->context->smarty->assign('productChoice1', $this->getItemsProductsChoice(1));
$this->context->smarty->assign('productChoice2', $this->getItemsProductsChoice(2));
$this->context->smarty->assign('livredorEnAvant',$this->getLivredorEnAvant());

View File

@ -0,0 +1,226 @@
<?php
class AdminPPreferencesControllerCore extends AdminController
{
public function __construct()
{
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$this->fields_options = array(
'products' => array(
'title' => $this->l('Products (general)'),
'fields' => array(
'PS_CATALOG_MODE' => array(
'title' => $this->l('Catalog mode'),
'desc' => $this->l('When active, all shopping features will be disabled.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_COMPARATOR_MAX_ITEM' => array(
'title' => $this->l('Product comparison'),
'desc' => $this->l('Set the maximum number of products that can be selected for comparison.').' '.$this->l('Set to "0" to disable this feature.'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_NB_DAYS_NEW_PRODUCT' => array(
'title' => $this->l('Number of days for which the product is considered \'new\''),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_CART_REDIRECT' => array(
'title' => $this->l('Redirect after adding product to cart'),
'desc' => $this->l('Only for non-AJAX versions of the cart.'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('Previous page'),
1 => $this->l('Cart summary')
)
),
'PS_PRODUCT_SHORT_DESC_LIMIT' => array(
'title' => $this->l('Max size of short description'),
'desc' => $this->l('Set the maximum size of product short description (in characters).'),
'validation' => 'isInt',
'cast' => 'intval',
'type' => 'text',
'suffix' => $this->l('characters'),
),
'PS_QTY_DISCOUNT_ON_COMBINATION' => array(
'title' => $this->l('Quantity discounts based on'),
'desc' => $this->l('How to calculate quantity discounts'),
'cast' => 'intval',
'show' => true,
'required' => false,
'type' => 'radio',
'validation' => 'isBool',
'choices' => array(
0 => $this->l('Products:'),
1 => $this->l('Combinations')
)
)
),
),
'order_by_pagination' => array(
'title' => $this->l('Pagination'),
'fields' => array(
'PS_PRODUCTS_PER_PAGE' => array(
'title' => $this->l('Products per page'),
'desc' => $this->l('Number of products displayed per page. Default is 10.'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text'
),
'PS_PRODUCTS_ORDER_BY' => array(
'title' => $this->l('Default order by'),
'desc' => $this->l('The order in which products are displayed in the product list.'),
'type' => 'select',
'list' => array(
array('id' => '0', 'name' => $this->l('Product name')),
array('id' => '1', 'name' => $this->l('Product price')),
array('id' => '2', 'name' => $this->l('Product add date')),
array('id' => '3', 'name' => $this->l('Product modified date')),
array('id' => '4', 'name' => $this->l('Position inside category')),
array('id' => '5', 'name' => $this->l('Manufacturer')),
array('id' => '6', 'name' => $this->l('Product quantity'))
),
'identifier' => 'id'
),
'PS_PRODUCTS_ORDER_WAY' => array(
'title' => $this->l('Default order method'),
'desc' => $this->l('Default order method for product list'),
'type' => 'select',
'list' => array(
array(
'id' => '0',
'name' => $this->l('Ascending')
),
array(
'id' => '1',
'name' => $this->l('Descending')
)
),
'identifier' => 'id'
)
)
),
'fo_product_page' => array(
'title' => $this->l('Product page'),
'fields' => array(
'PS_DISPLAY_QTIES' => array(
'title' => $this->l('Display available quantities on the product page'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_LAST_QTIES' => array(
'title' => $this->l('Display remaining quantities when the qty is lower than'),
'desc' => $this->l('Set to "0" to disable this feature.'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
),
'PS_DISPLAY_JQZOOM' => array(
'title' => $this->l('Enable JqZoom instead of Thickbox on the product page'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_DISP_UNAVAILABLE_ATTR' => array(
'title' => $this->l('Display unavailable product attributes on the product page'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_ATTRIBUTE_CATEGORY_DISPLAY' => array(
'title' => $this->l('Display the "add to cart" button when a product has attributes'),
'desc' => $this->l('Display or hide the "add to cart" button on category pages for products that have attributes forcing customers to see product details.'),
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool'
)
)
),
'stock' => array(
'title' => $this->l('Products stock'),
'fields' => array(
'PS_ORDER_OUT_OF_STOCK' => array(
'title' => $this->l('Allow ordering of out-of-stock products'),
'desc' => $this->l('Add to cart button is hidden when a product is unavailable'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool'
),
'PS_STOCK_MANAGEMENT' => array(
'title' => $this->l('Enable stock management'),
'desc' => '',
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'js' => array(
'on' => 'onchange="stockManagementActivationAuthorization()"',
'off' => 'onchange="stockManagementActivationAuthorization()"'
)
),
'PS_ADVANCED_STOCK_MANAGEMENT' => array(
'title' => $this->l('Enable advanced-stock management'),
'desc' => $this->l('Allows you to manage physical stock, warehouses and supply orders.'),
'validation' => 'isBool',
'cast' => 'intval',
'required' => false,
'type' => 'bool',
'visibility' => Shop::CONTEXT_ALL,
),
),
'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();</script>',
'submit' => array()
),
);
// Add specific field for fidelity
$this->fields_options['products']['fields']['PS_CATEGORY_FIDELITY'] = array(
'title' => $this->l('Offre de fidélité - Catégorie'),
'desc' => $this->l('Défini l\'id category pour les produits en offre fidélité.'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
);
$this->fields_options['products']['fields']['PS_CATEGORY_FIDELITYCHOICE1'] = array(
'title' => $this->l('Offre fidélité - Catégorie Liste 1'),
'desc' => $this->l('Défini l\'id catégory pour la liste des choix des produits offerts'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
);
$this->fields_options['products']['fields']['PS_CATEGORY_FIDELITYCHOICE2'] = array(
'title' => $this->l('Offre fidélité - Catégorie Liste 2'),
'desc' => $this->l('Défini l\'id catégory pour la liste des choix des produits offerts'),
'validation' => 'isUnsignedId',
'required' => true,
'cast' => 'intval',
'type' => 'text'
);
}
}

View File

@ -104,7 +104,7 @@
<label for="produits1">{l s='Produits'}<sup>***</sup></label>
<select id="produits1" name="produits1" class="selectBox inputSelect219">
<option value="">Choix n°1</option>
{foreach from=$generationProduits item=produit}
{foreach from=$productFidelity item=produit}
<option value="{$produit.name}">{$produit.name}</option>
{/foreach}
</select>
@ -113,7 +113,7 @@
<label for="produits2">&nbsp;</label>
<select id="produits2" name="produits2" class="selectBox inputSelect219">
<option value="">Choix n°2</option>
{foreach from=$generationProduits item=produit}
{foreach from=$productFidelity item=produit}
<option value="{$produit.name}">{$produit.name}</option>
{/foreach}
</select>
@ -121,12 +121,12 @@
<p><strong>{l s='- Cochez votre indice de satisfaction sur les produits que vous avez testés :'}</strong>
<br/>{l s='1 = Très satisfaite, 2 = Satisfaite, 3 = Assez satisfaite,'}<br/>{l s='4 = Pas du tout satisfaite'}</p>
</fieldset>
{if $generationProduits|@count>0}
{if $productFidelity|@count>0}
<fieldset>
{assign var=id_category_default value=false}
<table class="produits" style="width:auto">
<tbody>
{foreach from=$generationProduits item=produit}
{foreach from=$productFidelity item=produit}
{if $id_category_default!=$produit.id_category_default}
{assign var=id_category_default value=$produit.id_category_default}
<tr>
@ -145,7 +145,7 @@
{/foreach}
</tbody>
</table>
<input type="hidden" value="{foreach from=$generationProduits item=produit key=compteur}{if $compteur>0}-{/if}produit{$produit.id_product}{/foreach}" name="fullIds" />
<input type="hidden" value="{foreach from=$productFidelity item=produit key=compteur}{if $compteur>0}-{/if}produit{$produit.id_product}{/foreach}" name="fullIds" />
</fieldset>
{/if}
<div class="hidden">

View File

@ -87,7 +87,7 @@
<option value="">{l s='Choix n°1'}</option>
{assign var=id_category value=false}
{assign var=compteur value=0}
{foreach from=$generationProduits item=produit}
{foreach from=$productChoice1 item=produit}
{if $id_category!=$produit.id_category}
{assign var=id_category value=$produit.id_category}
{if $compteur>0}
@ -104,7 +104,7 @@
<option value="">{l s='Choix n°2'}</option>
{assign var=id_category value=false}
{assign var=compteur value=0}
{foreach from=$generationProduits item=produit}
{foreach from=$productChoice2 item=produit}
{if $id_category!=$produit.id_category}
{assign var=id_category value=$produit.id_category}
{if $compteur>0}
@ -121,12 +121,12 @@
<p><strong>{l s='- Cochez votre indice de satisfaction sur les produits que vous avez testés :'}</strong>
<br/>{l s='1 = Très satisfaite, 2 = Satisfaite, 3 = Assez satisfaite, 4 = Pas du tout satisfaite'}</p>
</fieldset>
{if $generationProduits|@count>0}
{if $productFidelity|@count>0}
<fieldset>
{assign var=id_category value=false}
<table class="produits">
<tbody>
{foreach from=$generationProduits item=produit}
{foreach from=$productFidelity item=produit}
{if $id_category!=$produit.id_category}
{assign var=id_category value=$produit.id_category}
<tr>
@ -145,7 +145,7 @@
{/foreach}
</tbody>
</table>
<input type="hidden" value="{foreach from=$generationProduits item=produit key=compteur}{if $compteur>0}-{/if}produit{$produit.id_product}{/foreach}" name="fullIds" />
<input type="hidden" value="{foreach from=$productFidelity item=produit key=compteur}{if $compteur>0}-{/if}produit{$produit.id_product}{/foreach}" name="fullIds" />
</fieldset>
{/if}
<div class="hidden">

View File

@ -70,11 +70,11 @@
</table>
<p><br/><br/><strong>{l s='- Cochez votre indice de satisfaction sur les produits que vous avez testés :'}</strong>
<br/>{l s='1 = Très satisfaite, 2 = Satisfaite, 3 = Assez satisfaite, 4 = Pas du tout satisfaite'}</p>
{if $generationProduits|@count>0}
{if $productFidelity|@count>0}
{assign var=idCategory value=0}
<table class="produits">
<tbody>
{foreach from=$generationProduits item=produit}
{foreach from=$productFidelity item=produit}
{if $idCategory!=$produit.id_category}
{assign var=idCategory value=$produit.id_category}
<tr>