[*] BO: store filter by category in admin products
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
if (this.value !== "")
|
if (this.value !== "")
|
||||||
location.href = base_url + '&id_category=' + parseInt(this.value);
|
location.href = base_url + '&id_category=' + parseInt(this.value);
|
||||||
else
|
else
|
||||||
location.href = base_url;
|
location.href = base_url + '&reset_filter_category=1';
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure the checkbox is checked/unchecked when the link is clicked
|
// Make sure the checkbox is checked/unchecked when the link is clicked
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$(this).find('input').removeAttr('checked');
|
$(this).find('input').removeAttr('checked');
|
||||||
location.href = base_url;
|
location.href = base_url + '&reset_filter_category=1';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
|
|
||||||
protected $submitted_tabs;
|
protected $submitted_tabs;
|
||||||
|
|
||||||
|
protected $id_current_category;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->table = 'product';
|
$this->table = 'product';
|
||||||
@@ -122,17 +124,28 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$this->available_tabs_lang['Module'.ucfirst($m['module'])] = Module::getModuleName($m['module']);
|
$this->available_tabs_lang['Module'.ucfirst($m['module'])] = Module::getModuleName($m['module']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Tools::getValue('reset_filter_category'))
|
||||||
|
$this->context->cookie->id_category_products_filter = false;
|
||||||
/* Join categories table */
|
/* Join categories table */
|
||||||
if ($id_category = (int)Tools::getValue('productFilter_cl!name'))
|
if ($id_category = (int)Tools::getValue('productFilter_cl!name'))
|
||||||
{
|
{
|
||||||
$this->_category = new Category((int)$id_category);
|
$this->_category = new Category((int)$id_category);
|
||||||
$_POST['productFilter_cl!name'] = $this->_category->name[$this->context->language->id];
|
$_POST['productFilter_cl!name'] = $this->_category->name[$this->context->language->id];
|
||||||
}
|
}
|
||||||
elseif ($id_category = Tools::getvalue('id_category'))
|
|
||||||
$this->_category = new Category((int)$id_category);
|
|
||||||
else
|
else
|
||||||
$this->_category = new Category();
|
{
|
||||||
|
if ($id_category = (int)Tools::getValue('id_category'))
|
||||||
|
{
|
||||||
|
$this->id_current_category = $id_category;
|
||||||
|
$this->context->cookie->id_category_products_filter = $id_category;
|
||||||
|
}
|
||||||
|
elseif ($id_category = $this->context->cookie->id_category_products_filter)
|
||||||
|
$this->id_current_category = $id_category;
|
||||||
|
if ($this->id_current_category)
|
||||||
|
$this->_category = new Category((int)$this->id_current_category);
|
||||||
|
else
|
||||||
|
$this->_category = new Category();
|
||||||
|
}
|
||||||
|
|
||||||
$join_category = false;
|
$join_category = false;
|
||||||
if (Validate::isLoadedObject($this->_category) && empty($this->_filter))
|
if (Validate::isLoadedObject($this->_category) && empty($this->_filter))
|
||||||
@@ -242,7 +255,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'orderby' => false
|
'orderby' => false
|
||||||
);
|
);
|
||||||
if ((int)Tools::getValue('id_category'))
|
|
||||||
|
if ((int)$this->id_current_category)
|
||||||
$this->fields_list['position'] = array(
|
$this->fields_list['position'] = array(
|
||||||
'title' => $this->l('Position'),
|
'title' => $this->l('Position'),
|
||||||
'width' => 70,
|
'width' => 70,
|
||||||
@@ -2127,8 +2141,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($id_category = (int)Tools::getValue('id_category'))
|
if ($id_category = (int)$this->id_current_category)
|
||||||
self::$currentIndex .= '&id_category='.(int)$id_category;
|
self::$currentIndex .= '&id_category='.(int)$this->id_current_category;
|
||||||
|
|
||||||
// If products from all categories are displayed, we don't want to use sorting by position
|
// If products from all categories are displayed, we don't want to use sorting by position
|
||||||
if (!$id_category)
|
if (!$id_category)
|
||||||
@@ -2140,8 +2154,9 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
unset($this->context->cookie->{$this->table.'Orderway'});
|
unset($this->context->cookie->{$this->table.'Orderway'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$id_category = (int)Tools::getValue('id_category', 1);
|
if (!$id_category)
|
||||||
$this->tpl_list_vars['is_category_filter'] = Tools::getValue('id_category') ? true : false;
|
$id_category = 1;
|
||||||
|
$this->tpl_list_vars['is_category_filter'] = (bool)$this->id_current_category;
|
||||||
|
|
||||||
// Generate category selection tree
|
// Generate category selection tree
|
||||||
$helper = new Helper();
|
$helper = new Helper();
|
||||||
|
|||||||
@@ -87,19 +87,11 @@ class ProductControllerCore extends FrontController
|
|||||||
{
|
{
|
||||||
header('HTTP/1.1 404 Not Found');
|
header('HTTP/1.1 404 Not Found');
|
||||||
header('Status: 404 Not Found');
|
header('Status: 404 Not Found');
|
||||||
|
$this->errors[] = Tools::displayError('Product not found');
|
||||||
}
|
}
|
||||||
else
|
|
||||||
$this->canonicalRedirection();
|
|
||||||
|
|
||||||
if (!Validate::isLoadedObject($this->product))
|
|
||||||
$this->errors[] = Tools::displayError('Product not found');
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Pack::isPack((int)$this->product->id) && !Pack::isInStock((int)$this->product->id))
|
$this->canonicalRedirection();
|
||||||
$this->product->quantity = 0;
|
|
||||||
|
|
||||||
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the product is associated to the shop
|
* If the product is associated to the shop
|
||||||
* and is active or not active but preview mode (need token + file_exists)
|
* and is active or not active but preview mode (need token + file_exists)
|
||||||
@@ -181,11 +173,14 @@ class ProductControllerCore extends FrontController
|
|||||||
|
|
||||||
if (!$this->errors)
|
if (!$this->errors)
|
||||||
{
|
{
|
||||||
|
if (Pack::isPack((int)$this->product->id) && !Pack::isInStock((int)$this->product->id))
|
||||||
|
$this->product->quantity = 0;
|
||||||
|
|
||||||
|
$this->product->description = $this->transformDescriptionWithImg($this->product->description);
|
||||||
|
|
||||||
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
|
// Assign to the template the id of the virtual product. "0" if the product is not downloadable.
|
||||||
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)$this->product->id));
|
$this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)$this->product->id));
|
||||||
|
|
||||||
// Product pictures management
|
|
||||||
require_once('images.inc.php');
|
|
||||||
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
$this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
|
||||||
|
|
||||||
if (Tools::isSubmit('submitCustomizedDatas'))
|
if (Tools::isSubmit('submitCustomizedDatas'))
|
||||||
@@ -204,15 +199,21 @@ class ProductControllerCore extends FrontController
|
|||||||
else if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture')))
|
else if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture')))
|
||||||
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
|
$this->errors[] = Tools::displayError('An error occurred while deleting the selected picture');
|
||||||
|
|
||||||
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
|
|
||||||
$pictures = array();
|
|
||||||
foreach ($files as $file)
|
|
||||||
$pictures['pictures_'.$this->product->id.'_'.$file['index']] = $file['value'];
|
|
||||||
|
|
||||||
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
|
$pictures = array();
|
||||||
$text_fields = array();
|
$text_fields = array();
|
||||||
foreach ($texts as $text_field)
|
if ($this->product->customizable)
|
||||||
$text_fields['textFields_'.$this->product->id.'_'.$text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
|
{
|
||||||
|
$files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
|
||||||
|
foreach ($files as $file)
|
||||||
|
$pictures['pictures_'.$this->product->id.'_'.$file['index']] = $file['value'];
|
||||||
|
|
||||||
|
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
|
||||||
|
|
||||||
|
foreach ($texts as $text_field)
|
||||||
|
$text_fields['textFields_'.$this->product->id.'_'.$text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
|
||||||
|
}
|
||||||
|
|
||||||
$this->context->smarty->assign(array(
|
$this->context->smarty->assign(array(
|
||||||
'pictures' => $pictures,
|
'pictures' => $pictures,
|
||||||
'textFields' => $text_fields));
|
'textFields' => $text_fields));
|
||||||
|
|||||||
Reference in New Issue
Block a user