コード例 #1
0
 protected function findModel($product_id, $ebay_account_id)
 {
     if (($model = ListingImages::findOne(['product_id' => $product_id, 'ebay_account_id' => $ebay_account_id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #2
0
ファイル: ListingController.php プロジェクト: sea129/kbay
 public function actionReviseOneItem()
 {
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $post = Yii::$app->request->post();
         $ebayListing = new EbayListing($post['ebayID']);
         $listing = Listing::find()->where(['item_id' => $post['itemID']])->one();
         if ($listing == null) {
             return false;
         }
         $listingItem = new ApiListingItem();
         $listingItem->item_id = $listing->item_id;
         $listingItem->title = $post['title'];
         $listingItem->qty = $post['qty'];
         $listingItem->price = $post['price'];
         $listingItem->shippingCost = $post['shipping'];
         $listingItem->shippingExpressCost = $post['expressShipping'];
         $product = Product::findOne(['sku' => $listing->sku]);
         $ebayAccount = EbayAccount::findOne($post['ebayID']);
         $lstImages = ListingImages::findOne(['product_id' => $product->id, 'ebay_account_id' => $post['ebayID']]);
         $listingImages = ['http://i.imgur.com/roXpiR8.png'];
         if ($lstImages) {
             $listingImages = json_decode($lstImages->image_url);
         }
         $listingItem->description = $this->renderFile(Yii::$app->params['listingTemplatePath'] . $ebayAccount->listingTemplate->name . '.php', ['ebayAcc' => $ebayAccount, 'product' => $product, 'lstImages' => $listingImages]);
         $result = $ebayListing->reviseItem($listingItem);
         if (isset($result['itemID']) && !isset($result['error'])) {
             $result['status'] = 'success';
             $result['message'] = "Item: " . $result['itemID'] . " revised";
         } else {
             $result['status'] = 'failed';
             $result['message'] = "Item: " . $result['itemID'] . " NOT revised";
         }
         return $result;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: ProductController.php プロジェクト: sea129/kbay
 public function actionUpdateLstImgInfo()
 {
     if (Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $post = Yii::$app->request->post();
         //return $post;
         $lstImages = ListingImages::findOne(['product_id' => $post['productID'], 'ebay_account_id' => $post['ebayID']]);
         if (empty($post['listingImages']) && $lstImages->delete()) {
             return true;
         }
         if ($lstImages != null) {
             $lstImages->image_url = json_encode($post['listingImages']);
             if ($lstImages->save()) {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
コード例 #4
0
ファイル: Product.php プロジェクト: sea129/kbay
 public function getEbayLstImgs()
 {
     return $ebayLstImgs = ListingImages::find()->allOfProduct($this->id);
 }