';
+ $tiles=[['Ceremonial sashes',$sashes.' designs · made to order','catalog/all-products','nav-clan-v2.webp','sash'],['Donor ranks',$ranks.' ways to support the realms','catalog/all-products','nav-account-v2.webp','rank'],['Sale',count($saleIds)?'Explore current offers':'No sales active right now','catalog/sales','nav-exchange-v2.webp','']];
+ $out.='';
+ foreach([['New arrivals','Recently added to the collection',array_slice($rows,0,6),'catalog/products-new'],['Featured','Selected pieces from the realms',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$featuredIds))),'catalog/featured-products'],['Sale','Current offers from the emporium',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$saleIds))),'catalog/sales']] as [$title,$sub,$items,$route]){
+ $out.='
';
+ }
+ $out.='';
+ }
+ $out.='';
+ return $this->renderContent($out);
+ }
+}
diff --git a/website/ops/oscommerce/dune-shop-cards.css b/website/ops/oscommerce/dune-shop-cards.css
new file mode 100644
index 00000000..fc80cc0d
--- /dev/null
+++ b/website/ops/oscommerce/dune-shop-cards.css
@@ -0,0 +1,30 @@
+/* DuneRealms dev alpha storefront: readable framed cards and specification rows. */
+html,body{height:auto!important;min-height:0!important}.main-content{min-height:280px!important}
+.w-logo,.warrantyProduct,.tripleBanner,#box-110187{display:none!important}
+.main-content .title,.main-content .heading,.main-content .categories-title,.main-content strong{color:#e8d39b!important}
+.w-product-model,.w-product-description-short,.w-product-description,.w-product-properties,.productNavigation{background:linear-gradient(135deg,#1b3d30,#102a21)!important;border:1px solid #8e7b48!important;border-radius:13px!important;box-shadow:0 7px 22px #0002!important;padding:20px!important;margin-bottom:16px!important;box-sizing:border-box!important}
+.productNavigation{border-top:3px solid #c5a65a!important}.productNavigation .block{background:transparent!important}
+.w-product-description-short{line-height:1.7!important}.w-product-model{font-size:13px!important;letter-spacing:.025em;color:#c4cfbc!important}
+.w-product-attributes .select-box{display:block!important;padding:0 0 18px!important;margin:0 0 18px!important;border-bottom:1px solid #526341!important}.w-product-attributes .attr-title{display:block!important;font-size:14px!important;font-weight:600!important;color:#e7d7b0!important;margin-bottom:10px!important;line-height:1.5!important}
+.w-product-attributes input[type=text],.w-product-attributes select:not([style*="display:none"]){width:100%!important;min-height:46px!important;padding:12px 14px!important;box-sizing:border-box!important;background:#091f18!important;border:1px solid #9f8c55!important;border-radius:8px!important;color:#fff0cb!important;font-size:15px!important}.w-product-attributes input::placeholder{color:#a3b6a5!important}.w-product-attributes input:focus{outline:2px solid #d8b65e!important;outline-offset:3px}
+.w-product-price,.w-product-price *,.product-price-current,.price-current,#product-price-current,#product-price-current *{color:#f1d58a!important;opacity:1!important}.w-product-price{font-size:30px!important;font-weight:700!important;margin:12px 0!important}.w-product-stock{color:#e4c890!important}.w-product-quantity input{color:#f4ead2!important}
+.w-product-properties{max-width:none!important;padding:0!important;overflow:hidden!important}.product-properties{width:100%!important;max-width:none!important;font-size:14px!important;line-height:1.65!important}
+.product-properties .properties-table,.product-properties .property-ul{display:grid!important;grid-template-columns:minmax(140px,28%) minmax(0,1fr)!important;gap:0!important;width:100%!important;margin:0!important;padding:0!important;list-style:none!important;border-bottom:1px solid #3b5745!important;background:#143227!important;box-sizing:border-box!important}
+.product-properties .property-ul:nth-child(even),.product-properties .properties-table:nth-child(even){background:#193a2c!important}.product-properties li{float:none!important;display:block!important;width:auto!important;max-width:none!important;padding:13px 18px!important;margin:0!important;box-sizing:border-box!important;text-align:left!important}.product-properties li:first-child{background:#0d251d80!important;border-right:1px solid #3b5745!important}.product-properties a,.product-properties span{color:#dce6d3!important;text-decoration:none!important}.product-properties strong,.product-properties strong span{color:#ddc586!important;font-weight:600!important}
+.w-product-images{padding:18px!important;background:radial-gradient(ellipse,#274b35,#10271e 75%)!important;border:1px solid #746943!important;border-radius:14px!important;box-sizing:border-box!important}.w-product-images .img-holder,.w-product-images .produst-image{height:380px!important;max-height:380px!important;padding-top:0!important;overflow:hidden!important}.w-product-images img{height:360px!important;max-height:360px!important;width:auto!important;max-width:100%!important;object-fit:contain!important;cursor:zoom-in}.w-product-images .additional-images img{height:64px!important;max-height:64px!important}.w-product-images a[data-fancybox-group]{display:flex!important;justify-content:center;align-items:center;height:100%!important}
+.w-product-images:after{content:'Click image to view full size';display:block;text-align:center;font-size:11px;color:#b9c9ad;padding-top:12px;letter-spacing:.035em}.main-content .btn,.main-content button{min-height:38px!important;font-size:13px!important}
+@media(max-width:680px){.product-properties .properties-table,.product-properties .property-ul{grid-template-columns:1fr!important}.product-properties li:first-child{border-right:0!important;padding-bottom:4px!important}.product-properties li+li{padding-top:4px!important}.w-product-images .img-holder,.w-product-images .produst-image{height:300px!important}.w-product-images img{height:280px!important;max-height:280px!important}}
+/* Balanced product columns with independent, consistently spaced cards. */
+#box-110822{display:grid!important;grid-template-columns:minmax(250px,30%) minmax(0,1fr)!important;gap:24px!important;max-width:1200px!important;margin:24px auto!important;padding:0!important;align-items:start!important}#box-110822>.block,#box-110830>.block{float:none!important;width:auto!important;min-width:0!important;padding:0!important;margin:0!important}#box-110830{display:grid!important;grid-template-columns:minmax(190px,1fr) minmax(270px,1.25fr)!important;gap:24px!important;padding:0!important;align-items:start!important}#box-110838,#box-110841{padding:0!important}#box-110839{width:100%!important;margin:0!important;padding:22px!important}.w-product-model,.w-product-description-short{text-align:center!important;margin:0 0 18px!important}.w-product-images{margin:0!important}.w-product-name{text-align:center!important}#product-attributes{display:flex!important;flex-direction:column!important;gap:18px!important}.w-product-attributes .select-box{float:none!important;clear:both!important;width:100%!important;min-width:0!important;margin:0!important;padding:0 0 18px!important;box-sizing:border-box!important}.w-product-attributes .textinput,.w-product-attributes .js-attr-text-input{display:block!important;width:100%!important;max-width:none!important}.w-product-attributes select{width:100%!important;max-width:none!important}.w-product-price,.w-product-stock,.w-product-quantity,.w-product-buttons{text-align:center!important}.main-content:has(input[name="products_id"][value="76"]) .w-product-quantity{display:none!important}.main-content:has(input[name="products_id"][value="76"]) .productNavigation:after{content:'Collection preview · ordering is not open';display:block;margin-top:18px;padding:12px;border:1px solid #6f7149;border-radius:8px;background:#253f2d;color:#e4d6ad;font-size:12px;line-height:1.5;text-align:center}
+@media(max-width:1050px){#box-110822{grid-template-columns:minmax(220px,35%) minmax(0,1fr)!important;gap:20px!important}#box-110830{grid-template-columns:1fr!important;gap:0!important}}@media(max-width:650px){#box-110822{grid-template-columns:1fr!important;gap:20px!important}.w-product-images{max-width:340px!important;width:100%!important;margin:auto!important}#box-110839{padding:18px!important}}
+/* Dev alpha table rhythm: alternating rows and a restrained hover highlight. */
+.main-content table{border:1px solid #756b45!important;border-collapse:separate!important;border-spacing:0!important;border-radius:11px!important;overflow:hidden!important;width:100%!important}.main-content table th{background:#244b36!important;color:#e8cd87!important;font-size:12px!important;letter-spacing:.035em!important;padding:13px 16px!important;text-align:left!important}.main-content table tbody tr:nth-child(odd){background:#102b21!important}.main-content table tbody tr:nth-child(even){background:#1b3a2c!important}.main-content table td{color:#e0e7d6!important;padding:13px 16px!important;border-bottom:1px solid #355340!important}.main-content table tbody tr:hover{background:#294a34!important}.product-properties .property-ul:nth-child(odd),.product-properties>.properties-table:nth-child(odd){background:#102b21!important}.product-properties .property-ul:nth-child(even),.product-properties>.properties-table:nth-child(even){background:#1b3a2c!important}.product-properties .property-ul:hover,.product-properties .properties-table:hover{background:#294a34!important;transition:background .15s}
+/* Product tabs use the same dev-alpha card treatment, including every state. */
+.w-tabs>.tab-navigation{display:flex!important;gap:12px!important;padding:0 0 16px!important;background:transparent!important;border:0!important}.w-tabs>.tab-navigation>.tab-li{flex:1!important;float:none!important;margin:0!important;border:0!important;background:transparent!important}.w-tabs .tab-navigation .tab-a,.w-tabs .accordion-heading{display:block!important;padding:16px 20px!important;border:1px solid #756c45!important;border-radius:10px!important;background:linear-gradient(135deg,#1c3e2e,#10291f)!important;color:#d8c391!important;font-size:15px!important;font-weight:600!important;line-height:1.4!important;text-align:center!important;box-shadow:0 4px 14px #0002!important}.w-tabs .tab-navigation .active .tab-a,.w-tabs .tab-navigation .tab-li.active .tab-a,.w-tabs .tab-navigation .tab-a.active,.w-tabs .accordion-heading.active{background:linear-gradient(135deg,#315238,#1a3828)!important;border-color:#cfaf59!important;color:#fff0c4!important;box-shadow:inset 0 2px #d6b35c,0 4px 14px #0002!important}.w-tabs .tab-navigation .tab-a:hover{background:#294b34!important;color:#fff0c4!important}.w-tabs>.block{background:transparent!important;border:0!important;padding:0!important}.w-tabs .tab-navigation .tab-a:focus-visible{outline:2px solid #e2c06c!important;outline-offset:3px}@media(max-width:500px){.w-tabs>.tab-navigation{gap:8px!important}.w-tabs .tab-navigation .tab-a{padding:12px 8px!important;font-size:13px!important}}
+/* Catalogue cards keep tall artwork at thumbnail scale. */
+.products-listing{display:grid!important;grid-template-columns:repeat(auto-fill,minmax(235px,1fr))!important;gap:22px!important;align-items:start!important}.products-listing>.item{float:none!important;clear:none!important;width:auto!important;max-width:340px!important;margin:0 auto!important;padding:0!important;box-sizing:border-box!important;border:1px solid #7a7047!important;border-radius:13px!important;overflow:hidden!important;background:linear-gradient(140deg,#1e402f,#10281f)!important;box-shadow:0 8px 22px #0002!important}.products-listing .item-holder,.products-listing .item-wrapper,.products-listing .item-content{background:transparent!important}.products-listing .item-content{padding:18px!important;text-align:center!important}.products-listing .image{height:270px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 0 16px!important;background:radial-gradient(ellipse,#294b35,transparent 75%)!important}.products-listing .image a,.products-listing .image picture{display:flex!important;align-items:center!important;justify-content:center!important;height:100%!important;width:100%!important}.products-listing .image img{height:250px!important;max-height:250px!important;max-width:100%!important;width:auto!important;object-fit:contain!important}.products-listing .price,.products-listing .price *{color:#f1d58a!important;font-size:24px!important;font-weight:700!important;opacity:1!important}.products-listing .name h2{font-size:18px!important;line-height:1.4!important;margin:12px 0!important}.products-listing .description{color:#bdcfbb!important;font-size:13px!important;line-height:1.6!important}.products-listing .item-nav{display:flex!important;align-items:center!important;justify-content:center!important;gap:14px!important;background:#10291f!important;padding:14px!important;border-top:1px solid #465d41!important}.products-listing .compare{font-size:11px!important;color:#bac9ae!important}.products-listing .out-stock{color:#c9b779!important;font-size:12px!important}.w-catalog-title h1{font-size:28px!important}.leftCategories,.leftCategories a,.w-catalog-counts-items{color:#d9d6ba!important}
+.header-middle .w-image{display:none!important}.header-middle{background:linear-gradient(110deg,#102d22ec,#153629de),url('https://www.dunerealms.com/assets/sietch.webp') center 45%/cover!important;padding:22px!important;border:1px solid #7a7047!important;border-radius:12px!important}.header-middle>.block{gap:22px!important}.header-middle .w-search{flex:1!important;min-width:180px!important}.header-middle .search-input{background:#0a2019!important;border:1px solid #8f8050!important;border-radius:8px!important;color:#eee4c9!important;min-height:44px!important}.w-cart .cart-icon,.w-account .account-icon{background:#294a32!important;color:#e0c47a!important}.header-menu-holder a{font-size:13px!important;letter-spacing:.04em!important;color:#e1cc94!important}.header-menu-holder a:hover{background:#294a32!important}.footer-bottom{background:#10271e!important;color:#9db39e!important}.w-catalog-view .active{background:#34563b!important;color:#f0d692!important}.w-catalog-view a{color:#dac381!important}.w-search input{color:#f3e8cc!important}.w-languages,.w-currencies{color:#dfd5b9!important}
+/* Commercial storefront home, using real catalogue data. */
+.dune-store-welcome{display:flex;align-items:center;justify-content:space-between;gap:28px;border:1px solid #9a8349;border-radius:16px;padding:40px;margin:0 auto 24px;background:linear-gradient(100deg,#0b261aec,#173c2cc7),url('https://www.dunerealms.com/assets/sietch.webp') center/cover;box-shadow:0 12px 30px #0003}.dune-store-welcome small{color:#ceb36e;letter-spacing:.16em;font-size:11px}.dune-store-welcome h1{font-size:clamp(28px,3vw,43px);line-height:1.15;margin:14px 0!important;max-width:600px}.dune-store-welcome p{font-size:15px;line-height:1.7;color:#ccd9c4;max-width:570px;margin-bottom:24px}.dune-store-welcome>img{width:155px;height:155px;object-fit:contain;filter:drop-shadow(0 8px 18px #0008)}.dune-store-button{display:inline-flex!important;align-items:center;justify-content:center;padding:11px 18px;border:1px solid #b79a53;border-radius:8px;background:linear-gradient(#385b39,#23422c);color:#f5e1ad!important;font-size:13px;font-weight:600;text-decoration:none!important;box-shadow:0 4px 12px #0003}.dune-store-button:hover{background:#416345;transform:translateY(-1px)}
+.dune-store-categories{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-bottom:34px}.dune-store-categories>a{display:flex;align-items:center;gap:16px;padding:22px;border:1px solid #6e7046;border-radius:12px;background:linear-gradient(130deg,#21412e,#112b20);text-decoration:none!important;transition:border-color .15s,transform .15s}.dune-store-categories>a:hover{border-color:#d4b369;transform:translateY(-2px)}.dune-store-categories img{width:58px;height:58px;object-fit:contain}.dune-store-categories h2{font-size:17px!important;margin:0 0 6px!important}.dune-store-categories p{margin:0;color:#afc2aa;font-size:12px;line-height:1.5}.dune-store-categories span{margin-left:auto;color:#dfc37f;font-size:20px}.dune-store-section{margin:0 0 32px;border:1px solid #486143;border-radius:13px;padding:24px;background:#102a20}.dune-store-section>header{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:22px;padding-bottom:16px;border-bottom:1px solid #425b40}.dune-store-section h2{font-size:23px!important;margin:0 0 7px!important}.dune-store-section header p{margin:0;color:#aabea5;font-size:12px}.dune-store-section header>a{font-size:12px;color:#d9be7b!important;white-space:nowrap}.dune-store-products{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}.dune-store-products article{display:flex;flex-direction:column;align-items:center;text-align:center;border:1px solid #536a47;border-radius:11px;background:linear-gradient(145deg,#1b3b29,#0c251b);padding:18px;box-sizing:border-box}.dune-store-product-art{display:flex;align-items:center;justify-content:center;width:100%;height:230px;margin-bottom:16px;background:radial-gradient(ellipse,#2f5033,transparent 72%)}.dune-store-product-art img{display:block!important;height:220px!important;max-height:220px!important;max-width:100%!important;width:auto!important;object-fit:contain}.dune-store-products small{font-size:9px;letter-spacing:.12em;color:#b8a66e}.dune-store-products h3{font-size:16px!important;line-height:1.45;margin:10px 0!important}.dune-store-products h3 a{color:#e6d5a3!important;text-decoration:none}.dune-store-price{font-size:23px;font-weight:700;color:#f1d28a;margin:auto 0 16px;padding-top:8px}.dune-store-products .dune-store-button{width:100%;box-sizing:border-box}.dune-store-empty{border:1px dashed #566849;border-radius:9px;padding:26px;color:#afc1a5;text-align:center;font-size:13px;background:#183223}.dune-store-preview{border-left:3px solid #b99850;border-radius:9px;background:#243c28;padding:20px 24px;color:#cad5ba;font-size:13px;line-height:1.7}.dune-store-preview strong{color:#e1c785}.dune-store-preview p{margin:6px 0 0}
+@media(min-width:1500px){.dune-store-products{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(max-width:900px){.dune-store-categories{grid-template-columns:1fr}.dune-store-products{grid-template-columns:repeat(2,minmax(0,1fr))}.dune-store-welcome{padding:28px}.dune-store-welcome>img{width:110px;height:110px}}@media(max-width:550px){.dune-store-welcome{padding:24px;gap:12px}.dune-store-welcome>img{display:none}.dune-store-products{grid-template-columns:1fr}.dune-store-section{padding:18px}.dune-store-section>header{align-items:flex-start}.dune-store-product-art{height:210px}.dune-store-product-art img{height:200px!important}.header-middle>.block{flex-wrap:wrap!important;justify-content:center!important}.header-middle .w-search{flex-basis:100%!important}}
diff --git a/website/ops/oscommerce/finish-catalog-edging.py b/website/ops/oscommerce/finish-catalog-edging.py
new file mode 100644
index 00000000..611a7e47
--- /dev/null
+++ b/website/ops/oscommerce/finish-catalog-edging.py
@@ -0,0 +1,12 @@
+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.')
diff --git a/website/ops/oscommerce/import-shop-catalog.py b/website/ops/oscommerce/import-shop-catalog.py
new file mode 100644
index 00000000..a30f52f7
--- /dev/null
+++ b/website/ops/oscommerce/import-shop-catalog.py
@@ -0,0 +1,70 @@
+from pathlib import Path
+import subprocess,json,re,html,shutil,decimal
+def q(s,db='dunerealms_oscommerce'):
+ return subprocess.check_output(['mysql','-N','--raw',db,'-e',"SET SESSION sql_mode='';"+s],text=True).strip()
+def h(s):return "CONVERT(0x"+str(s).encode().hex()+" USING utf8mb4)" if str(s) else "''"
+def run(s):subprocess.run(['mysql','dunerealms_oscommerce'],input="SET SESSION sql_mode='';"+s,text=True,check=True,capture_output=True)
+rows=json.loads(q("SELECT JSON_ARRAYAGG(JSON_OBJECT('id',p.id,'name',p.name,'price',p.price,'description',p.description,'short',p.short_description,'image',p.image,'rank',p.dune_website_rank)) FROM shop_packages p WHERE p.name LIKE '%Sash%' OR p.id IN (SELECT package_id FROM dune_supporter_packages)",'dunerealms_store'))
+run('CREATE TABLE IF NOT EXISTS dune_catalog_import(source_package_id INT PRIMARY KEY,products_id INT NOT NULL UNIQUE,kind VARCHAR(16) NOT NULL,source_rank VARCHAR(64) NOT NULL DEFAULT \'\');')
+def category(name,slug):
+ old=q('SELECT c.categories_id FROM categories c JOIN categories_description d ON d.categories_id=c.categories_id WHERE d.language_id=1 AND d.categories_name='+h(name)+' LIMIT 1')
+ if old:return int(old)
+ return int(q('INSERT INTO categories(parent_id,categories_status,categories_seo_page_name,date_added,created_by_platform_id) VALUES(0,1,'+h(slug)+',NOW(),7);SET @c=LAST_INSERT_ID();INSERT INTO categories_description(categories_id,language_id,categories_name,categories_heading_title,categories_seo_page_name) VALUES(@c,1,'+h(name)+','+h(name)+','+h(slug)+');INSERT INTO platforms_categories VALUES(7,@c);SELECT @c;'))
+cats={'sash':category('Ceremonial Sashes','ceremonial-sashes'),'rank':category('Donor Ranks','donor-ranks')}
+mid=q("SELECT manufacturers_id FROM manufacturers WHERE manufacturers_name='DuneRealms' LIMIT 1")
+if not mid:mid=q("INSERT INTO manufacturers(manufacturers_name,date_added) VALUES('DuneRealms',NOW());SELECT LAST_INSERT_ID();")
+cols=[x.split('\t')[0] for x in q('DESCRIBE products').splitlines() if not x.startswith('products_id\t')]
+colsql=','.join('`'+x+'`' for x in cols)
+def prop(pid,name,value,sort):
+ x=q('SELECT properties_id FROM properties_description WHERE language_id=1 AND properties_name='+h(name)+' LIMIT 1')
+ if not x:x=q("INSERT INTO properties(properties_type,display_product,sort_order,date_added) VALUES('text',1,"+str(sort)+",NOW());SET @p=LAST_INSERT_ID();INSERT INTO properties_description(properties_id,language_id,properties_name) VALUES(@p,1,"+h(name)+");SELECT @p;")
+ x=int(x)
+ if q(f'SELECT values_id FROM properties_to_products WHERE products_id={pid} AND properties_id={x} LIMIT 1'):return
+ v=int(q('SELECT COALESCE(MAX(values_id),0)+1 FROM properties_values'))
+ run(f'INSERT INTO properties_values(values_id,properties_id,language_id,values_text) VALUES({v},{x},1,{h(value)});INSERT INTO properties_to_products(products_id,properties_id,values_id) VALUES({pid},{x},{v});')
+for row in rows:
+ kind='sash' if 'sash' in row['name'].lower() else 'rank'
+ existing=q('SELECT products_id FROM dune_catalog_import WHERE source_package_id='+str(row['id']))
+ if existing:continue
+ slug=re.sub('[^a-z0-9]+','-',row['name'].lower()).strip('-')
+ if row['id']==64:pid=76
+ else:
+ pid=int(q(f'INSERT INTO products({colsql}) SELECT {colsql} FROM products WHERE products_id=76;SELECT LAST_INSERT_ID();'))
+ # Each imported record is independently editable through the native backend.
+ dcols=[x.split('\t')[0] for x in q('DESCRIBE products_description').splitlines() if not x.startswith('products_id\t')]
+ dc=','.join('`'+x+'`' for x in dcols)
+ run(f'INSERT INTO products_description(products_id,{dc}) SELECT {pid},{dc} FROM products_description WHERE products_id=76;INSERT INTO platforms_products VALUES(7,{pid});')
+ note='
Collection preview: ordering is not open yet.
'
+ if kind=='sash':
+ intro=re.search(r'
(.*?)
',row['description'],re.S)
+ intro=html.unescape(re.sub('<[^>]+>','',intro[1])) if intro else row['short']
+ details={html.unescape(re.sub('<[^>]+>','',a)):html.unescape(re.sub('<[^>]+>','',b)) for a,b in re.findall(r'
(.*?)
\s*
(.*?)
',row['description'],re.S)}
+ desc='
'+html.escape(intro)+'
'+note+'
Made to order. Enter the preferred name to embroider. Standard side edging is included, without metallic side lining. Silver side edging adds €50; gold side edging adds €75. These upgrades do not change the bottom fringe.
This physical sash does not grant a rank or honour.
'
+ values={'Eligibility':details.get('Eligibility',''),'Embroidery':details.get('Embroidery',''),'Ribbon size':details.get('Ribbon','').split(' · ')[0],'Cord and bottom fringe':details.get('Ribbon','').split(' · ')[-1],'Side edging':'Standard included · Silver +€50 · Gold +€75. Bottom fringe unchanged.','Maker':details.get('Maker','Julla Studentenlinten'),'Shipping':'€20 once per order when ordering opens.','Availability':'Made to order · collection preview.','Honour':'The physical sash does not grant a rank or honour.'}
+ for i,(name,value) in enumerate(values.items()):
+ if value:prop(pid,name,value,i)
+ if pid!=76:
+ ac=[x.split('\t')[0] for x in q('DESCRIBE products_attributes').splitlines() if not x.startswith(('products_attributes_id\t','products_id\t'))]
+ aa=','.join(ac)
+ run(f'INSERT INTO products_attributes(products_id,{aa}) SELECT {pid},{aa} FROM products_attributes WHERE products_id=76;INSERT INTO dune_product_requirements SELECT {pid},option_id,1 FROM dune_product_requirements WHERE products_id=76;')
+ else:
+ desc=row['description']+note+'
Rank purchases will become available after payment and automatic delivery integration is ready.
'
+ for i,(name,value) in enumerate({'Delivery':'Digital · linked DuneRealms account','Availability':'Preview · purchasing is not open yet','Manufacturer':'DuneRealms'}.items()):prop(pid,name,value,i)
+ price=decimal.Decimal(str(row['price']))/decimal.Decimal('1.2')
+ # Preserve the existing store tax configuration while retaining the source's displayed EUR price.
+ run(f"UPDATE products SET products_model={h('DR-'+kind.upper()+'-'+str(row['id']))},products_price={price:.6f},products_seo_page_name={h(slug)},cart_button=0,products_quantity=0,manual_stock_unlimited={1 if kind=='sash' else 0},is_virtual={1 if kind=='rank' else 0},manufacturers_id={int(mid) if kind=='rank' else '(SELECT manufacturers_id FROM (SELECT manufacturers_id FROM products WHERE products_id=76) base)'},products_status=1,products_image={h(row['image'] or '')},products_last_modified=NOW() WHERE products_id={pid};UPDATE products_description SET products_name={h(row['name'])},products_description={h(desc)},products_description_short={h((intro if kind=='sash' else row['short'])[:240])},products_seo_page_name={h(slug)},products_head_title_tag={h(row['name'][:60]+' | DuneRealms')} WHERE products_id={pid};INSERT IGNORE INTO products_to_categories VALUES({pid},{cats[kind]},0);INSERT INTO dune_catalog_import VALUES({row['id']},{pid},{h(kind)},{h(row['rank'] or '')});")
+ if pid!=76:
+ run(f'INSERT INTO products_prices(products_id,groups_id,products_group_price,currencies_id) VALUES({pid},0,{price:.6f},0);')
+ # Keep the user-edited Aerdrecht artwork; register the originals for new imports.
+ if pid!=76 and row['image']:
+ sources=[Path('/home/dunerealms/apps/azuriom/public/assets/img/merch')/row['image'],Path('/home/dunerealms/apps/azuriom/storage/app/public/packages')/row['image']]
+ src=next((x for x in sources if x.exists()),None)
+ if src:
+ iid=int(q(f'INSERT INTO products_images(products_id,default_image,image_status) VALUES({pid},1,1);SELECT LAST_INSERT_ID();'))
+ run(f'INSERT INTO products_images_description(products_images_id,language_id,image_title,image_alt,orig_file_name,hash_file_name,file_name,no_watermark) VALUES({iid},1,{h(row["name"])},{h(row["name"])},{h(src.name)},{h(src.name)},{h(src.name)},1);')
+ for dims in q("SELECT CONCAT(image_types_x,'x',image_types_y) FROM image_types").splitlines()+['originals']:
+ folder=Path('/home/dunerealms/apps/oscommerce/images/products')/str(pid)/str(iid)/dims/'en';folder.mkdir(parents=True,exist_ok=True);shutil.copyfile(src,folder/src.name)
+ print('Imported',row['id'],pid,kind,row['name'])
+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;")
+subprocess.run(['chown','-R','dunerealms:dunerealms','/home/dunerealms/apps/oscommerce/images/products'],check=True)
+print(q('SELECT kind,COUNT(*) FROM dune_catalog_import GROUP BY kind'))
diff --git a/website/ops/oscommerce/install-sash-rules.py b/website/ops/oscommerce/install-sash-rules.py
new file mode 100644
index 00000000..823b5d06
--- /dev/null
+++ b/website/ops/oscommerce/install-sash-rules.py
@@ -0,0 +1,18 @@
+from pathlib import Path
+import subprocess
+app=Path('/home/dunerealms/apps/oscommerce')
+p=app/'lib/frontend/components/CartFactory.php';s=p.read_text()
+needle=' public static function work() {'
+if 'DuneProductRules::validateCartRequest' not in s:
+ s=s.replace(needle,needle+"\n require_once __DIR__.'/DuneProductRules.php';\n DuneProductRules::validateCartRequest();",1)
+s=s.replace(' DuneProductRules::validateCartRequest();',' \\frontend\\components\\DuneProductRules::validateCartRequest();')
+p.write_text(s)
+p=app/'lib/frontend/themes/basic/boxes/product/attributes/select.tpl';s=p.read_text()
+needle='name="attr_text[{$item.id}]"'
+if 'maxlength="80"' not in s:
+ s=s.replace(needle,needle+'{if $item.title == \'Preferred name\'} required maxlength="80" aria-label="Preferred name for embroidery (required)" placeholder="Enter the name to embroider"{/if}',1)
+p.write_text(s)
+for f in [app/'lib/frontend/components/CartFactory.php',app/'lib/frontend/components/DuneProductRules.php']:
+ subprocess.run(['php','-l',str(f)],check=True)
+subprocess.run(['chown','dunerealms:dunerealms',str(p),str(app/'lib/frontend/components/CartFactory.php'),str(app/'lib/frontend/components/DuneProductRules.php')],check=True)
+print('Native embroidery text attribute is required; server rejects missing names and preview purchases.')
diff --git a/website/ops/oscommerce/publish-oscommerce-portal.py b/website/ops/oscommerce/publish-oscommerce-portal.py
index 83babe40..d3243462 100644
--- a/website/ops/oscommerce/publish-oscommerce-portal.py
+++ b/website/ops/oscommerce/publish-oscommerce-portal.py
@@ -2,7 +2,7 @@ from pathlib import Path
import re,subprocess,urllib.request,urllib.parse
app=Path('/home/dunerealms/apps/oscommerce');target=Path('/var/www/dunerealms-shop-portal');target.mkdir(exist_ok=True)
html=urllib.request.urlopen('https://www.dunerealms.com/shop.html',timeout=30).read().decode()
-html=re.sub(r'(