Jump to content

[SOLVED] Multistore problem blocklayered module


Recommended Posts

Hi guys,

 

I've been messing around with version 1.6 in multistore mode quite a lot since beta and I must say I really do love it (eventhough it can sometimes get a bit confusing).

 

Filter module is one of the most crucial features I was looking forward to. BUT it does NOT work properly in multistore mode. When it creates index for one store, it deletes everything for other stores. I almost wanted to cry when I noticed that...

 

Has anyone manage to find a workaround for this?

 

Thank you for any response!

Edited by jadeitelibraswallow (see edit history)
  • Like 2
Link to comment
Share on other sites

Okay I have found a quick workaround for this issue.

 

Edit file modules/blocklayered/blocklayered.php

 

Go to the line 881 and replace

Db::getInstance()->execute('
            INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`, `id_shop`)
            SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group, product_attribute_shop.`id_shop`
            FROM '._DB_PREFIX_.'product_attribute pa'.
            Shop::addSqlAssociation('product_attribute', 'pa').'
            INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
            INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute)
            INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group
            '.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).'
            GROUP BY a.id_attribute, pa.id_product , product_attribute_shop.`id_shop`'
        );

with

Db::getInstance()->execute('
			INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`, `id_shop`)
			SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group, pas.id_shop
			FROM '._DB_PREFIX_.'product_attribute pa
			INNER JOIN '._DB_PREFIX_.'product_attribute_shop pas ON pas.id_product_attribute = pa.id_product_attribute
			INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
			INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute)
			INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group
			'.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).'
			GROUP BY a.id_attribute, pa.id_product, pas.id_shop'
		);

I'll try to send a pull request to developers because I don't like "hardcoding" like this :)

 

Hope it helps other people who are struggling with the same issue.

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

Thank you Samir for your help.

 

We have replaced the code by yours and blocklayered still not working in our second store (in the first go fine with original blocklayered and with yours solution). We are working with prestashop 1.6.0.6 and blocklayered 1.11. I'm thinking that our versions are more recents, may be?

 

We have tried many possibilities rebuilding the indexes and changing the templates, but no way to make it work.

 

Thanks for any help.

Link to comment
Share on other sites

  • 2 months later...

Thank you Samir for your help.

 

We have replaced the code by yours and blocklayered still not working in our second store (in the first go fine with original blocklayered and with yours solution). We are working with prestashop 1.6.0.6 and blocklayered 1.11. I'm thinking that our versions are more recents, may be?

 

We have tried many possibilities rebuilding the indexes and changing the templates, but no way to make it work.

 

Thanks for any help.

 

I have Prestashop 1.6.0.9 (so the most recent at this time) but blocklayered module is in version 2.0.1 (according to the config.xml file in the module's folder). This combination works. So try to update your module and keep me updated :)

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

  • 4 weeks later...
  • 3 weeks later...
  • 2 weeks later...

I am using the latest version PS 1.6.0.9 with module version 2.0. and it partly worked for me. 

I said partly worked because i have 3 stores and it only worked for 2 of my stores.

Any Idea why? 

Thank you for the solution samiramisek.

 

Kindest Regards

Gordon

Link to comment
Share on other sites

I am using the latest version PS 1.6.0.9 with module version 2.0. and it partly worked for me. 

I said partly worked because i have 3 stores and it only worked for 2 of my stores.

Any Idea why? 

Thank you for the solution samiramisek.

 

Kindest Regards

Gordon

I finally got my Layered Block Navigation to work with my 3 store. I think Being my 3rd store uses a different default currency from the other 2 stores, I removed the price Product Price Filter, saved the template and it worked. Strange but it worked :-) .. Finally I can move to the next step before going live. Thanks for all your help guys.. Especially samiramisek. :-) 

Link to comment
Share on other sites

I finally got my Layered Block Navigation to work with my 3 store. I think Being my 3rd store uses a different default currency from the other 2 stores, I removed the price Product Price Filter, saved the template and it worked. Strange but it worked :-) .. Finally I can move to the next step before going live. Thanks for all your help guys.. Especially samiramisek. :-) 

 

Glad you figured it out!

Link to comment
Share on other sites

Hello all,

 

I've got version of Layered block 2.0.4 and presta 1.6.0.6 and it still doesn't work at all. Employee from shop A can delete a template from shop B what will "disable" the block in shop B. 

 

The block is still useless isn't it.

 

I think a template created by an employee of a shop A shouldn't be visable to any other employees.

And to modify coding after an update ... it is not a solution.

Link to comment
Share on other sites

I finally got my Layered Block Navigation to work with my 3 store. I think Being my 3rd store uses a different default currency from the other 2 stores, I removed the price Product Price Filter, saved the template and it worked. Strange but it worked :-) .. Finally I can move to the next step before going live. Thanks for all your help guys.. Especially samiramisek. :-) 

 

 

It happened to me, too, but after the first indexing it disappeared. In the end I went for the 3rd party solution which works good.

Link to comment
Share on other sites

 

Hello all,
 
I've got version of Layered block 2.0.4 and presta 1.6.0.6 and it still doesn't work at all. Employee from shop A can delete a template from shop B what will "disable" the block in shop B. 
 
The block is still useless isn't it.
 
I think a template created by an employee of a shop A shouldn't be visable to any other employees.
And to modify coding after an update ... it is not a solution.

 

 

That is one of the points I mention on this bug report: http://forge.prestashop.com/browse/PNM-2840 please vote and comment there to try to get some response from the team.

Link to comment
Share on other sites

  • 1 year later...
  • 9 months later...

I can confirm that this bug still exists in PS 1.6.1.11 and blocklayered 2.2.0.

 

I will include what fixed this issue for me, combined with my other need not to show out of stock attributes:

 

blocklayered.php

 

approx. row 870, function indexAttribute:

		Db::getInstance()->execute('
			INSERT INTO `'._DB_PREFIX_.'layered_product_attribute` (`id_attribute`, `id_product`, `id_attribute_group`, `id_shop`)
			SELECT pac.id_attribute, pa.id_product, ag.id_attribute_group, pas.id_shop
			FROM '._DB_PREFIX_.'product_attribute pa
			INNER JOIN '._DB_PREFIX_.'product_attribute_shop pas ON pas.id_product_attribute = pa.id_product_attribute
			INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pac.id_product_attribute = pa.id_product_attribute
			INNER JOIN '._DB_PREFIX_.'stock_available sa ON (sa.id_product_attribute = pac.id_product_attribute AND sa.quantity > 0)
			INNER JOIN '._DB_PREFIX_.'attribute a ON (a.id_attribute = pac.id_attribute)
			INNER JOIN '._DB_PREFIX_.'attribute_group ag ON ag.id_attribute_group = a.id_attribute_group
			'.(is_null($id_product) ? '' : 'AND pa.id_product = '.(int)$id_product).'
			GROUP BY a.id_attribute, pa.id_product, pas.id_shop'
		);

approx row 1800, under case: 'id_attribute_group':

					foreach ($sub_queries as $sub_query) 
					{
						$query_filters_where .= ' AND p.id_product IN (SELECT pa.`id_product`
						FROM `'._DB_PREFIX_.'product_attribute_combination` pac
						LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
						ON (pa.`id_product_attribute` = pac.`id_product_attribute`)'.
						Shop::addSqlAssociation('product_attribute', 'pa').'
						JOIN `'._DB_PREFIX_.'stock_available` sa
						ON (sa.`id_product_attribute`=pac.`id_product_attribute` AND sa.`quantity`>0)
						WHERE '.implode(' OR ', $sub_query).') ';
					}

In order to make the block appear you have to go through all your shops, go in the product list, check all the enabled products and from mass actions enable them again.

(Possibly indexing attributes works too, but I found out this to be the most reliable method).

 

Hope this helps somebody, cheers.

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

×
×
  • Create New...