public function getAdminInterface() { $st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name"; $products = Database::singleton()->query_fetch_all($st); $formPath = "/admin/EComm§ion=Plugins&page=ChangeProductPrice"; $form = new Form('change_product_prices', 'post', $formPath); if ($form->validate() && isset($_REQUEST['submit'])) { foreach ($products as $product) { $ECommProduct = new Product($product['product_id']); $ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]); $ECommProduct->save(); } return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>"; } $oldSupplier = 0; $currentSupplier = 0; $defaultValue = array(); foreach ($products as $product) { $currentSupplier = $product['supplier_id']; if ($oldSupplier != $currentSupplier) { $form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>'); } $form->addElement('text', 'product_' . $product['product_id'], $product['product_name']); $defaultValue['product_' . $product['product_id']] = $product['product_price']; $oldSupplier = $product['supplier_id']; } $form->addElement('submit', 'submit', 'Submit'); $form->setDefaults($defaultValue); return $form->display(); }
public function getOrderByOrderTime($campaignId, $orderStatTime, $orderEndTime) { if (empty($campaignId) || empty($orderStatTime) || empty($orderEndTime)) { echo "campaignId ,orderStatTime or orderEndTime is null"; exit; } $sql = "SELECT p.order_id,order_sn,add_time,order_status,pay_status,pay_name,order_time,cid,wi,order_status,pay_status,pay_name,shipping_fee,surplus,bonus,order_amount FROM `cps` as p LEFT OUTER JOIN ecs_order_info as i on i.order_id=p.order_id where p.cid=" . $campaignId . " and order_time>" . $orderStatTime . " and order_time<" . $orderEndTime; $dborder = $GLOBALS['db']->getAll($sql); if (empty($dborder)) { return NULL; } foreach ($dborder as $k => $v) { $order = new Order(); $order->setOrderNo($v['order_sn']); $order_time = date('Y-m-d H:i:s', $v['order_time']); $order->setOrderTime($order_time); // 设置下单时间 $order->setUpdateTime($order_time); // 设置订单更新时间,如果没有下单时间,要提前对接人提前说明 $order->setCampaignId($v['cid']); // 测试时使用"101",正式上线之后活动id必须要从数据库里面取 $order->setFeedback($v['wi']); $order->setFare($v['shipping_fee']); $order->setFavorable($v['bonus'] + $v['surplus']); //$orderStatus = new OrderStatus(); //$orderStatus -> setOrderNo($order -> getOrderNo()); $order->setOrderStatus($v['order_status']); // 设置订单状态 $order->setPaymentStatus($v['pay_status']); // 设置支付状态 $order->setPaymentType($v['pay_name']); // 支付方式 $sql = "select * from ecs_order_goods where order_id=" . $v['order_id'] . " and goods_price>100"; $order_goods = $GLOBALS['db']->getAll($sql); //echo "<pre>";print_r($order_goods); foreach ($order_goods as $k1 => $v1) { $pro = new Product(); //$pro -> setOrderNo($order -> getOrderNo()); $pro->setProductNo($v1['goods_sn']); $pro->setName($v1['goods_name']); $pro->setCategory("蛋糕"); $pro->setCommissionType(""); $pro->setAmount($v1['goods_number']); $a = number_format($v1['goods_price'] * (1 - ($v['bonus'] + $v['surplus']) / ($v['bonus'] + $v['surplus'] + $v['order_amount'])), 2, ".", ""); $pro->setPrice($a); $products[] = $pro; } $order->setProducts($products); $orderlist[] = $order; $products = array(); } //print_r($orderlist); //echo json_encode($orderlist); return $orderlist; }
/** * @param integer $categoryId * @return Product[] */ public static function getProducts($categoryId) { $resource = Database::query("SELECT id, name, price FROM product WHERE category_id = {$categoryId}"); $products = array(); while ($row = mysql_fetch_assoc($resource)) { $product = new Product($row['id'], $row['name']); $product->setPrice($row['price']); $products[] = $product; } return $products; }
public function createAction() { $article = new Product(); $article->setTitle('Trophée Descartes 2013'); $article->setPrice('6/7 Arvil'); $article->setContent('Lorem ipsum dolor'); $em = $this->getDoctrine()->getManager(); $em->persist($article); $em->flush(); return new Response('Id du produit créé : ' . $article->getId()); }
public static function map(Product $product, array $properties) { if (array_key_exists('product_id', $properties)) { $product->setProductId($properties['product_id']); } if (array_key_exists('product_name', $properties)) { $product->setProductName($properties['product_name']); } if (array_key_exists('price', $properties)) { $product->setPrice($properties['price']); } }
public function testCalculatePrices() { // Create new prices $this->product->setPrice(self::getApplication()->getDefaultCurrencyCode(), $defaultPrice = 1); $this->product->save(); // Just check that prices for other currencies are generated $this->product->loadSpecification(); $pricing = $this->product->getPricingHandler(); $prices = $pricing->toArray(ProductPricing::BOTH); foreach (self::getApplication()->getCurrencyArray(!LiveCart::INCLUDE_DEFAULT) as $currencyCode) { $this->assertTrue(isset($prices[ProductPricing::CALCULATED][$currencyCode]) && $prices[ProductPricing::CALCULATED][$currencyCode] > 0); $this->assertFalse(isset($prices[ProductPricing::DEFINED][$currencyCode])); } }
public function getProduct($product_id) { $db = Database::getDB(); $query = "SELECT * FROM products\n WHERE productID = '{$product_id}'"; $result = $db->query($query); $row = $result->fetch(); $category = CategoryDB::getCategory($row['categoryID']); $product = new Product(); $product->setCategory($category); $product->setId($row['productID']); $product->setCode($row['productCode']); $product->setName($row['productName']); $product->setPrice($row['listPrice']); return $product; }
private function createProducts() { $ipad = new Product(); $ipad->setId(1); $ipad->setDescription('A brand new 16 GIGA iPad'); $ipad->setPrice('499.00'); $this->allProducts[] = $ipad; $iphone = new Product(); $iphone->setId(2); $iphone->setDescription('A brand new 32 GIGA iPhone'); $iphone->setPrice(599.0); $this->allProducts[] = $iphone; $ipod = new Product(); $ipod->setId(3); $ipod->setDescription('A brand new 8 GIGA iPod'); $ipod->setPrice(299.0); $this->allProducts[] = $ipod; }
public function testChildProduct() { $this->product->setPrice($this->usd, 20); $this->product->shippingWeight->set(200); $this->product->save(); $child = $this->product->createChildProduct(); $root = Category::getRootNode(); $root->reload(); $productCount = $root->totalProductCount->get(); // in array representation, parent product data is used where own data is not set $array = $child->toArray(); $this->assertEquals($array['name_en'], $this->product->getValueByLang('name', 'en')); // auto-generated SKU is based on parent SKU $child->save(); $this->assertEquals($child->sku->get(), $this->product->sku->get() . '-1'); // category counters should not change $root->reload(); $this->assertEquals($root->totalProductCount->get(), $productCount); // parent product price used if not defined $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd)); // parent shipping weight used if not defined $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight()); // add/substract parent prices/shipping weights $child->setChildSetting('test', 'value'); $this->assertEquals($child->getChildSetting('test'), 'value'); // prices $child->setChildSetting('price', Product::CHILD_ADD); $child->setPrice($this->usd, 5); $this->assertEquals(20, $this->product->getPrice($this->usd)); $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd) + 5); $child->setChildSetting('price', Product::CHILD_SUBSTRACT); $this->assertEquals($child->getPrice($this->usd), $this->product->getPrice($this->usd) - 5); $child->setChildSetting('price', Product::CHILD_OVERRIDE); $this->assertEquals($child->getPrice($this->usd), 5); // shipping weight $child->setChildSetting('weight', Product::CHILD_ADD); $child->shippingWeight->set(5); $this->assertEquals(200, $this->product->getShippingWeight()); $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight() + 5); $child->setChildSetting('weight', Product::CHILD_SUBSTRACT); $this->assertEquals($child->getShippingWeight(), $this->product->getShippingWeight() - 5); $child->setChildSetting('weight', Product::CHILD_OVERRIDE); $this->assertEquals($child->getShippingWeight(), 5); }
public static function generateProducts() { //read in xml document(products) $doc = simplexml_load_file(APPLICATION_PATH . '/../products.xml'); foreach ($doc->category as $cat) { $categoryObj = new Category(); $categoryObj->setUrlKey($cat->urlkey); $categoryObj->setName($cat->name); $categoryObj->save(); } foreach ($doc->product as $product) { $productObj = new Product(); $productObj->setName($product->name); $productObj->setPrice($product->price); $productObj->setSku($product->sku); $productObj->setDateCreated(date('d-m-Y H:i:s', time())); $productObj->setUrlKey($product->urlkey); $productObj->setProductImage($product->image); $productObj->setCategoryId($product->category); $productObj->save(); } }
public function create(SubCategory $sub_category, $name, $description, $price, $img, $stock) { $errors = array(); $product = new Product($this->db); try { $product->setSubCategory($sub_category); $product->setName($name); $product->setDescription($description); $product->setPrice($price); $product->setImg($img); $product->setStock($stock); } catch (Exception $e) { $errors[] = $e->getMessage(); } $errors = array_filter($errors, function ($val) { return $val !== true; }); if (count($errors) == 0) { $idSubCategory = intval($product->getIdSubCategory()); $name = $this->db->quote($product->getName()); $description = $this->db->quote($product->getDescription()); $price = $this->db->quote($product->getPrice()); $img = $this->db->quote($product->getImg()); $stock = $this->db->quote($product->getStock()); $query = "INSERT INTO product(id_sub_category, name, description, price, img, stock) VALUES('" . $idSub_category . "', " . $name . ", " . $description . ", " . $price . ", " . $img . ", " . $stock . ")"; $res = $this->db->exec($query); if ($res) { $id = $this->db->lastInsertId(); if ($id) { return $this->findById($id); } else { return "Internal Server error"; } } } else { return $errors; } }
// 设置订单状态 $cps->setPaymentStatus($order['pay_status']); // 设置支付状态 $cps->setPaymentType($order['pay_name']); // 支付方式 foreach ($cart_goods as $k => $v) { if ($v['goods_price'] > 0) { $pro = new Product(); // $pro2 -> setOrderNo($order -> getOrderNo()); $pro->setProductNo($v['goods_sn']); $pro->setName($v['goods_name']); $pro->setCategory("蛋糕"); $pro->setCommissionType(""); $pro->setAmount($v['goods_number']); $a = number_format($v['goods_price'] * (1 - ($order['bonus'] + $order['surplus']) / ($order['bonus'] + $order['surplus'] + $order['order_amount'])), 2, ".", ""); $pro->setPrice($a); $products[] = $pro; } } $cps->setProducts($products); //var_dump(get_object_vars($cps)); $sender = new Sender(); $sender->setOrder($cps); $sender->sendOrder(); $ordertime = $order['add_time'] + 8 * 3600; $sql = "INSERT INTO cps ( " . "order_id,src,channel,cid,wi,order_time)" . " values('{$new_order_id}','emar','cps'," . $arr[2] . ",'" . $arr[3] . "','" . $ordertime . "') "; $db->query($sql); } /* 修改拍卖活动状态 if ($order['extension_code']=='auction') {
<?php require_once 'Product.php'; require_once 'Tool.php'; require_once 'Electronic.php'; $form = new Product(); if (isset($_POST['submit'])) { $form->setTitle($_POST['title']); $form->setDescription($_POST['description']); $form->setPrice($_POST['price']); $form->saveProduct(); }
<?php require_once 'includes/ShoppingCart.php'; require_once 'includes/Product.php'; require_once 'includes/Customer.php'; session_start(); if (!isset($_SESSION['customer'])) { //todo fix $customer = new Customer(rand(1, 1000)); $sc = new ShoppingCart(rand(1, 1000)); $customer->setShoppingCart(rand(1, 1000)); $_SESSION['customer'] = serialize($customer); } $customer = unserialize($_SESSION['customer']); $product = new Product($_GET['product']); $product->setPrice($_GET['price']); $customer->getShoppingCart()->setProduct([$product->getName() => $product]); $_SESSION['customer'] = serialize($customer); ?> <html> <header> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <link rel="stylesheet" href="includes/css/prism.css"> <script src="includes/js/prism.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> <title>CityAds implementation via third party services (Google Tag Manager, Shopify). Molanco Team</title> </header>
protected function processRecord(Product $product) { $act = $this->getAction(); $field = $this->getField(); if ('manufacturer' == $act) { $product->manufacturer->set($this->params['manufacturer']); } else { if ('price' == $act) { $product->setPrice($this->params['baseCurrency'], $this->params['price']); } else { if (in_array($act, array('inc_price', 'multi_price', 'div_price'))) { $actions = array('inc_price' => 'increasePriceByPercent', 'multi_price' => 'multiplyPrice', 'div_price' => 'dividePrice'); $action = $actions[$act]; $pricing = $product->getPricingHandler(); foreach ($this->params['currencies'] as $currency) { if ($pricing->isPriceSet($currency)) { $p = $pricing->getPrice($currency); $p->{$action}($this->params['inc_price_value'], $this->params['inc_quant_price']); $p->save(); } } } else { if ('inc_stock' == $act) { $product->stockCount->set($product->stockCount->get() + $this->request->get($act)); } else { if ('addRelated' == $act) { $product->addRelatedProduct($this->params['relatedProduct']); } else { if ('copy' == $act) { $cloned = clone $product; $cloned->category->set($this->params['category']); $cloned->save(); } else { if ('addCat' == $act) { // check if the product is not assigned to this category already $relation = ActiveRecordModel::getInstanceByIdIfExists('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $this->params['category']->getID())); if (!$relation->isExistingRecord() && $product->category->get() !== $category) { $relation->save(); } } else { if ('theme' == $act) { $instance = CategoryPresentation::getInstance($product); $instance->theme->set($this->params['theme']); $instance->save(); } else { if ('shippingClass' == $act) { $product->shippingClass->set(ActiveRecordModel::getInstanceByIDIfExists('ShippingClass', $this->params['shippingClass'], false)); } else { if ('taxClass' == $act) { $product->taxClass->set(ActiveRecordModel::getInstanceByIDIfExists('TaxClass', $this->params['taxClass'], false)); } else { if (substr($act, 0, 13) == 'set_specField') { $this->params['request']->remove('manufacturer'); $product->loadRequestData($this->params['request']); } else { if (substr($act, 0, 16) == 'remove_specField') { $this->params['request']->remove('manufacturer'); if ($this->params['field']->isMultiValue->get()) { // remove only selected multi-select options $product->loadRequestData($this->params['request']); } else { $product->removeAttribute($this->params['field']); } } else { parent::processRecord($product); } } } } } } } } } } } } }
protected function processRecord(Product $product) { $act = $this->getAction(); $field = $this->getField(); if ('manufacturer' == $act) { $product->manufacturer->set($this->params['manufacturer']); } else { if ('price' == $act) { $product->setPrice($this->params['baseCurrency'], $this->params['price']); } else { if ('inc_price' == $act) { $pricing = $product->getPricingHandler(); foreach ($this->params['currencies'] as $currency) { if ($pricing->isPriceSet($currency)) { $p = $pricing->getPrice($currency); $p->increasePriceByPercent($this->params['inc_price_value'], $this->params['inc_quant_price']); $p->save(); } } } else { if ('inc_stock' == $act) { $product->stockCount->set($product->stockCount->get() + $this->request->get($act)); } else { if ('addRelated' == $act) { $product->addRelatedProduct($this->params['relatedProduct']); } else { if ('copy' == $act) { $cloned = clone $product; $cloned->category->set($this->params['category']); $cloned->save(); } else { if ('addCat' == $act) { // check if the product is not assigned to this category already $relation = ActiveRecordModel::getInstanceByIdIfExists('ProductCategory', array('productID' => $product->getID(), 'categoryID' => $this->params['category']->getID())); if (!$relation->isExistingRecord() && $product->category->get() !== $category) { $relation->save(); } } else { if ('theme' == $act) { $instance = CategoryPresentation::getInstance($product); $instance->theme->set($this->params['theme']); $instance->save(); } else { if ('shippingClass' == $act) { $product->shippingClass->set(ActiveRecordModel::getInstanceByIDIfExists('ShippingClass', $this->params['shippingClass'], false)); } else { if ('taxClass' == $act) { $product->taxClass->set(ActiveRecordModel::getInstanceByIDIfExists('TaxClass', $this->params['taxClass'], false)); } else { parent::processRecord($product); } } } } } } } } } } }
if (productExistsLocally($sku, STN::getPDO())) { $alreadyImported[] = $sku; $importCount += 1; continue; } try { $product = $provider->getProductBySTNSKU($sku); if (!empty($product)) { $product_id = importProduct($product, $provider, $categories); $changes = array('sku' => $importable['POSItemNumber'], 'quantity' => $importable['QOH']); $failed = array(); Product::update($product_id, $changes, $failed); if (!empty($failed)) { throw new Exception('Saving product data failed.'); } Product::setPrice($product_id, $importable['RegularPrice']); } else { $errorSkus[$sku] = "Product not found on master database: " . $sku; continue; } } catch (Exception $e) { $errorSkus[$sku] = $e->getMessage(); continue; } $markImported->execute(array(':id' => $importable['ID'])); $processedSkus[] = $sku; $importCount += 1; } } catch (Exception $e) { $error[] = $e->getMessage(); }
<?php /** * Created by PhpStorm. * User: Denis * Date: 07.11.2015 * Time: 11:04 */ /** * SOLID * O - Принцип открытости/закрытости * open/closed principle */ //$logger = new Logger(); //$product = new Product($logger); //$product->setProduct(10); $loggerDb = new DBLogger(); $loggerFile = new FileLogger(); $product = new Product($loggerFile); $product->setPrice(10);
public function parseProducts() { $products = new Products(); $keyParams = array(); $currencies = $this->parseCurrencies(); $measurements = $this->parseMeasurements(); foreach ($this->xmlProducts as $xmlProduct) { $code = $xmlProduct->getCode(); $name = $xmlProduct->getName(); $isAGroup = $xmlProduct->isAGroup(); $articul = $xmlProduct->getArticul(); $basicMeasurementUnitCode = $xmlProduct->getBasicMeasurementUnit(); $basicMeasurementUnit = $measurements->getUnitByCode($basicMeasurementUnitCode); $price = $xmlProduct->getPrice(); $currencyCode = $xmlProduct->getCurrency(); $currency = $currencies->getUnitByCode($currencyCode); $measurementUnitCode = $xmlProduct->getBasicMeasurementUnit(); $measurementUnit = $measurements->getUnitByCode($measurementUnitCode); if (!empty($code) && !in_array($code, $keyParams)) { array_push($keyParams, $code); $product = new Product(); $product->setIsAGroup($isAGroup); $product->setCode($code); $product->setName($name); $product->setArticul($articul); $product->setBasicMeasurementUnit($basicMeasurementUnit); $product->setPrice($price); $currency == null ? '' : $product->setCurrency($currency); $measurementUnit == null ? '' : $product->setMeasurementUnit($measurementUnit); $products->setItem($product); } } $categories = $this->parseCategories(); foreach ($this->xmlProducts as $xmlProduct) { $catCode = $xmlProduct->getCategoryCode(); $code = $xmlProduct->getCode(); $current = $products->getItemByCode($code); $parent = $categories->getItemByCode($catCode); if ($parent != null) { $current->setParent($parent); } } $productDAO = new ProductDAO(); $productDAO->insertItems($products); return $products; }
<?php function __autoload($class_name) { include $class_name . '.php'; } $cus1 = new Customer('binh'); $cus2 = new Customer('nam'); $product = new Product('laptop', 123); $product->attachObserver($cus1); $product->attachObserver($cus2); $product->setPrice(125); // $product->setPrice(124);
if (isset($_POST["btnSave"])) { if (isset($_POST["txtControl"])) { $control->setValue($_POST["txtControl"]); } if (isset($_POST["txtProID"])) { $Product->setProID($_POST["txtProID"]); } if (isset($_POST["txtProName"])) { $Product->setProName($_POST["txtProName"]); } if (isset($_POST["txtImageURL_Old"])) { $Product->setImageURL($_POST["txtImageURL_Old"]); } if (isset($_POST["txtProPrice"])) { $fProPrice = str_replace(',', '', $_POST["txtProPrice"]); $Product->setPrice($fProPrice); } if (isset($_POST["txtProQuantity"])) { $fProQuantity = str_replace(',', '', $_POST["txtProQuantity"]); $Product->setInStock($fProQuantity); } if (isset($_POST["txtProCreated"])) { $dProCreate = strtotime(str_replace('/', '-', $_POST["txtProCreated"])); //d-m-Y $Product->setProCreated($dProCreate); } if (isset($_POST["cboCatPro"])) { $oCatPro = new Category($_POST["cboCatPro"]); $Product->setCatPro($oCatPro); } if (isset($_POST["txtTinyDes"])) {
//truyền số record cần hiển thịs } $offset = ($curPage - 1) * $rowsPerPage; // tính offset bắt đầu load //filter $SortName = ""; $SortType = "ASC"; $filterPro = new Product(); if (isset($_POST['ProID']) & !empty($_POST['ProID'])) { $filterPro->setProID($_POST['ProID']); } if (isset($_POST['ProName']) & !empty($_POST['ProName'])) { $filterPro->setProName($_POST['ProName']); } if (isset($_POST['Price']) & !empty($_POST['Price'])) { $filterPro->setPrice($_POST['Price']); } if (isset($_POST['InStock']) & !empty($_POST['InStock'])) { $filterPro->setInStock($_POST['InStock']); } if (isset($_POST['CatProID']) & !empty($_POST['CatProID'])) { $filterPro->setCatPro(new Category($_POST['CatProID'])); } if (isset($_POST['Status']) & !empty($_POST['Status'])) { $filterPro->setStatus($_POST['Status']); } if (isset($_POST['SortName']) & !empty($_POST['SortName'])) { $SortName = $_POST['SortName']; } if (isset($_POST['SortType']) & !empty($_POST['SortType'])) { $SortType = $_POST['SortType'];
public function testPriceCannotBecomeNegative() { $instance = new Product(); $instance->setPrice(-1); $this->assertEquals(-1, $instance->getPrice()); }
$pro->setCategory("asdf"); // 设置商品类型 $pro->setCommissionType("A"); // 设置佣金类型,如:普通商品 佣金比例是10%、佣金编号(可自行定义然后通知双方商务)A $pro->setAmount("1"); // 设置商品数量 $pro->setPrice("3000"); // 设置商品价格 $pro1 = new Product(); // $pro1 -> setOrderNo($order -> getOrderNo()); $pro1->setProductNo("1002"); $pro1->setName("测试商品5"); $pro1->setCategory("a"); $pro1->setCommissionType("B"); $pro1->setAmount("3"); $pro1->setPrice("100"); $pro2 = new Product(); // $pro2 -> setOrderNo($order -> getOrderNo()); $pro2->setProductNo("1003"); $pro2->setName("测试商品4"); $pro2->setCategory("2"); $pro2->setCommissionType("B"); $pro2->setAmount("5"); $pro2->setPrice("500"); $products = array($pro, $pro1, $pro2); // 实现商品信息集合 $order->setProducts($products); //var_dump(get_object_vars($order)); $sender = new Sender(); $sender->setOrder($order); $sender->sendOrder();
public function importProducts(Import $entity, $output) { $sql = ' SELECT p.*, o.nombre as opticName, m.nombre as brand, mo.nombre as model, s.nombre as category FROM `producto` AS p ' . ' LEFT JOIN optica AS o ON o.id = p.id_optica ' . ' LEFT JOIN servicio AS s ON s.id = p.id_servicio ' . ' LEFT JOIN marca AS m ON m.id_marca = p.id_marca ' . ' LEFT JOIN modelo AS mo ON mo.id_modelo = p.id_modelo ' . ' ORDER BY p.id ' . ' LIMIT ' . $entity->getLimitStart() . ', ' . $entity->getLimitEnd(); $link = mysqli_connect($entity->getServer(), $entity->getUsername(), $entity->getPassword(), $entity->getDbname()) or die('No se pudo conectar: ' . mysqli_error($link)); $resultado = $link->query($sql); $x = 0; if (mysqli_num_rows($resultado) > 0) { while ($fila = mysqli_fetch_assoc($resultado)) { $x++; print_r($x . '-' . utf8_encode($fila['nombre'])); echo PHP_EOL; $em = $this->container->get('doctrine')->getManager(); $optic = $em->getRepository('CoreBundle:Optic')->findOneByName(utf8_encode($fila['opticName'])); $category = $em->getRepository('EcommerceBundle:Category')->findOneByName(utf8_encode($fila['category'])); $brand = $em->getRepository('EcommerceBundle:Brand')->findOneByName(utf8_encode($fila['brand'])); $model = $em->getRepository('EcommerceBundle:BrandModel')->findOneByName(utf8_encode($fila['model'])); //Create Products if ($optic instanceof Optic && $fila['id'] != 746 && $fila['id'] != 747 && $fila['id'] != 748 && $fila['id'] != 749 && $fila['id'] != 750 && $fila['id'] != 751 && $fila['id'] != 752 && $fila['id'] != 753) { $product = new Product(); $product->setName(utf8_encode($fila['nombre'])); $product->setDescription(utf8_encode($fila['descripcion'])); if ($fila['precio_original'] != '') { $product->setInitPrice($fila['precio_original']); } else { $product->setInitPrice(0); } $product->setPrice($fila['precio']); if ($fila['tipo_precio'] != '') { $product->setPriceType($fila['tipo_precio']); } else { $product->setPriceType(0); } $product->setDiscount($fila['descuento']); $product->setDiscountType($fila['tipo_descuento']); if ($fila['stock'] != '') { $product->setStock($fila['stock']); } else { $product->setStock(0); } $product->setWeight($fila['kilos']); $product->setOutlet($fila['outlet']); $product->setPublic($fila['publicado']); if ($fila['recoger_tienda'] != '') { $product->setStorePickup($fila['recoger_tienda']); } else { $product->setStorePickup(0); } $product->setMetaTitle(utf8_encode($fila['meta_titulo'])); $product->setMetaDescription(utf8_encode($fila['meta_descripcion'])); $product->setMetaTags(utf8_encode($fila['meta_keywords'])); $product->setOptic($optic); $product->setBrand($brand); $product->setModel($model); $product->setCategory($category); $product->setActive(true); $product->setAvailable(true); $product->setHighlighted(false); $product->setFreeTransport(false); $slug = $this->slugify(utf8_encode($fila['nombre'] . '-' . $optic->getCity())); // $p = $em->getRepository('EcommerceBundle:Product')->findOneBySlug($slug); // if($p instanceof Product) $slug = $slug.'_'.rand(1000,9999); $product->setSlug($slug); $em->persist($product); $em->flush(); //image if ($fila['imagen'] != '') { $imagePath = ''; $dir = '/home/sebastian/www/src/Symfony/web/uploads/documents'; $absoluteImagePath = $dir . '/' . utf8_encode($fila['imagen']); if (file_exists($absoluteImagePath . '.jpeg')) { $imagePath = utf8_encode($fila['imagen']) . '.jpeg'; } if (file_exists($absoluteImagePath . '.jpg')) { $imagePath = utf8_encode($fila['imagen']) . '.jpg'; } if (file_exists($absoluteImagePath . '.gif')) { $imagePath = utf8_encode($fila['imagen']) . '.gif'; } if (file_exists($absoluteImagePath . '.png')) { $imagePath = utf8_encode($fila['imagen']) . '.png'; } //Thumb $imagePathThumb = ''; $absoluteImagePathThumb = $dir . '/' . utf8_encode($fila['imagen']) . '_260.jpg'; if (file_exists($absoluteImagePathThumb)) { $imagePathThumb = utf8_encode($fila['imagen']) . '_260.jpg'; } $imagePathThumb2 = ''; $absoluteImagePathThumb2 = $dir . '/' . utf8_encode($fila['imagen']) . '_142.jpg'; if (file_exists($absoluteImagePathThumb2)) { $imagePathThumb2 = utf8_encode($fila['imagen']) . '_142.jpg'; } if ($imagePath == '') { $dir = 'http://web.com/uploads/documents/'; $imagePath = $fila['imagen'] . '.' . $fila['extension_img']; } print_r($dir . '/' . $imagePath); echo PHP_EOL; @mkdir(__DIR__ . '/../../../../../web/uploads/images/product'); @mkdir(__DIR__ . '/../../../../../web/uploads/images/product/' . $product->getId()); @mkdir(__DIR__ . '/../../../../../web/uploads/images/product/' . $product->getId() . '/thumbnail'); copy($dir . '/' . $imagePath, __DIR__ . '/../../../../../web/uploads/images/product/' . $product->getId() . '/' . $imagePath); if ($imagePathThumb != '') { copy($dir . '/' . $imagePathThumb, __DIR__ . '/../../../../../web/uploads/images/product/' . $product->getId() . '/thumbnail/' . $imagePathThumb); } if ($imagePathThumb2 != '') { copy($dir . '/' . $imagePathThumb2, __DIR__ . '/../../../../../web/uploads/images/product/' . $product->getId() . '/thumbnail/' . $imagePathThumb2); } $image0 = new Image(); $image0->setPath($imagePath); $product->addImage($image0); $em->persist($image0); } $em->flush(); } } } }
/** * @param $productID * @return Product */ public function getProduct($productID) { APIWrapper::verifyReadiness(); $requestURL = "https://app.fetchapp.com/api/v2/products/" . $productID; $product = APIWrapper::makeRequest($requestURL, "GET"); if (is_a($product, "SimpleXMLElement")) { $tempProduct = new Product(); $tempProduct->setProductID($product->id); $tempProduct->setSKU($product->sku); $tempProduct->setName($product->name); $tempProduct->setPrice($product->price); $tempProduct->setCurrency(Currency::getValue($product->currency)); $tempProduct->setOrderCount($product->order_count); $tempProduct->setDownloadCount($product->download_count); $tempProduct->setPaypalAddToCartLink($product->paypal_add_to_cart_link['href']); $tempProduct->setPaypalBuyNowLink($product->paypal_buy_now_link['href']); $tempProduct->setPaypalViewCartLink($product->paypal_view_cart_link['href']); $tempProduct->setCreationDate(new \DateTime($product->created_at)); $tempProduct->setFilesUri($product->files_uri); $tempProduct->setDownloadsUri($product->downloads_uri); } return $tempProduct; }
header("Location: .?category_id={$category_id}"); } else { if ($action == 'show_add_form') { $categories = $categoryDB->getCategories(); include 'product_add.php'; } else { if ($action == 'add_product') { $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT); $code = filter_input(INPUT_POST, 'code'); $name = filter_input(INPUT_POST, 'name'); $price = filter_input(INPUT_POST, 'price'); if ($category_id == NULL || $category_id == FALSE || $code == NULL || $name == NULL || $price == NULL || $price == FALSE) { $error = "Invalid product data. Check all fields and try again."; include '../errors/error.php'; } else { $current_category = $categoryDB->getCategory($category_id); // Create the Product object $product = new Product(); $product->setCategory($current_category); $product->setCode($code); $product->setName($name); $product->setPrice($price); // Add the Product object to the database $productDB->addProduct($product); // Display the Product List page for the current category header("Location: .?category_id={$category_id}"); } } } } }
if (isAlreadyHaveProduct($productCode) == 0) { print "<br><br>************** Input wrong product code **************<br><br><br>"; } else { if (isOwner($productCode, $username, $password) == 0) { print "<br><br>************** This isn't your product code **************<br><br><br>"; } else { //database connection $conn = mysql_connect("localhost", "root", "root") or die("****** can't connect to sever ******"); mysql_select_db("easystock", $conn) or die("****** can't select database ******"); //load product form database $rs = $easystockDB->fncSelectRecord("product", "code LIKE '{$productCode}%'"); //Set value to class then use function sell() to calculate $productSell = new Product(); $productSell->setAmount($rs[amount]); $productSell->setCost($rs[cost]); $productSell->setPrice($rs[price]); $productSell->setSale($rs[sale]); $productSell->sell($amount); $amountSell = $productSell->getAmount(); $saleSell = $productSell->getSale(); //update detail to database $easystockDB->fncUpdateRecord("product", "amount='{$amountSell}'", "code='{$productCode}'"); $easystockDB->fncUpdateRecord("product", "sale='{$saleSell}'", "code='{$productCode}'"); mysql_close($conn); } } } /*** Home ***/ //database connection $conn = mysql_connect("localhost", "root", "root"); mysql_select_db("easystock", $conn);
// số lượng dòng được hiển thị 1 trang $curPage = 1; // Trang hiện tại $numberOfRows = 0; if (isset($_GET['page']) && !empty($_GET['page'])) { $curPage = $_GET['page']; //truyền thứ tự trang cần xem } $offset = ($curPage - 1) * $rowsPerPage; // tính offset bắt đầu load if (isset($_GET["btnSearch"])) { $Product = new Product(); $Product->setProName($_GET["txtProName"]); $Price = $_GET["txtPrice"]; $Price = explode(',', $Price); $Product->setPrice($Price); require_once './entities/Category.php'; require_once './entities/Brand.php'; require_once './entities/Device.php'; $CatPro = new Category(); $CatPro->setBrand(new Brand($_GET["cboBra"])); $CatPro->setDevice(new Device($_GET["cboDevice"])); $Product->setCatPro($CatPro); $ListPro = $Product->loadLimit($rowsPerPage, $offset, "ProName"); $numberOfRows = $Product->countRecords(); $flag = true; } ?> <div class="box clearfix"> <ol class="breadcrumb box-top"> <li><a href="index.php"><i class="fa fa-home"></i></a></li>
<?php require 'Subjects/SubjectInterface.php'; require 'Observers/ObserverInterface.php'; require 'Observers/ShoppingCart.php'; require 'Subjects/Product.php'; require 'Observers/Checkout.php'; error_reporting(E_ALL); ini_set("display_errors", 1); $product = new Product(); $shoppingCart = new ShoppingCart(); $checkout = new Checkout(); $product->attach($shoppingCart); $product->attach($checkout); $product->setPrice(20);