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);
 }