Ejemplo n.º 1
0
 public function actionCategories()
 {
     self::actionDisableproducts();
     $url = 'http://mccreative.jaspersonline.co.uk/api/products/getCategories';
     $data = DynamicCall::getData($url);
     if (!$data->count) {
         throw new CHttpException(403, 'category is empty');
     }
     DynamicCall::syncCat($data->data);
 }
Ejemplo n.º 2
0
 public static function syncProd($cat_id, $pid)
 {
     if (!$cat_id) {
         return false;
     }
     if (!$pid) {
         $url = 'http://mccreative.jaspersonline.co.uk/api/products/getCatPro/' . $cat_id;
     } else {
         $url = 'http://mccreative.jaspersonline.co.uk/api/products/getModrenCatPro/' . $cat_id;
     }
     $products = DynamicCall::getData($url);
     if (!$products->count) {
         return false;
     }
     foreach ($products->data as $product) {
         $pro = Product::model()->findByPk($product->id);
         if (!$pro) {
             $pro = new Product();
             $pro->id = $product->id;
         }
         $pro->name = $product->name;
         $pro->desc = $product->description;
         $pro->cat_id = $product->jcid;
         $pro->per100g = $product->per100g;
         $pro->allergies = $product->allergies;
         $pro->ingredients = $product->ingridients;
         $pro->pic = "http://bmsdev.jaspersonline.co.uk/store/products/order_images/{$pro->id}.jpg";
         $pro->save();
         mErrors($pro, 0);
     }
 }