public static function Create($name, $ref, $desc, $manufacturer, $features, $pprice, $rprice, $wprice, $tax, $img, $pheight, $pwidth, $plength, $pweight, $pshape, $images) { $unit = Enumerable::Create('Item'); //temporal, individual, $typedata = ResourceType::FetchType("Good", $unit); $sqlone = 'SELECT * FROM products WHERE name = "' . $name . '" AND reference = "' . $ref . '"'; $res = DatabaseHandler::GetRow($sqlone); if (empty($res)) { //create product $sql = 'INSERT INTO products (type_id, type_name, name, reference, description, retail_price, wholesale_price, tax_code, img_url, manufacturer) VALUES (' . $typedata['id'] . ', "' . $typedata['type'] . '", "' . $name . '", "' . $ref . '", "' . $desc . '", "' . $rprice . '", "' . $wprice . '", "' . $tax . '", "' . $img . '", "' . $manufacturer . '")'; DatabaseHandler::Execute($sql); $sqlone = 'SELECT resource_id FROM products WHERE name = "' . $name . '" AND reference = "' . $ref . '"'; $res = DatabaseHandler::GetRow($sqlone); //create product features foreach ($features as $feature) { $sql = 'INSERT INTO features (resource_id, attribute) VALUES (' . $res['resource_id'] . ', "' . $feature . '")'; DatabaseHandler::Execute($sql); } $sqltwo = 'SELECT * FROM features WHERE resource_id = ' . $res['resource_id']; $features = DatabaseHandler::GetAll($sqltwo); //create product images foreach ($images as $image) { foreach ($image['features'] as $feature) { $sql = 'INSERT INTO images (resource_id, image_title, image_url, tag, value) VALUES (' . $res['resource_id'] . ', "' . $image['imgtitle'] . '", "' . $image['imgurl'] . '", "' . $feature['feature'] . '", "' . $feature['value'] . '")'; DatabaseHandler::Execute($sql); } } //$sqltwo = 'SELECT * FROM images WHERE resource_id = '.$res['resource_id']; //$images = ProductImage::FetchImages($res['resource_id']); } $product = new Product($res['resource_id'], $typedata['id'], $typedata['type'], $name, $ref, $unit, $desc, $features, $manufacturer, $rprice, $wprice, $tax, $img, $plength, $pwidth, $pheight, $pweight, $pshape); return $product; // $product->setShippingDetails($res['id'], $plength, $pwidth, $pheight, $pweight, $pshape); /*/after creation it returns the product object to be used in the inventory, shipping and category classes $couriers, $shippingmethod = [$road, $air, $sea, $space] //shipping class - dispatch and delivery $cat //category class $avail, $featured, $openstock, $optstock, $lowstock //inventory class $pprice // determined by supplier and varies with batch -- same product different batches and prices will lead to different valuation of stock */ }