Configure fidelity
- Add a new category "Offre de fidélité - Liste de choix" - Move it near "Offre de fidélité" - Copy product between the two category - Configure in admin "Préférences > Produits"
This commit is contained in:
parent
0f7fb86c84
commit
46cfa2b8f3
@ -115,21 +115,42 @@ class OffrefideliteControllerCore extends FrontController
|
||||
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()
|
||||
{
|
||||
$id_shop = $this->context->shop->id;
|
||||
$id_lang = $this->context->language->id;
|
||||
$id_category = Configuration::get('PS_CATEGORY_FIDELITYCHOICE');
|
||||
$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 +175,8 @@ class OffrefideliteControllerCore extends FrontController
|
||||
$this->emailOffreFidelite();
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('generationProduits',$this->getItemsProducts());
|
||||
$this->context->smarty->assign('productFidelity',$this->getItemsProducts());
|
||||
$this->context->smarty->assign('productChoice', $this->getItemsProductsChoice());
|
||||
|
||||
$this->context->smarty->assign('livredorEnAvant',$this->getLivredorEnAvant());
|
||||
|
||||
|
217
override/controllers/admin/AdminPPreferencesController.php
Executable file
217
override/controllers/admin/AdminPPreferencesController.php
Executable file
@ -0,0 +1,217 @@
|
||||
<?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('Catégorie offre de fidélité'),
|
||||
'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_FIDELITYCHOICE'] = array(
|
||||
'title' => $this->l('Catégorie liste des choix offre fidélité'),
|
||||
'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'
|
||||
);
|
||||
}
|
||||
}
|
@ -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"> </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">
|
||||
|
@ -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=$productFidelity 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=$productFidelity 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">
|
||||
|
Loading…
Reference in New Issue
Block a user