Example #1
0
 /**
  * Update categories for a shop
  *
  * @param string $categories Categories list to associate a shop
  * @param string $id_shop Categories list to associate a shop
  * @return array Update/insertion result
  */
 public static function updateFromShop($categories, $id_shop)
 {
     $shop = new Shop($id_shop);
     // if array is empty or if the default category is not selected, return false
     if (!is_array($categories) || !count($categories) || !in_array($shop->id_category, $categories)) {
         return false;
     }
     // delete categories for this shop
     Category::deleteCategoriesFromShop($id_shop);
     // and add $categories to this shop
     return Category::addToShop($categories, $id_shop);
 }
 public function processDelete()
 {
     if (!Validate::isLoadedObject($object = $this->loadObject())) {
         $this->errors[] = Tools::displayError('Unable to load this shop.');
     } else {
         if (!Shop::hasDependency($object->id)) {
             $result = Category::deleteCategoriesFromShop($object->id) && parent::processDelete();
             Tools::generateHtaccess();
             return $result;
         } else {
             $this->errors[] = Tools::displayError('You can\'t delete this shop (customer and/or order dependency).');
         }
     }
     return false;
 }