示例#1
0
 public function shortSearch($params)
 {
     $query = Product::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'sku', $this->sku])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#2
0
 public function getProduct()
 {
     return $this->hasOne(Product::className(), ['sku' => 'item_sku']);
 }
示例#3
0
 /**
  * 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.');
     }
 }
示例#4
0
<?php

use yii\jui\AutoComplete;
use frontend\models\products\Product;
?>

 <div class="row">
	<div class="col-xs-12 col-sm-8">
		<div class="input-group">
			<span class="input-group-addon">
				<i class="ace-icon fa fa-cube"></i>
			</span>
 <?php 
$this->registerCss('.ui-autocomplete{z-index:1060}');
$mainSKUs = Product::find()->where(['is not', 'stock_qty', null])->andWhere(['qty_per_order' => 1])->asArray()->indexBy('sku')->all();
echo AutoComplete::widget(['name' => 'main-sku', 'clientOptions' => ['source' => array_keys($mainSKUs)], 'options' => ['class' => 'form-control search-query', 'placeholder' => 'Put the main product SKU', 'id' => 'main-sku']]);
?>
  <span class="input-group-btn">
				<button type="button" class="btn btn-purple btn-sm" id="link-product">
					<span class="ace-icon fa fa-link icon-on-right bigger-110"></span>
					Link
				</button>
			</span>
		</div>
	</div>
</div>



			
示例#5
0
 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;
     }
 }
示例#6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSub0()
 {
     return $this->hasOne(Product::className(), ['id' => 'sub']);
 }
示例#7
0
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios['batch'] = ['sku', 'mini_desc', 'name', 'weight', 'description', 'specs', 'comment', 'supplier_id', 'is_trackable', 'stock_location', 'cost', 'category_id', 'qty_per_order', 'main_image'];
     return $scenarios;
 }