/**
  * @param $id
  * @param $imageName
  * @param $type
  * @return productGalleryModel
  */
 public function addProductImage($id, $imageName, $type)
 {
     $productGallery = new productGalleryModel();
     $productModel = new productModel();
     $prefixPath = '/images/product/';
     $product = $productModel->getProductById($id, false);
     $thumbPath = '';
     $newThumbPath = '';
     $imageNameFinal = explode('.', $imageName);
     $typeImage = $imageNameFinal[count($imageNameFinal) - 1];
     if ($type == PRODUCT_IMAGE_TYPE_SLIDE) {
         $newThumbPath = $prefixPath . $product->name . ' thumb ' . crc32($imageName) . '.' . $typeImage;
         $thumbPath = str_replace(PATH_PUBLIC, '', $this->createThumbnail(PATH_PUBLIC . $imageName, 80, 80, [255, 255, 255]));
         $this->uploadToS3($thumbPath, $newThumbPath);
     }
     $newImageName = $prefixPath . $product->name . ' ' . crc32($imageName) . '.' . $typeImage;
     $return = $productGallery->addProductImage($id, $newImageName, $newThumbPath, $type);
     $this->uploadToS3($imageName, $newImageName);
     return $return;
 }
示例#2
0
 /**
  * create Base product
  *
  * @param $item
  * @return bool
  */
 public function createBaseProduct($item)
 {
     $product = new productModel();
     $product->name = $item['name'];
     $product->price = $item['price'];
     $product->sell_price = $item['sell_price'];
     $product->status = KACANA_PRODUCT_STATUS_INACTIVE;
     $product->created = date('Y-m-d H:i:s');
     $product->updated = date('Y-m-d H:i:s');
     return $product->save();
 }
示例#3
0
 /**
  * @param $userId
  * @param $productId
  * @return bool
  */
 public function isValidProduct($userId, $productId)
 {
     $productModel = new productModel();
     $product = $productModel->getProductById($productId, false);
     if ($product->boot_priority > 0) {
         return true;
     } else {
         return false;
     }
 }
示例#4
0
 public function getProductsToBoot($productIds, $userId)
 {
     $productModel = new productModel();
     $util = new Util();
     $google = $util->initGoogle();
     if (!count($productIds)) {
         throw new \Exception('BAD Product ID');
     }
     $products = $productModel->getProductsToBoot($productIds);
     foreach ($products as &$product) {
         $product->list_gallery = $product->galleries;
         $product->price = 0;
         $product->caption = '👝👜👛' . ucfirst($product->name) . '<br>🤑Giá: ' . formatMoney($product->sell_price - $product->discount) . '<br>🎒👝💼' . $product->short_description;
         $product->sell_price = formatMoney($product->sell_price);
     }
     return $products;
 }