Mass update of a characteristic's price based on main price

  • Posts: 248
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
1 year 1 month ago #349979

-- url of the page with the problem -- : eop-inc.com
-- HikaShop version -- : 4.7.1
-- Joomla version -- : 3.10.11
-- PHP version -- : 7.4.33
-- Browser(s) name and version -- : Chrome

Hi,
I've a site for clothing where I need to mass add/update the price for all articles that are of the size XXL. It needs to be the main item price plus $2
So if the shirt price is $25 I need to update all of the XXL sized shirts to $27.

Is this possible? I've tried the action of
Update the values
price_value = OPERATION price.price_value+2

But of course that didn't work

Any assistance gratefully appreciated

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 1 month ago #349986

Hi,

The action you tried would work if only you had already the main product price entered in the variant's price.
You'll have to run a MySQL query directly in your PHPMyAdmin to do that.
Something like that would add the variant price based on the main product price:

INSERT into #__hikashop_price (price_product_id, price_value, price_currency_id, price_min_quantity) SELECT main.product_id, main_price.price_value+2, main_price.price_currency_id, main_price.price_min_quantity FROM #__hikashop_product AS main LEFT JOIN #__hikashop_product as variant on main.product_id = variant.product_parent_id LEFT JOIN #__hikashop_variant as link ON variant.product_id = link.product_id LEFT JOIN #__hikashop_characteristic as characteristic_value ON characteristic_value.characteristic_id=link.characteristic_id LEFT JOIN #__hikashop_characteristic AS characteristic ON characteristic_value.characteristic_parent_id=characteristic.characteristic_id LEFT JOIN #__hikashop_price as main_price ON main.product_id = main_price.price_product_id
WHERE characteristic.characteristic_value = 'XXX' AND characteristic_value.characteristic_value = 'YYY'
where XXX is the name of the characteristic and YYY the value of the characteristic you want to target, and #__ the table prefix of your website tables.
As you can see, that's quite a complex MySQL query...

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

  • Posts: 248
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
1 year 1 month ago #350119

Thanks for that. Unfortunately I need to come up with a process that the client can use and modify each time they enter a new item in their shop. She is not savvy enough to manipulate and run the queries in the DB each time.

Is there a way using Mass Actions to populate each variant's price with the main price? Then I can create three others for her to update 2XL, 3XL and 4XL items.

Last edit: 1 year 1 month ago by a2zcs.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 1 month ago #350122

Hi,

Then I don't see a way without some development. I guess the easiest would be to use the same principle as the "main product price percentage" setting of the variants but to add a setting for a fixed amount to add.
That way, the variant price would be calculated dynamically based on the main product price, and you would just have to update the main product prices without worrying of the variants.

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

Time to create page: 0.059 seconds
Powered by Kunena Forum