public function listAction() { $ns = new Zend_Session_Namespace(); $products = array(); // get the category uri $uri = $this->getRequest()->getParam('q'); if (!empty($uri)) { // Save the path of the user $ns->lastcategory = $uri; // Get the category information $category = $this->categories->getAllInfobyURI($uri); if (!empty($category[0])) { $this->view->category = $category[0]; // Get the subcategories $this->view->subcategory = ProductsCategories::getbyParentId($category[0]['category_id'], 1, true); // Set the Metatag information $this->view->headTitle()->prepend($category[0]['name']); if (!empty($category[0]['keywords'])) { $this->view->headMeta()->setName('keywords', $category[0]['keywords']); } if (!empty($category[0]['description'])) { $this->view->headMeta()->setName('description', $category[0]['description'] ? Shineisp_Commons_Utilities::truncate(strip_tags($category[0]['description'])) : '-'); } $this->view->headertitle = $category[0]['name']; // Get the products information $fields = "pd.productdata_id as productdata_id, \n\t\t\t\t pd.name as name, \n\t\t\t\t pd.shortdescription as shortdescription, \n\t\t\t\t pd.metakeywords as metakeywords, \n\t\t\t\t pd.metadescription as metadescription, \n\t\t\t\t p.*, pag.code as groupcode"; $data = $this->categories->getProductListbyCatUri($uri, $fields, $ns->langid); if (!empty($data['records'])) { // Get the media information for each product foreach ($data['records'] as $product) { $product['reviews'] = Reviews::countItems($product['product_id']); $product['attributes'] = ProductsAttributes::getAttributebyProductID($product['product_id'], $ns->langid, true); $products[] = $product; } $this->view->products = $products; $this->view->pager = $data['pager']; } $this->view->layoutmode = !empty($ns->layoutmode) ? $ns->layoutmode : "list"; $this->_helper->viewRenderer($ns->layoutmode); } else { $this->_helper->redirector('index', 'index', 'default'); } } }
/** * Search products * * @param string $needed * @param integer $locale * @return ArrayObject */ public static function search($needed, $locale = 1, $retarray = TRUE) { $data = array(); $dq = Doctrine_Query::create()->select('p.*, pag.code as groupcode, pd.name as name, pd.shortdescription as shortdescription, pd.metakeywords as keywords, pm.path as imgpath')->from('Products p')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->leftJoin("p.ProductsMedia pm")->leftJoin("p.ProductsAttributesGroups pag")->where("pd.name like ? and p.enabled = ?", array("%{$needed}%", 1))->orWhere("pd.shortdescription like ?", "%{$needed}%")->orWhere("pd.description like ?", "%{$needed}%")->orWhere("pd.metakeywords like ?", "%{$needed}%")->addWhere("p.isp_id = ?", Isp::getCurrentId()); if ($retarray) { $data = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); } else { // Create the pagination of the records $dq = self::pager($dq, 5); // Execute the query $products = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY); foreach ($products as $product) { $product['reviews'] = Reviews::countItems($product['product_id']); // Add the total of the reviews for each product $data['records'][] = ProductsData::checkTranslation($product); // Check the product data translation text } // Get the pager object $data['pager'] = $dq->display(null, true); } return $data; }