Пример #1
0
 public function getAllProducts($categoryId = null, $language = 'nl')
 {
     $db = Zend_Registry::get('db');
     $select = $db->select()->from(array('p' => 'Product'), array('*'))->joinLeft(array('t' => 'ProductTsl'), 'p.product_id = t.product_id')->where('t.language LIKE "' . $language . '"');
     if ($categoryId !== null) {
         $select->where('p.category_id = ?', $categoryId);
     }
     $stmt = $db->query($select);
     $result = $stmt->fetchAll();
     $products = array();
     foreach ($result as $product) {
         $category = new SxCms_Product_Category();
         $category->setId($product['category_id'])->setLanguage($_SESSION['System']['lng']);
         $category->loadState();
         $productObj = new SxCms_Product();
         $productObj->setId($product['product_id'])->setLanguage($product['language'])->setTitle($product['title'])->setDescription($product['description'])->setSummary($product['summary'])->setPrice($product['price'])->setCategory($category);
         $products[$product['product_id']] = $productObj;
     }
     return $products;
 }
Пример #2
0
 /**
  * Deletes a product from the shopping cart
  * 
  * @param SxCms_Product $product
  * @return SxCms_Cart
  */
 public function deleteProduct(SxCms_Product $product)
 {
     $product->loadState();
     if (isset($this->products[$product->getId()])) {
         $total = $this->products[$product->getId()]['qty'] * $product->getPrice();
         $this->total -= $total;
         unset($this->products[$product->getId()]);
     }
     return $this;
 }