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


PHP Product::add方法代码示例

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


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

示例1: testAdd

 /**
  * @covers QueueController::Add
  * @todo Implement testAdd().
  */
 public function testAdd()
 {
     $person = Person::factory('adult');
     $person->name = 'Poehavshiy';
     $person->add();
     $store = Store::factory('Grocery');
     $store->name = 'Prison';
     $store->add();
     $product = new Product();
     $product->name = 'Sladkiy hleb';
     $product->add();
     $request = Application::getInstance()->request;
     $request->setParams(array('storeId' => $store->id, 'personId' => $person->id, 'product_' . $product->id => 'on'));
     $personId = $request->p('personId');
     $storeId = $request->p('storeId');
     $store = Store::get($storeId);
     $person = Person::get($personId);
     $store->queue->add($person);
     $person->basket->drop();
     $name = 'product_' . $product->id;
     $value = $product;
     if (preg_match_all('/^product_(\\d+)$/', $name, $matches)) {
         $person->basket->add(Product::get($matches[1][0]));
     }
 }
开发者ID:ruyozora,项目名称:Test-test,代码行数:29,代码来源:QueueControllerTest.php

示例2: Add

 public function Add()
 {
     $this->_response()->asJSON();
     try {
         $name = $this->_request()->p('name');
         $product = new Product();
         $product->name = trim($name);
         $product->add();
         return array('id' => $product->id, 'name' => $product->name);
     } catch (Exception $e) {
         return array('error' => $e->getMessage());
     }
 }
开发者ID:ruyozora,项目名称:Test-test,代码行数:13,代码来源:ProductController.php

示例3: testAdd

 /**
  * @covers Assortment::add
  * @todo Implement testAdd().
  */
 public function testAdd()
 {
     $db = Application::getInstance()->mysqli;
     $db->query('DELETE FROM Product');
     $db->query('DELETE FROM Store');
     $db->query('DELETE FROM Assortment');
     for ($i = 1; $i < 3; $i++) {
         $store = Store::factory('grocery');
         $store->name = 'store_' . $i;
         $store->add();
         $stores[] = $store;
     }
     for ($i = 1; $i < 10; $i++) {
         $product = new Product();
         $product->name = 'product_' . $i;
         $product->add();
         $products[] = $product;
         $map[$product->id] = rand(0, 2);
     }
     $a = $stores[1]->assortment;
     $a->map($map);
 }
开发者ID:ruyozora,项目名称:Test-test,代码行数:26,代码来源:AssortmentTest.php

示例4: product_handler

 function product_handler()
 {
     $this->check_login();
     $params = $this->input->post();
     if (isset($params['save'])) {
         Product::add($params);
     }
     redirect('admin/products');
 }
开发者ID:pojok-webdev,项目名称:pattimura,代码行数:9,代码来源:admin.php

示例5: handleConfirm


//.........这里部分代码省略.........
                 $product->generic_color = $generic_color;
                 $product->garment_type = $garment_type;
                 $product->work_type = $work_type;
                 $product->blouse_length = $blouse_length ? $blouse_length : ' ';
                 $product->wash_care = $wash_care ? $wash_care : ' ';
                 $product->other_info = $other_info ? $other_info : ' ';
                 $product->shipping_estimate = $shipping_estimate ? $shipping_estimate : ' ';
                 $product->is_customizable = $customizable == 1 ? 1 : 0;
                 $product->kameez_style = $kameez_style;
                 $product->salwar_style = $salwar_style;
                 $product->sleeves = $sleeves;
                 $product->skirt_length = $skirt_length;
                 $product->dupatta_length = $dupatta_length;
                 $product->stone = $stone;
                 $product->plating = $plating;
                 $product->material = $material;
                 $product->dimensions = $dimensions;
                 $product->look = $look;
                 $product->as_shown = $as_shown;
                 $product->id_sizechart = $id_sizechart;
                 $product->is_exclusive = $is_exclusive;
                 $product->handbag_occasion = $handbag_occasion;
                 $product->handbag_style = $handbag_style;
                 $product->handbag_material = $handbag_material;
                 $product->indexed = 0;
                 $products_to_import[] = $product;
             } else {
                 $smarty->assign('error', $error);
                 return;
                 $file_error = true;
             }
         }
         if (!$file_error) {
             $added_product_ids = array();
             foreach ($products_to_import as $product) {
                 $fieldError = $product->validateFields(UNFRIENDLY_ERROR, true);
                 $langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
                 if ($fieldError === true and $langFieldError === true) {
                     // check quantity
                     if ($product->quantity == NULL) {
                         $product->quantity = 0;
                     }
                     // If no id_product or update failed
                     if ($update && $product->id) {
                         $res = $product->update();
                     } else {
                         $res = $product->add();
                     }
                     $added_product_ids[] = $product->id;
                 }
                 if (isset($product->discount) && $product->discount > 0) {
                     SpecificPrice::deleteByProductId((int) $product->id);
                     $specificPrice = new SpecificPrice();
                     $specificPrice->id_product = (int) $product->id;
                     $specificPrice->id_shop = (int) Shop::getCurrentShop();
                     $specificPrice->id_currency = 0;
                     $specificPrice->id_country = 0;
                     $specificPrice->id_group = 0;
                     $specificPrice->from_quantity = 1;
                     $specificPrice->reduction = $product->discount / 100;
                     $specificPrice->reduction_type = 'percentage';
                     $specificPrice->from = '2012-01-01 00:00:00';
                     $specificPrice->to = '2016-01-01 00:00:00';
                     $specificPrice->price = $product->price;
                     $specificPrice->add();
                 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:67,代码来源:AdminProductImport.php

示例6: loadProduct

 public function loadProduct($id_category, $fields)
 {
     $product = new Product();
     $product->copyFromPost();
     $product->id_category_default = (int) end($id_category);
     $product->id_brand = (int) $fields['id_brand'];
     $product->price = (double) $fields['price'];
     $product->special_price = (double) $fields['old_price'];
     $product->ean13 = pSQL($fields['ean13']);
     $product->weight = 1;
     $product->in_stock = 1;
     $product->quantity = (double) $fields['quantity'];
     $product->name = pSQL($fields['name']);
     $product->rewrite = pSQL(preg_replace("/[^-0-9a-zA-Z]+/", "", str_replace(' ', '-', trim($fields['name']))));
     $product->description = pSQL($fields['description'], true);
     $product->active = 1;
     if ($product->add()) {
         $product->updateCategories($id_category);
         return (int) $product->id;
     } else {
         print_r($product->_errors);
     }
 }
开发者ID:yiuked,项目名称:tmcart,代码行数:23,代码来源:Import.php

示例7: _saveProtectionItems

    /**
     * Save in special database each buyer protection product for a certificate,
     * Each Trusted Shops particular characteristics is saved.
     * Create a product in Prestashop database to allow added each of them in cart.
     *
     * @param array|stdClass $protection_items
     * @param string $ts_id
     */
    private function _saveProtectionItems($protection_items, $ts_id)
    {
        $sql = '
		DELETE ts, p, pl
		FROM `' . _DB_PREFIX_ . TSBuyerProtection::DB_ITEMS . '` AS ts
		LEFT JOIN `' . _DB_PREFIX_ . 'product` AS p ON ts.`id_product` = p.`id_product`
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` AS pl ON ts.`id_product` = pl.`id_product`
		WHERE ts.`ts_id`="' . $ts_id . '"';
        Db::getInstance()->Execute($sql);
        foreach ($protection_items as $key => $item) {
            //add hidden product
            $product = new Product();
            foreach ($this->available_languages as $iso => $lang) {
                $language = Language::getIdByIso(strtolower($iso));
                if ((int) $language !== 0) {
                    $product->name[$language] = 'TrustedShops guarantee';
                    $product->link_rewrite[$language] = 'trustedshops_guarantee';
                }
            }
            // If the default lang is different than available languages :
            // (Bug occurred otherwise)
            if (!array_key_exists(Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT')), $this->available_languages)) {
                $product->name[(int) Configuration::get('PS_LANG_DEFAULT')] = 'Trustedshops';
                $product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')] = 'trustedshops';
            }
            // Add specifics translations
            $id_lang = Language::getIdByIso('de');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops Käuferschutz';
            }
            $id_lang = Language::getIdByIso('en');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops buyer protection';
            }
            $id_lang = Language::getIdByIso('fr');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops protection acheteur';
            }
            $product->quantity = 1000;
            $product->price = ToolsCore::convertPrice($item->grossFee, Currency::getIdByIsoCode($item->currency));
            $product->id_category_default = TSBuyerProtection::$CAT_ID;
            $product->active = true;
            $product->id_tax = 0;
            $product->add();
            if ($product->id) {
                $sql = '
				INSERT INTO `' . _DB_PREFIX_ . TSBuyerProtection::DB_ITEMS . '` (
				`creation_date`,
				`id_product`,
				`ts_id`,
				`id`,
				`currency`,
				`gross_fee`,
				`net_fee`,
				`protected_amount_decimal`,
				`protection_duration_int`,
				`ts_product_id`
				) VALUES (
				"' . pSQL($item->creationDate) . '",
				"' . pSQL($product->id) . '",
				"' . pSQL($ts_id) . '",
				"' . (int) $item->id . '",
				"' . pSQL($item->currency) . '",
				"' . pSQL($item->grossFee) . '",
				"' . pSQL($item->netFee) . '",
				"' . pSQL($item->protectedAmountDecimal) . '",
				"' . pSQL($item->protectionDurationInt) . '",
				"' . pSQL($item->tsProductID) . '"
				)';
                Db::getInstance()->Execute($sql);
            } else {
                $this->errors['products'] = $this->l('Product wasn\'t saved.');
            }
        }
    }
开发者ID:ricardo-rdfs,项目名称:Portal-BIP,代码行数:83,代码来源:TSBuyerProtection.php

示例8: insertProductForPrestashop

 /**
  * Inserts a product in Prestashop.
  * 
  * @param array $product_attributes
  * @param string $url
  * @param array $triple_cod_col_siz
  * @param array $array_combinations
  * @param integer $language
  * @return array 
  * @see $this->setSupplierForProduct
  * @see $this->setArrayElementForLinkRewrite
  * @see $this->setManufacturerForProduct
  * @see $this->addFeaturesForProducts
  * @see $this->setCategoriesForProduct
  * @see $this->addCombinationsForPrestashop
  * @see PrestashopImageHandler insertImageInPrestashop()
  *
  */
 public function insertProductForPrestashop($product_attributes = array(), $url_photo, $triple_cod_col_siz, $array_combinations, $language = 1)
 {
     $product = new Product();
     //$language is 1 because 1 -> italian
     $string_name_product = trim($product_attributes["Nome"]);
     $product->name = $this->setArrayElementForLinkRewrite($string_name_product, true, $language);
     $product->meta_keywords = $string_name_product;
     $product->link_rewrite = $this->setArrayElementForLinkRewrite($string_name_product, false, $language);
     $product->id_category_default = 2;
     //Home
     $product->redirect_type = '404';
     $product->price = (double) $product_attributes["Prezzo"];
     $product->active = (int) $product_attributes["Attivo"];
     $product->minimal_quantity = (int) $product_attributes["Qta_min"];
     $product->show_price = 1;
     $product->reference = $product_attributes["Reference"];
     $product->id_tax_rules_group = 0;
     //$product->id_supplier = $this->setSupplierForProduct(trim($product_attributes["Supplier"]));
     $product->id_supplier = 0;
     $product->id_manufacturer = $this->setManufacturerForProduct(trim($product_attributes["Manufacture"]));
     $array_features = $product_attributes["Feature"];
     $product->width = (double) $array_features["Larghezza"];
     $product->height = (double) $array_features["Altezza"];
     $product->add();
     $this->addFeaturesForProducts($product->id, $language, $array_features);
     $categories = trim($product_attributes["Categorie"]);
     $tmp = explode(",", $categories);
     $griffe = $tmp[1];
     $modello = $tmp[0];
     $id_parent = null;
     $id_child = null;
     $id_parent = $this->setCategoriesForProduct(trim($griffe), 2, $language);
     $id_child = $this->setCategoriesForProduct(trim($modello), $id_parent, $language);
     $cat_pos_tmp = array();
     array_push($cat_pos_tmp, $id_child);
     array_push($cat_pos_tmp, $id_parent);
     $product->addToCategories($cat_pos_tmp);
     if ($product->active != 0) {
         $activeCategory = new Category($id_parent);
         $activeCategory->active = 1;
         $activeCategory->update();
         $activeCategory = new Category($id_child);
         $activeCategory->active = 1;
         $activeCategory->update();
     }
     $tmp = explode(".jpg,", trim($product_attributes["URL"]));
     $size_url = sizeof($tmp);
     $array_id_image = array();
     for ($i = 0; $i < $size_url; $i++) {
         if (!empty($tmp[$i])) {
             $url = trim($url_photo);
             $image = new PrestashopImageHandler();
             $id_image = $image->insertImageInPrestashop($product->id, $url, $tmp[$i]);
             array_push($array_id_image, $id_image);
         }
     }
     $this->addCombinationsForPrestashop($product->id, $url_photo, $triple_cod_col_siz, $array_combinations, $language);
     $return = array();
     $array_images_combinations_of_the_product = $product->getImages($language);
     array_push($return, $product->id);
     $element = array();
     foreach ($array_images_combinations_of_the_product as $array_combo_image) {
         $name_of_the_image = $array_combo_image['legend'];
         $id_image_of_the_product = $array_combo_image['id_image'];
         array_push($element, $id_image_of_the_product . ";" . $name_of_the_image);
     }
     array_push($return, $element);
     return $return;
 }
开发者ID:valucifer,项目名称:S-SoldP-Pal,代码行数:87,代码来源:PrestashopProducts.php

示例9: _addTaxesAndDutiesProduct

 private function _addTaxesAndDutiesProduct()
 {
     $product = new Product();
     $product->id_shop_default = (int) $this->context->shop->id;
     $product->id_manufacturer = 0;
     $product->id_supplier = 0;
     $product->reference = 'TAXDUTIES';
     $product->supplier_reference = '';
     $product->location = '';
     $product->width = 0;
     $product->height = 0;
     $product->depth = 0;
     $product->weight = 0;
     $product->quantity_discount = false;
     $product->ean13 = '';
     $product->upc = '';
     $product->is_virtual = false;
     $product->id_category_default = 2;
     $product->id_tax_rules_group = 1;
     $product->on_sale = 0;
     $product->online_only = 0;
     $product->ecotax = 0;
     $product->minimal_quantity = 1;
     $product->price = 0;
     $product->wholesale_price = 0;
     $product->unity = '';
     $product->unit_price_ratio = 1;
     $product->additional_shipping_cost = 0;
     $product->customizable = 0;
     $product->active = 1;
     $product->condition = 'new';
     $product->show_price = false;
     $product->visibility = 'none';
     $product->date_add = date('Y-m-d H:i:s');
     $product->date_upd = date('Y-m-d H:i:s');
     $product->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $this->l('Taxes and Duties');
     $product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')] = 'taxes-and-duties';
     $result = $product->add();
     /* Allowed to be ordered even if stock = 0 */
     if ($result) {
         StockAvailable::setProductOutOfStock((int) $product->id, 1);
         StockAvailable::setProductDependsOnStock((int) $product->id, false);
         StockAvailable::setQuantity((int) $product->id, 0, 1000000);
     }
     return $result ? (int) $product->id : 0;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:46,代码来源:gointerpay.php

示例10: _postValidation

 /**
  * @brief Validate Method
  *
  * @return update the module depending on klarna webservices
  */
 private function _postValidation()
 {
     $klarna = new Klarna();
     if ($_POST['klarna_mod'] == 'live') {
         Configuration::updateValue('KLARNA_MOD', Klarna::LIVE);
     } else {
         Configuration::updateValue('KLARNA_MOD', Klarna::BETA);
     }
     if (isset($_POST['klarna_active_invoice']) && $_POST['klarna_active_invoice']) {
         Configuration::updateValue('KLARNA_ACTIVE_INVOICE', true);
     } else {
         Configuration::deleteByName('KLARNA_ACTIVE_INVOICE');
     }
     if (isset($_POST['klarna_active_partpayment']) && $_POST['klarna_active_partpayment']) {
         Configuration::updateValue('KLARNA_ACTIVE_PARTPAYMENT', true);
     } else {
         Configuration::deleteByName('KLARNA_ACTIVE_PARTPAYMENT');
     }
     if (isset($_POST['klarna_email']) && $_POST['klarna_email']) {
         Configuration::updateValue('KLARNA_EMAIL', true);
     } else {
         Configuration::deleteByName('KLARNA_EMAIL');
     }
     foreach ($this->countries as $country) {
         Db::getInstance()->delete(_DB_PREFIX_ . 'klarna_payment_pclasses', 'country = "' . (int) $country['code'] . '"');
         Configuration::updateValue('KLARNA_STORE_ID_' . $country['name'], null);
         Configuration::updateValue('KLARNA_SECRET_' . $country['name'], null);
     }
     foreach ($this->countries as $key => $country) {
         if (isset($_POST['activate' . $country['name']])) {
             $storeId = (int) Tools::getValue('klarnaStoreId' . $country['name']);
             $secret = pSQL(Tools::getValue('klarnaSecret' . $country['name']));
             if ($storeId > 0 && $secret == '' || $storeId <= 0 && $secret != '') {
                 $this->_postErrors[] = $this->l('your credentials are incorrect and can\'t be used in ') . $country['name'];
             } elseif ($storeId >= 0 && $secret != '') {
                 $error = false;
                 try {
                     $klarna->config($storeId, Tools::safeOutput($secret), $country['code'], $country['langue'], $country['currency'], Configuration::get('KLARNA_MOD'), 'mysql', $this->_getDb());
                     $PClasses = $klarna->fetchPClasses($country['code']);
                 } catch (Exception $e) {
                     $error = true;
                     $this->_postErrors[] = (int) $e->getCode() . ': ' . Tools::safeOutput($e->getMessage());
                 }
                 if (!$error) {
                     Configuration::updateValue('KLARNA_STORE_ID_' . $country['name'], $storeId);
                     Configuration::updateValue('KLARNA_SECRET_' . $country['name'], $secret);
                     Configuration::updateValue('KLARNA_INVOICE_FEE_' . $country['name'], (double) Tools::getValue('klarnaInvoiceFee' . $country['name']));
                     Configuration::updateValue('KLARNA_MINIMUM_VALUE_' . $country['name'], (double) Tools::getValue('klarnaMinimumValue' . $country['name']));
                     Configuration::updateValue('KLARNA_MAXIMUM_VALUE_' . $country['name'], $_POST['klarnaMaximumValue' . $country['name']] != 0 ? (double) Tools::getValue('klarnaMaximumValue' . $country['name']) : 99999);
                     $id_product = Db::getInstance()->getValue('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product_lang` WHERE `name` = \'invoiceFee' . $country['name'] . '\'');
                     $taxeRules = TaxRulesGroup::getAssociatedTaxRatesByIdCountry(Country::getByIso($key));
                     $maxiPrice = 0;
                     $idTaxe = 0;
                     foreach ($taxeRules as $key => $val) {
                         if ((int) $val > $maxiPrice) {
                             $maxiPrice = (int) $val;
                             $idTaxe = $key;
                         }
                     }
                     if ($id_product != null) {
                         $productInvoicefee = new Product((int) $id_product);
                         $productInvoicefee->price = (double) Tools::getValue('klarnaInvoiceFee' . $country['name']);
                         if (_PS_VERSION_ >= 1.5) {
                             StockAvailable::setProductOutOfStock((int) $productInvoicefee->id, true, null, 0);
                         }
                         if ($idTaxe != 0) {
                             $productInvoicefee->id_tax_rules_group = (int) $idTaxe;
                         }
                         $productInvoicefee->update();
                     } else {
                         $productInvoicefee = new Product();
                         $productInvoicefee->out_of_stock = 1;
                         $productInvoicefee->available_for_order = true;
                         $productInvoicefee->id_category_default = 2;
                         if ($idTaxe != 0) {
                             $productInvoicefee->id_tax_rules_group = (int) $idTaxe;
                         }
                         $languages = Language::getLanguages(false);
                         foreach ($languages as $language) {
                             $productInvoicefee->name[$language['id_lang']] = 'invoiceFee' . $country['name'];
                             $productInvoicefee->link_rewrite[$language['id_lang']] = 'invoiceFee' . $country['name'];
                         }
                         $productInvoicefee->price = (double) Tools::getValue('klarnaInvoiceFee' . $country['name']);
                         if (_PS_VERSION_ >= 1.5) {
                             $productInvoicefee->active = false;
                         }
                         $productInvoicefee->add();
                         if (_PS_VERSION_ >= 1.5) {
                             StockAvailable::setProductOutOfStock((int) $productInvoicefee->id, true, null, 0);
                         }
                     }
                     Configuration::updateValue('KLARNA_INV_FEE_ID_' . $country['name'], $productInvoicefee->id);
                     $this->_postValidations[] = $this->l('Your account has been updated to be used in ') . $country['name'];
                 }
                 $error = false;
//.........这里部分代码省略.........
开发者ID:juniorhq88,项目名称:PrestaShop-modules,代码行数:101,代码来源:klarnaprestashop.php

示例11: saveProtectionItems

    /**
     * Save in special database each buyer protection product for a certificate,
     * Each Trusted Shops particular characteristics is saved.
     * Create a product in Prestashop database to allow added each of them in cart.
     *
     * @param array|stdClass $protection_items
     * @param string $ts_id
     */
    private function saveProtectionItems($protection_items, $ts_id)
    {
        $query = '
		DELETE ts, p, pl
		FROM `' . _DB_PREFIX_ . TSCommon::DB_ITEMS . '` AS ts
		LEFT JOIN `' . _DB_PREFIX_ . 'product` AS p ON ts.`id_product` = p.`id_product`
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` AS pl ON ts.`id_product` = pl.`id_product`
		WHERE ts.`ts_id`="' . pSQL($ts_id) . '"';
        Db::getInstance()->Execute($query);
        foreach ($protection_items as $item) {
            //add hidden product
            $product = new Product();
            foreach (array_keys(self::$available_languages) as $iso) {
                $language = Language::getIdByIso(Tools::strtolower($iso));
                if ((int) $language !== 0) {
                    $product->name[$language] = 'TrustedShops guarantee';
                    $product->link_rewrite[$language] = 'trustedshops_guarantee';
                }
            }
            // If the default lang is different than available languages :
            // (Bug occurred otherwise)
            if (!array_key_exists(Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT')), self::$available_languages)) {
                $product->name[(int) Configuration::get('PS_LANG_DEFAULT')] = 'Trustedshops';
                $product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')] = 'trustedshops';
            }
            // Add specifics translations
            $id_lang = Language::getIdByIso('de');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops Käuferschutz';
            }
            $id_lang = Language::getIdByIso('en');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops buyer protection';
            }
            $id_lang = Language::getIdByIso('fr');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops protection acheteur';
            }
            $id_lang = Language::getIdByIso('it');
            if ((int) $id_lang > 0) {
                $product->name[$id_lang] = 'Trusted Shops protezione acquirenti';
            }
            $product->quantity = 1000;
            $product->price = Tools::convertPrice($item->grossFee, Currency::getIdByIsoCode($item->currency));
            $product->id_category_default = TSCommon::$cat_id;
            $product->active = true;
            $product->visibility = 'none';
            $product->id_tax_rules_group = 0;
            $product->add();
            $product->addToCategories(TSCommon::$cat_id);
            if ($product->id) {
                $query = '
				INSERT INTO `' . _DB_PREFIX_ . TSCommon::DB_ITEMS . '`
				(`creation_date`, `id_product`, `ts_id`, `id`, `currency`, `gross_fee`, `net_fee`,
				`protected_amount_decimal`, `protection_duration_int`, `ts_product_id`)
				VALUES ("' . pSQL($item->creationDate) . '", "' . pSQL($product->id) . '", "' . pSQL($ts_id) . '",
				"' . (int) $item->id . '", "' . pSQL($item->currency) . '", "' . pSQL($item->grossFee) . '",
				"' . pSQL($item->netFee) . '", "' . pSQL($item->protectedAmountDecimal) . '",
				"' . pSQL($item->protectionDurationInt) . '", "' . pSQL($item->tsProductID) . '")';
                Db::getInstance()->Execute($query);
                if (class_exists('StockAvailable')) {
                    $id_stock_available = Db::getInstance()->getValue('
						SELECT s.`id_stock_available` FROM `' . _DB_PREFIX_ . 'stock_available` s
						WHERE s.`id_product` = ' . (int) $product->id);
                    $stock = new StockAvailable($id_stock_available);
                    $stock->id_product = $product->id;
                    $stock->out_of_stock = 1;
                    $stock->id_product_attribute = 0;
                    $stock->quantity = 1000000;
                    $stock->id_shop = Context::getContext()->shop->id;
                    if ($stock->id) {
                        $stock->update();
                    } else {
                        $stock->add();
                    }
                }
            } else {
                $this->errors['products'] = $this->l('Product wasn\'t saved.');
            }
        }
    }
开发者ID:alexsimple,项目名称:trustedshops,代码行数:89,代码来源:TSCommon.php

示例12: addDotpayVirtualProduct

 /**
  * Added Dotpay virtual product for extracharge option
  * @return bool
  */
 private function addDotpayVirtualProduct()
 {
     if (Validate::isInt($this->config->getDotpayExchVPid()) and Validate::isLoadedObject($product = new Product($this->config->getDotpayExchVPid())) and Validate::isInt($product->id)) {
         return true;
     }
     $product = new Product();
     $product->name = array((int) Configuration::get('PS_LANG_DEFAULT') => 'Online payment');
     $product->link_rewrite = array((int) Configuration::get('PS_LANG_DEFAULT') => 'online-payment');
     $product->visibility = 'none';
     $product->reference = 'DOTPAYFEE';
     $product->price = 0.0;
     $product->is_virtual = 1;
     $product->online_only = 1;
     $product->redirect_type = '404';
     $product->quantity = 9999999;
     $product->id_tax_rules_group = 0;
     $product->active = 1;
     $product->meta_keywords = 'payment';
     $product->id_category = 1;
     $product->id_category_default = 1;
     if (!$product->add()) {
         return false;
     }
     $product->addToCategories(array(1));
     StockAvailable::setQuantity($product->id, NULL, $product->quantity);
     $this->config->setDotpayExchVPid($product->id);
     return true;
 }
开发者ID:dotpay,项目名称:dotpay,代码行数:32,代码来源:dotpay.php

示例13: addPaymentMethodCostVirtualItemToCart

 public function addPaymentMethodCostVirtualItemToCart($cart)
 {
     $config = $this->loadConfiguration();
     $langId = Context::getContext()->language->id;
     $product = new Product();
     $product->is_virtual = true;
     $product->indexed = false;
     $product->active = true;
     $product->price = $this->calculatePaymentCost($cart);
     $product->visibility = 'none';
     $product->name = array($langId => $config['PAYMENT_METHOD_COST_TITLE']);
     $product->link_rewrite = array($langId => uniqid());
     $product->id_tax_rules_group = 0;
     $product->add();
     StockAvailable::setQuantity($product->id, null, 1);
     $cart->updateQty(1, $product->id, null, false);
     $cart->update();
     $cart->getPackageList(true);
     return $product->id;
 }
开发者ID:invipay,项目名称:invipay-prestashop,代码行数:20,代码来源:Helper.php

示例14: runUpgrades

 /**
  * Launch upgrade process
  */
 public function runUpgrades($install = false)
 {
     if (!Configuration::get('SOCOLISSIMO_CARRIER_ID_SELLER')) {
         //add carrier for seller cost
         $this->createSoColissimoCarrierSeller($this->_config);
     }
     if (!Configuration::get('SOCOLISSIMO_PRODUCT_ID_BELG')) {
         //add hidden product overcots belgium
         $product = new Product();
         $languages = Language::getLanguages(true);
         foreach ($languages as $language) {
             if ($language['iso_code'] == 'fr') {
                 $product->name[$language['id_lang']] = 'Surcoût belgique';
                 $product->link_rewrite[$language['id_lang']] = 'belgium';
             }
             if ($language['iso_code'] == 'en') {
                 $product->name[$language['id_lang']] = 'Overcost Belgium';
                 $product->link_rewrite[$language['id_lang']] = 'belgium';
             }
         }
         $product->quantity = 10;
         $product->price = 0;
         $product->id_category_default = intval(Configuration::get('SOCOLISSIMO_CAT_ID'));
         $product->active = true;
         $product->id_tax = 0;
         $product->add();
         Configuration::updateValue('SOCOLISSIMO_PRODUCT_ID_BELG', intval($product->id));
     }
     if (Configuration::get('SOCOLISSIMO_VERSION') != $this->version) {
         foreach (array('1.7', '1.9') as $version) {
             $file = dirname(__FILE__) . '/upgrade/install-' . $version . '.php';
             if (Configuration::get('SOCOLISSIMO_VERSION') < $version && file_exists($file)) {
                 include_once $file;
                 call_user_func('upgrade_module_' . str_replace('.', '_', $version), $this, $install);
             }
         }
     }
 }
开发者ID:quadra-informatique,项目名称:SoColissimo-1.x-PrestaShop,代码行数:41,代码来源:socolissimo.php

示例15: postProcess

    /**
     * postProcess handle every checks before saving products information
     *
     * @param mixed $token
     * @return void
     */
    public function postProcess($token = null)
    {
        global $cookie, $currentIndex;
        // Add a new product
        if (Tools::isSubmit('submitAddproduct') || Tools::isSubmit('submitAddproductAndStay') || Tools::isSubmit('submitAddProductAndPreview')) {
            if (Tools::getValue('id_product') && $this->tabAccess['edit'] === '1' || $this->tabAccess['add'] === '1' && !Tools::isSubmit('id_product')) {
                $this->submitAddproduct($token);
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to add here.');
            }
        }
        /* Delete a product in the download folder */
        if (Tools::getValue('deleteVirtualProduct')) {
            if ($this->tabAccess['delete'] === '1') {
                $this->deleteVirtualProduct();
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
            }
        } elseif (Tools::isSubmit('submitAddAttachments')) {
            if ($this->tabAccess['add'] === '1') {
                $languages = Language::getLanguages(false);
                $is_attachment_name_valid = false;
                foreach ($languages as $language) {
                    $attachment_name_lang = Tools::getValue('attachment_name_' . (int) $language['id_lang']);
                    if (strlen($attachment_name_lang) > 0) {
                        $is_attachment_name_valid = true;
                    }
                    if (!Validate::isGenericName(Tools::getValue('attachment_name_' . (int) $language['id_lang']))) {
                        $this->_errors[] = Tools::displayError('Invalid Name');
                    } elseif (Tools::strlen(Tools::getValue('attachment_name_' . (int) $language['id_lang'])) > 32) {
                        $this->_errors[] = Tools::displayError('Name is too long');
                    }
                    if (!Validate::isCleanHtml(Tools::getValue('attachment_description_' . (int) $language['id_lang']))) {
                        $this->_errors[] = Tools::displayError('Invalid description');
                    }
                }
                if (!$is_attachment_name_valid) {
                    $this->_errors[] = Tools::displayError('Attachment Name Required');
                }
                if (empty($this->_errors)) {
                    if (isset($_FILES['attachment_file']) && is_uploaded_file($_FILES['attachment_file']['tmp_name'])) {
                        if ($_FILES['attachment_file']['size'] > Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024) {
                            $this->_errors[] = $this->l('File too large, maximum size allowed:') . ' ' . Configuration::get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 . ' ' . $this->l('kb') . '. ' . $this->l('File size you\'re trying to upload is:') . number_format($_FILES['attachment_file']['size'] / 1024, 2, '.', '') . $this->l('kb');
                        } else {
                            do {
                                $uniqid = sha1(microtime());
                            } while (file_exists(_PS_DOWNLOAD_DIR_ . $uniqid));
                            if (!copy($_FILES['attachment_file']['tmp_name'], _PS_DOWNLOAD_DIR_ . $uniqid)) {
                                $this->_errors[] = $this->l('File copy failed');
                            }
                            @unlink($_FILES['attachment_file']['tmp_name']);
                        }
                    } elseif ((int) $_FILES['attachment_file']['error'] === 1) {
                        $max_upload = (int) ini_get('upload_max_filesize');
                        $max_post = (int) ini_get('post_max_size');
                        $upload_mb = min($max_upload, $max_post);
                        $this->_errors[] = $this->l('the File') . ' <b>' . $_FILES['attachment_file']['name'] . '</b> ' . $this->l('exceeds the size allowed by the server, this limit is set to') . ' <b>' . $upload_mb . $this->l('Mb') . '</b>';
                    }
                    if (empty($this->_errors) && isset($uniqid)) {
                        $attachment = new Attachment();
                        foreach ($languages as $language) {
                            if (isset($_POST['attachment_name_' . (int) $language['id_lang']])) {
                                $attachment->name[(int) $language['id_lang']] = pSQL($_POST['attachment_name_' . (int) $language['id_lang']]);
                            }
                            if (isset($_POST['attachment_description_' . (int) $language['id_lang']])) {
                                $attachment->description[(int) $language['id_lang']] = pSQL($_POST['attachment_description_' . (int) $language['id_lang']]);
                            }
                        }
                        $attachment->file = $uniqid;
                        $attachment->mime = $_FILES['attachment_file']['type'];
                        $attachment->file_name = pSQL($_FILES['attachment_file']['name']);
                        if (empty($attachment->mime) or Tools::strlen($attachment->mime) > 128) {
                            $this->_errors[] = Tools::displayError('Invalid file extension');
                        }
                        if (!Validate::isGenericName($attachment->file_name)) {
                            $this->_errors[] = Tools::displayError('Invalid file name');
                        }
                        if (Tools::strlen($attachment->file_name) > 128) {
                            $this->_errors[] = Tools::displayError('File name too long');
                        }
                        if (!sizeof($this->_errors)) {
                            $attachment->add();
                            Tools::redirectAdmin($currentIndex . '&id_product=' . (int) Tools::getValue($this->identifier) . '&id_category=' . (int) Tools::getValue('id_category') . '&addproduct&conf=4&tabs=6&token=' . ($token ? $token : $this->token));
                        } else {
                            $this->_errors[] = Tools::displayError('Invalid file');
                        }
                    }
                }
            } else {
                $this->_errors[] = Tools::displayError('You do not have permission to add here.');
            }
        } elseif (Tools::isSubmit('submitAttachments')) {
            if ($this->tabAccess['edit'] === '1') {
                if ($id = (int) Tools::getValue($this->identifier)) {
//.........这里部分代码省略.........
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:101,代码来源:AdminProducts.php


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