当前位置: 首页>>代码示例>>PHP>>正文


PHP SpecificPrice::getSpecificPrice方法代码示例

本文整理汇总了PHP中SpecificPrice::getSpecificPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecificPrice::getSpecificPrice方法的具体用法?PHP SpecificPrice::getSpecificPrice怎么用?PHP SpecificPrice::getSpecificPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpecificPrice的用法示例。


在下文中一共展示了SpecificPrice::getSpecificPrice方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isDiscounted

    public static function isDiscounted($id_product, $quantity = 1)
    {
        global $cookie, $cart;
        $id_customer = (Validate::isCookie($cookie) and isset($cookie->id_customer) and $cookie->id_customer) ? (int) $cookie->id_customer : NULL;
        $id_group = $id_customer ? (int) Customer::getDefaultGroupId($id_customer) : _PS_DEFAULT_CUSTOMER_GROUP_;
        $cart_quantity = !$cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT SUM(`quantity`)
			FROM `' . _DB_PREFIX_ . 'cart_product`
			WHERE `id_product` = ' . (int) $id_product . ' AND `id_cart` = ' . (int) $cart->id);
        $quantity = $cart_quantity ? $cart_quantity : $quantity;
        $id_currency = (int) (Validate::isLoadedObject($cart) ? $cart->id_currency : ((isset($cookie->id_currency) and (int) $cookie->id_currency) ? $cookie->id_currency : Configuration::get('PS_CURRENCY_DEFAULT')));
        $ids = Address::getCountryAndState((int) $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
        $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
        $id_shop = (int) Shop::getCurrentShop();
        return (bool) SpecificPrice::getSpecificPrice((int) $id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity);
    }
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:16,代码来源:Product.php

示例2: getProducts

    /**
     * Return cart products
     *
     * @result array Products
     */
    public function getProducts($refresh = false, $id_product = false, $id_country = null)
    {
        if (!$this->id) {
            return array();
        }
        // Product cache must be strictly compared to NULL, or else an empty cart will add dozens of queries
        if ($this->_products !== null && !$refresh) {
            // Return product row with specified ID if it exists
            if (is_int($id_product)) {
                foreach ($this->_products as $product) {
                    if ($product['id_product'] == $id_product) {
                        return array($product);
                    }
                }
                return array();
            }
            return $this->_products;
        }
        // Build query
        $sql = new DbQuery();
        // Build SELECT
        $sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`,
                        cp.`price_more`,cp.`price_more_text`, cp.price_more_id,
						pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`,
						p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
						product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
						stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
						p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
						CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
						product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference');
        // Build FROM
        $sql->from('cart_product', 'cp');
        // Build JOIN
        $sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
        $sql->innerJoin('product_shop', 'product_shop', '(product_shop.`id_shop` = cp.`id_shop` AND product_shop.`id_product` = p.`id_product`)');
        $sql->leftJoin('product_lang', 'pl', '
			p.`id_product` = pl.`id_product`
			AND pl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('pl', 'cp.id_shop'));
        $sql->leftJoin('category_lang', 'cl', '
			product_shop.`id_category_default` = cl.`id_category`
			AND cl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('cl', 'cp.id_shop'));
        $sql->leftJoin('product_supplier', 'ps', 'ps.`id_product` = cp.`id_product` AND ps.`id_product_attribute` = cp.`id_product_attribute` AND ps.`id_supplier` = p.`id_supplier`');
        // @todo test if everything is ok, then refactorise call of this method
        $sql->join(Product::sqlStock('cp', 'cp'));
        // Build WHERE clauses
        $sql->where('cp.`id_cart` = ' . (int) $this->id);
        if ($id_product) {
            $sql->where('cp.`id_product` = ' . (int) $id_product);
        }
        $sql->where('p.`id_product` IS NOT NULL');
        // Build ORDER BY
        $sql->orderBy('cp.`date_add`, cp.`id_product`, cp.`id_product_attribute` ASC');
        if (Customization::isFeatureActive()) {
            $sql->select('cu.`id_customization`, cu.`quantity` AS customization_quantity');
            $sql->leftJoin('customization', 'cu', 'p.`id_product` = cu.`id_product` AND cp.`id_product_attribute` = cu.`id_product_attribute` AND cu.`id_cart` = ' . (int) $this->id);
            $sql->groupBy('cp.`id_product_attribute`, cp.`id_product`, cp.`id_shop`');
        } else {
            $sql->select('NULL AS customization_quantity, NULL AS id_customization');
        }
        if (Combination::isFeatureActive()) {
            $sql->select('
				product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
				IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
				(p.`weight`+ pa.`weight`) weight_attribute,
				IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
				IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
				IFNULL(product_attribute_shop.`minimal_quantity`, product_shop.`minimal_quantity`) as minimal_quantity,
				IF(product_attribute_shop.wholesale_price > 0,  product_attribute_shop.wholesale_price, product_shop.`wholesale_price`) wholesale_price
			');
            $sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
            $sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.`id_shop` = cp.`id_shop` AND product_attribute_shop.`id_product_attribute` = pa.`id_product_attribute`)');
        } else {
            $sql->select('p.`reference` AS reference, p.`ean13`,
				p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity, product_shop.`wholesale_price` wholesale_price');
        }
        $sql->select('image_shop.`id_image` id_image, il.`legend`');
        $sql->leftJoin('image_shop', 'image_shop', 'image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $this->id_shop);
        $sql->leftJoin('image_lang', 'il', 'il.`id_image` = image_shop.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang);
        $result = Db::getInstance()->executeS($sql);
        // Reset the cache before the following return, or else an empty cart will add dozens of queries
        $products_ids = array();
        $pa_ids = array();
        if ($result) {
            foreach ($result as $key => $row) {
                $products_ids[] = $row['id_product'];
                $pa_ids[] = $row['id_product_attribute'];
                $specific_price = SpecificPrice::getSpecificPrice($row['id_product'], $this->id_shop, $this->id_currency, $id_country, $this->id_shop_group, $row['cart_quantity'], $row['id_product_attribute'], $this->id_customer, $this->id);
                if ($specific_price) {
                    $reduction_type_row = array('reduction_type' => $specific_price['reduction_type']);
                } else {
                    $reduction_type_row = array('reduction_type' => 0);
                }
                $result[$key] = array_merge($row, $reduction_type_row);
            }
        }
//.........这里部分代码省略.........
开发者ID:satanicman,项目名称:Pizzushi.loc,代码行数:101,代码来源:Cart.php

示例3: isDiscounted

    public static function isDiscounted($id_product, $quantity = 1, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        $id_group = $context->customer->id_default_group;
        $cart_quantity = !$context->cart ? 0 : Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
			SELECT SUM(`quantity`)
			FROM `' . _DB_PREFIX_ . 'cart_product`
			WHERE `id_product` = ' . (int) $id_product . ' AND `id_cart` = ' . (int) $context->cart->id);
        $quantity = $cart_quantity ? $cart_quantity : $quantity;
        $id_currency = (int) $context->currency->id;
        $ids = Address::getCountryAndState((int) $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
        $id_country = (int) ($ids['id_country'] ? $ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
        return (bool) SpecificPrice::getSpecificPrice((int) $id_product, $context->shop->id, $id_currency, $id_country, $id_group, $quantity);
    }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:16,代码来源:Product.php

示例4: productImportOne


//.........这里部分代码省略.........
            // Product supplier
            if (!$validateOnly && isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                if ($id_product_supplier) {
                    $product_supplier = new ProductSupplier($id_product_supplier);
                } else {
                    $product_supplier = new ProductSupplier();
                }
                $product_supplier->id_product = (int) $product->id;
                $product_supplier->id_product_attribute = 0;
                $product_supplier->id_supplier = (int) $product->id_supplier;
                $product_supplier->product_supplier_price_te = $product->wholesale_price;
                $product_supplier->product_supplier_reference = $product->supplier_reference;
                $product_supplier->save();
            }
            // SpecificPrice (only the basic reduction feature is supported by the import)
            if (!$shop_is_feature_active) {
                $info['shop'] = 1;
            } elseif (!isset($info['shop']) || empty($info['shop'])) {
                $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
            }
            // Get shops for each attributes
            $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
            $id_shop_list = array();
            foreach ($info['shop'] as $shop) {
                if (!empty($shop) && !is_numeric($shop)) {
                    $id_shop_list[] = (int) Shop::getIdByName($shop);
                } elseif (!empty($shop)) {
                    $id_shop_list[] = $shop;
                }
            }
            if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                foreach ($id_shop_list as $id_shop) {
                    $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                    if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
                        $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']);
                    } else {
                        $specific_price = new SpecificPrice();
                    }
                    $specific_price->id_product = (int) $product->id;
                    $specific_price->id_specific_price_rule = 0;
                    $specific_price->id_shop = $id_shop;
                    $specific_price->id_currency = 0;
                    $specific_price->id_country = 0;
                    $specific_price->id_group = 0;
                    $specific_price->price = -1;
                    $specific_price->id_customer = 0;
                    $specific_price->from_quantity = 1;
                    $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
                    $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
                    $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
                    $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
                    if (!$validateOnly && !$specific_price->save()) {
                        $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
                    }
                }
            }
            if (!$validateOnly && isset($product->tags) && !empty($product->tags)) {
                if (isset($product->id) && $product->id) {
                    $tags = Tag::getProductTags($product->id);
                    if (is_array($tags) && count($tags)) {
                        if (!empty($product->tags)) {
                            $product->tags = explode($this->multiple_value_separator, $product->tags);
                        }
                        if (is_array($product->tags) && count($product->tags)) {
                            foreach ($product->tags as $key => $tag) {
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php

示例5: VALUES

 if ((double) substr(_PS_VERSION_, 0, 3) < 1.6) {
     $reference = '\'' . $reference . '\'';
 }
 $combination = $product_attribute_id . '|' . $quantity . '|' . $new_price . '|0|' . $image . '|' . $reference . '|0.00|' . $minimal_quantity . '|';
 //	Add for Prestashop 1.5 version and above
 if ((double) substr(_PS_VERSION_, 0, 3) >= 1.5) {
     //	Add product attribute shop
     Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_shop (id_product_attribute, id_shop, price, wholesale_price, weight, minimal_quantity, available_date) VALUES (' . $product_attribute_id . ', ' . $shop_id . ', ' . $new_price . ', ' . $wholesale_price . ', ' . $weight . ', ' . $minimal_quantity . ', "0000-00-00")');
     //	Add stock availability
     $product_tmp = new Product($request_product);
     Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'stock_available (id_product, id_product_attribute, id_shop, id_shop_group, quantity, out_of_stock) VALUES (' . $request_product . ', ' . $product_attribute_id . ', ' . $shop_id . ', 0, ' . $quantity . ', ' . $product_tmp->out_of_stock . ')');
     //	Update stock for base product
     Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'stock_available SET quantity = quantity + ' . $quantity . ' WHERE id_product = ' . $request_product . ' AND id_product_attribute = 0 AND ' . 'id_shop = ' . $shop_id);
     //	Specific price
     $country_id = (int) Db::getInstance()->getValue('SELECT id_country FROM ' . _DB_PREFIX_ . 'address WHERE id_customer = ' . (int) $cookie->id_customer . ' AND active = 1 ORDER by id_address ASC');
     $specific_price = SpecificPrice::getSpecificPrice($request_product, $shop_id, (int) $cookie->id_currency, $country_id, $group_id, $quantity, $product_attribute_id, (int) $cookie->id_customer);
     if (!empty($specific_price)) {
         if ($specific_price['reduction_type'] == 'percentage') {
             $specific_price_combination = (double) $specific_price['reduction'] * 100 . '|0|' . (double) $specific_price['price'] . '|percentage|';
         } else {
             $specific_price_combination = '0|' . (double) $specific_price['reduction'] . '|' . (double) $specific_price['price'] . '|amount|';
         }
     } else {
         $specific_price_combination = '0|0|0|\'\'|';
     }
     //	Attribute datas
     $group_name = Db::getInstance()->getValue('SELECT name FROM ' . _DB_PREFIX_ . 'attribute_group_lang WHERE id_attribute_group = ' . $group . ' AND id_lang = ' . (int) $cookie->id_lang);
     $attribute = $attribute_id . '|\'' . $request_value . '\'|\'' . $group_name . '\'|\'' . $group . '\'|';
     //	Return string
     $combination .= '0000-00-00|' . $specific_price_combination . $attribute;
     //	Add weight, attributes names for Prestashop 1.6.0.6 and above
开发者ID:EliosIT,项目名称:PS_AchatFilet,代码行数:31,代码来源:ajax.php

示例6: generateProductsData

    protected function generateProductsData()
    {
        $delimiter = ';';
        $titles = array();
        $id_lang = $this->use_lang;
        $new_path = new Sampledatainstall();
        $f = fopen($new_path->sendPath() . 'output/products.vsc', 'w');
        foreach ($this->product_fields as $field => $array) {
            $titles[] = $array['label'];
        }
        fputcsv($f, $titles, $delimiter, '"');
        $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', false, true);
        foreach ($products as $product) {
            $line = array();
            $p = new Product($product['id_product'], true, $id_lang, 1);
            foreach ($this->product_fields as $field => $array) {
                $line[$field] = property_exists('Product', $field) && !is_array($p->{$field}) && !Tools::isEmpty($p->{$field}) ? $p->{$field} : '';
            }
            $cats = $p->getProductCategoriesFull($p->id, 1);
            $cat_array = array();
            foreach ($cats as $cat) {
                $cat_array[] = $cat['id_category'];
            }
            $line['categories'] = implode(',', $cat_array);
            $line['price_tex'] = $p->getPrice(false);
            $line['price_tin'] = $p->getPrice(true);
            $line['upc'] = $p->upc ? $p->upc : '';
            $line['features'] = '';
            $features = $p->getFrontFeatures($id_lang);
            $position = 1;
            $devider = '';
            foreach ($features as $feature) {
                $sql = 'SELECT `id_feature`
						FROM ' . _DB_PREFIX_ . 'feature_lang
						WHERE `name` = "' . pSql($feature['name']) . '"';
                $sql1 = 'SELECT `id_feature_value`
						FROM ' . _DB_PREFIX_ . 'feature_value_lang
						WHERE `value` = "' . pSql($feature['value']) . '"';
                $id_feature = Db::getInstance()->getValue($sql);
                $id_feature_value = Db::getInstance()->getValue($sql1);
                $line['features'] .= $devider . $id_feature . ':' . $id_feature_value . ':' . $position;
                $devider = ',';
                $position++;
            }
            $specificPrice = SpecificPrice::getSpecificPrice($p->id, 1, 0, 0, 0, 0);
            $line['reduction_price'] = '';
            $line['reduction_percent'] = '';
            $line['reduction_from'] = '';
            $line['reduction_to'] = '';
            if ($specificPrice) {
                if ($specificPrice['reduction_type'] == 'amount') {
                    $line['reduction_price'] = $specificPrice['reduction'];
                } elseif ($specificPrice['reduction_type'] == 'percent') {
                    $line['reduction_percent'] = $specificPrice['reduction'];
                }
                if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
                    $line['reduction_from'] = $specificPrice['from'];
                    $line['reduction_to'] = $specificPrice['to'];
                }
            }
            $tags = $p->getTags($id_lang);
            $line['tags'] = $tags;
            $link = new Link();
            $imagelinks = array();
            $images = $p->getImages($id_lang);
            foreach ($images as $image) {
                $imagelink = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
                $this->copyConverFileName($imagelink);
                $imagelinks[] = $imagelink;
            }
            $line['image'] = implode(',', $imagelinks);
            $line['delete_existing_images'] = 0;
            $line['shop'] = 1;
            $warehouses = Warehouse::getWarehousesByProductId($p->id);
            $line['warehouse'] = '';
            if (!empty($warehouses)) {
                $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
            }
            $values = array();
            $accesories = $p->getAccessories($id_lang);
            if (isset($accesories) && $accesories && count($accesories)) {
                foreach ($accesories as $accesorie) {
                    $values[] = $accesorie['id_product'];
                }
            }
            $line['accessories'] = $values ? implode(',', $values) : '';
            $values = array();
            $carriers = $p->getCarriers();
            if (isset($carriers) && $carriers && count($carriers)) {
                foreach ($carriers as $carrier) {
                    $values[] = $carrier['id_carrier'];
                }
            }
            $line['carriers'] = $values ? implode(',', $values) : '';
            $values = array();
            $customization_fields_ids = $p->getCustomizationFieldIds();
            if (class_exists('CustomizationField') && isset($customization_fields_ids) && $customization_fields_ids && count($customization_fields_ids)) {
                foreach ($customization_fields_ids as $customization_field_id) {
                    $cf = new CustomizationField($customization_field_id['id_customization_field'], $this->use_lang);
                    $values[] = $cf->id . ':' . $cf->type . ':' . $cf->required . ':' . $cf->name;
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:AdminSampleDataInstallExport.php

示例7: priceCalculation

 public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $use_group_reduction, $id_customer = 0, $use_customer_price = true, $id_cart = 0, $real_quantity = 0, $service_date = null, $service_time_from = null, $service_time_to = null)
 {
     require_once dirname(__FILE__) . '/../../modules/aphrodinet/classes/AphCustomPrice.php';
     static $address = null;
     static $context = null;
     if ($address === null) {
         $address = new Address();
     }
     if ($context == null) {
         $context = Context::getContext()->cloneContext();
     }
     if ($id_shop !== null && $context->shop->id != (int) $id_shop) {
         $context->shop = new Shop((int) $id_shop);
     }
     if (!$use_customer_price) {
         $id_customer = 0;
     }
     if ($id_product_attribute === null) {
         $id_product_attribute = Product::getDefaultAttribute($id_product);
     }
     if (!empty($id_cart)) {
         $res = Db::getInstance()->executeS('SELECT `delivery_date`, `delivery_time_from`, `delivery_time_to` ' . 'FROM ' . _DB_PREFIX_ . 'cart_product ' . 'WHERE `id_cart` = ' . (int) $id_cart . ' AND `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute . ' ' . 'LIMIT 1');
         if (!empty($res) && empty($service_date)) {
             $res = $res[0];
             if (!empty($res)) {
                 $service_date = $res['delivery_date'];
                 $service_time_from = $res['delivery_time_from'];
                 $service_time_to = $res['delivery_time_to'];
             }
         }
     }
     if (!empty($service_time_from) && strlen($service_time_from) == 5) {
         $service_time_from .= ':00';
     }
     if (!empty($service_time_to) && strlen($service_time_to) == 5) {
         $service_time_to .= ':00';
     }
     $cache_id = (int) $id_product . '-' . (int) $id_shop . '-' . (int) $id_currency . '-' . (int) $id_country . '-' . $id_state . '-' . $zipcode . '-' . (int) $id_group . '-' . (int) $quantity . '-' . (int) $id_product_attribute . '-' . (int) $with_ecotax . '-' . (int) $id_customer . '-' . (int) $use_group_reduction . '-' . (int) $id_cart . '-' . (int) $real_quantity . '-' . ($only_reduc ? '1' : '0') . '-' . ($use_reduc ? '1' : '0') . '-' . ($use_tax ? '1' : '0') . '-' . (int) $decimals . (!empty($service_date) && $service_date != '0000-00-00' ? '-' . $service_date : '') . (!empty($service_time_to) && $service_time_to != '00:00:00' ? '-' . $service_time_from : '') . (!empty($service_time_to) && $service_time_to != '00:00:00' ? '-' . $service_time_to : '');
     // reference parameter is filled before any returns
     $specific_price = SpecificPrice::getSpecificPrice((int) $id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_product_attribute, $id_customer, $id_cart, $real_quantity);
     if (isset(self::$_prices[$cache_id])) {
         if (isset($specific_price['price']) && $specific_price['price'] > 0) {
             $specific_price['price'] = self::$_prices[$cache_id];
         }
         return self::$_prices[$cache_id];
     }
     $cache_id_2 = $id_product . '-' . $id_shop . (!empty($service_date) && $service_date != '0000-00-00' ? '-' . $service_date : '') . (!empty($service_time_to) && $service_time_to != '00:00:00' ? '-' . $service_time_from : '') . (!empty($service_time_to) && $service_time_to != '00:00:00' ? '-' . $service_time_to : '');
     if (!isset(self::$_pricesLevel2[$cache_id_2])) {
         $base_price_wt = 0;
         $service_date_ts = strtotime($service_date);
         $service_date_week_day = date('w', $service_date_ts);
         if (!empty($service_date) && $service_date != '0000-00-00') {
             // cerco il prezzo del giorno
             $custom_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, -1, NULL, 1);
             if (!empty($custom_prices)) {
                 $base_price_wt = $custom_prices[0]['price_wt'];
             }
         }
         if (!empty($service_date) && $service_date != '0000-00-00') {
             $offer_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, -1, 0, 1);
         }
         if (!empty($service_date) && $service_date != '0000-00-00') {
             $offer_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, $service_date_week_day, 0, 1);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, -1);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, $service_date_week_day);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && !empty($service_time_to) && $service_time_to != '00:00:00' && empty($custom_prices) && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, -1, $service_time_from);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && !empty($service_time_to) && $service_time_to != '00:00:00' && empty($custom_prices) && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate($id_shop, $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, $service_date_week_day, $service_time_from);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && empty($custom_prices) && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate(Configuration::get('PS_SHOP_DEFAULT'), $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, -1);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && empty($custom_prices) && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate(Configuration::get('PS_SHOP_DEFAULT'), $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, $service_date_week_day);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && !empty($service_time_to) && $service_time_to != '00:00:00' && empty($custom_prices) && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate(Configuration::get('PS_SHOP_DEFAULT'), $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, -1, $service_time_from);
         }
         if (!empty($service_date) && $service_date != '0000-00-00' && !empty($service_time_to) && $service_time_to != '00:00:00' && empty($custom_prices) && empty($offer_prices)) {
             $custom_prices = AphCustomPrice::getByDate(Configuration::get('PS_SHOP_DEFAULT'), $id_currency, $id_country, $id_group, $service_date, $id_customer, (int) $id_product, $service_date_week_day, $service_time_from);
         }
         if (!empty($offer_prices)) {
             $res = $offer_prices;
         } elseif (!empty($custom_prices)) {
             $res = $custom_prices;
         } else {
             $sql = new DbQuery();
             $sql->select('product_shop.`price`, product_shop.`ecotax`');
             $sql->from('product', 'p');
             $sql->innerJoin('product_shop', 'product_shop', '(product_shop.id_product=p.id_product AND product_shop.id_shop = ' . (int) $id_shop . ')');
             $sql->where('p.`id_product` = ' . (int) $id_product);
             if (Combination::isFeatureActive()) {
                 $sql->select('IFNULL(product_attribute_shop.id_product_attribute,0) id_product_attribute, product_attribute_shop.`price` AS attribute_price, product_attribute_shop.default_on');
//.........这里部分代码省略.........
开发者ID:paolobattistella,项目名称:aphro,代码行数:101,代码来源:Product.php

示例8: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit('submitExport')) {
         $delimiter = Tools::getValue('export_delimiter');
         $id_lang = Tools::getValue('export_language');
         $id_shop = (int) $this->context->shop->id;
         set_time_limit(0);
         $fileName = 'products_' . date("Y_m_d_H_i_s") . '.csv';
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header('Content-Description: File Transfer');
         header("Content-type: text/csv");
         header("Content-Disposition: attachment; filename={$fileName}");
         header("Expires: 0");
         header("Pragma: public");
         $f = fopen('php://output', 'w');
         foreach ($this->available_fields as $field => $array) {
             $titles[] = $array['label'];
         }
         fputcsv($f, $titles, $delimiter, '"');
         $export_active = Tools::getValue('export_active') == 0 ? false : true;
         $export_category = Tools::getValue('export_category') == 99999 ? false : Tools::getValue('export_category');
         $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', $export_category, $export_active);
         foreach ($products as $product) {
             $line = array();
             $p = new Product($product['id_product'], true, $id_lang, $id_shop);
             $p->loadStockData();
             foreach ($this->available_fields as $field => $array) {
                 if (isset($p->{$field}) && !is_array($p->{$field})) {
                     $line[$field] = $p->{$field} ? $p->{$field} : ' ';
                 } else {
                     switch ($field) {
                         case 'categories':
                             $cats = $p->getProductCategoriesFull($p->id, $id_lang);
                             $cat_array = array();
                             foreach ($cats as $cat) {
                                 $cat_array[] = $cat['name'];
                             }
                             $line['categories'] = implode(",", $cat_array);
                             break;
                         case 'price_tex':
                             $line['price_tex'] = $p->getPrice(false);
                             $line['price_tin'] = $p->getPrice(true);
                             break;
                         case 'upc':
                             $line['upc'] = $p->upc ? $p->upc : ' ';
                             break;
                         case 'features':
                             $line['features'] = '';
                             $features = $p->getFrontFeatures($id_lang);
                             $position = 1;
                             foreach ($features as $feature) {
                                 $line['features'] .= $feature['name'] . ':' . $feature['value'] . ':' . $position;
                                 $position++;
                             }
                             break;
                         case 'reduction_price':
                             $specificPrice = SpecificPrice::getSpecificPrice($p->id, $id_shop, 0, 0, 0, 0);
                             $line['reduction_price'] = '';
                             $line['reduction_percent'] = '';
                             $line['reduction_from'] = '';
                             $line['reduction_to'] = '';
                             if ($specificPrice['reduction_type'] == "amount") {
                                 $line['reduction_price'] = $specificPrice['reduction'];
                             } elseif ($specificPrice['reduction_type'] == "percent") {
                                 $line['reduction_percent'] = $specificPrice['reduction'];
                             }
                             if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
                                 $line['reduction_from'] = date_format(date_create($specificPrice['from']), "Y-m-d");
                                 $line['reduction_to'] = date_format(date_create($specificPrice['to']), "Y-m-d");
                             }
                             break;
                         case 'tags':
                             $tags = $p->getTags($id_lang);
                             $line['tags'] = $tags;
                             break;
                         case 'image':
                             $link = new Link();
                             $imagelinks = array();
                             $images = $p->getImages($id_lang);
                             foreach ($images as $image) {
                                 $imagelinks[] = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
                             }
                             $line['image'] = implode(",", $imagelinks);
                             break;
                         case 'delete_existing_images':
                             $line['delete_existing_images'] = 0;
                             break;
                         case 'shop':
                             $line['shop'] = $id_shop;
                             break;
                         case 'warehouse':
                             $warehouses = Warehouse::getWarehousesByProductId($p->id);
                             $line['warehouse'] = '';
                             if (!empty($warehouses)) {
                                 $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
                             }
                             break;
                         case 'date_added':
                             $date = new DateTime($p->date_add);
                             $line['date_add'] = $date->format("Y-m-d");
//.........这里部分代码省略.........
开发者ID:KaipiYann,项目名称:exportproducts,代码行数:101,代码来源:AdminExportProducts.php

示例9: updateQty


//.........这里部分代码省略.........
            unset(self::$_totalWeight[$this->id]);
        }
        Hook::exec('actionBeforeCartUpdateQty', array('cart' => $this, 'product' => $product, 'id_product_attribute' => $id_product_attribute, 'id_customization' => $id_customization, 'quantity' => $quantity, 'operator' => $operator, 'id_address_delivery' => $id_address_delivery, 'shop' => $shop, 'auto_add_cart_rule' => $auto_add_cart_rule));
        if ((int) $quantity <= 0) {
            return $this->deleteProduct($id_product, $id_product_attribute, (int) $id_customization);
        } elseif (!$product->available_for_order || Configuration::get('PS_CATALOG_MODE') && !defined('_PS_ADMIN_DIR_')) {
            return false;
        } else {
            /* Check if the product is already in the cart */
            $result = $this->containsProduct($id_product, $id_product_attribute, (int) $id_customization, (int) $id_address_delivery);
            /* Update quantity if product already exist */
            if ($result) {
                if ($operator == 'up') {
                    $sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
							FROM ' . _DB_PREFIX_ . 'product p
							' . Product::sqlStock('p', $id_product_attribute, true, $shop) . '
							WHERE p.id_product = ' . $id_product;
                    $result2 = Db::getInstance()->getRow($sql);
                    $product_qty = (int) $result2['quantity'];
                    // Quantity for product pack
                    if (Pack::isPack($id_product)) {
                        $product_qty = Pack::getQuantity($id_product, $id_product_attribute);
                    }
                    $new_qty = (int) $result['quantity'] + (int) $quantity;
                    $qty = '+ ' . (int) $quantity;
                    if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock'])) {
                        if ($new_qty > $product_qty) {
                            return false;
                        }
                    }
                } elseif ($operator == 'down') {
                    $qty = '- ' . (int) $quantity;
                    $new_qty = (int) $result['quantity'] - (int) $quantity;
                    if ($new_qty < $minimal_quantity && $minimal_quantity > 1) {
                        return -1;
                    }
                } else {
                    return false;
                }
                /* Delete product from cart */
                if ($new_qty <= 0) {
                    return $this->deleteProduct((int) $id_product, (int) $id_product_attribute, (int) $id_customization);
                } elseif ($new_qty < $minimal_quantity) {
                    return -1;
                } else {
                    Db::getInstance()->execute('
						UPDATE `' . _DB_PREFIX_ . 'cart_product`
						SET `quantity` = `quantity` ' . $qty . ', `date_add` = NOW()
						WHERE `id_product` = ' . (int) $id_product . (!empty($id_product_attribute) ? ' AND `id_product_attribute` = ' . (int) $id_product_attribute : '') . '
						AND `id_cart` = ' . (int) $this->id . (Configuration::get('PS_ALLOW_MULTISHIPPING') && $this->isMultiAddressDelivery() ? ' AND `id_address_delivery` = ' . (int) $id_address_delivery : '') . '
						LIMIT 1');
                }
            } elseif ($operator == 'up') {
                $sql = 'SELECT stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity
						FROM ' . _DB_PREFIX_ . 'product p
						' . Product::sqlStock('p', $id_product_attribute, true, $shop) . '
						WHERE p.id_product = ' . $id_product;
                $result2 = Db::getInstance()->getRow($sql);
                // Quantity for product pack
                if (Pack::isPack($id_product)) {
                    $result2['quantity'] = Pack::getQuantity($id_product, $id_product_attribute);
                }
                if (!Product::isAvailableWhenOutOfStock((int) $result2['out_of_stock'])) {
                    if ((int) $quantity > $result2['quantity']) {
                        return false;
                    }
                }
                if ((int) $quantity < $minimal_quantity) {
                    return -1;
                }
                $context = Context::getContext();
                $context->shop->id = Tools::getIsset('ids') ? Tools::getValue('ids') : $shop->id;
                $specific_price = SpecificPrice::getSpecificPrice($id_product, $context->shop->id, null, null, null, 1, null, 0, 0, 0);
                $delivery_date = Tools::getIsset('delivery_date') ? Tools::getValue('delivery_date') : '';
                $delivery_time_from = Tools::getIsset('delivery_time_from') ? Tools::getValue('delivery_time_from') : '';
                $delivery_time_to = Tools::getIsset('delivery_time_to') ? Tools::getValue('delivery_time_to') : '';
                // $price = Product::getPriceStatic($id_product, true, 0, 2, null, false, true, 1, false, null, null, null, $specific_price, true, true, $context, true, $delivery_date, $delivery_time_from, $delivery_time_to);
                // if (empty($price))
                //     $price = $product->price;
                $result_add = Db::getInstance()->insert('cart_product', array('id_product' => (int) $id_product, 'id_product_attribute' => (int) $id_product_attribute, 'id_cart' => (int) $this->id, 'id_address_delivery' => (int) $id_address_delivery, 'id_shop' => Tools::getIsset('ids') ? Tools::getValue('ids') : $shop->id, 'quantity' => (int) $quantity, 'date_add' => date('Y-m-d H:i:s'), 'delivery_date' => $delivery_date, 'delivery_time_from' => $delivery_time_from, 'delivery_time_to' => $delivery_time_to));
                if (!$result_add) {
                    return false;
                }
            }
        }
        // refresh cache of self::_products
        $this->_products = $this->getProducts(true);
        $this->update();
        $context = Context::getContext()->cloneContext();
        $context->cart = $this;
        Cache::clean('getContextualValue_*');
        if ($auto_add_cart_rule) {
            CartRule::autoAddToCart($context);
        }
        if ($product->customizable) {
            return $this->_updateCustomizationQuantity((int) $quantity, (int) $id_customization, (int) $id_product, (int) $id_product_attribute, (int) $id_address_delivery, $operator);
        } else {
            return true;
        }
    }
开发者ID:paolobattistella,项目名称:aphro,代码行数:101,代码来源:Cart.php

示例10: productImport


//.........这里部分代码省略.........
                // Product supplier
                if (isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                    $id_product_supplier = ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                    if ($id_product_supplier) {
                        $product_supplier = new ProductSupplier((int) $id_product_supplier);
                    } else {
                        $product_supplier = new ProductSupplier();
                    }
                    $product_supplier->id_product = $product->id;
                    $product_supplier->id_product_attribute = 0;
                    $product_supplier->id_supplier = $product->id_supplier;
                    $product_supplier->product_supplier_price_te = $product->wholesale_price;
                    $product_supplier->product_supplier_reference = $product->supplier_reference;
                    $product_supplier->save();
                }
                // SpecificPrice (only the basic reduction feature is supported by the import)
                if (!Shop::isFeatureActive()) {
                    $info['shop'] = 1;
                } elseif (!isset($info['shop']) || empty($info['shop'])) {
                    $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
                }
                // Get shops for each attributes
                $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
                $id_shop_list = array();
                foreach ($info['shop'] as $shop) {
                    if (!empty($shop) && !is_numeric($shop)) {
                        $id_shop_list[] = (int) Shop::getIdByName($shop);
                    } elseif (!empty($shop)) {
                        $id_shop_list[] = $shop;
                    }
                }
                if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                    foreach ($id_shop_list as $id_shop) {
                        $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                        if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
                            $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']);
                        } else {
                            $specific_price = new SpecificPrice();
                        }
                        $specific_price->id_product = (int) $product->id;
                        $specific_price->id_specific_price_rule = 0;
                        $specific_price->id_shop = $id_shop;
                        $specific_price->id_currency = 0;
                        $specific_price->id_country = 0;
                        $specific_price->id_group = 0;
                        $specific_price->price = -1;
                        $specific_price->id_customer = 0;
                        $specific_price->from_quantity = 1;
                        $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
                        $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
                        $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
                        $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
                        if (!$specific_price->save()) {
                            $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
                        }
                    }
                }
                if (isset($product->tags) && !empty($product->tags)) {
                    if (isset($product->id) && $product->id) {
                        $tags = Tag::getProductTags($product->id);
                        if (is_array($tags) && count($tags)) {
                            if (!empty($product->tags)) {
                                $product->tags = explode($this->multiple_value_separator, $product->tags);
                            }
                            if (is_array($product->tags) && count($product->tags)) {
                                foreach ($product->tags as $key => $tag) {
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:67,代码来源:AdminImportController.php

示例11: setProductsSpecificPrices

    public static function setProductsSpecificPrices($id_search, $id_criterion_group, $id_product = false)
    {
        $specific_prices_cache = Db::getInstance()->ExecuteS('
			SELECT * FROM `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` app, `' . _DB_PREFIX_ . 'pm_advancedsearch_cache_product_' . $id_search . '` acp
			WHERE app.`id_cache_product`=acp.`id_cache_product`
			AND app.`is_specific`=1
			' . ($id_product != false ? ' AND acp.`id_product`=' . (int) $id_product : '') . ' 
			' . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND app.`id_shop`=' . (int) self::getShopBySearch($id_search) : '') . ' 
			GROUP BY acp.`id_product`, app.`id_shop`, app.`id_currency`, app.`id_country`, app.`id_group`');
        if ($id_product == false) {
            Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` SET `valid_id_specific_price`=0');
        } else {
            Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` app, `' . _DB_PREFIX_ . 'pm_advancedsearch_cache_product_' . $id_search . '` acp
			SET app.`valid_id_specific_price`=0
			WHERE app.`id_cache_product`=acp.`id_cache_product` AND acp.`id_product`=' . (int) $id_product);
        }
        if ($specific_prices_cache && AdvancedSearchCoreClass::_isFilledArray($specific_prices_cache)) {
            foreach ($specific_prices_cache as $row) {
                if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) {
                    $specific_price = SpecificPrice::getSpecificPrice((int) $row['id_product'], (int) $row['id_shop'], (int) $row['id_currency'], (int) $row['id_country'], (int) $row['id_group'], 1, null, 0, 0, 1);
                } else {
                    $specific_price = SpecificPrice::getSpecificPrice((int) $row['id_product'], (int) $row['id_shop'], (int) $row['id_currency'], (int) $row['id_country'], (int) $row['id_group'], 1);
                }
                if ($specific_price && AdvancedSearchCoreClass::_isFilledArray($specific_price)) {
                    Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` SET `valid_id_specific_price`=1 WHERE `id_group`=' . (int) $row['id_group'] . ' AND `id_cache_product`=' . (int) $row['id_cache_product'] . ' AND `id_specific_price`=' . (int) $specific_price['id_specific_price']);
                } else {
                    Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` SET `has_no_specific`=1 WHERE `id_group`=' . (int) $row['id_group'] . ' AND `id_cache_product`=' . (int) $row['id_cache_product'] . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND `id_shop`=' . (int) $row['id_shop'] : ''));
                    Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` WHERE `id_group`=' . (int) $row['id_group'] . ' AND `is_specific`=1 AND `id_cache_product`=' . (int) $row['id_cache_product'] . (version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? ' AND `id_shop`=' . (int) $row['id_shop'] : ''));
                }
            }
        }
        Db::getInstance()->Execute('
			UPDATE `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '` app
			JOIN (SELECT `id_cache_product`, `id_shop`, `id_group`
				FROM `' . _DB_PREFIX_ . 'pm_advancedsearch_product_price_' . $id_search . '`
				GROUP BY `id_cache_product`, `id_shop`, `id_group`
				HAVING SUM(`is_specific`)=0) as app2
			ON (app.`id_cache_product`=app2.`id_cache_product` AND app.`id_shop`=app2.`id_shop` AND app.`id_group`=app2.`id_group`)
			SET app.`has_no_specific`=1
		');
    }
开发者ID:acreno,项目名称:pm-ps,代码行数:41,代码来源:AdvancedSearchClass.php

示例12: productImport


//.........这里部分代码省略.........
                $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
            } else {
                if (isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                    $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                    if ($id_product_supplier) {
                        $product_supplier = new ProductSupplier($id_product_supplier);
                    } else {
                        $product_supplier = new ProductSupplier();
                    }
                    $product_supplier->id_product = (int) $product->id;
                    $product_supplier->id_product_attribute = 0;
                    $product_supplier->id_supplier = (int) $product->id_supplier;
                    $product_supplier->product_supplier_price_te = $product->wholesale_price;
                    $product_supplier->product_supplier_reference = $product->supplier_reference;
                    $product_supplier->save();
                }
                if (!Shop::isFeatureActive()) {
                    $info['shop'] = 1;
                } elseif (!isset($info['shop']) || empty($info['shop'])) {
                    $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
                }
                $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
                $id_shop_list = array();
                foreach ($info['shop'] as $shop) {
                    if (!empty($shop) && !is_numeric($shop)) {
                        $id_shop_list[] = (int) Shop::getIdByName($shop);
                    } elseif (!empty($shop)) {
                        $id_shop_list[] = $shop;
                    }
                }
                if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                    foreach ($id_shop_list as $id_shop) {
                        $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                        if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
                            $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']);
                        } else {
                            $specific_price = new SpecificPrice();
                        }
                        $specific_price->id_product = (int) $product->id;
                        $specific_price->id_specific_price_rule = 0;
                        $specific_price->id_shop = $id_shop;
                        $specific_price->id_currency = 0;
                        $specific_price->id_country = 0;
                        $specific_price->id_group = 0;
                        $specific_price->price = -1;
                        $specific_price->id_customer = 0;
                        $specific_price->from_quantity = 1;
                        $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
                        $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
                        $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
                        $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
                        if (!$specific_price->save()) {
                            $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
                        }
                    }
                }
                if (isset($product->tags) && !empty($product->tags)) {
                    if (isset($product->id) && $product->id) {
                        $tags = Tag::getProductTags($product->id);
                        if (is_array($tags) && count($tags)) {
                            if (!empty($product->tags)) {
                                $product->tags = explode($this->multiple_value_separator, $product->tags);
                            }
                            if (is_array($product->tags) && count($product->tags)) {
                                foreach ($product->tags as $key => $tag) {
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:67,代码来源:AdminImportController.php


注:本文中的SpecificPrice::getSpecificPrice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。