R.Kinkeris Posted September 26, 2013 Share Posted September 26, 2013 (edited) Hello,Does anyone know how can I get the current category only if it exists. I need to pass the parameter to mysql query only if it exists. 'weeksBestseller' => ProductSale::weeksBestseller((int)$this->context->cookie->id_lang, $quantity, $days, Tools::getValue('id_category')) Tools::getValue('id_category') gets the category if category isset, but on home page the category isn't set. And the query fails. Any idea how can I pass the parameter to the function only if ii isset? The query uses default parameter if it's not overridden. public static function weeksBestseller($id_lang, $quantity, $days, $category = 'p.`id_category_default`', Context $context = null) Edited September 26, 2013 by R.Kinkeris (see edit history) Link to comment Share on other sites More sharing options...
R.Kinkeris Posted September 26, 2013 Author Share Posted September 26, 2013 Problem solved. Works when using this syntax. In controller-> $categ = Tools::getValue('id_category'); if(!isset($catr)) { $categ = NULL; }; $this->smarty->assign(array( 'best_sellers' => $best_sellers, 'weeksBestseller' => ProductSale::weeksBestseller((int)$this->context->cookie->id_lang, $quantity, $days, $categ), )); and in class -> public static function weeksBestseller($id_lang, $quantity, $days, $category = NULL, Context $context = null) { if ($category == NULL) { $category = 2; } } where category 2 is home. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now