bebeboutik/modules/ant_wp/AdminAntWp.php

498 lines
25 KiB
PHP
Raw Normal View History

2017-10-27 13:16:02 +02:00
<?php
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
2017-10-31 12:32:41 +01:00
include_once(_PS_ROOT_DIR_.'/modules/ant_wp/GenerateWp.php');
require_once _PS_PHPEXCEL_DIR_.'Classes/PHPExcel.php';
require_once _PS_PHPEXCEL_DIR_.'Classes/PHPExcel/IOFactory.php';
2017-10-27 13:16:02 +02:00
2018-01-24 16:50:32 +01:00
ini_set('memory_limit', '8G');
ini_set('max_execution_time', 300);
2017-10-27 13:16:02 +02:00
class AdminAntWp extends AdminTab
{
2018-01-24 16:50:32 +01:00
const DUPLICATED_EANS = 'duplicated_ean';
const DUPLICATED_REFS = 'duplicated_refs';
2017-10-27 13:16:02 +02:00
protected $_html;
public $module_name;
public $config_tab;
public $controller;
public $helperForm;
public $_object;
2018-01-24 16:50:32 +01:00
public $report;
2017-10-27 13:16:02 +02:00
public function __construct($config_tab = true)
{
parent::__construct();
$this->_object = false;
$this->controller = 'AdminModules';
$this->module_name = 'ant_wp';
$this->config_tab = (bool)$config_tab;
if ($config_tab) {
$this->controller = 'AdminAntWp';
}
$this->helperForm = new HelperFormBootstrap();
2018-01-24 16:50:32 +01:00
$this->report = array();
$this->report[self::DUPLICATED_EANS] = array();
$this->report[self::DUPLICATED_REFS] = array();
2017-10-27 13:16:02 +02:00
// $this->helperForm->_select2 = true;
// $this->helperForm->_inputSwitch = true;
}
public function display()
{
parent::displayForm();
$this->_html = '';
$this->_postProcess();
$this->_addCss();
$this->_html .= $this->helperForm->renderStyle();
$this->_displayForm();
//$this->_displayList();
$this->_html .='<div class="clearfix"></div>';
$this->_addJs();
$this->_html .= $this->helperForm->renderScript();
echo $this->_html;
}
protected function _addJs()
{
$this->helperForm->_js .= '<script type="text/javascript"></script>';
}
protected function _addCss()
{
$this->helperForm->_css .='
.table tr th {
background: #565485;
background: rgba(86,84,133,0.9);
color: #fff;
font-size: 12px;
}
.table tr:nth-child(even) {
background: #F1F1F1;
}
.table .input-group-btn .btn {
padding: 4px 5px;
color: #504d8b;
}
.table .input-group-btn .btn .anticon{
font-size: 12px;
}
.bg-grey{
background: #EFEFEF;
border-radius:4px;
}
.bg-grey .div-title {
border-bottom: 2px solid #504D8B;
}
.control-label.text-left{
text-align:left!important;
}
';
}
protected function _postProcess()
{
2017-10-31 12:32:41 +01:00
if(isset($_FILES['csvfile']) && $_FILES['csvfile']['name'] != '') {
$filename = Tools::getValue('filename')?'WP-Vente '.Tools::getValue('filename'):'WP-Vente';
$marque = Tools::getValue('filename')?Tools::getValue('filename'):'Marque';
$params = array('marque' => $marque, 'filename' => $filename, 'lines' => array());
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
fgetcsv($f, 0, ';');
$products = array();
$product_info = array();
2018-01-24 16:50:32 +01:00
$timer_table = array();
$callStartTime = microtime(true);
2017-10-31 12:32:41 +01:00
$refs = array();
$eans = array();
while($line = fgetcsv($f, 0, ';')) {
if($line[0] == '' && $line[1] == '') {
continue;
}
if($line[0] != '') {
$ean = trim($line[0]);
2018-01-24 16:50:32 +01:00
if(!isset($products[$ean])){
$products[$ean] = array(
'ean' => $ean,
'supplier_ref' => trim((String)utf8_encode($line[1])),
'name_ha' => trim((String)utf8_encode($line[2])),
'quantity' => trim($line[3]),
'ppc' => trim((float)$line[4]),
'prix_ha' => trim((float)$line[5]),
'name_attribute_ha' => trim((String)$line[6])
);
}else{
$this->report[self::DUPLICATED_EANS][] = $ean;
}
2017-10-31 12:32:41 +01:00
$eans[] = $ean;
} else {
2017-11-22 16:31:51 +01:00
$ref = trim((String)utf8_encode($line[1]));
2018-01-24 16:50:32 +01:00
if(!isset($products[$ref])) {
$products[$ref] = array(
'ean' => trim($line[0]),
'supplier_ref' => $ref,
'name_ha' => trim((String)utf8_encode($line[2])),
'quantity' => trim($line[3]),
'ppc' => trim((float)$line[4]),
'prix_ha' => trim((float)$line[5]),
'name_attribute_ha' => trim((String)utf8_encode($line[6]))
);
}else{
$this->report[self::DUPLICATED_REFS][] = $ref;
}
2017-10-31 12:32:41 +01:00
$refs[] = $ref;
}
}
$product_info = array();
$product_found = 0;
$ids = array();
2017-12-07 10:37:02 +01:00
$exclude_ids = $this->getBraderieProducts();
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Excluded products gathered at '.(microtime(true)-$callStartTime);
if(count($eans) > 0) {
$sql = '
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`,
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`
FROM
`' . _DB_PREFIX_ . 'product` p
INNER JOIN (
SELECT date_add, max(id_product) as maxid
FROM `' . _DB_PREFIX_ . 'product`
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
GROUP BY ean13
) as b
ON p.`id_product` = b.maxid
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
ON (cu.`id_product` = p.`id_product`)
WHERE p.`ean13` IN ("' . implode('","', $eans) . '")
AND p.`id_product` IS NOT NULL
ORDER BY c.`position`
';
$result = Db::getInstance()->executeS($sql);
foreach ($result as $row) {
if($row['ean13'] == '8427077902761'){
$timer_table[] = json_encode($row);
}
if ($row['ean13'] != '' && isset($products[$row['ean13']])) {
$products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
$product_found++;
$ids[] = (int)$row['id_product'];
}
// elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
// $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
// $product_found++;
// $ids[] = (int)$row['id_product'];
// }
2017-12-07 10:37:02 +01:00
}
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Ean product gathered at '.(microtime(true)-$callStartTime);
if(count($refs)> 0) {
foreach (Db::getInstance()->executeS('
2017-12-07 10:37:02 +01:00
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, p.`ean13`, p.`price`, p.`wholesale_price`,
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`
FROM
2018-01-24 16:50:32 +01:00
`' . _DB_PREFIX_ . 'product` p
2017-12-07 10:37:02 +01:00
INNER JOIN (
SELECT date_add, max(id_product) as maxid
2018-01-24 16:50:32 +01:00
FROM `' . _DB_PREFIX_ . 'product`
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
2017-12-07 10:37:02 +01:00
GROUP BY supplier_reference
) as b
ON p.`id_product` = b.maxid
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
2017-12-07 10:37:02 +01:00
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
2017-12-07 10:37:02 +01:00
ON (cu.`id_product` = p.`id_product`)
2018-01-24 16:50:32 +01:00
WHERE p.`supplier_reference` IN ("' . implode('","', $refs) . '")
2017-12-07 10:37:02 +01:00
AND p.`id_product` IS NOT NULL
ORDER BY c.`position`
') as $row) {
2018-01-24 16:50:32 +01:00
// if($row['ean13']!='' && isset($products[$row['ean13']])){
// $products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
// $product_found++;
// $ids[] = (int)$row['id_product'];
// } else
if ($row['supplier_reference'] != '' && isset($products[$row['supplier_reference']])) {
$products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
$product_found++;
$ids[] = (int)$row['id_product'];
}
2017-10-31 12:32:41 +01:00
}
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Ref product gathered at '.(microtime(true)-$callStartTime);
if(count($eans) > 0) {
foreach (Db::getInstance()->executeS('
2017-12-07 10:37:02 +01:00
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`, b.`id_product_attribute`, b.`ean13`, b.`supplier_reference` as at_ref, p.`price`, p.`wholesale_price`,
2017-11-17 11:16:30 +01:00
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`,
al.`name` as attribute_name
2017-11-06 16:51:48 +01:00
FROM
2018-01-24 16:50:32 +01:00
`' . _DB_PREFIX_ . 'product` p
2017-12-07 10:37:02 +01:00
INNER JOIN (
SELECT max(id_product) as maxid, ean13, `supplier_reference`, `id_product_attribute`
2018-01-24 16:50:32 +01:00
FROM `' . _DB_PREFIX_ . 'product_attribute`
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
2017-12-07 10:37:02 +01:00
GROUP BY ean13
) as b
ON p.`id_product`= b.maxid
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
2017-11-06 16:51:48 +01:00
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
2017-11-06 16:51:48 +01:00
ON (cu.`id_product` = p.`id_product`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` ac
2017-12-07 10:37:02 +01:00
ON (ac.`id_product_attribute` = b.`id_product_attribute`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al
2017-11-22 16:31:51 +01:00
ON (al.`id_attribute` = ac.`id_attribute` AND al.`id_lang` = 2)
2018-01-24 16:50:32 +01:00
WHERE b.`ean13` IN ("' . implode('","', $eans) . '")
2017-11-06 17:36:53 +01:00
AND p.`id_product` IS NOT NULL
2017-11-06 16:51:48 +01:00
ORDER BY c.`position`
') as $row) {
2018-01-24 16:50:32 +01:00
if ($row['ean13'] != '' && isset($products[$row['ean13']])) {
$products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
$product_found++;
if (!in_array((int)$row['id_product'], $ids)) {
$ids[] = (int)$row['id_product'];
}
2017-12-07 10:37:02 +01:00
}
2018-01-24 16:50:32 +01:00
// elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
// $products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
// $product_found++;
// if(!in_array((int)$row['id_product'],$ids)){
// $ids[] = (int)$row['id_product'];
// }
// } elseif($row['at_ref']!='' && isset($products[$row['at_ref']])){
// $products[$row['at_ref']] = array_merge($products[$row['at_ref']], $row);
// $product_found++;
// if(!in_array((int)$row['id_product'],$ids)){
// $ids[] = (int)$row['id_product'];
// }
// }
2017-12-07 10:37:02 +01:00
}
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Ean product attr gathered at '.(microtime(true)-$callStartTime);
if(count($refs) > 0) {
foreach (Db::getInstance()->executeS('
2017-12-07 10:37:02 +01:00
SELECT p.`id_product`, p.`id_tax_rules_group`, p.`id_category_default`,b.`id_product_attribute`, b.`ean13`, b.`supplier_reference` as at_ref, p.`price`, p.`wholesale_price`,
p.`reference`, p.`supplier_reference`, p.`weight`, p.`height`, p.`width`, p.`depth`, c.`position`, cu.`nc8`, cu.`id_country`,
al.`name` as attribute_name
FROM
2018-01-24 16:50:32 +01:00
`' . _DB_PREFIX_ . 'product` p
2017-12-07 10:37:02 +01:00
INNER JOIN (
SELECT max(id_product) as maxid, ean13, `supplier_reference`, `id_product_attribute`
2018-01-24 16:50:32 +01:00
FROM `' . _DB_PREFIX_ . 'product_attribute`
WHERE id_product NOT IN (' . implode(',', $exclude_ids) . ')
2017-12-07 10:37:02 +01:00
GROUP BY supplier_reference
) as b
ON p.`id_product`= b.maxid
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` c
2017-12-07 10:37:02 +01:00
ON (b.maxid = c.`id_product` AND p.`id_category_default` = c.`id_category`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'product_customs` cu
2017-12-07 10:37:02 +01:00
ON (cu.`id_product` = p.`id_product`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` ac
2017-12-07 10:37:02 +01:00
ON (ac.`id_product_attribute` = b.`id_product_attribute`)
2018-01-24 16:50:32 +01:00
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al
2017-12-07 10:37:02 +01:00
ON (al.`id_attribute` = ac.`id_attribute` AND al.`id_lang` = 2)
2018-01-24 16:50:32 +01:00
WHERE b.`supplier_reference` IN ("' . implode('","', $refs) . '")
2017-12-07 10:37:02 +01:00
AND p.`id_product` IS NOT NULL
ORDER BY c.`position`
') as $row) {
2018-01-24 16:50:32 +01:00
// if($row['ean13']!='' && isset($products[$row['ean13']])){
// $products[$row['ean13']] = array_merge($products[$row['ean13']], $row);
// $product_found++;
// if(!in_array((int)$row['id_product'],$ids)){
// $ids[] = (int)$row['id_product'];
// }
// }
if ($row['at_ref'] != '' && isset($products[$row['at_ref']])) {
$products[$row['at_ref']] = array_merge($products[$row['at_ref']], $row);
$product_found++;
if (!in_array((int)$row['id_product'], $ids)) {
$ids[] = (int)$row['id_product'];
}
} elseif ($row['supplier_reference'] != '' && isset($products[$row['supplier_reference']])) {
$products[$row['supplier_reference']] = array_merge($products[$row['supplier_reference']], $row);
$product_found++;
if (!in_array((int)$row['id_product'], $ids)) {
$ids[] = (int)$row['id_product'];
}
2017-12-07 10:37:02 +01:00
}
2017-11-06 16:51:48 +01:00
}
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Ref product attr gathered at '.(microtime(true)-$callStartTime);
2017-11-06 17:36:53 +01:00
$new_products = count($products) - $product_found;
2017-10-31 12:32:41 +01:00
if(!empty($ids)){
foreach (Db::getInstance()->executeS('
SELECT p.`ean13`, p.`supplier_reference`, pl.*
2017-11-22 16:31:51 +01:00
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.`id_product` = p.`id_product`)
WHERE p.`id_product` IN ('.implode(',',$ids).')
AND (pl.id_lang = 2 OR pl.id_lang = 3)
ORDER BY p.`id_product`
') as $row) {
if($row['ean13']!='' && isset($products[(int)$row['ean13']])){
if(!isset($products[$row['ean13']]['lang'])){
$products[$row['ean13']]['lang'] = array();
}
if(!isset($products[$row['ean13']]['lang'][(int)$row['id_lang']])){
$products[$row['ean13']]['lang'][(int)$row['id_lang']] = $row;
}
} elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
if(!isset($products[$row['supplier_reference']]['lang'])){
$products[$row['supplier_reference']]['lang'] = array();
}
if(!isset($products[$row['supplier_reference']]['lang'][(int)$row['id_lang']])){
$products[$row['supplier_reference']]['lang'][(int)$row['id_lang']] = $row;
}
}
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Additional info gathered at '.(microtime(true)-$callStartTime);
2017-11-22 16:31:51 +01:00
foreach (Db::getInstance()->executeS('
2017-12-07 10:37:02 +01:00
SELECT at.`ean13`, at.`supplier_reference` as at_ref, p.`supplier_reference`, pl.*
2017-11-22 16:31:51 +01:00
FROM '._DB_PREFIX_.'product p
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.`id_product` = p.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute` at ON (at.`id_product` = p.`id_product`)
WHERE p.`id_product` IN ('.implode(',',$ids).')
2017-10-31 12:32:41 +01:00
AND (pl.id_lang = 2 OR pl.id_lang = 3)
2017-11-22 16:31:51 +01:00
ORDER BY p.`id_product`
2017-10-31 12:32:41 +01:00
') as $row) {
2017-11-22 16:31:51 +01:00
if($row['ean13']!='' && isset($products[(int)$row['ean13']])){
2017-10-31 12:32:41 +01:00
if(!isset($products[$row['ean13']]['lang'])){
$products[$row['ean13']]['lang'] = array();
}
if(!isset($products[$row['ean13']]['lang'][(int)$row['id_lang']])){
$products[$row['ean13']]['lang'][(int)$row['id_lang']] = $row;
}
} elseif($row['supplier_reference']!='' && isset($products[$row['supplier_reference']])){
if(!isset($products[$row['supplier_reference']]['lang'])){
$products[$row['supplier_reference']]['lang'] = array();
}
if(!isset($products[$row['supplier_reference']]['lang'][(int)$row['id_lang']])){
$products[$row['supplier_reference']]['lang'][(int)$row['id_lang']] = $row;
}
2017-12-07 10:37:02 +01:00
} elseif($row['at_ref']!='' && isset($products[$row['at_ref']])){
if(!isset($products[$row['at_ref']]['lang'])){
$products[$row['at_ref']]['lang'] = array();
}
if(!isset($products[$row['at_ref']]['lang'][(int)$row['id_lang']])){
$products[$row['at_ref']]['lang'][(int)$row['id_lang']] = $row;
}
2017-10-31 12:32:41 +01:00
}
}
2018-01-24 16:50:32 +01:00
$timer_table[] = 'Additional info (attr) gathered at '.(microtime(true)-$callStartTime);
2017-10-31 12:32:41 +01:00
}
$params['lines'] = $products;
if(!empty($params['lines'])){
$wp = new GenerateWp();
2018-01-24 16:50:32 +01:00
$wp->generate($params, $timer_table, $callStartTime);
2017-10-31 12:41:11 +01:00
$filename = str_replace(' ', '_', $filename);
2018-01-24 16:50:32 +01:00
$wp->objWriter->save(__DIR__ .'/'.$filename.'.xlsx');
$timer_table_formatted = implode('<br>', $timer_table);
$duplicated_formatted = '';
if (!empty($this->report[self::DUPLICATED_REFS])) {
$duplicated_formatted = '<hr>Duplications de Reférences<br><p style="color:darkred">' . implode('<br>', $this->report[self::DUPLICATED_REFS]). '</p>';
}
if (!empty($this->report[self::DUPLICATED_EANS])) {
$duplicated_formatted .= '<hr>Duplications d\'EANs<br><p style="color:darkred">' . implode('<br>', $this->report[self::DUPLICATED_EANS]) . '</p>';
}
$this->_html .= HelperFormBootstrap::displaySuccess('Génération complète <br><a class="btn btn-primary btn-xs" href="../modules/ant_wp/'.$filename.'.xlsx" download="'.$filename.'.xlsx">Télécharger le XLS</a>'.
'<br>Produits trouvés : '.$product_found.'<br>Produits nouveaux : '.$new_products.$duplicated_formatted.'<p style="font-size: 6px"><br>Timers : <br>'.$timer_table_formatted.'</p>');
2017-10-31 12:32:41 +01:00
} else {
$this->_html .= HelperFormBootstrap::displayErrors($this->l('Veuillez charger un fichier correct !'));
}
2017-10-27 13:16:02 +02:00
}
}
private function _displayForm()
{
global $cookie, $currentIndex;
if (Validate::isLoadedObject($this->_object)){
$trackingTag = $this->_object;
}
$ps_url = ((Configuration::get('PS_SSL_ENABLED') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PORT'] == '443')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].__PS_BASE_URI__;
$this->helperForm->_forms = array(
array(
2017-10-31 12:32:41 +01:00
'action' => $currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'),
// 'action' => $ps_url.'modules/ant_wp/GenerateWp.php?url='.$currentIndex . '&token=' . Tools::getAdminTokenLite('AdminAntWp'),
2017-10-27 13:16:02 +02:00
'title' => '<span class="text-rose anticon anticon-table2"></span> '.$this->l('WP'),
'class' => 'form-horizontal',
'class_div' => 'col-md-12',
'sections' => array(
array(
'class' => 'col-md-6',
'inputs' => array(
array(
'type' => 'simpleText',
'name' => 'filename',
'label-class' => 'col-md-12 text-left',
'input-class' => 'col-md-6',
'text-class' => 'input-sm',
'label' => $this->l('Sale name :'),
),
array(
'type' => 'file',
'label' => $this->l('File :'),
'name' => 'csvfile',
'label-class' => 'col-md-12 text-left',
'input-class' => 'col-md-6',
),
),
'actions' => array(),
'actions-class' => 'text-right',
),
array(
'class' => 'col-md-6 bg-grey',
'title' => '<span class="anticon anticon-info"></span> Informations',
'inputs' => array(),
'info_html' => '
<p>Pour la génération du WP</p>
<p>Veuillez importer un fichier sous format csv<br>
Avec les colonnes suivantes :<br>
</p>
<ul style="list-style:none;">
2017-11-17 11:16:30 +01:00
<li style="font-size:13px;"><i>ean;ref_fournisseur;nom_produit_HA;quantite;PPC;prix_achat;taille_ha</i></li>
2017-10-27 13:16:02 +02:00
</ul>
<p>Les colonnes suivantes et la première ligne du fichier seront ignorées.</p>
<p></p>'
),
),
'actions' => array(),
'actions-class' => 'text-right',
)
);
$this->helperForm->_forms[0]['sections'][0]['title'] = "Générer un WP";
$this->helperForm->_forms[0]['sections'][0]['actions'] = array(
array(
'type' => 'submit',
'class' => 'btn-primary',
'name' => 'uploadWP',
'value' => $this->l('Générer')
),
);
$this->helperForm->renderForm();
}
2017-12-07 10:37:02 +01:00
public function getBraderieProducts()
{
$products = array();
foreach(Db::getInstance()->executeS('
SELECT categ.id_product
FROM '._DB_PREFIX_.'category_product categ
INNER JOIN '._DB_PREFIX_.'category_lang lang ON (categ.id_category=lang.id_category AND lang.id_lang=2 AND lang.name LIKE "%braderie%")'
) as $row){
$products[] = (int)$row['id_product'];
}
return $products;
}
2017-10-27 13:16:02 +02:00
}