perusi Posted April 25, 2014 Share Posted April 25, 2014 Hi, I have a product carousel that displays the latest added products (new products). How can i exclude from these new products the products that are online only...? I`m newbie in php...so i need your help guys. I want to display the latest added products but with p.online_only = 0 Here is my code, maybe you will help me out: This is the function that calls for new products. private function _getNewProducts(){ $number_of_products = 10; //(int)(Configuration::get('AUT_SHOWCASE_NEWCOUNT')); $new_products = Product::getNewProducts((int)Context::getContext()->language->id, 0, $number_of_products); $this->smarty->assign(array( 'new_products' => $new_products, 'new_prices' => Configuration::get('AUT_SHOWCASE_NEWPRICES'), 'new_cart' => Configuration::get('AUT_SHOWCASE_NEWCART'), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')) )); } and the products are called within a .tpl file with this code: {foreach $new_products as $new} .... {/foreach} Thank you! Link to comment Share on other sites More sharing options...
vekia Posted April 25, 2014 Share Posted April 25, 2014 you have to change this function: Product::getNewProducts there is an sql query. add there addition if condition p.online_only is not '1' Link to comment Share on other sites More sharing options...
perusi Posted April 25, 2014 Author Share Posted April 25, 2014 could you please explain me how? i`m a newbie and some of the php functions are way above me Link to comment Share on other sites More sharing options...
vekia Posted April 25, 2014 Share Posted April 25, 2014 let me know the exact number of your prestashop version Link to comment Share on other sites More sharing options...
perusi Posted April 25, 2014 Author Share Posted April 25, 2014 1.5.3.1 Thanks again Link to comment Share on other sites More sharing options...
vekia Posted April 25, 2014 Share Posted April 25, 2014 ok thank you so open this file: /classes/Product.php near line 1971 you can find code like: $sql->where('product_shop.`active` = 1'); right after this code paste this: $sql->where('p.`online_only` <> 1'); and... that's all! voila Link to comment Share on other sites More sharing options...
perusi Posted April 25, 2014 Author Share Posted April 25, 2014 ok. one more question. does this affect the classes for all the products? I want the online only just to be excluded from the carousel. Thanks Link to comment Share on other sites More sharing options...
vekia Posted April 25, 2014 Share Posted April 25, 2014 yes, this will affect all of "new products feed" if you want to do it only for your carousel duplicate getNewProducts function in product.php file and rename it to public static function getNewProductsCarousel($id_lang, $page_number = 0, $nb_products = 10, $count = false, $order_by = null, $order_way = null, Context $context = null) then in your carousel module use this new funciton (getNewProductsCarousel) instead of original (getNewProducts) 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