コード例 #1
0
 public function init($categoryId, $limit, $sort)
 {
     $this->categoryId = $categoryId;
     $this->limit = $limit;
     $this->sort = $sort;
     $this->products = array();
     $productDa = new ProductDa();
     $productsGet = $productDa->getProductByCategorySort($this->categoryId, $sort, $limit);
     if (isset($productsGet) && count($productsGet) >= 3) {
         foreach ($productsGet as $product) {
             $productStd = new ProductItemModel();
             $productStd->init($product);
             array_push($this->products, $productStd);
         }
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: ProductDetailModel.php プロジェクト: hopdq/taka
 public function init()
 {
     if (isset($this->productId)) {
         $productDa = new ProductDa();
         $this->detail = $productDa->getProductDetail($this->productId);
         $imageDa = new ImageDa();
         $this->imgs = $imageDa->GetImgListByProduct($this->productId);
         $this->load->helper('url');
         foreach ($this->imgs as $img) {
             $img->Path = base_url($img->Path);
         }
         $relateProducts = $productDa->getRelateProduct($this->productId, $this->categoryId);
         foreach ($relateProducts as $product) {
             $productItem = new ProductItemModel();
             $productItem->init($product);
             array_push($this->relateProducts, $productItem);
         }
     }
 }
コード例 #3
0
ファイル: ProductDetailModel.php プロジェクト: hopdq/ecom
 public function init()
 {
     if (isset($this->productId)) {
         $productDa = new ProductDa();
         $this->detail = $productDa->getProductDetail($this->productId);
         $imageDa = new ImageDa();
         $this->imgs = $imageDa->GetImgListByProduct($this->productId);
         $this->load->helper('url');
         foreach ($this->imgs as $img) {
             $img->Path = base_url($img->Path);
         }
         $relateProducts = $productDa->getRelateProduct($this->productId, $this->categoryId);
         foreach ($relateProducts as $product) {
             $productItem = new ProductItemModel();
             $productItem->init($product);
             array_push($this->relateProducts, $productItem);
         }
         $attributeValuesDa = new AttributeValueDa();
         $attrs = $attributeValuesDa->getListMappingProduct($this->productId);
         $stdAttrs = array();
         if (isset($attrs) && count($attrs) > 0) {
             foreach ($attrs as $attr) {
                 if (isset($stdAttrs[$attr->AttributeId])) {
                     $stdAttr = $stdAttrs[$attr->AttributeId];
                     $stdAttr->Value += ";" + $attr->Value;
                 } else {
                     $stdAttrs[$attr->AttributeId] = $attr;
                 }
             }
         }
         if (count($stdAttrs) > 0) {
             foreach ($stdAttrs as $attr) {
                 array_push($this->attrs, $attr);
             }
         }
     }
 }
コード例 #4
0
ファイル: ProductGridModel.php プロジェクト: hopdq/taka
 public function init($filter, $sorter, $paging)
 {
     $this->filter = $filter;
     $this->sorter = $sorter;
     $this->paging = $paging;
     $productDa = new ProductDa();
     $productResults = $productDa->getProductsFilterSortPaging($this->filter, $this->sorter, $this->paging);
     if (isset($productResults)) {
         if (isset($productResults['paging'])) {
             $resultPaging = $productResults['paging'];
             $paging->calTotalPages($resultPaging->totalItems);
         }
         if (isset($productResults['products'])) {
             $products = $productResults['products'];
             if (count($products) > 0) {
                 foreach ($products as $product) {
                     $productItem = new ProductItemModel();
                     $productItem->init($product);
                     array_push($this->products, $productItem);
                 }
             }
         }
     }
     $filters = $productDa->getFilters($this->filter);
     if (isset($filters)) {
         //provider filter
         if (isset($filters['providers'])) {
             $providers = $filters['providers'];
             $this->filterModel->providers = array();
             if (count($providers) > 0) {
                 foreach ($providers as $provider) {
                     $provider->isActive = $provider->Id == $this->filter->providerId;
                     $provider->activeClass = $provider->isActive ? "active" : "";
                     array_push($this->filterModel->providers, $provider);
                 }
             }
         }
         //price filter
         if (isset($filters['prices'])) {
             $prices = $filters['prices'];
             $this->filterModel->price = new PriceFilterModel($prices->minPrice, $prices->maxPrice);
         }
         $this->filterModel->attrs = array();
         //attributes filter
         if (isset($filters['attributeValues'])) {
             $attributeValues = $filters['attributeValues'];
             if (count($attributeValues) > 0) {
                 foreach ($attributeValues as $attr) {
                     $title = "";
                     $code = "";
                     if (isset($attr) && count($attr) > 0) {
                         $title = $attr[0]->AttributeName;
                         $code = $attr[0]->AttributeCode;
                     }
                     $filterItem = new FilterItemModel();
                     $filterItem->title = $title;
                     $filterItem->code = $code;
                     $filterItem->items = array();
                     foreach ($attr as $value) {
                         $item = new AttributeFilterModel($value->Id, $value->Value);
                         $item->attrId = $value->AttributeId;
                         $item->Cnt = $value->Cnt;
                         $item->isActive = false;
                         if (isset($this->filter) && isset($this->filter->attrValues)) {
                             foreach ($this->filter->attrValues as $filterAttr) {
                                 if ($filterAttr->value == $value->Id) {
                                     $item->isActive = true;
                                     break;
                                 }
                             }
                         }
                         array_push($filterItem->items, $item);
                     }
                     array_push($this->filterModel->attrs, $filterItem);
                 }
             }
         }
         //attributes filter
         if (isset($filters['otherAttributeValues'])) {
             $attributeValues = $filters['otherAttributeValues'];
             if (count($attributeValues) > 0) {
                 $attrs = array();
                 foreach ($attributeValues as $attr) {
                     if (!array_key_exists($attr->AttributeId, $attrs)) {
                         $attrs[$attr->AttributeId] = $attr;
                     }
                 }
                 if (count($attrs) > 0) {
                     foreach ($attrs as $key => $value) {
                         $filterItem = new FilterItemModel();
                         $filterItem->title = $value->AttributeName;
                         $filterItem->code = $value->AttributeCode;
                         $filterItem->items = array();
                         foreach ($attributeValues as $attrValue) {
                             if ($attrValue->AttributeId == $key) {
                                 $item = new AttributeFilterModel($attrValue->Id, $attrValue->Value);
                                 $item->attrId = $attrValue->AttributeId;
                                 $item->Cnt = $attrValue->Cnt;
                                 $item->isActive = false;
                                 if (isset($this->filter) && isset($this->filter->attrValues)) {
                                     foreach ($this->filter->attrValues as $filterAttr) {
                                         if ($filterAttr->value == $attrValue->Id) {
                                             $item->isActive = true;
                                             break;
                                         }
                                     }
                                 }
                                 array_push($filterItem->items, $item);
                             }
                         }
                         if (count($filterItem->items) > 0) {
                             array_push($this->filterModel->attrs, $filterItem);
                         }
                     }
                 }
             }
         }
     }
 }