addition of reassociation of product ps cache for specific default category

This commit is contained in:
Marion Muszynski 2016-12-26 12:31:43 +01:00
parent d148fffa70
commit 7df71fc8ff

View File

@ -81,6 +81,43 @@ class AdminAntConfigurations extends AdminTab
} elseif(Tools::isSubmit('submitUpdateLoyaltyOrders') && $cookie->id_employee == 1) {
$nb_credits = $this->updateLoyaltyOrders();
HelperFormBootstrap::echoConfirmation($this->l('Credit fidélité mis à jour : ').$nb_credits);
} elseif(Tools::isSubmit('submitUpdateCacheSale') && $cookie->id_employee == 1) {
$id_category = Tools::getValue('id_category');
if($id_category) {
Db::getInstance()->ExecuteS('
INSERT IGNORE INTO `'._DB_PREFIX_.'product_ps_cache` (
SELECT p.id_product, IFNULL(
(
SELECT s.id_sale
FROM `'._DB_PREFIX_.'privatesale_category` s
WHERE s.`id_category` = p.`id_category_default`
LIMIT 1)
, 0
)
FROM `ps_product` p
WHERE p.`id_category_default` = '.$id_category.'
)
');
HelperFormBootstrap::echoConfirmation($this->l('Association vente produit mise à jour: #').$id_category);
} else {
HelperFormBootstrap::echoError($this->l('Veuillez choisir une categorie'));
}
} elseif(Tools::isSubmit('submitShowProductCacheSale') && $cookie->id_employee == 1) {
$id_category = Tools::getValue('id_category');
if($id_category) {
$products_ids = array();
foreach(Db::getInstance()->ExecuteS('
SELECT p.id_product
FROM `ps_product` p
WHERE p.`id_category_default` = '.$id_category.'
') as $row) {
$products_ids[(int)$row['id_product']] = (int)$row['id_product'];
}
$result = implode(', ',$products_ids);
HelperFormBootstrap::echoConfirmation($this->l('Produits concernés ').'('.count($products_ids).') :<br />'.wordwrap($result, 100, "<br />"));
} else {
HelperFormBootstrap::echoError($this->l('Veuillez choisir une categorie'));
}
}
}
@ -131,6 +168,7 @@ class AdminAntConfigurations extends AdminTab
</style>';
$id_sale_options = array();
$id_category_options = array();
foreach(Db::getInstance()->ExecuteS('
SELECT p.`id_sale`, c.`name`, c.`id_category`
FROM `'._DB_PREFIX_.'privatesale` p
@ -144,6 +182,10 @@ class AdminAntConfigurations extends AdminTab
'label' => (int) $row['id_sale'].' - '.$row['name'].(empty($extrafields[(int) $row['id_category']]['sales'][1])?'':' - '.$extrafields[(int) $row['id_category']]['sales'][1]) ,
'value' => (int) $row['id_sale']
);
$id_category_options[] = array(
'label' => (int) $row['id_sale'].' (#'.(int) $row['id_category'].') - '.$row['name'].(empty($extrafields[(int) $row['id_category']]['sales'][1])?'':' - '.$extrafields[(int) $row['id_category']]['sales'][1]) ,
'value' => (int) $row['id_category']
);
}
$helperForm = new HelperFormBootstrap();
@ -209,7 +251,7 @@ class AdminAntConfigurations extends AdminTab
'sections' => array(
array(
'class' => 'col-md-6',
//'title' => $this->l('Mettre à jour les crédit fidélité'),
'title' => $this->l('Actions diverses'),
'inputs' => array(
array(
'type' => 'submit',
@ -220,6 +262,34 @@ class AdminAntConfigurations extends AdminTab
),
),
),
array(
'class' => 'col-md-6',
'title' => $this->l('Mettre à jour PS Cache'),
'inputs' => array(
array(
'label' => $this->l('PS Cache : '),
'type' => 'select2',
'class-select' => '',
'name' => 'id_category',
'options' => $id_category_options,
),
),
'actions' => array(
array(
'type' => 'submit',
'class' => 'btn-default',
'name' => 'submitShowProductCacheSale',
'value' => $this->l('Voir'),
),
array(
'type' => 'submit',
'class' => 'btn-primary',
'name' => 'submitUpdateCacheSale',
'value' => $this->l('Ré-Associer'),
),
),
'actions-class' => 'text-right',
),
),
);
}