//SupplierController+ManufacturerController : Refacto done
This commit is contained in:
1 parent
fc71efe424
commit
8cb0d06446
2 files changed
+29
-17
No files matched your search
@@ -42,6 +42,10 @@ class ManufacturerControllerCore extends FrontController
|
|||||||
parent::canonicalRedirection($this->context->link->getManufacturerLink($this->manufacturer));
|
parent::canonicalRedirection($this->context->link->getManufacturerLink($this->manufacturer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize manufaturer controller
|
||||||
|
* @see FrontController::init()
|
||||||
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
@@ -63,6 +67,22 @@ class ManufacturerControllerCore extends FrontController
|
|||||||
public function process()
|
public function process()
|
||||||
{
|
{
|
||||||
if (Validate::isLoadedObject($this->manufacturer) AND $this->manufacturer->active AND $this->manufacturer->isAssociatedToGroupShop())
|
if (Validate::isLoadedObject($this->manufacturer) AND $this->manufacturer->active AND $this->manufacturer->isAssociatedToGroupShop())
|
||||||
|
{
|
||||||
|
$this->productSort();
|
||||||
|
$this->assignOne();
|
||||||
|
$this->setTemplate(_PS_THEME_DIR_.'manufacturer.tpl');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->assignAll();
|
||||||
|
$this->setTemplate(_PS_THEME_DIR_.'manufacturer-list.tpl');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign template vars if displaying one manufacturer
|
||||||
|
*/
|
||||||
|
protected function assignOne()
|
||||||
{
|
{
|
||||||
$nbProducts = $this->manufacturer->getProducts($this->manufacturer->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
|
$nbProducts = $this->manufacturer->getProducts($this->manufacturer->id, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true);
|
||||||
$this->pagination((int)$nbProducts);
|
$this->pagination((int)$nbProducts);
|
||||||
@@ -71,10 +91,12 @@ class ManufacturerControllerCore extends FrontController
|
|||||||
'products' => $this->manufacturer->getProducts($this->manufacturer->id, $this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
|
'products' => $this->manufacturer->getProducts($this->manufacturer->id, $this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay),
|
||||||
'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
|
'path' => ($this->manufacturer->active ? Tools::safeOutput($this->manufacturer->name) : ''),
|
||||||
'manufacturer' => $this->manufacturer));
|
'manufacturer' => $this->manufacturer));
|
||||||
|
|
||||||
$this->setTemplate(_PS_THEME_DIR_.'manufacturer.tpl');
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
/**
|
||||||
|
* Assign template vars if displaying the manufacturer list
|
||||||
|
*/
|
||||||
|
protected function assignAll()
|
||||||
{
|
{
|
||||||
if (Configuration::get('PS_DISPLAY_SUPPLIERS'))
|
if (Configuration::get('PS_DISPLAY_SUPPLIERS'))
|
||||||
{
|
{
|
||||||
@@ -98,14 +120,5 @@ class ManufacturerControllerCore extends FrontController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
$this->context->smarty->assign('nbManufacturers', 0);
|
$this->context->smarty->assign('nbManufacturers', 0);
|
||||||
|
|
||||||
$this->setTemplate(_PS_THEME_DIR_.'manufacturer-list.tpl');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function displayHeader($display = true)
|
|
||||||
{
|
|
||||||
parent::displayHeader();
|
|
||||||
$this->productSort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,18 +73,17 @@ class SupplierControllerCore extends FrontController
|
|||||||
public function process()
|
public function process()
|
||||||
{
|
{
|
||||||
if (Validate::isLoadedObject($this->supplier) && $this->supplier->active && $this->supplier->isAssociatedToGroupShop())
|
if (Validate::isLoadedObject($this->supplier) && $this->supplier->active && $this->supplier->isAssociatedToGroupShop())
|
||||||
$this->assignOne();
|
|
||||||
else if (!Tools::getValue('id_supplier'))
|
|
||||||
$this->assignAll();
|
|
||||||
|
|
||||||
if ($this->supplier)
|
|
||||||
{
|
{
|
||||||
|
$this->assignOne();
|
||||||
$this->productSort();
|
$this->productSort();
|
||||||
$this->setTemplate(_PS_THEME_DIR_.'supplier.tpl');
|
$this->setTemplate(_PS_THEME_DIR_.'supplier.tpl');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
$this->assignAll();
|
||||||
$this->setTemplate(_PS_THEME_DIR_.'supplier-list.tpl');
|
$this->setTemplate(_PS_THEME_DIR_.'supplier-list.tpl');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign template vars if displaying one supplier
|
* Assign template vars if displaying one supplier
|
||||||
|
|||||||
Reference in new issue
Block a user