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


PHP StockAvailable::setProductOutOfStock方法代码示例

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


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

示例1: add

 public function add($autodate = true, $null_values = false)
 {
     if (!parent::add($autodate, $null_values)) {
         return false;
     }
     $product = new Product((int) $this->id_product);
     if ($product->getType() == Product::PTYPE_VIRTUAL) {
         StockAvailable::setProductOutOfStock((int) $this->id_product, 1, null, (int) $this->id);
     } else {
         StockAvailable::setProductOutOfStock((int) $this->id_product, StockAvailable::outOfStock((int) $this->id_product), null, $this->id);
     }
     SpecificPriceRule::applyAllRules(array((int) $this->id_product));
     return true;
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:14,代码来源:Combination.php

示例2: ajaxProcessProductQuantity

 public function ajaxProcessProductQuantity()
 {
     if (!Tools::getValue('actionQty')) {
         return Tools::jsonEncode(array('error' => $this->l('Undefined action')));
     }
     $product = new Product((int) Tools::getValue('id_product'), true);
     switch (Tools::getValue('actionQty')) {
         case 'depends_on_stock':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) Tools::getValue('value') != 0 && (int) Tools::getValue('value') != 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             if (!$product->advanced_stock_management && (int) Tools::getValue('value') == 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
             }
             if ($product->advanced_stock_management && Pack::isPack($product->id)) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if the product is a pack.'))));
             }
             StockAvailable::setProductDependsOnStock($product->id, (int) Tools::getValue('value'));
             break;
         case 'out_of_stock':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if (!in_array((int) Tools::getValue('value'), array(0, 1, 2))) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             StockAvailable::setProductOutOfStock($product->id, (int) Tools::getValue('value'));
             break;
         case 'set_qty':
             if (Tools::getValue('value') === false || !is_numeric(trim(Tools::getValue('value')))) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if (Tools::getValue('id_product_attribute') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined id product attribute'))));
             }
             StockAvailable::setQuantity($product->id, (int) Tools::getValue('id_product_attribute'), (int) Tools::getValue('value'));
             Hook::exec('actionProductUpdate', array('product' => $this->object));
             // Catch potential echo from modules
             $error = ob_get_contents();
             if (!empty($error)) {
                 ob_end_clean();
                 die(Tools::jsonEncode(array('error' => $error)));
             }
             break;
         case 'advanced_stock_management':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) Tools::getValue('value') != 1 && (int) Tools::getValue('value') != 0) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) Tools::getValue('value') == 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
             }
             if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && Pack::isPack($product->id)) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if the product is a pack.'))));
             }
             $product->setAdvancedStockManagement((int) Tools::getValue('value'));
             if (StockAvailable::dependsOnStock($product->id) == 1 && (int) Tools::getValue('value') == 0) {
                 StockAvailable::setProductDependsOnStock($product->id, 0);
             }
             break;
     }
     die(Tools::jsonEncode(array('error' => false)));
 }
开发者ID:,项目名称:,代码行数:68,代码来源:

示例3: productImportOne


//.........这里部分代码省略.........
                $product->quantity = 0;
            }
            // If match ref is specified && ref product && ref product already in base, trying to update
            if ($match_ref && $product->reference && $product->existsRefInDatabase($product->reference)) {
                $datas = Db::getInstance()->getRow('
					SELECT product_shop.`date_add`, p.`id_product`
					FROM `' . _DB_PREFIX_ . 'product` p
					' . Shop::addSqlAssociation('product', 'p') . '
					WHERE p.`reference` = "' . pSQL($product->reference) . '"
				', false);
                $product->id = (int) $datas['id_product'];
                $product->date_add = pSQL($datas['date_add']);
                $res = $validateOnly || $product->update();
            } elseif ($productExistsInDatabase) {
                $datas = Db::getInstance()->getRow('
					SELECT product_shop.`date_add`
					FROM `' . _DB_PREFIX_ . 'product` p
					' . Shop::addSqlAssociation('product', 'p') . '
					WHERE p.`id_product` = ' . (int) $product->id, false);
                $product->date_add = pSQL($datas['date_add']);
                $res = $validateOnly || $product->update();
            }
            // If no id_product or update failed
            $product->force_id = (bool) $force_ids;
            if (!$res) {
                if (isset($product->date_add) && $product->date_add != '') {
                    $res = $validateOnly || $product->add(false);
                } else {
                    $res = $validateOnly || $product->add();
                }
            }
            if (!$validateOnly) {
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    StockAvailable::setProductOutOfStock((int) $product->id, 1);
                } else {
                    StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock);
                }
                if ($product_download_id = ProductDownload::getIdFromIdProduct((int) $product->id)) {
                    $product_download = new ProductDownload($product_download_id);
                    $product_download->delete(true);
                }
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    $product_download = new ProductDownload();
                    $product_download->filename = ProductDownload::getNewFilename();
                    Tools::copy($info['file_url'], _PS_DOWNLOAD_DIR_ . $product_download->filename);
                    $product_download->id_product = (int) $product->id;
                    $product_download->nb_downloadable = (int) $info['nb_downloadable'];
                    $product_download->date_expiration = $info['date_expiration'];
                    $product_download->nb_days_accessible = (int) $info['nb_days_accessible'];
                    $product_download->display_filename = basename($info['file_url']);
                    $product_download->add();
                }
            }
        }
        $shops = array();
        $product_shop = explode($this->multiple_value_separator, $product->shop);
        foreach ($product_shop as $shop) {
            if (empty($shop)) {
                continue;
            }
            $shop = trim($shop);
            if (!empty($shop) && !is_numeric($shop)) {
                $shop = Shop::getIdByName($shop);
            }
            if (in_array($shop, $shop_ids)) {
                $shops[] = $shop;
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php

示例4: ajaxProcessProductQuantity

 public function ajaxProcessProductQuantity()
 {
     if ($this->tabAccess['edit'] === '0') {
         return die(Tools::jsonEncode(array('error' => $this->l('You do not have the right permission'))));
     }
     if (!Tools::getValue('actionQty')) {
         return Tools::jsonEncode(array('error' => $this->l('Undefined action')));
     }
     $product = new Product((int) Tools::getValue('id_product'), true);
     switch (Tools::getValue('actionQty')) {
         case 'depends_on_stock':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) Tools::getValue('value') != 0 && (int) Tools::getValue('value') != 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             if (!$product->advanced_stock_management && (int) Tools::getValue('value') == 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
             }
             if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) Tools::getValue('value') == 1 && (Pack::isPack($product->id) && !Pack::allUsesAdvancedStockManagement($product->id) && ($product->pack_stock_type == 2 || $product->pack_stock_type == 1 || $product->pack_stock_type == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 1 || Configuration::get('PS_PACK_STOCK_TYPE') == 2)))) {
                 die(Tools::jsonEncode(array('error' => $this->l('You cannot use advanced stock management for this pack because') . '<br />' . $this->l('- advanced stock management is not enabled for these products') . '<br />' . $this->l('- you have chosen to decrement products quantities.'))));
             }
             StockAvailable::setProductDependsOnStock($product->id, (int) Tools::getValue('value'));
             break;
         case 'pack_stock_type':
             $value = Tools::getValue('value');
             if ($value === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) $value != 0 && (int) $value != 1 && (int) $value != 2 && (int) $value != 3) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             if ($product->depends_on_stock && !Pack::allUsesAdvancedStockManagement($product->id) && ((int) $value == 1 || (int) $value == 2 || (int) $value == 3 && (Configuration::get('PS_PACK_STOCK_TYPE') == 1 || Configuration::get('PS_PACK_STOCK_TYPE') == 2))) {
                 die(Tools::jsonEncode(array('error' => $this->l('You cannot use this stock management option because:') . '<br />' . $this->l('- advanced stock management is not enabled for these products') . '<br />' . $this->l('- advanced stock management is enabled for the pack'))));
             }
             Product::setPackStockType($product->id, $value);
             break;
         case 'out_of_stock':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if (!in_array((int) Tools::getValue('value'), array(0, 1, 2))) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             StockAvailable::setProductOutOfStock($product->id, (int) Tools::getValue('value'));
             break;
         case 'set_qty':
             if (Tools::getValue('value') === false || !is_numeric(trim(Tools::getValue('value')))) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if (Tools::getValue('id_product_attribute') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined id product attribute'))));
             }
             StockAvailable::setQuantity($product->id, (int) Tools::getValue('id_product_attribute'), (int) Tools::getValue('value'));
             Hook::exec('actionProductUpdate', array('id_product' => (int) $product->id, 'product' => $product));
             // Catch potential echo from modules
             $error = ob_get_contents();
             if (!empty($error)) {
                 ob_end_clean();
                 die(Tools::jsonEncode(array('error' => $error)));
             }
             break;
         case 'advanced_stock_management':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) Tools::getValue('value') != 1 && (int) Tools::getValue('value') != 0) {
                 die(Tools::jsonEncode(array('error' => $this->l('Incorrect value'))));
             }
             if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) Tools::getValue('value') == 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is disabled. '))));
             }
             $product->setAdvancedStockManagement((int) Tools::getValue('value'));
             if (StockAvailable::dependsOnStock($product->id) == 1 && (int) Tools::getValue('value') == 0) {
                 StockAvailable::setProductDependsOnStock($product->id, 0);
             }
             break;
     }
     die(Tools::jsonEncode(array('error' => false)));
 }
开发者ID:Rohit-jn,项目名称:hotelcommerce,代码行数:81,代码来源:AdminProductsController.php

示例5: addCombinationEntity

 /**
  * @param integer $quantity DEPRECATED
  * @param string $supplier_reference DEPRECATED
  */
 public function addCombinationEntity($wholesale_price, $price, $weight, $unit_impact, $ecotax, $quantity, $id_images, $reference, $id_supplier, $ean13, $default, $location = null, $upc = null, $minimal_quantity = 1, array $id_shop_list = array())
 {
     $id_product_attribute = $this->addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location, $upc, $minimal_quantity, $id_shop_list);
     $this->addSupplierReference($id_supplier, $id_product_attribute);
     $result = ObjectModel::updateMultishopTable('Combination', array('wholesale_price' => (double) $wholesale_price), 'a.id_product_attribute = ' . (int) $id_product_attribute);
     if (!$id_product_attribute || !$result) {
         return false;
     }
     if ($this->getType() == Product::PTYPE_VIRTUAL) {
         StockAvailable::setProductOutOfStock((int) $this->id, 1, null, $id_product_attribute);
     } else {
         StockAvailable::setProductOutOfStock((int) $this->id, StockAvailable::outOfStock($this->id), null, $id_product_attribute);
     }
     SpecificPriceRule::applyAllRules(array((int) $this->id));
     return $id_product_attribute;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:20,代码来源:Product.php

示例6: add

 public function add($autodate = true, $null_values = false)
 {
     if (!parent::add($autodate, $null_values)) {
         return false;
     }
     $id_shop_list = Shop::getContextListShopID();
     if ($this->getType() == Product::PTYPE_VIRTUAL) {
         foreach ($id_shop_list as $value) {
             StockAvailable::setProductOutOfStock((int) $this->id, 1, $value);
         }
         if ($this->active && !Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE')) {
             Configuration::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', '1');
         }
     } else {
         foreach ($id_shop_list as $value) {
             StockAvailable::setProductOutOfStock((int) $this->id, 2, $value);
         }
     }
     $this->setGroupReduction();
     Hook::exec('actionProductSave', array('id_product' => (int) $this->id, 'product' => $this));
     return true;
 }
开发者ID:yewed,项目名称:share,代码行数:22,代码来源:Product.php

示例7: add

 public function add($autodate = true, $null_values = false)
 {
     if (!parent::add($autodate, $null_values)) {
         return false;
     }
     if ($this->getType() == Product::PTYPE_VIRTUAL) {
         StockAvailable::setProductOutOfStock((int) $this->id, 1);
     } else {
         StockAvailable::setProductOutOfStock((int) $this->id, 2);
     }
     $this->setGroupReduction();
     Hook::exec('actionProductSave', array('id_product' => $this->id));
     return true;
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:14,代码来源:Product.php

示例8: upsert


//.........这里部分代码省略.........
        $product->deleteFeatures();
        if ($line['author']) {
            $id_feature_value = FeatureValue::addFeatureValueImport(9, $line['author'], null, Configuration::get('PS_LANG_DEFAULT'));
            Product::addFeatureProductImport($product->id, 9, $id_feature_value);
        }

        if ($line['year']) {
            $id_feature_value = FeatureValue::addFeatureValueImport(10, $line['year'], null, Configuration::get('PS_LANG_DEFAULT'));
            Product::addFeatureProductImport($product->id, 10, $id_feature_value);
        }

        if ($line['paperback']) {
            Product::addFeatureProductImport($product->id, 11, 1); //1 - id значения "переплёт" у харакатеристики "Переплёт"
        }

        if ($line['pages']) {
            $id_feature_value = FeatureValue::addFeatureValueImport(12, $line['pages'], null, Configuration::get('PS_LANG_DEFAULT'), true);
            Product::addFeatureProductImport($product->id, 12, $id_feature_value);
        }

        /*
        if ($line['weight']) {
            $id_feature_value = FeatureValue::addFeatureValueImport(4, $line['weight'], null, Configuration::get('PS_LANG_DEFAULT'), true);
            Product::addFeatureProductImport($product->id, 4, $id_feature_value);
        }
        */

        if ($line['isbn']) {
            $id_feature_value = FeatureValue::addFeatureValueImport(13, $line['isbn'], null, Configuration::get('PS_LANG_DEFAULT'), true);
            Product::addFeatureProductImport($product->id, 13, $id_feature_value);
        }

        if ($line['publishing']) {
            $id_feature_value = FeatureValue::addFeatureValueImport(14, $line['publishing'], null, Configuration::get('PS_LANG_DEFAULT'), true);
            Product::addFeatureProductImport($product->id, 14, $id_feature_value);
        }

        $location = WarehouseProductLocation::getIdByProductAndWarehouse($product->id, 0, $line['warehouse']);
        $location = new WarehouseProductLocation($location);
        $location->id_product = $product->id;
        $location->id_product_attribute = 0;
        $location->id_warehouse = $line['warehouse'];
        $location->save();

        $stock = DB::getInstance()->getValue("SELECT `id_stock` FROM `" . _DB_PREFIX_ . "stock` WHERE `id_product` = {$product->id} AND `id_warehouse` = {$line['warehouse']}");
        $stock = new Stock($stock);
        $stock->id_product = $product->id;
        $stock->id_product_attribute = 0;
        $stock->id_warehouse = $line['warehouse'];
        $stock->physical_quantity = $line['count'];
        $stock->usable_quantity = $line['count'];
        $stock->price_te = 0;
        $stock->save();

        $available = DB::getInstance()->getValue("SELECT `id_stock_available` FROM `". _DB_PREFIX_ . "stock_available` WHERE `id_product` = {$product->id} AND `id_shop` = " . Context::getContext()->shop->id);
        $available = new StockAvailable($available);
        $available->id_product = $product->id;
        $available->id_product_attribute = 0;
        //$available->id_shop = Context::getContext()->shop->id;
        $available->quantity = StockManagerFactory::getManager()->getProductPhysicalQuantities($product->id, 0);
        $available->save();

        StockAvailable::setProductDependsOnStock($product->id, true, null);
        StockAvailable::setProductOutOfStock($product->id, 1, null); //allow

        while(strlen($line['reference']) < 9) {
            $line['reference'] = '0' . $line['reference'];
        }

        if (file_exists(_PS_ROOT_DIR_ . '/upload/import/' . $line['reference'] . '.jpg')) {
            $product->deleteImages();

            $image = new Image();
            $image->id_product = $product->id;
            $image->cover = 1;
            $image->position = 0;
            $image->save();

            $name = $image->getPathForCreation();

            copy(_PS_ROOT_DIR_ . '/upload/import/' . $line['reference'] . '.jpg', $name.'.'.$image->image_format);

            $types = ImageType::getImagesTypes('products');
            foreach ($types as $type) {
                ImageManager::resize(_PS_ROOT_DIR_ . '/upload/import/' . $line['reference'] . '.jpg', $name . '-' . $type['name'] . '.' . $image->image_format, $type['width'], $type['height'], $image->image_format);
            }
        }

        /*
        Db::getInstance()->update('stock_available', array(
           'depends_on_stock' => (int)1, //1 - доступное количество на основе ASM. 0 - указывается вручную
            'out_of_stock' => (int)1, //1-allow
        ), 'id_product='.$product->id.'');
         $affrows = Db::getInstance()->Affected_Rows();
         var_dump($affrows);
         */

        //var_dump($product->reference);
        //echo "<br/><br/><br/><br/>";
    }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例9: ajaxProcessProductQuantity

 public function ajaxProcessProductQuantity()
 {
     if (!Tools::getValue('actionQty')) {
         return Tools::jsonEncode(array('error' => $this->l('Undefined action')));
     }
     $product = new Product((int) Tools::getValue('id_product'), true);
     switch (Tools::getValue('actionQty')) {
         case 'depends_on_stock':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) Tools::getValue('value') != 0 && (int) Tools::getValue('value') != 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Uncorrect value'))));
             }
             if (!$product->advanced_stock_management && (int) Tools::getValue('value') == 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is not enabled'))));
             }
             if ($product->advanced_stock_management && Pack::isPack($product->id)) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if the product is a pack'))));
             }
             StockAvailable::setProductDependsOnStock($product->id, (int) Tools::getValue('value'));
             break;
         case 'out_of_stock':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if (!in_array((int) Tools::getValue('value'), array(0, 1, 2))) {
                 die(Tools::jsonEncode(array('error' => $this->l('Uncorrect value'))));
             }
             StockAvailable::setProductOutOfStock($product->id, (int) Tools::getValue('value'));
             break;
         case 'set_qty':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if (Tools::getValue('id_product_attribute') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined id product attribute'))));
             }
             StockAvailable::setQuantity($product->id, (int) Tools::getValue('id_product_attribute'), (int) Tools::getValue('value'));
             break;
         case 'advanced_stock_management':
             if (Tools::getValue('value') === false) {
                 die(Tools::jsonEncode(array('error' => $this->l('Undefined value'))));
             }
             if ((int) Tools::getValue('value') != 1 && (int) Tools::getValue('value') != 0) {
                 die(Tools::jsonEncode(array('error' => $this->l('Uncorrect value'))));
             }
             if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) Tools::getValue('value') == 1) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if advanced stock management is not enabled'))));
             }
             if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && Pack::isPack($product->id)) {
                 die(Tools::jsonEncode(array('error' => $this->l('Not possible if the product is a pack'))));
             }
             $product->setAdvancedStockManagement((int) Tools::getValue('value'));
             if (StockAvailable::dependsOnStock($product->id) == 1 && (int) Tools::getValue('value') == 0) {
                 StockAvailable::setProductDependsOnStock($product->id, 0);
             }
             break;
     }
     die(Tools::jsonEncode(array('error' => false)));
 }
开发者ID:jicheng17,项目名称:pengwine,代码行数:61,代码来源:AdminProductsController.php

示例10: ajaxProcessProductQuantity

function ajaxProcessProductQuantity()
{
    $kvfqwksjfmi = "product";
    if (!Tools::getValue("actionQty")) {
        return Tools::jsonEncode(array("error" => Tools::displayError("Undefined action")));
    }
    ${$kvfqwksjfmi} = new Product((int) Tools::getValue("id_product"));
    switch (Tools::getValue("actionQty")) {
        case "depends_on_stock":
            if (Tools::getValue("value") === false) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Undefined value")));
            }
            if ((int) Tools::getValue("value") != 0 && (int) Tools::getValue("value") != 1) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Uncorrect value")));
            }
            if (!$product->advanced_stock_management && (int) Tools::getValue("value") == 1) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Not possible if advanced stock management is not enabled")));
            }
            if ($product->advanced_stock_management && Pack::isPack($product->id)) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Not possible if the product is a pack")));
            }
            StockAvailable::setProductDependsOnStock($product->id, (int) Tools::getValue("value"));
            break;
        case "out_of_stock":
            if (Tools::getValue("value") === false) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Undefined value")));
            }
            if (!in_array((int) Tools::getValue("value"), array(0, 1, 2))) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Uncorrect value")));
            }
            StockAvailable::setProductOutOfStock($product->id, (int) Tools::getValue("value"));
            break;
        case "set_qty":
            if (Tools::getValue("value") === false) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Undefined value")));
            }
            if (Tools::getValue("id_product_attribute") === false) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Undefined id product attribute")));
            }
            StockAvailable::setQuantity($product->id, (int) Tools::getValue("id_product_attribute"), (int) Tools::getValue("value"));
            break;
        case "advanced_stock_management":
            if (Tools::getValue("value") === false) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Undefined value")));
            }
            if ((int) Tools::getValue("value") != 1 && (int) Tools::getValue("value") != 0) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Uncorrect value")));
            }
            if (!Configuration::get("PS_ADVANCED_STOCK_MANAGEMENT") && (int) Tools::getValue("value") == 1) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Not possible if advanced stock management is not enabled")));
            }
            if (Configuration::get("PS_ADVANCED_STOCK_MANAGEMENT") && Pack::isPack($product->id)) {
                return Tools::jsonEncode(array("error" => Tools::displayError("Not possible if the product is a pack")));
            }
            $product->advanced_stock_management = (int) Tools::getValue("value");
            $product->save();
            if (StockAvailable::dependsOnStock($product->id) == 1 && (int) Tools::getValue("value") == 0) {
                StockAvailable::setProductDependsOnStock($product->id, 0);
            }
            break;
    }
    return Tools::jsonEncode(array("error" => false));
}
开发者ID:evilscripts,项目名称:gy,代码行数:63,代码来源:ajax_products.php

示例11: _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

示例12: _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

示例13: productImport


//.........这里部分代码省略.........
            $lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
            if ($field_error === true && $lang_field_error === true) {
                if ($product->quantity == null) {
                    $product->quantity = 0;
                }
                if (Tools::getValue('match_ref') && $product->reference && $product->existsRefInDatabase($product->reference)) {
                    $datas = Db::getInstance()->getRow('
						SELECT product_shop.`date_add`, p.`id_product`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`reference` = "' . pSQL($product->reference) . '"
					');
                    $product->id = (int) $datas['id_product'];
                    $product->date_add = pSQL($datas['date_add']);
                    $res = $product->update();
                } elseif ($product->id && Product::existsInDatabase((int) $product->id, 'product')) {
                    $datas = Db::getInstance()->getRow('
						SELECT product_shop.`date_add`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`id_product` = ' . (int) $product->id);
                    $product->date_add = pSQL($datas['date_add']);
                    $res = $product->update();
                }
                $product->force_id = (bool) Tools::getValue('forceIDs');
                if (!$res) {
                    if (isset($product->date_add) && $product->date_add != '') {
                        $res = $product->add(false);
                    } else {
                        $res = $product->add();
                    }
                }
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    StockAvailable::setProductOutOfStock((int) $product->id, 1);
                } else {
                    StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock);
                }
            }
            $shops = array();
            $product_shop = explode($this->multiple_value_separator, $product->shop);
            foreach ($product_shop as $shop) {
                if (empty($shop)) {
                    continue;
                }
                $shop = trim($shop);
                if (!empty($shop) && !is_numeric($shop)) {
                    $shop = Shop::getIdByName($shop);
                }
                if (in_array($shop, $shop_ids)) {
                    $shops[] = $shop;
                } else {
                    $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
                }
            }
            if (empty($shops)) {
                $shops = Shop::getContextListShopID();
            }
            if (!$res) {
                $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 {
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:67,代码来源:AdminImportController.php

示例14: attribute

 public function attribute()
 {
     $app = JFactory::getApplication();
     // Don't process if the combination fields have not been submitted
     if (!JeproshopCombinationModelCombination::isFeaturePublished() || !$app->input->get('attribute_combination_list')) {
         return;
     }
     if (Validate::isLoadedObject($product = $this->object)) {
         if ($this->isProductFieldUpdated('attribute_price') && (!Tools::getIsset('attribute_price') || Tools::getIsset('attribute_price') == null)) {
             $this->has_errors = Tools::displayError('The price attribute is required.');
         }
         if (!Tools::getIsset('attribute_combination_list') || Tools::isEmpty(Tools::getValue('attribute_combination_list'))) {
             $this->has_errors = Tools::displayError('You must add at least one attribute.');
         }
         $array_checks = array('reference' => 'isReference', 'supplier_reference' => 'isReference', 'location' => 'isReference', 'ean13' => 'isEan13', 'upc' => 'isUpc', 'wholesale_price' => 'isPrice', 'price' => 'isPrice', 'ecotax' => 'isPrice', 'quantity' => 'isInt', 'weight' => 'isUnsignedFloat', 'unit_price_impact' => 'isPrice', 'default_on' => 'isBool', 'minimal_quantity' => 'isUnsignedInt', 'available_date' => 'isDateFormat');
         foreach ($array_checks as $property => $check) {
             if (Tools::getValue('attribute_' . $property) !== false && !call_user_func(array('Validate', $check), Tools::getValue('attribute_' . $property))) {
                 $this->errors[] = sprintf(Tools::displayError('Field %s is not valid'), $property);
             }
         }
         if (!count($this->errors)) {
             if (!isset($_POST['attribute_wholesale_price'])) {
                 $_POST['attribute_wholesale_price'] = 0;
             }
             if (!isset($_POST['attribute_price_impact'])) {
                 $_POST['attribute_price_impact'] = 0;
             }
             if (!isset($_POST['attribute_weight_impact'])) {
                 $_POST['attribute_weight_impact'] = 0;
             }
             if (!isset($_POST['attribute_ecotax'])) {
                 $_POST['attribute_ecotax'] = 0;
             }
             if (Tools::getValue('attribute_default')) {
                 $product->deleteDefaultAttributes();
             }
             // Change existing one
             if (($id_product_attribute = (int) Tools::getValue('id_product_attribute')) || ($id_product_attribute = $product->productAttributeExists(Tools::getValue('attribute_combination_list'), false, null, true, true))) {
                 if ($this->tabAccess['edit'] === '1') {
                     if ($this->isProductFieldUpdated('available_date_attribute') && (Tools::getValue('available_date_attribute') != '' && !Validate::isDateFormat(Tools::getValue('available_date_attribute')))) {
                         $this->errors[] = Tools::displayError('Invalid date format.');
                     } else {
                         $product->updateAttribute((int) $id_product_attribute, $this->isProductFieldUpdated('attribute_wholesale_price') ? Tools::getValue('attribute_wholesale_price') : null, $this->isProductFieldUpdated('attribute_price_impact') ? Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact') : null, $this->isProductFieldUpdated('attribute_weight_impact') ? Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact') : null, $this->isProductFieldUpdated('attribute_unit_impact') ? Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact') : null, $this->isProductFieldUpdated('attribute_ecotax') ? Tools::getValue('attribute_ecotax') : null, Tools::getValue('id_image_attr'), Tools::getValue('attribute_reference'), Tools::getValue('attribute_ean13'), $this->isProductFieldUpdated('attribute_default') ? Tools::getValue('attribute_default') : null, Tools::getValue('attribute_location'), Tools::getValue('attribute_upc'), $this->isProductFieldUpdated('attribute_minimal_quantity') ? Tools::getValue('attribute_minimal_quantity') : null, $this->isProductFieldUpdated('available_date_attribute') ? Tools::getValue('available_date_attribute') : null, false);
                         StockAvailable::setProductDependsOnStock((int) $product->id, $product->depends_on_stock, null, (int) $id_product_attribute);
                         StockAvailable::setProductOutOfStock((int) $product->id, $product->out_of_stock, null, (int) $id_product_attribute);
                     }
                 } else {
                     $this->errors[] = Tools::displayError('You do not have permission to add this.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     if ($product->productAttributeExists(Tools::getValue('attribute_combination_list'))) {
                         $this->errors[] = Tools::displayError('This combination already exists.');
                     } else {
                         $id_product_attribute = $product->addCombinationEntity(Tools::getValue('attribute_wholesale_price'), Tools::getValue('attribute_price') * Tools::getValue('attribute_price_impact'), Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'), Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'), Tools::getValue('attribute_ecotax'), 0, Tools::getValue('id_image_attr'), Tools::getValue('attribute_reference'), null, Tools::getValue('attribute_ean13'), Tools::getValue('attribute_default'), Tools::getValue('attribute_location'), Tools::getValue('attribute_upc'), Tools::getValue('attribute_minimal_quantity'), array(), Tools::getValue('available_date_attribute'));
                         StockAvailable::setProductDependsOnStock((int) $product->id, $product->depends_on_stock, null, (int) $id_product_attribute);
                         StockAvailable::setProductOutOfStock((int) $product->id, $product->out_of_stock, null, (int) $id_product_attribute);
                     }
                 } else {
                     $this->errors[] = Tools::displayError('You do not have permission to') . '<hr>' . Tools::displayError('edit here.');
                 }
             }
             if (!count($this->errors)) {
                 $combination = new Combination((int) $id_product_attribute);
                 $combination->setAttributes(Tools::getValue('attribute_combination_list'));
                 // images could be deleted before
                 $id_images = Tools::getValue('id_image_attr');
                 if (!empty($id_images)) {
                     $combination->setImages($id_images);
                 }
                 $product->checkDefaultAttributes();
                 if (Tools::getValue('attribute_default')) {
                     Product::updateDefaultAttribute((int) $product->id);
                     if (isset($id_product_attribute)) {
                         $product->cache_default_attribute = (int) $id_product_attribute;
                     }
                     if ($available_date = Tools::getValue('available_date_attribute')) {
                         $product->setAvailableDate($available_date);
                     }
                 }
             }
         }
     }
 }
开发者ID:jeprodev,项目名称:jeproshop,代码行数:84,代码来源:product.php

示例15: importProducts


//.........这里部分代码省略.........
             $product->unity = $line[28];
         }
         if (trim($line[29])) {
             $product->unit_price = $line[29];
         }
         foreach ($languages as $lang) {
             $product->description_short[$lang['id_lang']] = $line[30];
             $product->description[$lang['id_lang']] = $line[31];
         }
         if ($line[32]) {
             foreach ($languages as $lang) {
                 Tag::addTags($lang['id_lang'], $product->id, $line[32]);
             }
         }
         foreach ($languages as $lang) {
             $product->meta_title[$lang['id_lang']] = $line[33];
             $product->meta_keywords[$lang['id_lang']] = $line[34];
             $product->meta_description[$lang['id_lang']] = $line[35];
             $product->link_rewrite[$lang['id_lang']] = $line[36];
             $product->available_now[$lang['id_lang']] = $line[37];
             $product->available_later[$lang['id_lang']] = $line[38];
         }
         $product->available_for_order = $line[39];
         $product->available_date = $line[40];
         $product->date_add = $line[41];
         $product->show_price = $line[42];
         // Features import
         $features = explode(',', $line[45]);
         if ($features) {
             foreach ($features as $feature) {
                 $value = explode(':', $feature);
                 if ($value[0] && $value[1]) {
                     Product::addFeatureProductImport((int) $product->id, (int) $value[0], (int) $value[1]);
                     SpecificPriceRule::applyAllRules(array((int) $product->id));
                 }
             }
         }
         $product->online_only = trim($line[46]) ? $line[46] : 0;
         $product->condition = $line[47];
         $product->customizable = trim($line[48]) ? $line[48] : 0;
         $product->uploadable_files = trim($line[49]) ? $line[49] : 0;
         $product->text_fields = trim($line[50]) ? $line[50] : 0;
         if ($product->getType() == Product::PTYPE_VIRTUAL) {
             StockAvailable::setProductOutOfStock((int) $product->id, 1);
         } else {
             StockAvailable::setProductOutOfStock((int) $product->id, (int) $line[51]);
         }
         $product->id_shop_default = $line[52];
         // add product accessories
         if ($line[56]) {
             $accessories = explode(',', $line[56]);
             foreach ($accessories as $accessory) {
                 $a[]['id'] = $accessory;
             }
             $product->setWsAccessories($a);
         }
         // add product carriers
         if ($line[57]) {
             $carriers = explode(',', $line[57]);
             $product->setCarriers($carriers);
         }
         // add costomisation fields
         if (!Tools::isEmpty($line[58]) && class_exists('CustomizationField')) {
             $customisation_fields_ids = explode(',', $line[58]);
             foreach ($customisation_fields_ids as $customisation_field) {
                 $result = false;
                 $customisation_data = explode(':', $customisation_field);
                 $cf = new CustomizationField();
                 $cf->id_product = $product->id;
                 $cf->type = $customisation_data[1];
                 $cf->required = $customisation_data[2];
                 foreach ($languages as $lang) {
                     $cf->name[$lang['id_lang']] = $customisation_data[3] ? $customisation_data[3] : ' ';
                 }
                 $cf->force_id = 1;
                 if (!$result) {
                     $result = $cf->add();
                 }
             }
         }
         // add attachments
         if ($line[59]) {
             $attachments = explode(',', $line[59]);
             if (isset($attachments) && count($attachments)) {
                 Attachment::attachToProduct($product->id, $attachments);
             }
         }
         if ($line[60]) {
             $product->date_upd = $line[60];
         }
         $product->price = $line[61];
         $product->force_id = 1;
         if (!$res) {
             $res = $product->add();
         }
     }
     $this->closeCsvFile($handle);
     Search::indexation(true);
     return true;
 }
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:AdminSampleDataInstallImport.php


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