12 lines
2.9 KiB
Python
12 lines
2.9 KiB
Python
import subprocess
|
|
def q(s):return subprocess.check_output(['mysql','-N','dunerealms_oscommerce','-e',s],text=True).strip()
|
|
def run(s):subprocess.run(['mysql','dunerealms_oscommerce'],input=s,text=True,check=True,capture_output=True)
|
|
oid=int(q("SELECT products_options_id FROM products_options WHERE products_options_name IN ('Ribbon finish','Side edging') LIMIT 1"))
|
|
gold=q("SELECT products_options_values_id FROM products_options_values WHERE products_options_values_name='Gold side edging' LIMIT 1")
|
|
if not gold:
|
|
gold=int(q('SELECT MAX(products_options_values_id)+1 FROM products_options_values'))
|
|
run(f"INSERT INTO products_options_values(products_options_values_id,language_id,products_options_values_name,custom_input_type) VALUES({gold},1,'Gold side edging',0);INSERT INTO products_options_values_to_products_options(products_options_id,products_options_values_id) VALUES({oid},{gold});")
|
|
run(f"UPDATE products_options SET products_options_name='Side edging' WHERE products_options_id={oid};UPDATE products_options_values SET products_options_values_name='Standard side edging (included)' WHERE products_options_values_name='Standard finish (included)';UPDATE products_options_values SET products_options_values_name='Silver side edging' WHERE products_options_values_name='Silver edges';INSERT INTO products_attributes(products_id,options_id,options_values_id,options_values_price) SELECT d.products_id,{oid},{gold},62.5 FROM dune_catalog_import d WHERE d.kind='sash' AND NOT EXISTS(SELECT 1 FROM products_attributes a WHERE a.products_id=d.products_id AND a.options_values_id={gold} AND a.options_id={oid});")
|
|
run("INSERT IGNORE INTO products_attributes_prices(products_attributes_id,groups_id,currencies_id,attributes_group_price) SELECT a.products_attributes_id,g.g,c.c,a.options_values_price FROM products_attributes a JOIN dune_catalog_import d ON d.products_id=a.products_id CROSS JOIN (SELECT 0 g UNION SELECT groups_id FROM `groups`) g CROSS JOIN (SELECT 0 c UNION SELECT currencies_id FROM currencies) c;")
|
|
run("UPDATE properties_values v JOIN properties_to_products p ON p.values_id=v.values_id AND p.properties_id=v.properties_id JOIN properties_description d ON d.properties_id=v.properties_id AND d.language_id=v.language_id JOIN dune_catalog_import i ON i.products_id=p.products_id AND i.kind='sash' SET v.values_text='Made to order. Collection preview: ordering is not open.' WHERE d.properties_name='Availability';UPDATE properties_values v JOIN properties_to_products p ON p.values_id=v.values_id AND p.properties_id=v.properties_id JOIN properties_description d ON d.properties_id=v.properties_id AND d.language_id=v.language_id SET v.values_text='Standard side edging included; silver sides +€50, gold sides +€75. Bottom fringe unchanged.' WHERE p.products_id=76 AND d.properties_name IN ('Trim','Finish');")
|
|
print('All 12 sashes: required preferred name; standard/silver +50/gold +75 side edging. Bottom fringe retained.')
|

Staff