Select category to use for Google products plugin

  • Posts: 128
  • Thank you received: 3
8 years 2 weeks ago #234734

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.3.24

Is there a way I can modify the Google products plugin to where I can select what product categories to use for my feed instead of using all of them?

Please Log in or Create an account to join the conversation.

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
8 years 2 weeks ago #234750

Hi,

Sure.
You want to edit the file plugins/hikashop/google_products/google_products.php and for example, you could change the line:
$queryCategoryId = 'SELECT * FROM '.hikashop_table('product_category').' WHERE product_id IN ('.implode(',',$ids).')';
to:
$queryCategoryId = 'SELECT * FROM '.hikashop_table('product_category').' WHERE product_id IN ('.implode(',',$ids).') AND category_id NOT IN( XXX, YYY, ZZZ )';

Then, the categories XXX, YYY and ZZZ wouldn't be used in the XML feed.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
8 years 2 weeks ago #234812

Ok I gotcha on this. I have different prices for different user groups for each product, such as dealer prices and regular customer prices. I need to make this plugin where it will only retrieve products with prices for user groups I select. I added this field to the xml file

<param name="price_access" type="sql" default="" label="User group prices" description="Choose the group prices that you want displayed in your feed." query="SELECT id AS value, title AS title FROM #__usergroups" multiple="multiple" />

How can I use this to where it will only show products where the prices equal the user groups I select?

Please Log in or Create an account to join the conversation.

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
8 years 2 weeks ago #234833

That's quite complex as the system isn't supposed to handle that.
It automatically takes the prices of the user who is logged in and is generating the XML.
I would recommend to simply create a user with the user groups you want and access to the backend and then generate the XML manually with that user.

Otherwise, you would have to directly modify the function hikashop_addACLFilters in the file administrator/components/com_hikashop/helpers/helper.php which is the function used everywhere to handle user groups restrictions.
So you would need your plugin to set a global variable, for example in the $_SESSION, and then check it in that function to force the user groups check, and then unset it in the $_SESSION in the plugin before existing.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 3
8 years 2 weeks ago #234921

I'm logged in as the superuser when generating configuring this plugin and generating the xml and it is taking the prices from my dealer price access not the superuser. Why is it not using my superuser prices if I'm logged in as the superuser?

Please Log in or Create an account to join the conversation.

  • Posts: 81504
  • Thank you received: 13064
  • MODERATOR
8 years 2 weeks ago #234941

You're right, I forgot a condition.

In the code of the plugin, you can change the call to the getListingPrices function and add a fifth parameter witht he id of the user for which you want to load the prices.

Please Log in or Create an account to join the conversation.

  • Posts: 344
  • Thank you received: 3
7 years 6 months ago #251488

Hika 2.6.4.
Joomla 3.6.2

Hi,

Sure.
You want to edit the file plugins/hikashop/google_products/google_products.php and for example, you could change the line:
$queryCategoryId = 'SELECT * FROM '.hikashop_table('product_category').' WHERE product_id IN ('.implode(',',$ids).')';
to:
$queryCategoryId = 'SELECT * FROM '.hikashop_table('product_category').' WHERE product_id IN ('.implode(',',$ids).') AND category_id NOT IN( XXX, YYY, ZZZ )';

Then, the categories XXX, YYY and ZZZ wouldn't be used in the XML feed.

I don't get this. Should XXX, YYY be the ID of the categories I want to exclude from the Google feed ?

Last edit: 7 years 6 months ago by river.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
7 years 6 months ago #251491

Hi,

Yes ; that's what Nicolas wrote and that's what the SQL query is saying too.
" category_id NOT IN (x, y, z) " means that the category_id should not be in the list.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.081 seconds
Powered by Kunena Forum