コード例 #1
0
ファイル: BatchProduct.php プロジェクト: sea129/kbay
 public function __construct($id = null)
 {
     parent::__construct();
     if ($id == null) {
         //throw new NotFoundHttpException('NOT valid main product.');
     } else {
         $mainProduct = Product::findOne($id);
         if ($mainProduct->stock_qty == null || $mainProduct->qty_per_order != 1) {
             throw new NotFoundHttpException('NOT valid main product.');
         } else {
             //$this->setAttributes($mainProduct->getAttributes());
             $this->scenario = 'batch';
             $this->attributes = $mainProduct->getAttributes();
             $this->qty_per_order = 2;
             $this->stock_qty = null;
         }
     }
 }
コード例 #2
0
ファイル: ProductController.php プロジェクト: sea129/kbay
 /**
  * Finds the Product model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Product the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Product::findOne($id)) !== null && Yii::$app->user->can('ebaycontrol', ['userID' => $model->user_id])) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
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;
     }
 }