Пример #1
0
 /**
  * Update categories for a shop
  *
  * @param string $categories Categories list to associate a shop
  * @param string $shop_id Categories list to associate a shop
  * @return array Update/insertion result
  */
 public static function updateFromShop($categories, $shop_id)
 {
     $shop = new JeproshopShopModelShop($shop_id);
     // if array is empty or if the default category is not selected, return false
     if (!is_array($categories) || !count($categories) || !in_array($shop->category_id, $categories)) {
         return false;
     }
     // delete categories for this shop
     JeproshopCategoryModelCategory::deleteCategoriesFromShop($shop_id);
     // and add $categories to this shop
     return JeproshopCategoryModelCategory::addToShop($categories, $shop_id);
 }