예제 #1
0
 public function add($autodate = true, $null_values = false)
 {
     if (Tools::isSubmit('submitAddcategoryAndBackToParent')) {
         $checked_artists_id = array();
         foreach ($_POST as $key => $val) {
             $hasString = strpos($key, 'related_artists');
             if ($hasString !== false) {
                 $checked_artists_id[] = $val;
             }
         }
         $serialize_artists = serialize($checked_artists_id);
         $this->related_artists[1] = $serialize_artists;
     }
     if (!isset($this->level_depth)) {
         $this->level_depth = $this->calcLevelDepth();
     }
     if ($this->is_root_category && ($id_root_category = (int) Configuration::get('PS_ROOT_CATEGORY'))) {
         $this->id_parent = $id_root_category;
     }
     $ret = parent::add($autodate, $null_values);
     if (Tools::isSubmit('checkBoxShopAsso_category')) {
         foreach (Tools::getValue('checkBoxShopAsso_category') as $id_shop => $value) {
             $position = Category::getLastPosition((int) $this->id_parent, $id_shop);
             $this->addPosition($position, $id_shop);
         }
     } else {
         foreach (Shop::getShops(true) as $shop) {
             $position = Category::getLastPosition((int) $this->id_parent, $shop['id_shop']);
             if (!$position) {
                 $position = 1;
             }
             $this->addPosition($position, $shop['id_shop']);
         }
     }
     if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree) {
         Category::regenerateEntireNtree();
     }
     $this->updateGroup($this->groupBox);
     Hook::exec('actionCategoryAdd', array('category' => $this));
     return $ret;
 }
예제 #2
0
 public function add($autodate = true, $null_values = false)
 {
     if (!isset($this->level_depth)) {
         $this->level_depth = $this->calcLevelDepth();
     }
     if ($this->is_root_category && ($id_root_category = (int) Configuration::get('PS_ROOT_CATEGORY'))) {
         $this->id_parent = $id_root_category;
     }
     $ret = parent::add($autodate, $null_values);
     if (Tools::isSubmit('checkBoxShopAsso_category')) {
         foreach (Tools::getValue('checkBoxShopAsso_category') as $id_shop => $value) {
             $position = (int) Category::getLastPosition((int) $this->id_parent, $id_shop);
             $this->addPosition($position, $id_shop);
         }
     } else {
         foreach (Shop::getShops(true) as $shop) {
             $position = (int) Category::getLastPosition((int) $this->id_parent, $shop['id_shop']);
             $this->addPosition($position, $shop['id_shop']);
         }
     }
     if (!isset($this->doNotRegenerateNTree) || !$this->doNotRegenerateNTree) {
         Category::regenerateEntireNtree();
     }
     $this->updateGroup($this->groupBox);
     Hook::exec('actionCategoryAdd', array('category' => $this));
     return $ret;
 }