Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ItemProp::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['prop_id' => $this->prop_id, 'category_id' => $this->category_id, 'parent_prop_id' => $this->parent_prop_id, 'parent_value_id' => $this->parent_value_id, 'type' => $this->type, 'is_key_prop' => $this->is_key_prop, 'is_sale_prop' => $this->is_sale_prop, 'is_color_prop' => $this->is_color_prop, 'must' => $this->must, 'multi' => $this->multi, 'status' => $this->status, 'sort_order' => $this->sort_order]);
     $query->andFilterWhere(['like', 'prop_name', $this->prop_name])->andFilterWhere(['like', 'prop_alias', $this->prop_alias]);
     return $dataProvider;
 }
Exemplo n.º 2
0
}
?>
">
        <table class="description_table type_2 m_bottom_15">

            <!-- Price Starts -->
<!--            <div class="deal_price">-->
<!--                <span class="cor_gray">市场价:<strong>--><?php 
//echo  $itemModel->price
?>
<!--</strong>元</span>-->
<!--            </div>-->

                <?php 
$itemProps = $propValues = array();
$itemPropModels = \star\catalog\models\ItemProp::find()->where(['category_id' => $itemModel->category_id])->all();
foreach ($itemPropModels as $itemProp) {
    $itemProps[$itemProp->prop_id] = $itemProp;
    foreach ($itemProp->propValues as $propValue) {
        $propValues[$propValue->value_id] = $propValue;
    }
}
$pvids = json_decode($itemModel->props);
foreach ($pvids as $pid => $pvid) {
    if (isset($itemProps[$pid]) && $itemProps[$pid]->is_sale_prop) {
        $itemProp = $itemProps[$pid];
        ?>
                        <tr><td class="v_align_m"><?php 
        echo $itemProp->prop_name;
        ?>
:</td>
Exemplo n.º 3
0
<div id="item_prop_values">
    <?php 
use yii\helpers\Html;
if ($model && $model->props) {
    $itemPropValues = json_decode($model->props, true);
}
if (!isset($itemProps)) {
    $itemProps = \star\catalog\models\ItemProp::findAll(['category_id' => $tree_id]);
}
$i = 0;
/** @var \star\catalog\models\ItemProp $itemProp */
foreach ($itemProps as $itemProp) {
    if (!$itemProp->is_sale_prop) {
        $propValues = $itemProp->propValues;
        $propValueData = array();
        foreach ($propValues as $propValue) {
            $propValueData[$propValue->value_id] = $propValue->value_name;
        }
        $itemPropValue = '';
        if (isset($itemPropValues[$itemProp->prop_id])) {
            if (is_array($itemPropValues[$itemProp->prop_id])) {
                $itemPropValue = array();
                foreach ($itemPropValues[$itemProp->prop_id] as $value) {
                    $values = explode(':', $value);
                    $itemPropValue[] = $values[1];
                }
            } else {
                $values = explode(':', $itemPropValues[$itemProp->prop_id]);
                $itemPropValue = $values[1];
            }
        }
Exemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProp()
 {
     return $this->hasOne(ItemProp::className(), ['prop_id' => 'prop_id']);
 }
Exemplo n.º 5
0
 /**
  * format item prop data to json format from post
  * @param $itemProps
  * @return array
  * @author Lujie.Zhou(gao_lujie@live.cn, qq:821293064).
  */
 protected function handleItemProps($itemProps)
 {
     $props = array();
     $props_name = array();
     foreach ($itemProps as $pid => $vid) {
         $itemProp = Yii::createObject(ItemProp::className());
         $itemProp = $itemProp::findOne(['prop_id' => $pid]);
         $pname = $itemProp->prop_name;
         if (is_array($vid)) {
             $props[$pid] = array();
             $props_name[$pname] = array();
             foreach ($vid as $v) {
                 $props[$pid][] = $pid . ':' . $v;
                 $propValue = Yii::createObject(PropValue::className());
                 $propValue = $propValue::findOne(['value_id' => $v]);
                 $vname = $propValue ? $propValue->value_name : $v;
                 $props_name[$pname][] = $pname . ':' . $vname;
             }
         } else {
             $props[$pid] = $pid . ':' . $vid;
             $propValue = Yii::createObject(PropValue::className());
             $propValue = $propValue::findOne(['value_id' => $vid]);
             $vname = $propValue ? $propValue->value_name : $vid;
             $props_name[$pname] = $pname . ':' . $vname;
         }
     }
     return array(json_encode($props), json_encode($props_name));
 }
Exemplo n.º 6
0
 /**
  * Finds the ItemProp model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ItemProp the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ItemProp::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 7
0
 /**
  * Finds the ItemProp model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ItemProp the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     $itemProp = Yii::createObject(ItemProp::className());
     if (($model = $itemProp::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }