Jump to content

Product Carousel - New products exclude Online Only


perusi

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...