// Back office optimization begun (memory & SQL) and will resume tomorrow
This commit is contained in:
@@ -189,6 +189,9 @@ class AdminControllerCore extends Controller
|
||||
* @var array ids of the rows selected
|
||||
*/
|
||||
protected $boxes;
|
||||
|
||||
/** @var string Do not automatically select * anymore but select only what is necessary */
|
||||
protected $explicitSelect = false;
|
||||
|
||||
/** @var string Add fields into data query to display list */
|
||||
protected $_select;
|
||||
@@ -2063,8 +2066,24 @@ class AdminControllerCore extends Controller
|
||||
|
||||
$this->_listsql = '
|
||||
SELECT SQL_CALC_FOUND_ROWS
|
||||
'.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '').'
|
||||
'.($this->lang ? 'b.*, ' : '').'a.*'.(isset($this->_select) ? ', '.$this->_select.' ' : '').$select_shop.'
|
||||
'.($this->_tmpTableFilter ? ' * FROM (SELECT ' : '');
|
||||
|
||||
if ($this->explicitSelect)
|
||||
{
|
||||
foreach ($this->fields_list as $key => $array_value)
|
||||
if (isset($array_value['filter_key']))
|
||||
$this->_listsql .= str_replace('!', '.', $array_value['filter_key']).',';
|
||||
elseif ($key == 'id_'.$this->table)
|
||||
$this->_listsql .= 'a.`'.bqSQL($key).'`,';
|
||||
elseif ($key != 'image' && !preg_match('/'.preg_quote($key, '/').'/i', $this->_select))
|
||||
$this->_listsql .= '`'.bqSQL($key).'`,';
|
||||
$this->_listsql = rtrim($this->_listsql, ',');
|
||||
}
|
||||
else
|
||||
$this->_listsql .= ($this->lang ? 'b.*,' : '').' a.*';
|
||||
|
||||
$this->_listsql .= '
|
||||
'.(isset($this->_select) ? ', '.$this->_select : '').$select_shop.'
|
||||
FROM `'._DB_PREFIX_.$sql_table.'` a
|
||||
'.$lang_join.'
|
||||
'.(isset($this->_join) ? $this->_join.' ' : '').'
|
||||
|
||||
@@ -38,6 +38,7 @@ class AdminAddressesControllerCore extends AdminController
|
||||
$this->className = 'Address';
|
||||
$this->lang = false;
|
||||
$this->addressType = 'customer';
|
||||
$this->explicitSelect = true;
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->addRowAction('edit');
|
||||
|
||||
@@ -32,6 +32,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
$this->table = 'cart';
|
||||
$this->className = 'Cart';
|
||||
$this->lang = false;
|
||||
$this->explicitSelect = true;
|
||||
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('delete');
|
||||
@@ -87,7 +88,6 @@ class AdminCartsControllerCore extends AdminController
|
||||
'width' => 40,
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'filter_key' => 'id_guest',
|
||||
'havingFilter' => true,
|
||||
'icon' => array(0 => 'blank.gif', 1 => 'tab-customers.gif')
|
||||
)
|
||||
|
||||
@@ -45,6 +45,7 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
$this->className = 'Category';
|
||||
$this->lang = true;
|
||||
$this->deleted = false;
|
||||
$this->explicitSelect = true;
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
@@ -73,7 +74,7 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'cs!position',
|
||||
'filter_key' => 'sa!position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
),
|
||||
|
||||
@@ -34,6 +34,7 @@ class AdminCountriesControllerCore extends AdminController
|
||||
$this->lang = true;
|
||||
$this->deleted = false;
|
||||
|
||||
$this->explicitSelect = true;
|
||||
$this->addRowAction('edit');
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
@@ -41,6 +41,7 @@ class AdminCustomersControllerCore extends AdminController
|
||||
$this->className = 'Customer';
|
||||
$this->lang = false;
|
||||
$this->deleted = true;
|
||||
$this->explicitSelect = true;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('view');
|
||||
@@ -63,6 +64,15 @@ class AdminCustomersControllerCore extends AdminController
|
||||
$genders[$gender->id] = $gender->name;
|
||||
}
|
||||
|
||||
$this->_select = '
|
||||
a.date_add,
|
||||
IF (YEAR(`birthday`) = 0, "-", (YEAR(CURRENT_DATE)-YEAR(`birthday`)) - (RIGHT(CURRENT_DATE, 5) < RIGHT(birthday, 5))) AS `age`, (
|
||||
SELECT c.date_add FROM '._DB_PREFIX_.'guest g
|
||||
LEFT JOIN '._DB_PREFIX_.'connections c ON c.id_guest = g.id_guest
|
||||
WHERE g.id_customer = a.id_customer
|
||||
ORDER BY c.date_add DESC
|
||||
LIMIT 1
|
||||
) as connect';
|
||||
$this->fields_list = array(
|
||||
'id_customer' => array(
|
||||
'title' => $this->l('ID'),
|
||||
@@ -212,14 +222,6 @@ class AdminCustomersControllerCore extends AdminController
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->_select = 'IF (YEAR(`birthday`) = 0, "-", (YEAR(CURRENT_DATE)-YEAR(`birthday`)) - (RIGHT(CURRENT_DATE, 5) < RIGHT(birthday, 5))) AS `age`, (
|
||||
SELECT c.date_add FROM '._DB_PREFIX_.'guest g
|
||||
LEFT JOIN '._DB_PREFIX_.'connections c ON c.id_guest = g.id_guest
|
||||
WHERE g.id_customer = a.id_customer
|
||||
ORDER BY c.date_add DESC
|
||||
LIMIT 1
|
||||
) as connect';
|
||||
|
||||
if (Tools::isSubmit('submitBulkdelete'.$this->table) || Tools::isSubmit('delete'.$this->table))
|
||||
$this->tpl_list_vars = array(
|
||||
'delete_customer' => true,
|
||||
|
||||
@@ -41,6 +41,7 @@ class AdminMetaControllerCore extends AdminController
|
||||
$this->sm_file = _PS_ROOT_DIR_.'/sitemap.xml';
|
||||
$this->rb_data = $this->getRobotsContent();
|
||||
|
||||
$this->explicitSelect = true;
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
@@ -35,11 +35,13 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->className = 'Order';
|
||||
$this->lang = false;
|
||||
$this->addRowAction('view');
|
||||
$this->explicitSelect = true;
|
||||
|
||||
$this->deleted = false;
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = '
|
||||
a.id_currency,
|
||||
a.id_order AS id_pdf,
|
||||
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
|
||||
osl.`name` AS `osname`,
|
||||
@@ -77,7 +79,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'width' => 25,
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'filter_key' => 'new',
|
||||
'tmpTableFilter' => true,
|
||||
'icon' => array(
|
||||
0 => 'blank.gif',
|
||||
@@ -90,7 +91,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
),
|
||||
'customer' => array(
|
||||
'title' => $this->l('Customer'),
|
||||
'filter_key' => 'customer',
|
||||
'tmpTableFilter' => true
|
||||
),
|
||||
'total_paid_tax_incl' => array(
|
||||
|
||||
@@ -60,6 +60,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->table = 'product';
|
||||
$this->className = 'Product';
|
||||
$this->lang = true;
|
||||
$this->explicitSelect = true;
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
if (!Tools::getValue('id_product'))
|
||||
@@ -72,84 +73,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
|
||||
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
|
||||
$this->fields_list = array();
|
||||
$this->fields_list['id_product'] = array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 20
|
||||
);
|
||||
$this->fields_list['image'] = array(
|
||||
'title' => $this->l('Photo'),
|
||||
'align' => 'center',
|
||||
'image' => 'p',
|
||||
'width' => 70,
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false
|
||||
);
|
||||
$this->fields_list['name'] = array(
|
||||
'title' => $this->l('Name'),
|
||||
'filter_key' => 'b!name'
|
||||
);
|
||||
$this->fields_list['reference'] = array(
|
||||
'title' => $this->l('Reference'),
|
||||
'align' => 'left',
|
||||
'width' => 80
|
||||
);
|
||||
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
|
||||
$this->fields_list['shopname'] = array(
|
||||
'title' => $this->l('Default Shop'),
|
||||
'width' => 230,
|
||||
'filter_key' => 'shop!name',
|
||||
);
|
||||
else
|
||||
$this->fields_list['name_category'] = array(
|
||||
'title' => $this->l('Category'),
|
||||
'width' => 230,
|
||||
'filter_key' => 'cl!name',
|
||||
);
|
||||
$this->fields_list['price'] = array(
|
||||
'title' => $this->l('Base price'),
|
||||
'width' => 90,
|
||||
'type' => 'price',
|
||||
'align' => 'right',
|
||||
'filter_key' => 'a!price'
|
||||
);
|
||||
$this->fields_list['price_final'] = array(
|
||||
'title' => $this->l('Final price'),
|
||||
'width' => 90,
|
||||
'type' => 'price',
|
||||
'align' => 'right',
|
||||
'havingFilter' => true,
|
||||
'orderby' => false
|
||||
);
|
||||
$this->fields_list['sav_quantity'] = array(
|
||||
'title' => $this->l('Quantity'),
|
||||
'width' => 90,
|
||||
'align' => 'right',
|
||||
'filter_key' => 'sav!quantity',
|
||||
'orderby' => true,
|
||||
'hint' => $this->l('This is the quantity available in the current shop/group'),
|
||||
);
|
||||
$this->fields_list['active'] = array(
|
||||
'title' => $this->l('Displayed'),
|
||||
'width' => 70,
|
||||
'active' => 'status',
|
||||
'filter_key' => 'sa!active',
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
);
|
||||
if ((int)Tools::getValue('id_category'))
|
||||
$this->fields_list['position'] = array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 70,
|
||||
'filter_key' => 'cp!position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
);
|
||||
|
||||
|
||||
// @since 1.5 : translations for tabs
|
||||
$this->available_tabs_lang = array (
|
||||
'Informations' => $this->l('Information'),
|
||||
@@ -250,7 +173,86 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->_where .= ' AND ((image_shop.id_image IS NOT NULL OR i.id_image IS NULL) OR (image_shop.id_image IS NULL AND i.cover=1))';
|
||||
else
|
||||
$this->_where .= ' AND (i.cover=1 OR i.id_image IS NULL)';
|
||||
|
||||
$this->fields_list = array();
|
||||
$this->fields_list['id_product'] = array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 20
|
||||
);
|
||||
$this->fields_list['image'] = array(
|
||||
'title' => $this->l('Photo'),
|
||||
'align' => 'center',
|
||||
'image' => 'p',
|
||||
'width' => 70,
|
||||
'orderby' => false,
|
||||
'filter' => false,
|
||||
'search' => false
|
||||
);
|
||||
$this->fields_list['name'] = array(
|
||||
'title' => $this->l('Name'),
|
||||
'filter_key' => 'b!name'
|
||||
);
|
||||
$this->fields_list['reference'] = array(
|
||||
'title' => $this->l('Reference'),
|
||||
'align' => 'left',
|
||||
'width' => 80
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP)
|
||||
$this->fields_list['shopname'] = array(
|
||||
'title' => $this->l('Default Shop'),
|
||||
'width' => 230,
|
||||
'filter_key' => 'shop!name',
|
||||
);
|
||||
else
|
||||
$this->fields_list['name_category'] = array(
|
||||
'title' => $this->l('Category'),
|
||||
'width' => 230,
|
||||
'filter_key' => 'cl!name',
|
||||
);
|
||||
$this->fields_list['price'] = array(
|
||||
'title' => $this->l('Base price'),
|
||||
'width' => 90,
|
||||
'type' => 'price',
|
||||
'align' => 'right',
|
||||
'filter_key' => 'a!price'
|
||||
);
|
||||
$this->fields_list['price_final'] = array(
|
||||
'title' => $this->l('Final price'),
|
||||
'width' => 90,
|
||||
'type' => 'price',
|
||||
'align' => 'right',
|
||||
'havingFilter' => true,
|
||||
'orderby' => false
|
||||
);
|
||||
$this->fields_list['sav_quantity'] = array(
|
||||
'title' => $this->l('Quantity'),
|
||||
'width' => 90,
|
||||
'align' => 'right',
|
||||
'filter_key' => 'sav!quantity',
|
||||
'orderby' => true,
|
||||
'hint' => $this->l('This is the quantity available in the current shop/group'),
|
||||
);
|
||||
$this->fields_list['active'] = array(
|
||||
'title' => $this->l('Displayed'),
|
||||
'width' => 70,
|
||||
'active' => 'status',
|
||||
'filter_key' => $alias.'!active',
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
);
|
||||
if ((int)Tools::getValue('id_category'))
|
||||
$this->fields_list['position'] = array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 70,
|
||||
'filter_key' => 'cp!position',
|
||||
'align' => 'center',
|
||||
'position' => 'position'
|
||||
);
|
||||
}
|
||||
|
||||
protected function _cleanMetaKeywords($keywords)
|
||||
{
|
||||
if (!empty($keywords) && $keywords != '')
|
||||
|
||||
Reference in New Issue
Block a user