O
O
Oleg Korolenko2018-08-13 20:23:50
SQL
Oleg Korolenko, 2018-08-13 20:23:50

How to set product options in Opencart 1.5 via SQL?

Guys: such a question: There is a site on opencart. It is necessary to put down the Option (Promotional product (option_id = 17))
and the value of this option (Contract price (option_value_id = 65)) for certain products in bulk.
Options are used in the product filter
. I do it like this (I add an option to products):

insert into ukr_product_option (product_id, option_id, option_value, required)
  
SELECT product_id,17,65,0from ukr_product
  
where product_type_id = 4;

product_type_id - custom field with product types.
Next, I set the value of the option:
insert into ukr_product_option_value (product_option_id, product_id, option_id, option_value_id, quantity, subtract, price, price_prefix, points, points_prefix, weight, weight_prefix)
  
select product_option_id,
product_id,
17,
65,
0,
0,
0.0000,
'+',
0,
'+',
0.00000000,
'+'from ukr_product_option 
where option_id = 17;

Everything seems to work correctly, an option with the correct value appears in the product card, a counter next to the filter (which on the category page shows how many products match a certain filter, also displays the correct number of products), but does not filter.
I click on the filter - no products are displayed .. But after I just go to the card and save the product, everything works as it should.
Tell me what could be the problem? (CACHE CLEANED)
Options are still written somewhere, or is there something wrong in the cache?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
web-mechanic, 2018-08-13
@legoex

create an option, add it to the product and see what has changed in the database tables, then export the records, here you will have an example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question