/**
  * @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
 /**
  * @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;
     }
 }
示例#3
0
 public function postProductToFacebook($productId, $descPost, $images, $userId)
 {
     $productModel = new productModel();
     $userSocialModel = new userSocialModel();
     $util = new Util();
     $socialAccount = $userSocialModel->getItem($userId, KACANA_SOCIAL_TYPE_FACEBOOK);
     $facebook = $util->initFacebook();
     $facebook->setDefaultAccessToken($socialAccount->token);
     $product = $productModel->getProductById($productId);
     if (!$product) {
         throw new \Exception('BAD Product ID');
     }
     $galleries = $product->galleries;
     $arrayFbMedia = [];
     foreach ($galleries as $gallery) {
         if (in_array($gallery->id, $images)) {
             array_push($arrayFbMedia, $facebook->postPhoto('http:' . AWS_CDN_URL . str_replace(' ', '%20', $gallery->getOriginal('image')), $product->name));
         }
     }
     return $facebook->postFeed($arrayFbMedia, $descPost);
 }