Jump to content

[FREE MODULE] Shop by Price


wildchief
 Share

Recommended Posts

Hello,

I have created a module here to allow the shop owner to specify price ranges links that are display on the shop. This allows the user to browse products within the price range link. See the attached screen shot for a better idea of the modules purpose.

The module and supporting documentation can be found here

Please let me know if there any bugs or any other feature or improvements please let me know here or on the web site.

Thank you and I hope it is useful to some users.

David

34119_A3I1ld6uuBMoIPEQbRK7_t

  • Like 5

Share this post


Link to post
Share on other sites

Hi

Thanks for making this module & keeping it free. I'm having the same problem, the product not in the price range are displayed too.

Also some issue with pagination. If there are less than 10 products, pagination still shows for several pages. If I select any other page I get error: no product in that price range.

And if for the last price range which mostly will have no maximum price, it should be labelled "above" whatever the min. price is coz right now it just shows the price. Ex: 10,000 - Max. Price is now displayed 10,000. It should be Above 10,000.

Share this post


Link to post
Share on other sites

Hello John,
Thanks for that - me thinks I released this module too soon. Still at least the feed back means I can get it all fixed and become a useful module (hopefully)

Ta

Dave

Sorting of the links isnt very good, it seems to be sorting it on the first digit and not the whole number. See my image below

Share this post


Link to post
Share on other sites

Hello John,
Thanks for that - me thinks I released this module too soon. Still at least the feed back means I can get it all fixed and become a useful module (hopefully)

Ta

Dave

Sorting of the links isnt very good, it seems to be sorting it on the first digit and not the whole number. See my image below


I hope so, it would make a good addition to the store.

Share this post


Link to post
Share on other sites

Inblockshopbyprice.tpl the following lines should not have a / following the smarty command

                      {$currencysign}{$pricerange[nr].minprice}
                      {else}
{$currencysign}{$pricerange[nr].minprice} - {$pricerange[nr].maxprice}



therefore they should be

                      {$currencysign}{$pricerange[nr].minprice}
                      {else}
{$currencysign}{$pricerange[nr].minprice} - {$pricerange[nr].maxprice}

Share this post


Link to post
Share on other sites

Sorting of the links isnt very good, it seems to be sorting it on the first digit and not the whole number. See my image below


Try adding a couple of spaces in front of the lower value prices, that worked for me

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello,

There is a version 1.2 of this module which resolves some of the problems listed before today.

I have added a display order field to allow shop admins to set an order which the price ranges are displayed. I hope this will address the issues that users have reported with the order of price ranges. I still need to fix the pagination and the products that sometimes fall outside the range. I believe that the fellow user razaro has a fix for this which I hope to implement.

I hope this makes the module at least "beta" :)

It is still downloaded from here

Thanks

Dave

Share this post


Link to post
Share on other sites

In configuration there is 2 times " Enter Minimum Price "

Enter Minimum Price
Enter Minimum Price
Enter Display Order

Translations doesn't work, in tpl files you must add mod='blockshopbyprice'
in blockshopbyprice.tpl and shopbyprice.tpl

example:

{l s='Shop by Price' mod='blockshopbyprice'}



else:
"The selected shop price range has been deleted" isn't translated (some spaces to remove in in blockshopbyprice.php)

Share this post


Link to post
Share on other sites

Hi

Thanks for module and hope you will continue to update it.

And about price out o range fix I made some changes to your code but it still don't work in some cases.
Fix is for searching products depending on tax display choice (inc or excl) but problem remains for products with price drop and for products which have default combination with price impact (different then 0).

Ok for fix in file shopbyprice.php find

        function getQuery()
       {

           if (getmaxPrice())
           {
               $query = 'AND p.`price` BETWEEN '.getminPrice().' and '.getmaxPrice().'';
           }
            else
           {
               $query = 'AND p.`price` >= '.getminPrice().'';
           }

       return $query;
       }



and replace it with

        function getQuery()
       {
           $price_tax_exl = Product::getTaxCalculationMethod();
           if (getmaxPrice())            
           {
               if (!$price_tax_exl)
               {
                   $query = 'AND p.`price`* ((100 + (t.`rate`))/100)  BETWEEN '.getminPrice().' and '.getmaxPrice().'';
               }
               else
               {
                   $query = 'AND p.`price` BETWEEN '.getminPrice().' and '.getmaxPrice().'';                
               }

           }
            else
           {
               if ( !$price_tax_exl )
               {
                   $query = 'AND p.`price`* ((100 + (t.`rate`))/100) >= '.getminPrice().'';
               }
               else
               {
                   $query = 'AND p.`price` >= '.getminPrice().'';
               }

           }

       return $query;
       }

Share this post


Link to post
Share on other sites

Does it work with multi-currency shops?

We use Lebanese Pounds, Euro and Dollars but it seems it's not filtering correctly. Because, the $1 = 1,000POUNDS. So it doesn't make sense to put:

1$ - 10$, it will translate to: 1POUND-10POUNDS which have no monetary value at all.
1$ - 10$ should become: 1,000POUND-10,000POUNDS which has monetary value.

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Here is fix for pagination problem.

Replace

                        if ($count)
                       {
                               $result = Db::getInstance()->getRow('
                               SELECT COUNT(`id_product`) AS nb
                               FROM `'._DB_PREFIX_.'product` p
                               WHERE `active` = 1
                               AND p.`id_product` IN (
                                       SELECT cp.`id_product`
                                       FROM `'._DB_PREFIX_.'category_group` cg
                                       LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                                       WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
                               )
                               ');

                               return intval($result['nb']);
                       }


with


                       if ($count)
                       {
                               $result = Db::getInstance()->getRow('
                               SELECT COUNT(`id_product`) AS nb
                               FROM `'._DB_PREFIX_.'product` p
                               WHERE p.`active` = 1
                               '.getQuery().'
                               AND p.`id_product` IN (
                                       SELECT cp.`id_product`
                                       FROM `'._DB_PREFIX_.'category_group` cg
                                       LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                                       WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
                               )
                               ');

                               return intval($result['nb']);
                       }

Share this post


Link to post
Share on other sites

Thank you very much for your efforts Razaro, I will get these rolled up into a new version for all to use

Here is fix for pagination problem.

Replace
                        if ($count)
                       {
                               $result = Db::getInstance()->getRow('
                               SELECT COUNT(`id_product`) AS nb
                               FROM `'._DB_PREFIX_.'product` p
                               WHERE `active` = 1
                               AND p.`id_product` IN (
                                       SELECT cp.`id_product`
                                       FROM `'._DB_PREFIX_.'category_group` cg
                                       LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                                       WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
                               )
                               ');

                               return intval($result['nb']);
                       }


with


                       if ($count)
                       {
                               $result = Db::getInstance()->getRow('
                               SELECT COUNT(`id_product`) AS nb
                               FROM `'._DB_PREFIX_.'product` p
                               WHERE p.`active` = 1
                               '.getQuery().'
                               AND p.`id_product` IN (
                                       SELECT cp.`id_product`
                                       FROM `'._DB_PREFIX_.'category_group` cg
                                       LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                                       WHERE cg.`id_group` '.(!$cookie->id_customer ?  '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').'
                               )
                               ');

                               return intval($result['nb']);
                       }

Share this post


Link to post
Share on other sites

Hello.

Im trying to install shopbyprice module v.1.2.1 on PrestaShop v1.4.0.6 - 4114 (2010-12-29)
and getting error:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

If im not mistaken the error appear in the method

hookRightColumn 

of the class

Blockshopbyprice 


on line 52:

return $this->display(__FILE__, 'blockshopbyprice.tpl');

Share this post


Link to post
Share on other sites

Ive made this module working in Presta v1.4.
First, in both template files (shopbyprice.tpl and blockshopbyprice.tpl) you need to replace quotes like ‘ with single or double quotes (' or ").

Second, in the shopbyprice.php file you need to change SQL query, find

(t.`id_tax` = p.`id_tax`)

and replace with

(t.`id_tax` = p.`id_tax_rules_group`)

.
Probably they changed row name in products table from id_tax to id_tax_rules_group

ps: i`ll attach fixed module for 1.4

blockshopbyprice_fix_for1.4.zip

Share this post


Link to post
Share on other sites

  • 3 weeks later...

I have a problem with Internet Explorer. When I search products by price, the product images aren't displayed at all.
This happens just with IE (no problem with Firefox and Chrome). Any idea how to fix this?
Thanks a lot

Share this post


Link to post
Share on other sites

  • 2 months later...
  • 1 month later...
  • 5 weeks later...
  • 1 month later...

For some reason, my template is coming broken for this page, when this page loads up. Any help thanks. I am using PS 1.4.4

 

ps.jpg

 

Also in the module, there comes an error log showing:

 

[02-Aug-2011 03:56:22] PHP Warning: file_put_contents(/home/ridahas/public_html/store/config/../cache/cachefs/0/6/1/06170eb46a28d8480da3602ab1935734) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory in /home/ridahas/public_html/store/classes/CacheFS.php on line 51

Share this post


Link to post
Share on other sites

I have a problem with Internet Explorer. When I search products by price, the product images aren't displayed at all.<br/>This happens just with IE (no problem with Firefox and Chrome). Any idea how to fix this?<br/>Thanks a lot

 

I think you should switch off all compressions and optimisations for ie

Share this post


Link to post
Share on other sites

  • 3 weeks later...

For some reason, my template is coming broken for this page, when this page loads up. Any help thanks. I am using PS 1.4.4

 

ps.jpg

 

Also in the module, there comes an error log showing:

 

[02-Aug-2011 03:56:22] PHP Warning: file_put_contents(/home/ridahas/public_html/store/config/../cache/cachefs/0/6/1/06170eb46a28d8480da3602ab1935734) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory in /home/ridahas/public_html/store/classes/CacheFS.php on line 51

 

With the search-function i have had the same with displaying:

It is an error with PS 1.4.1 the filename off the file /themes/name/css/product-list.css.

The Searchcontroller is looking for product-list.css but the original file looks product_list.css.

 

Copying product-list.css to product_list.css is one to fix it.

 

I think this very good module use the same funktion as search.php (i see product-sort.php) to show the assoziated product-list.

 

greet

Share this post


Link to post
Share on other sites

For some reason, my template is coming broken for this page, when this page loads up. Any help thanks. I am using PS 1.4.4

 

ps.jpg

 

Also in the module, there comes an error log showing:

 

[02-Aug-2011 03:56:22] PHP Warning: file_put_contents(/home/ridahas/public_html/store/config/../cache/cachefs/0/6/1/06170eb46a28d8480da3602ab1935734) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory in /home/ridahas/public_html/store/classes/CacheFS.php on line 51

 

With the search-function i have had the same with displaying:

It is an error with PS 1.4.1 the filename off the file /themes/name/css/product-list.css.

The Searchcontroller is looking for product-list.css but the original file looks product_list.css.

 

Copying product-list.css to product_list.css is one to fix it.

 

I think this very good module use the same funktion as search.php (i see product-sort.php) to show the assoziated product-list.

 

greet

 

I did what you said but unfortunately no luck. It does seem to be a problem with the css though.

Share this post


Link to post
Share on other sites

Hi, using latest version (1.2.1) on PS 1.4.4.0, shop goes blank on every page...

If I put index.php as an exception, it loads properly

Moved the plugin to right column, page loads only parts of the content... and then stops => page's incomplete and "ugly" ;-)

 

Any idea what to look for, to try to have it work properly...

Thx in advance.

Sincerely

DJM

Share this post


Link to post
Share on other sites

OK, made it work in 1.4.4.0

As stated by oleg_ua in January, you have to :

- modify shopbyprice.php as he explained above

- replace in both template files (shopbyprice.tpl and blockshopbyprice.tpl), quotes like ‘ with single quotes '

- add opening and closing " to all includes in shopbyprice.tpl, such as

{include file=$tpl_dir./breadcrumb.tpl}

becomes

{include file="$tpl_dir./breadcrumb.tpl"}

 

The CSS is still broken so far (same pb as Nabeel Aejaz above), but at least I get the content...

Will come back if I find the CSS pb...

 

Sincerely

DJM

Share this post


Link to post
Share on other sites

OK, re:CSS.

In fact product_list.css is not loaded by the page as nowhere in the PHP it"s requested.

You can check, as an example, the declaration in the file CategoryController.php that requests this CSS file as an extension to the current loaded styles

public function setMedia()
   {
       parent::setMedia();
       Tools::addCSS(array(
           _PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
           _THEME_CSS_DIR_.'scenes.css' => 'all',
           _THEME_CSS_DIR_.'category.css' => 'all',
           [color=#0000ff]_THEME_CSS_DIR_.'product_list.css' => 'all'[/color]));

       if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
           Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
   }

 

Ugly/dirty (but quick) method to solve pb:

* locate product_list.css in your theme CSS directory,

* copy all content from the file,

* open shopbyprice.tpl

* add

<style></style>

* in between these tags, paste the content from product_list.css

 

Nice way : I do suppose that the best way to achieve this would be to transform shopbyprice.php so that it extends the main controller...???

 

Sincerely

DJM

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hi again, I don't know why but I've been trying to upload several of your modules, Shopbyprice and requirelogin, and now we can't add products on our site. When we click on "Add to Cart".. any product is added. Can you please help? We have already deleted your modules but we don't know if your modules made some change in our PS shop. Thanx

Share this post


Link to post
Share on other sites

Can you please help me with the previous post:

 

Hi, tried to stablish the following ranges but an error appears...

 

Ranges we want: 0-5:5-10:10-20:20-30:30-50:50-100

 

We are using 1.4.3

 

What should I do?

Share this post


Link to post
Share on other sites

hello Cchhaass,

 

I think for us to help we need the error message. Would you mind posting it here, a screen shot or the error message itself

 

Thank you

 

Can you please help me with the previous post:

 

Hi, tried to stablish the following ranges but an error appears...

 

Ranges we want: 0-5:5-10:10-20:20-30:30-50:50-100

 

We are using 1.4.3

 

What should I do?

Share this post


Link to post
Share on other sites

Hello, good module, but I have a question, as can be done for the module to showproducts with attributes?, Ie I have with products that have different attributes andmodule prices will not be shown, then display only products the initial price.Another question I have is that the module searches by category, ie looking at the category in which he is, but as you can do to make search in all categories at once?, Thank you very much.

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hi, I miss a little function of this module, that will be very useful:

When I am in some category, I like to show all products in price range I selected that belong to category I choose.

If I do it now it shows all products independent on category I choose.

Can anyone help me? Any idea?

Share this post


Link to post
Share on other sites

  • 1 month later...

OK, re:CSS.

In fact product_list.css is not loaded by the page as nowhere in the PHP it"s requested.

You can check, as an example, the declaration in the file CategoryController.php that requests this CSS file as an extension to the current loaded styles

public function setMedia()
{
	parent::setMedia();
	Tools::addCSS(array(
		_PS_CSS_DIR_.'jquery.cluetip.css' => 'all',
		_THEME_CSS_DIR_.'scenes.css' => 'all',
		_THEME_CSS_DIR_.'category.css' => 'all',
		[color=#0000ff]_THEME_CSS_DIR_.'product_list.css' => 'all'[/color]));

	if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
		Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
}

 

Ugly/dirty (but quick) method to solve pb:

* locate product_list.css in your theme CSS directory,

* copy all content from the file,

* open shopbyprice.tpl

* add

<style></style>

* in between these tags, paste the content from product_list.css

 

Nice way : I do suppose that the best way to achieve this would be to transform shopbyprice.php so that it extends the main controller...???

 

Sincerely

DJM

 

Dear DJM,

 

Thanks for your effort..

 

But unfortunately, it didnt worked for me. If you see my website www.flowerstovizag.com, after clicking on Shop by price 1-300$ category, it is openign but the css is not good.

What exactly i need to do id removing right coulumn and expand the width of this shopbyprice.php page.

 

Please help me in doing this.

 

Regards

Vivek sakhilati

Share this post


Link to post
Share on other sites

  • 2 months later...

Absolutely great module. Well done!

 

13/3: Found the sorting according the original/normal price, where special/reduced price are enabled. Is there anyway to change the sorting by special/reduced price?

 

14/3: Pagination problem... Any Idea? <found something interesting, once you have selected the category then select the price range. it will works perfectly. that means without category selection, shopbyprice pagination wont works> it's clear something to do with id_category.

 

15/3: As a conclusion, up to version 1.4 even more errors and buggy. Minor changes wont help. Uninstalled!

 

Thanks.

 

Run on PS 1.4.4.1

Share this post


Link to post
Share on other sites

  • 3 weeks later...

[FREE MODULE] Shop by Price...

 

Pagination don't work, just the first 5 or 10 products...

 

It's a great module and very usefull only if it works like it should be. Anyone to fix it? Donation is waiting to give :)

Share this post


Link to post
Share on other sites

  • 3 weeks later...
  • 1 month later...

My fix to pagination problem.

 

I added this line in shopbyprice.php (around line 113):

 

 

$p = $_GET['p'];

 

Then added this:

 

if (empty($p)) $p = $controller->p;

 

And then changed the following line to use $p instead of $controller-p.

 

$result = productsbyPrice(intval($cookie->id_lang), intval($p) - 1, intval($controller->n), $controller->orderBy, $controller->orderWay, $id_category);

 

In my case, the pagination was not working because $controller->p was empty. This solved the issue.

  • Like 2

Share this post


Link to post
Share on other sites

  • 1 month later...

I still have the pagination problem. I have tried the fix of JulianM, but it doesn't work. it returns "no product in that price range".

I also tried the default pagination.tpl, but always display the first page.

I use 1.47. Anybody can help?

Thank you.

Share this post


Link to post
Share on other sites

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

Hi

 

Thanks for module and hope you will continue to update it.

 

And about price out o range fix I made some changes to your code but it still don't work in some cases.

Fix is for searching products depending on tax display choice (inc or excl) but problem remains for products with price drop and for products which have default combination with price impact (different then 0).

 

Ok for fix in file shopbyprice.php find

		function getQuery()
	{

		if (getmaxPrice())
		{
			$query = 'AND p.`price` BETWEEN '.getminPrice().' and '.getmaxPrice().'';
		}
		 else
		{
			$query = 'AND p.`price` >= '.getminPrice().'';
		}

	return $query;
	}

 

and replace it with

 

		function getQuery()
	{
		$price_tax_exl = Product::getTaxCalculationMethod();
		if (getmaxPrice())			
		{
			if (!$price_tax_exl)
			{
				$query = 'AND p.`price`* ((100 + (t.`rate`))/100)  BETWEEN '.getminPrice().' and '.getmaxPrice().'';
			}
			else
			{
				$query = 'AND p.`price` BETWEEN '.getminPrice().' and '.getmaxPrice().'';				
			}

		}
		 else
		{
			if ( !$price_tax_exl )
			{
				$query = 'AND p.`price`* ((100 + (t.`rate`))/100) >= '.getminPrice().'';
			}
			else
			{
				$query = 'AND p.`price` >= '.getminPrice().'';
			}

		}

	return $query;
	}

sorry ,what page I add this code ??

Share this post


Link to post
Share on other sites

  • 2 weeks later...

I used this module it was working very smooth, but after 1 6months on the result page it is not showing pagination, so only some products are comming on the result page, not all of the products

Please help

Share this post


Link to post
Share on other sites

  • 2 months later...

Thank you for this helpful module.

I didn't install it yet but read all the previous comments. It's amazing what you people are doing.

I'm new on Prestashop and don't want to mess around very much this my shop. Please let me know if this module is working on PS 1.5.3.1

Thank you once again.

Share this post


Link to post
Share on other sites

  • 3 months later...
  • 2 weeks later...
  • 1 year later...
  • 3 months later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More