Post by xena » Sat Dec 24, 2011 3:04 am

I am using v1.5.1.3.
I have several different customer groups that each have their own set of prices. When I log on as one of my test customers in a discounted group I sometimes see the undiscounted price in the latest or bestsellers. If I follow the link to the product page I see the correct price. This seems like a caching issue, but not sure how to fix it. I've tried going into the product from admin and resaving it, but it still doesn't show the correct price. Any ideas?
Last edited by xena on Thu Feb 09, 2012 6:26 am, edited 1 time in total.

User avatar
New member

Posts

Joined
Fri Oct 14, 2011 12:31 am

Post by Renato Frota » Wed Feb 08, 2012 10:11 am

catalog/model/catalog/product.php

in the function getLatestProducts, find

Code: Select all

		$product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit);
replace with

Code: Select all

		if ($this->customer->isLogged()) {
			$customer_group_id = $this->customer->getCustomerGroupId();
		} else {
			$customer_group_id = $this->config->get('config_customer_group_id');
		}	
		$product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit);
some lines below, find

Code: Select all

			$this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit, $product_data);
replace with

Code: Select all

			$this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit, $product_data);
in the function getBestSellerProducts, find

Code: Select all

		$product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit);
replace with:

Code: Select all

		if ($this->customer->isLogged()) {
			$customer_group_id = $this->customer->getCustomerGroupId();
		} else {
			$customer_group_id = $this->config->get('config_customer_group_id');
		}	
		$product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit);
some lines below, find

Code: Select all

			$this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit, $product_data);
replace with

Code: Select all

			$this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit, $product_data);

New member

Posts

Joined
Wed Aug 31, 2011 1:21 pm

Post by Renato Frota » Wed Feb 08, 2012 10:23 am

note: "Special" module could be update to use cache as well, considering groups this way.

New member

Posts

Joined
Wed Aug 31, 2011 1:21 pm

Post by Daniel » Wed Feb 08, 2012 2:12 pm

thanks. added this to the svn.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by xena » Thu Feb 09, 2012 6:23 am

Great, thanks! I've put your code into an xml file for anyone who is using vqmod:

Code: Select all

<modification>
        <id>Modify formats</id>
        <version>1.0</version>
        <vqmver>1.0.8</vqmver>
        <author>Xena, code by Renato Frota</author>

<!-- modify date formats -->		
        <file name="catalog/model/catalog/product.php">
                <operation>
                        <search position="replace"><![CDATA[
                         $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit);
                        ]]></search>
                        <add><![CDATA[
                         if ($this->customer->isLogged()) {
         $customer_group_id = $this->customer->getCustomerGroupId();
      } else {
         $customer_group_id = $this->config->get('config_customer_group_id');
      }   
      $product_data = $this->cache->get('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit);
                        ]]></add>
						
                </operation>
			
				
				 <operation>
                        <search position="replace"><![CDATA[
                        $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit, $product_data);
                        ]]></search>
                        <add><![CDATA[
                        $this->cache->set('product.latest.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit, $product_data);
                        ]]></add>
						
                </operation>
				
				
				 <operation>
                        <search position="replace"><![CDATA[
                        $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit);
                        ]]></search>
                        <add><![CDATA[
                        if ($this->customer->isLogged()) {
         $customer_group_id = $this->customer->getCustomerGroupId();
      } else {
         $customer_group_id = $this->config->get('config_customer_group_id');
      }   
      $product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit);
                        ]]></add>
						
                </operation>
				
				 <operation>
                        <search position="replace"><![CDATA[
                        $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$limit, $product_data);
                        ]]></search>
                        <add><![CDATA[
                       $this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $customer_group_id . '.' . (int)$limit, $product_data);
                        ]]></add>
						
                </operation>
        </file>
		
</modification>


User avatar
New member

Posts

Joined
Fri Oct 14, 2011 12:31 am

Post by Renato Frota » Thu Feb 09, 2012 9:59 pm

Thanks. I made a vqmod for me as well.

Just a suggestion: try to not use full lines as search strings. The after/before operations ever add the new content afoter/before the whole line where the search string was found.

You could search only: $this->cache->get('product.latest
And: $this->cache->set('product.bestseller

New member

Posts

Joined
Wed Aug 31, 2011 1:21 pm
Who is online

Users browsing this forum: No registered users and 44 guests