name = 'categoryfamily'; $this->tab = 'administration'; $this->author = 'Antadis'; $this->version = '1.0'; parent::__construct(); $this->displayName = $this->l('Category Family'); $this->description = $this->l('Associate Family to Category'); } public function install() { if(!parent::install() OR !$this->registerHook('categoryAddition') OR !$this->registerHook('categoryDeletion') OR !$this->registerHook('categoryUpdate')) { return FALSE; } return TRUE; } public function hookcategoryAddition($params) { self::setAssociations($params['category'], Tools::getValue('family')); } public function hookcategoryDeletion($params) { CategoryFamilyCore::deleteAssociations($params['category']->id); } public function hookcategoryUpdate($params) { self::setAssociations($params['category'], Tools::getValue('family')); } public static function setAssociations($category, $family) { if (!Validate::isLoadedObject($category)) { return FALSE; } $family = Tools::getValue('family'); if (!empty($family)) { CategoryFamilyCore::addAssociations($category->id, $family); } } }