public function Init($init = true) { if ($init) { $this->filter->BuildFilterModel(); } $productDa = new ProductDa(); $this->listData->PageModel->PageSize = 20; $productDa->GetProductList_Paging($this->listData, $this->filter); }
public function Index($productId) { $productDa = new ProductDa(); $data = $productDa->getShortInfor($productId); $temp['title'] = $data->Code . '-' . $data->Name; $temp['data'] = $data; $temp['loadDataUrl'] = site_url(array('ProductDetail', 'loadData', $productId, $data->CategoryId, $data->ProviderId)); $temp['loadRelateProducts'] = site_url(array('ProductDetail', 'loadData', $data->CategoryId)); if (isset($data->ProviderId)) { $temp['loadSameProviderProducts'] = site_url(array('ProductDetail', 'loadData', $data->ProviderId)); } $temp['content_view'] = 'Front/ProductDetail/Index'; $this->load->view("Front/Shared/_Layout", $temp); }
public static function getFilters($type, $filter) { $result = null; $productDa = new ProductDa(); switch ($type) { case 'category': $result = $productDa->getFilters($filter); break; case 'provider': $result = $productDa->getFilterByProvider($filter); break; } return $result; }
public function testFilters() { $productDa = new ProductDa(); $filter = new FilterSelectedModel(); $filter->categoryId = '1'; $attrValue = null; $attrValue->attrId = '1'; $attrValue->value = '1'; $attrValue2 = null; $attrValue2->attrId = '3'; $attrValue2->value = '10'; $filter->attrValues = array(1 => $attrValue, 2 => $attrValue2); $sort = 'OLD_NEW'; $result = $productDa->getFilters($filter); var_dump($result); }
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; }
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); } } }
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); } } } }
public function deleteTest() { $id = '12,10'; $result = 0; if ($id != null && $id != '') { $productDa = new ProductDa(); $result = $productDa->delProductByListId($id); } else { $result = 0; } echo $result; }
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); } } } } } } }
public function UpdateProduct() { $da = new ProductDa(); $result = $da->UpdateProduct($this->product); return result; }
public function updateProduct($product) { $validation = $this->dataStandardized($product); $validation = $this->validationProduct($product); if (count($validation) > 0) { return $validation; } $productDa = new ProductDa(); $result = $productDa->UpdateProduct($product); return $result; }