Jump to content

Display the Layered Navigation Block in new-products, prices-drop and best-sales


rhemaxos

Recommended Posts

Hi there,

 

As the title suggests I'm trying to make the blocklayered be displayed in prices-drop, new-products and best-sales in the LeftColumn hook.

Using a third-party custom module is not an option for me.

 

To my knowledge the Layered Navigation Block is a category specific module and I should try customizing the module in order to get it displayed in these pages.

 

If anyone knows what files should be modified and what I should modify, I'd greatly appreciate it!

 

Thanks in advance!

 

Nick

  • Like 1
Link to comment
Share on other sites

Hi.

 

You could try and edit the PHP file of the module and set it to use the home or root category if not category ID is supplied in the URL.

 

 

Regards.

 

Robin.

 

The CartExpert Team

 

Hi Robin,

 

Thanks for the answer. Can you be a bit more specific, the file I should modify is "/modules/blocklayered/blocklayered.php" ?

I'm looking through the blocklayered.php and that file has a lot of code, , where exactly should I modify the code?

 

Thanks!

Link to comment
Share on other sites

I'm sure an experienced PrestaShop developer could figure it out, but it seems I can't.

I see here the getSelectedFilters has this instruction:

$id_parent = (int)Tools::getValue('id_category', Tools::getValue('id_category_layered', 1));
if ($id_parent == 1)
return;

I'm guessing the getValue method returns either the id_category_layered either (int)1, in the case it's 1 it doesn't show.

If this is the case I've already commented out this line and it's still not showing in new-products, prices-drop or best-sales.

 

What am I missing here?

Link to comment
Share on other sites

  • 3 weeks later...

I'm having the same problem, Could you be more specific  anout this, please.

 I figure out thet the module should be assign to an hook that is present on that specifi page. In my case ins special products page.

II try to hook block_layered to  actionProductListOverride ( the old productlistassign), but seems the moduel is already hooked there, but still don't show on that page.

I try no found another hook to use, but no luck.

Any sugestions?

Link to comment
Share on other sites

  • 1 month later...

Hi, I'm having the same problem.

These are the modifications I made:

- I modified the blocklayered.tpl in order to target another blocklayered-ajax.php file if the current page is prices-drop

- I duplicated the blocklayered-ajax.php in blocklayered-prices-drop-ajax.php in order to separate the behavior of the module if the page is prices-drop since the function is different.

- I duplicated the function getProducts of the blocklayered.php calling it getPricesDrop and consequently I duplicated the getProductByFilters in getPricesDropByFilters in order to modify the sql query and apply the filters only on prices drop.

 

I thought it should work but I found out that the problem is the hookProductListAssign: it is executed only for the category pages and not for prices drop pages.

Right now I'm able to show the filters in the page but they are not filtering prices drops.

I looked into the prices drop controller and I figured out that the only method that I have to overwrite is the initContent but unfortunately I'm not able to do it.

 

Can anyone help me please?

Or did anyone succeed in displaying the layered navigation module in the Prices Drop page using another technique?

 

Thanks

Chris

Edited by chris_mini_charmed (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...

Hi, I would like to seek help for this issue too. Seems like there isn't a fix around yet. Hope that someone can build on the previous solution for coding noobs like me or suggest something else. Thanks in advance!

I don't understand, If the forum moderators can't give right solution as early as possible. What is the purpose of this Forum. This topic  is too old but still no solution. I am facing this problem too. Can anyone help us to get rid of this problem. I am trying to catch attention of the experienced Prestashop programmer and Moderators of this Forum.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

No one has yet managed to display the module on these pages?

I tried all the above and not working.
I do not understand because the Prestashop development team has thought to hide the module on these pages can benefit in something. Bad decision! :wacko:

 

Sorry for my english.

Link to comment
Share on other sites

  • 3 months later...

Same problem here.

Layered navigation should come with this option by default.

 

Manufacturer pages, New product pages and price-drop pages in prestashop havent been changed in ages! and need more functionality.

If someone can help us load the layered navigation in this pages, or point us to a module that can do this I would appreciate it.

 

Thanks!

Link to comment
Share on other sites

  • 2 months later...

Hi mlarino,

 

I am still trying to figure this out since i am upgrading my shop to 1.6.1 and prefer to avoid purchasing extra modules.  

 

If you are searching for a paid module then Ajax filter from Presto changeo can certainly do it.  I use it in my current shop 1.4.3 (see http://mathos-exclusive.com/en/prices-drop). Functionality and customer service are both great.

Edited by thanos26 (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 6 months later...
  • 3 months later...
  • 2 months later...
  • 1 month later...
  • 2 weeks later...

I got the solution, for Discount page (price-drops) is working great, i need to figure out for other page also. I will share solution here once other done.

Hey Amir... did you manage to complete the solution?

I still can't believe this is not a standard option for the get go!

Link to comment
Share on other sites

Hi everyone,

 

I'm interested too in displaying the layered nav on my specials / discount page... ( Without paying 200€ I mean )

That would be great because discount page is usually the kind of place where you find very mixed products.

 

Let's hope a solution comes soon... This question has been lasting for a few years now  :huh:

Link to comment
Share on other sites

  • 2 months later...

Aaaaand Amir92 dissapeared in the woods. Figures.

 

Hey  Alexandru Alexe, m here now :)

sorry i was so busy, m going to write my solution now.

meanwhile u can check working site: eddy(dot)com(dot)sa/en/prices-drop

Link to comment
Share on other sites




Thanks everyone for waiting too long for this solution ;) . Finally, i found the solution to show filter: block layered navigation module(prestashop default module) on Discount page(price_drop).For now, this is working for discount page only, in future i will try to implement on other page too as new_products and best_sales as soon i get time, or if you guys support by Donation, i will try to make in urgent, and many more free solution ;)


 


Here is the working solution you can check: eddy(dot)com(dot)sa/en/prices-drop


 


Note: I override most of the files. but you need to modify blocklayered module core file.


 


There are two issue. I will try to fix these issue in next release.


1) Total number of product count not correct.


2) You need to define "price_drop" page indexing manually in blocklayererd-ajax.php


 


Prestashop Supported Version: 1.6.1.10 (tested on this version)



 


List of file changes:


1) override/controllers/front/PricesDropController.php


2) themes/[current-theme-name]/prices-drop.tpl


3) override/classes/Product.php


4) modules/blocklayered/blocklayered.php


5) modules/blocklayered/blocklayered-ajax.php Update $query[x] index as per your store url for price_drop page. Ex: localhost/prestashop/en/prices-drop , then x = 3


6) themes/[current-theme-name]/js/modules/blocklayered/blocklayered.js


 


File download link: https://drive.google.com/file/d/0By68mIirpO34LU04a1dSNklLd2s/view ( Can anyone tell me from where i can upload file in this thread? )


 


Just download and replace above files in you store, and update $query[x] index in blocklayered-ajax.php as mentioned above.


 


Please let me know, if any issue :)




Edited by Amir92 (see edit history)
  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Thanks for answering, Amir :) We are all waiting for the miraculous solution, indeed. This issue became very frustrating the other day.

By the way, nice job with the electronics shop. Well built/maintained :D

 

Hey Alex,

please check my above solution, and let me know if its working for you :)

Link to comment
Share on other sites

Hi Amir,

Sorry for bad English, i'm french.

 

First, thank you very much for your development and your time to solve this problem.

I've try to follow your tutorial but i've obtain a big Internal Servor 500...  :unsure:

Perhaps, i've made something wrong.

- When i go to override/controllers/front/, i've not any file except index.php.

- i don't to how to update my $query in modules/blocklayered/blocklayered-ajax.php. What is the command to made this ?

 

Here my file blocklayered-ajax.php :

 

include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
//Get page_name by url(price_drop page)
$queries = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
$query = explode("/", $queries);
//Update $query[x] index as per your store url for price_drop page. Ex: localhost/prestashop/en/prices-drop , then x = 3
Context::getContext()->controller->php_self = $query[3];
$blockLayered = Module::getInstanceByName('blocklayered');
echo $blockLayered->ajaxCall();

Can you help me please ?

Thanks

Jimmy

Link to comment
Share on other sites

Hey Jimmy,

I am also not Englishman, sorry for my bad english ;)

 

I've try to follow your tutorial but i've obtain a big Internal Servor 500...   :unsure:

 

-Try to clear cache and enable debugging from config/defince.inc.php and check the exact error.

 

 When i go to override/controllers/front/, i've not any file except index.php.

 

-no issue, just copy override files in same folder, if folder not exist create folder.

 

- i don't to how to update my $query in modules/blocklayered/blocklayered-ajax.php. What is the command to made this ?

 

-Can you tell me your shop url?

by the way you may need to change line 7 

  1. Context::getContext()->controller->php_self = $query[3];

Ex: localhost/prestashop/en/prices-drop, then "price-drop" index is 3, so $query[3] 

Link to comment
Share on other sites

Hi Amir,

 

thank you so much for your fast response..

 

Sorry it's confused for me I'm not talented, can you make me a resume please ?

 

thank you so much for your help, 

 

Laetitia

You just need to replace file in the folder.

Link to comment
Share on other sites

Hey there Amir. I am now working to implement this on my client's site and if all's good I'll replicate solution to the whole portfolio :)

Thank you A LOT!

 

I have one request though. I have modified some parts of my current blocklayered.php file so I need to know what modifications you made to it so I can put only those in without replacing the whole file.

 

Also, @rhemaxos, please mark this thread as SOLVED ;)

Link to comment
Share on other sites

UPDATE 1:
Just replacing said files produces this error on Price Drop page:

Fatal error: Call to protected method ProductCore::_getProductIdByDate() from context 'BlockLayered' in /home/r36469cond/public_html/modules/blocklayered/blocklayered.php on line 2173

Link to comment
Share on other sites

UPDATE 1:

Just replacing said files produces this error on Price Drop page:

Fatal error: Call to protected method ProductCore::_getProductIdByDate() from context 'BlockLayered' in /home/r36469cond/public_html/modules/blocklayered/blocklayered.php on line 2173

Hey, you missed Product.php file which override getProductIdByDate() method

Please copy override/classes/Product.php file.

Try to replace all changes.

Link to comment
Share on other sites

Sorry but it messes up the site. Replaced all files, in the right places. No filters on category pages, Fatal error on Prices Drop.

I rolled back the changes because I can't keep the live site crooked for long stretches of time :(

Can you on debugging and paste error here.

Try to setup on localhost first :)

Link to comment
Share on other sites

  • 1 month later...

Thank you, Amir for your solution
I also use the template sp-revo, but when I load all the files, I get the error below

 

Fatal error: Call to protected method ProductCore::_getProductIdByDate() from context 'BlockLayered' in C:\xampp\htdocs\revo\modules\blocklayered\blocklayered.php on line 2173

Edited by soleymani (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 4 months later...
Em 6/7/2017 em 10:45 AM, Amir92 disse:
 
 
 

Thanks everyone for waiting too long for this solution ;) . Finally, i found the solution to show filter: block layered navigation module(prestashop default module) on Discount page(price_drop).For now, this is working for discount page only, in future i will try to implement on other page too as new_products and best_sales as soon i get time, or if you guys support by Donation, i will try to make in urgent, and many more free solution ;)

 

 

 

Here is the working solution you can check: eddy(dot)com(dot)sa/en/prices-drop

 

 

 

Note: I override most of the files. but you need to modify blocklayered module core file.

 

 

 

There are two issue. I will try to fix these issue in next release.

 

1) Total number of product count not correct.

 

2) You need to define "price_drop" page indexing manually in blocklayererd-ajax.php

 
 
 
 

Prestashop Supported Version: 1.6.1.10 (tested on this version)

 

 

 

List of file changes:

 

1) override/controllers/front/PricesDropController.php

 

2) themes/[current-theme-name]/prices-drop.tpl

 

3) override/classes/Product.php

 

4) modules/blocklayered/blocklayered.php

 

5) modules/blocklayered/blocklayered-ajax.php Update $query[x] index as per your store url for price_drop page. Ex: localhost/prestashop/en/prices-drop , then x = 3

 

6) themes/[current-theme-name]/js/modules/blocklayered/blocklayered.js

 

 

 

File download link: https://drive.google.com/file/d/0By68mIirpO34LU04a1dSNklLd2s/view ( Can anyone tell me from where i can upload file in this thread? )

 

 

 

Just download and replace above files in you store, and update $query[x] index in blocklayered-ajax.php as mentioned above.

 

 

 

Please let me know, if any issue :)

 

Hi there, this topic is too old and you maybe dont use this anymore, but i had to used it (Thank you very much @Amir92) and i found a solution for this bugs.

For the blocklayered-ajax.php, do this:

<?php

include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');

$context = Context::getContext();

//Get page_name by url(price_drop page)
$queries = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH);
$query = explode("/", $queries);

//Get page original name from page
$php_self = Db::getInstance()->getValue('
	SELECT m.page FROM `ps_meta` m
	LEFT JOIN `ps_meta_lang` l
	ON m.id_meta = l.id_meta
	WHERE l.url_rewrite = "'.$query[1].'"
	AND l.id_lang = '.$context->language->id);

$context->controller->php_self = $php_self ? $php_self : 'category';
$blockLayered = Module::getInstanceByName('blocklayered');
echo $blockLayered->ajaxCall();

 

And to show the actual number of results you should make the changes in blocklayered.php, but first find this line:

Db::getInstance()->execute('DROP TEMPORARY TABLE IF EXISTS '._DB_PREFIX_.'cat_filter_restriction', false);

Before this line, add this code:

if($tab_id_product && is_array($tab_id_product)){
	$query_filters_where .= ' AND product_shop.`id_product` IN ('.implode(', ', $tab_id_product).')';
}

I hope I have helped you guys.

 

Edited by viniciuscoder (see edit history)
Link to comment
Share on other sites

  • 2 years later...
  • 1 month later...
  • 2 months later...

Hello everyone, maybe someone will find this information useful:

To display the filter in New product
1. Created the "New products" category
2. Added products there
3. Added this category to the filter template in the block layered settings
4. Directed a menu item to this category

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...