Esempio n. 1
0
 /**
  * Index view for products
  *
  *@return view
  */
 function getIndex()
 {
     $vendorID = Session::get('vendor_id');
     $products = ProductModel::getProducts($vendorID);
     $productCount = ProductModel::totalVendorProducts($vendorID);
     return View::make('product.index')->with('id', $vendorID)->with('products', $products)->with('productCount', $productCount);
 }
 public function addById($id, $data)
 {
     $pm = new ProductModel();
     $pm->loadData($id);
     $arr = $pm->getProducts();
     $product = $arr[0];
     $product->setProperties($data);
     $this->addProduct($product);
 }
Esempio n. 3
0
 function getProducts($params)
 {
     // check params
     if (!is_object($params)) {
         JsonRpc::setInvalidParamsError($this);
         return null;
     }
     // expected params are offset/count/filters(object)/order_by/order_dir.
     // for now the filters will include category/search_term/price_lower/price_higher/code/sale(y/n)/in_stock
     return ProductModel::getProducts($params->limit, $params->offset, $params->filters);
 }
 public function getPageContent()
 {
     $model = new ProductModel();
     $model->loadData(intval($_GET["id"]));
     $products = $model->getProducts();
     if (count($products) !== 1) {
         return "";
     }
     $id = $products[0]->getId();
     $price = $products[0]->getPrice();
     $template = $this->getTemplateEngine()->readTemplate($this->getTemplate());
     $template = $this->getTemplateEngine()->replaceTag("name-de", $this->getValue($id, "name", "de"), $template);
     $template = $this->getTemplateEngine()->replaceTag("name-en", $this->getValue($id, "name", "en"), $template);
     $template = $this->getTemplateEngine()->replaceTag("name-fr", $this->getValue($id, "name", "fr"), $template);
     $template = $this->getTemplateEngine()->replaceTag("description-de", $this->getValue($id, "description", "de"), $template);
     $template = $this->getTemplateEngine()->replaceTag("description-en", $this->getValue($id, "description", "en"), $template);
     $template = $this->getTemplateEngine()->replaceTag("description-fr", $this->getValue($id, "description", "fr"), $template);
     $template = $this->getTemplateEngine()->replaceTag("price", $price, $template);
     $template = $this->getTemplateEngine()->replaceTag("id", $id, $template);
     return $template;
 }
 public function getPageContent()
 {
     $model = new ProductModel();
     $model->loadData(null);
     $products = $model->getProducts();
     if (count($products) === 0) {
         return "dafuq";
     }
     $template = $this->getTemplateEngine()->readTemplate($this->getTemplate());
     $rows = "";
     foreach ($products as $product) {
         $path = "images/products/" . $product->getClassification() . "/" . $product->getType() . "/" . $product->getImgname();
         $row = $this->getTemplateEngine()->readTemplate(Template::ADMIN_DELETE_ROW);
         $row = $this->getTemplateEngine()->replaceTag("id", $product->getId(), $row);
         $row = $this->getTemplateEngine()->replaceTag("imgpath", $path, $row);
         $row = $this->getTemplateEngine()->replaceTag("name", $product->getName(), $row);
         $rows .= $row;
     }
     $template = $this->getTemplateEngine()->replaceTag("rows", $rows, $template);
     return $template;
 }