/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// Create the product object and initialize its fields
$product = Shop_Product::create();
$product->price = 100;
$product->product_type_id = Shop_ProductType::create()->find_by_name('Goods')->id;
$product->url_name = 'test_product';
$product->name = 'Test product';
$product->sku = 'test_product_01';
$product->tax_class_id = Shop_TaxClass::get_default_class_id();
// Create price tier and save
$price_tier = Shop_PriceTier::create();
$price_tier->customer_group_id = 1;
$price_tier->quantity = 1;
$price_tier->price = 50;
$price_tier->save();
// Add the price tier to the product
$product->price_tiers->add($price_tier, $session_key);
// Save the product
$product->save(null, $session_key);
Comments
 Subscribe to comments
                    Subscribe to comments
                
                