ZaLuno Posted November 16, 2013 Share Posted November 16, 2013 Hi! On my dev page test.zaluno.si I have a big featured products slider, that shows first 4 products from Home category. Then I have another featured products slider with 8 products, but first four repeat from top slider. Is it possible to set featured products module to display products from position number 5 to 13 and ignore first 4? I tried searching the web but I do not even know where to start Also - not as important but would help a lot - can I display 8 featured products in two rows instead of a slider with 2x4 products? Link to comment Share on other sites More sharing options...
PascalVG Posted November 16, 2013 Share Posted November 16, 2013 Hi Zaluno, Go to /modules/<your 2nd slider module name>/<your 2nd slider module name>.php Sowewhere in the code, you probably see a function getProducts(...) It can either be Product::getProducts(...) or $somecategory->getProducts or similar If it is Product::getProducts, its definition is (in classes/product.php: public static function getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category = false, $only_active = false, Context $context = null) Here $start indicates the amount of products that need to be skipped, so here you can change $start to 5 (N.B. or maybe 4, as it may start counting at 0..) if it was $category->getProducts(...), its definition is (in classes/Category.php:) public function getproducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null) Where $p is the 'page' and $n the 'number of items per page' So here you could add 2,8 (it then skips the first 8 products. Skipping only four needs programming... (copy the function, and change the way it LIMITs the query result...) My 2 cents, pascal Link to comment Share on other sites More sharing options...
ZaLuno Posted November 16, 2013 Author Share Posted November 16, 2013 I have located this code based on your instructions: public function getproducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null) Now I suppose I am screwed I have no programming knowledge. I was hoping this is just some number I can change, but I guess no cigar today ... I will look into it when get more time to learn some of this stuff, thank you for your thorough answer! If no better solution comes up, I will start looking for a different (free) module with Product::getProducts(...) version of the code. Link to comment Share on other sites More sharing options...
PascalVG Posted November 16, 2013 Share Posted November 16, 2013 Hi Zaluno, The code you found is the DEFINITION of the function. What we now need it the call of this function. Do you know the name of the 2nd slider bar module? Try to locate the module and hover (put) your mouse over the 'reset' link (DON'T PRESS!). At the bottom of your browser, you will then probably some text of where the link goes to. Look carefully in the text and you will see apart that says module_name=<modulename>&.... If you have found this: Then, in de /modules folder, there should be a folder with the same module name. Go in there and there should be a file with the same name as the folder and extension .php Open this file and see if you can find the call of the function getProducts. If it gets too complicated, let me know. Maybe I can help, but then I need access to your back office and to your files. Try first, and if it doesn't work out, report back and we can go to plan B... pascal Link to comment Share on other sites More sharing options...
ZaLuno Posted November 16, 2013 Author Share Posted November 16, 2013 The module is homefeatured. The code around getProducts looks like this: $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); $nb = (int)(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 10)); shuffle($products); $this->smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), What now? Link to comment Share on other sites More sharing options...
PascalVG Posted November 16, 2013 Share Posted November 16, 2013 Try this: $products = $category->getProducts((int)Context::getContext()->language->id, 2, ($nb ? $nb : 10)); and in modules->modules go to homefeatured and click configure. Set amount of products to 8. Hope this helps, pascal Link to comment Share on other sites More sharing options...
ZaLuno Posted November 16, 2013 Author Share Posted November 16, 2013 Did as you said, cleared my cache, tried all browsers but product #1 from Home category still appears in homefeatured slider Link to comment Share on other sites More sharing options...
Mario.89 Posted November 16, 2013 Share Posted November 16, 2013 the Category method getProducts have this line:(row 649 for prestashop 1.5.6 in the file classes/category.php) LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n; $p is the number you pass with the function getProducts(pascalvg suggest you to put 2) .$n is the number you set in the BackOffice(8 for instance). so in this way you set a query that take rows from 8 to 16 you should delete the "* (int)$n" but i don't know if other module call this function(you could have error somewhere else) i suggest you to put a control in the homefeatured.tpl that show product with id different from those you use in the other feature slider. hope this help (sry for english i'm italian ) Link to comment Share on other sites More sharing options...
vekia Posted November 17, 2013 Share Posted November 17, 2013 and what about to add interation counter to foreach loop ? something like: {if iteration > 8} DISPLAYCODEHERE {/if} iteration is a "foreach loop" counter Link to comment Share on other sites More sharing options...
PascalVG Posted November 17, 2013 Share Posted November 17, 2013 Did you turn on force compilation in advanced parameters->performance! and turn off smarty cache as well? pascal N.B. Only temporarily, of course... Link to comment Share on other sites More sharing options...
Mario.89 Posted November 17, 2013 Share Posted November 17, 2013 you can also unset the first X items in the blockcart.php (avoiding control in the loop and useless products info saved) Link to comment Share on other sites More sharing options...
PascalVG Posted November 26, 2013 Share Posted November 26, 2013 Hi Zaluno, Did you manage to make it work? Let us know, pascal Link to comment Share on other sites More sharing options...
ZaLuno Posted November 26, 2013 Author Share Posted November 26, 2013 I made some modifications but apparently this issue is not so simple to tackle I will try with my developer if he knows how to solve this with help from your suggestions. I will definitely get back to you with a solution if we solve this, thank you so far! 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