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


PHP StockAvailable::outOfStock方法代码示例

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


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

 /**
  * For a given id_product and id_product_attribute sets the quantity available
  *
  * @param int $id_product
  * @param int $id_product_attribute Optional
  * @param int $delta_quantity The delta quantity to update
  * @param int $id_shop Optional
  */
 public static function setQuantity($id_product, $id_product_attribute, $quantity, $id_shop = null)
 {
     if (!Validate::isUnsignedId($id_product)) {
         return false;
     }
     $context = Context::getContext();
     // if there is no $id_shop, gets the context one
     if ($id_shop === null && Shop::getContext() != Shop::CONTEXT_GROUP) {
         $id_shop = (int) $context->shop->id;
     }
     $depends_on_stock = StockAvailable::dependsOnStock($id_product);
     //Try to set available quantity if product does not depend on physical stock
     if (!$depends_on_stock) {
         $id_stock_available = (int) StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop);
         if ($id_stock_available) {
             $stock_available = new StockAvailable($id_stock_available);
             $stock_available->quantity = (int) $quantity;
             $stock_available->update();
         } else {
             $out_of_stock = StockAvailable::outOfStock($id_product, $id_shop);
             $stock_available = new StockAvailable();
             $stock_available->out_of_stock = (int) $out_of_stock;
             $stock_available->id_product = (int) $id_product;
             $stock_available->id_product_attribute = (int) $id_product_attribute;
             $stock_available->quantity = (int) $quantity;
             $shop_group = new ShopGroup((int) Shop::getContextShopGroupID());
             // if quantities are shared between shops of the group
             if ($shop_group->share_stock) {
                 $stock_available->id_shop = 0;
                 $stock_available->id_shop_group = (int) $shop_group->id;
             } else {
                 $stock_available->id_shop = $id_shop;
                 $stock_available->id_shop_group = Shop::getGroupFromShop($id_shop);
             }
             $stock_available->add();
         }
         Hook::exec('actionUpdateQuantity', array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'quantity' => $stock_available->quantity));
     }
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:47,代码来源:StockAvailable.php

示例3: processUpdate

 public function processUpdate()
 {
     $existing_product = $this->object;
     $this->checkProduct();
     if (!empty($this->errors)) {
         $this->display = 'edit';
         return false;
     }
     $id = (int) Tools::getValue('id_' . $this->table);
     /* Update an existing product */
     if (isset($id) && !empty($id)) {
         $object = new $this->className((int) $id);
         $this->object = $object;
         if (Validate::isLoadedObject($object)) {
             $this->_removeTaxFromEcotax();
             $product_type_before = $object->getType();
             $this->copyFromPost($object, $this->table);
             $object->indexed = 0;
             if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
                 $object->setFieldsToUpdate((array) Tools::getValue('multishop_check'));
             }
             // Duplicate combinations if not associated to shop
             if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP && !$object->isAssociatedToShop()) {
                 $is_associated_to_shop = false;
                 $combinations = Product::getProductAttributesIds($object->id);
                 if ($combinations) {
                     foreach ($combinations as $id_combination) {
                         $combination = new Combination((int) $id_combination['id_product_attribute']);
                         $default_combination = new Combination((int) $id_combination['id_product_attribute'], null, (int) $this->object->id_shop_default);
                         $def = ObjectModel::getDefinition($default_combination);
                         foreach ($def['fields'] as $field_name => $row) {
                             $combination->{$field_name} = ObjectModel::formatValue($default_combination->{$field_name}, $def['fields'][$field_name]['type']);
                         }
                         $combination->save();
                     }
                 }
             } else {
                 $is_associated_to_shop = true;
             }
             if ($object->update()) {
                 // If the product doesn't exist in the current shop but exists in another shop
                 if (Shop::getContext() == Shop::CONTEXT_SHOP && !$existing_product->isAssociatedToShop($this->context->shop->id)) {
                     $out_of_stock = StockAvailable::outOfStock($existing_product->id, $existing_product->id_shop_default);
                     $depends_on_stock = StockAvailable::dependsOnStock($existing_product->id, $existing_product->id_shop_default);
                     StockAvailable::setProductOutOfStock((int) $this->object->id, $out_of_stock, $this->context->shop->id);
                     StockAvailable::setProductDependsOnStock((int) $this->object->id, $depends_on_stock, $this->context->shop->id);
                 }
                 PrestaShopLogger::addLog(sprintf($this->l('%s edition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int) $this->object->id, true, (int) $this->context->employee->id);
                 if (in_array($this->context->shop->getContext(), array(Shop::CONTEXT_SHOP, Shop::CONTEXT_ALL))) {
                     if ($this->isTabSubmitted('Shipping')) {
                         $this->addCarriers();
                     }
                     if ($this->isTabSubmitted('Associations')) {
                         $this->updateAccessories($object);
                     }
                     if ($this->isTabSubmitted('Suppliers')) {
                         $this->processSuppliers();
                     }
                     if ($this->isTabSubmitted('Features')) {
                         $this->processFeatures();
                     }
                     if ($this->isTabSubmitted('Combinations')) {
                         $this->processProductAttribute();
                     }
                     if ($this->isTabSubmitted('Prices')) {
                         $this->processPriceAddition();
                         $this->processSpecificPricePriorities();
                     }
                     if ($this->isTabSubmitted('Customization')) {
                         $this->processCustomizationConfiguration();
                     }
                     if ($this->isTabSubmitted('Attachments')) {
                         $this->processAttachments();
                     }
                     $this->updatePackItems($object);
                     // Disallow avanced stock management if the product become a pack
                     if ($product_type_before == Product::PTYPE_SIMPLE && $object->getType() == Product::PTYPE_PACK) {
                         StockAvailable::setProductDependsOnStock((int) $object->id, false);
                     }
                     $this->updateDownloadProduct($object, 1);
                     $this->updateTags(Language::getLanguages(false), $object);
                     if ($this->isProductFieldUpdated('category_box') && !$object->updateCategories(Tools::getValue('categoryBox'))) {
                         $this->errors[] = Tools::displayError('An error occurred while linking the object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('To categories');
                     }
                 }
                 if ($this->isTabSubmitted('Warehouses')) {
                     $this->processWarehouses();
                 }
                 if (empty($this->errors)) {
                     if (in_array($object->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
                         Search::indexation(false, $object->id);
                     }
                     // Save and preview
                     if (Tools::isSubmit('submitAddProductAndPreview')) {
                         $this->redirect_after = $this->getPreviewUrl($object);
                     } else {
                         // Save and stay on same form
                         if ($this->display == 'edit') {
                             $this->confirmations[] = $this->l('Update successful');
                             $this->redirect_after = self::$currentIndex . '&id_product=' . (int) $this->object->id . (Tools::getIsset('id_category') ? '&id_category=' . (int) Tools::getValue('id_category') : '') . '&updateproduct&conf=4&key_tab=' . Tools::safeOutput(Tools::getValue('key_tab')) . '&token=' . $this->token;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: getFilterBlock


//.........这里部分代码省略.........
                case 'condition':
                    $condition_array = array('new' => array('name' => $this->l('New'), 'nbr' => 0), 'used' => array('name' => $this->l('Used'), 'nbr' => 0), 'refurbished' => array('name' => $this->l('Refurbished'), 'nbr' => 0));
                    if (isset($products) && $products) {
                        foreach ($products as $product) {
                            if (isset($selected_filters['condition']) && in_array($product['condition'], $selected_filters['condition'])) {
                                $condition_array[$product['condition']]['checked'] = true;
                            }
                        }
                    }
                    foreach ($condition_array as $key => $condition) {
                        if (isset($selected_filters['condition']) && in_array($key, $selected_filters['condition'])) {
                            $condition_array[$key]['checked'] = true;
                        }
                    }
                    if (isset($products) && $products) {
                        foreach ($products as $product) {
                            if (isset($condition_array[$product['condition']])) {
                                $condition_array[$product['condition']]['nbr']++;
                            }
                        }
                    }
                    $filter_blocks[] = array('type_lite' => 'condition', 'type' => 'condition', 'id_key' => 0, 'name' => $this->l('Condition'), 'values' => $condition_array, 'filter_show_limit' => $filter['filter_show_limit'], 'filter_type' => $filter['filter_type']);
                    break;
                case 'quantity':
                    $quantity_array = array(0 => array('name' => $this->l('Not available'), 'nbr' => 0), 1 => array('name' => $this->l('In stock'), 'nbr' => 0));
                    foreach ($quantity_array as $key => $quantity) {
                        if (isset($selected_filters['quantity']) && in_array($key, $selected_filters['quantity'])) {
                            $quantity_array[$key]['checked'] = true;
                        }
                    }
                    if (isset($products) && $products) {
                        foreach ($products as $product) {
                            //If oosp move all not available quantity to available quantity
                            if ((int) $product['quantity'] > 0 || Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($product['id_product']))) {
                                $quantity_array[1]['nbr']++;
                            } else {
                                $quantity_array[0]['nbr']++;
                            }
                        }
                    }
                    $filter_blocks[] = array('type_lite' => 'quantity', 'type' => 'quantity', 'id_key' => 0, 'name' => $this->l('Availability'), 'values' => $quantity_array, 'filter_show_limit' => $filter['filter_show_limit'], 'filter_type' => $filter['filter_type']);
                    break;
                case 'manufacturer':
                    if (isset($products) && $products) {
                        $manufaturers_array = array();
                        foreach ($products as $manufacturer) {
                            if (!isset($manufaturers_array[$manufacturer['id_manufacturer']])) {
                                $manufaturers_array[$manufacturer['id_manufacturer']] = array('name' => $manufacturer['name'], 'nbr' => $manufacturer['nbr']);
                            }
                            if (isset($selected_filters['manufacturer']) && in_array((int) $manufacturer['id_manufacturer'], $selected_filters['manufacturer'])) {
                                $manufaturers_array[$manufacturer['id_manufacturer']]['checked'] = true;
                            }
                        }
                        $filter_blocks[] = array('type_lite' => 'manufacturer', 'type' => 'manufacturer', 'id_key' => 0, 'name' => $this->l('Manufacturer'), 'values' => $manufaturers_array, 'filter_show_limit' => $filter['filter_show_limit'], 'filter_type' => $filter['filter_type']);
                    }
                    break;
                case 'id_attribute_group':
                    $attributes_array = array();
                    if (isset($products) && $products) {
                        foreach ($products as $attributes) {
                            if (!isset($attributes_array[$attributes['id_attribute_group']])) {
                                $attributes_array[$attributes['id_attribute_group']] = array('type_lite' => 'id_attribute_group', 'type' => 'id_attribute_group', 'id_key' => (int) $attributes['id_attribute_group'], 'name' => $attributes['attribute_group_name'], 'is_color_group' => (bool) $attributes['is_color_group'], 'values' => array(), 'url_name' => $attributes['name_url_name'], 'meta_title' => $attributes['name_meta_title'], 'filter_show_limit' => $filter['filter_show_limit'], 'filter_type' => $filter['filter_type']);
                            }
                            if (!isset($attributes_array[$attributes['id_attribute_group']]['values'][$attributes['id_attribute']])) {
                                $attributes_array[$attributes['id_attribute_group']]['values'][$attributes['id_attribute']] = array('color' => $attributes['color'], 'name' => $attributes['attribute_name'], 'nbr' => (int) $attributes['nbr'], 'url_name' => $attributes['value_url_name'], 'meta_title' => $attributes['value_meta_title']);
                            }
开发者ID:Beattle,项目名称:perrino-shop,代码行数:67,代码来源:blocklayered.php

示例5: loadStockData

    /**
     * Fill the variables used for stock management
     */
    public function loadStockData()
    {
        if (Validate::isLoadedObject($this)) {
            // By default, the product quantity correspond to the available quantity to sell in the current shop
            $this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
            $this->out_of_stock = StockAvailable::outOfStock($this->id);
            $this->depends_on_stock = StockAvailable::dependsOnStock($this->id);
            if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1) {
                $this->advanced_stock_management = Db::getInstance()->getValue('SELECT `advanced_stock_management`
																	FROM ' . _DB_PREFIX_ . 'product_shop
																	WHERE id_product=' . (int) $this->id . Shop::addSqlRestriction());
            }
        }
    }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:17,代码来源:Product.php

示例6: loadStockData

 /**
  * Fill the variables used for stock management
  */
 public function loadStockData()
 {
     if (Validate::isLoadedObject($this)) {
         // By default, the product quantity correspond to the available quantity to sell in the current shop
         $this->quantity = StockAvailable::getQuantityAvailableByProduct($this->id, 0);
         $this->out_of_stock = StockAvailable::outOfStock($this->id);
         $this->depends_on_stock = StockAvailable::dependsOnStock($this->id);
         if (Context::getContext()->shop->getContext() == Shop::CONTEXT_GROUP && Context::getContext()->shop->getContextShopGroup()->share_stock == 1) {
             $this->advanced_stock_management = $this->useAdvancedStockManagement();
         }
     }
 }
开发者ID:yewed,项目名称:share,代码行数:15,代码来源:Product.php

示例7: init

 public function init()
 {
     global $smarty;
     parent::init();
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     $this->getLastId();
     if (isset($_POST["price"])) {
         $_POST["price"] = str_replace(",", ".", $_POST["price"]);
     }
     if (isset($_POST["priceTI"])) {
         $_POST["priceTI"] = str_replace(",", ".", $_POST["priceTI"]);
     }
     if (isset($_POST["wholesale_price"])) {
         $_POST["wholesale_price"] = str_replace(",", ".", $_POST["wholesale_price"]);
     }
     $this->max_image_size = (int) Configuration::get("PS_PRODUCT_PICTURE_MAX_SIZE") / 1000;
     $this->languages = Language::getLanguages(false);
     $this->id_object = intval(Tools::getValue("id_product"));
     // $this->id_language    = intval(Tools::getValue("id_language"));
     $this->id_language = intval(Tools::getValue("id_language"));
     $this->product_menu = intval(Tools::getValue("product_menu"));
     if ($this->product_menu == 0) {
         $this->product_menu = 1;
     }
     if ($this->id_language == 0) {
         $this->id_language = $this->context->language->id;
     }
     $this->object = $this->agileLoadProduct($this->id_object, true);
     if (empty($this->object->city[2])) {
         $this->object->city[2] = $this->object->city[1];
     }
     if (empty($this->object->address2[2])) {
         $this->object->address2[2] = $this->object->address2[1];
     }
     // die('<pre>' . print_r($this->object, true));
     if ($this->id_object == 0) {
         $this->object->out_of_stock = StockAvailable::outOfStock(0);
     }
     $ltyvyfkplnj = "hasOwnerShip";
     ${${"GLOBALS"}["fprzbrt"]} = $this->hasOwnerShip();
     if (!${$ltyvyfkplnj}) {
         $this->errors = Tools::displayError("You do not have permission to access/modify this data.");
     }
     $smarty->assign(array("hasOwnerShip" => ${${"GLOBALS"}["fprzbrt"]}));
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:46,代码来源:sellerproductdetailbase.php

示例8: setQuantity

 public static function setQuantity($id_product, $id_product_attribute, $quantity, $id_shop = null)
 {
     if (!Validate::isUnsignedId($id_product)) {
         return false;
     }
     $context = Context::getContext();
     if ($id_shop === null && Shop::getContext() != Shop::CONTEXT_GROUP) {
         $id_shop = (int) $context->shop->id;
     }
     $depends_on_stock = StockAvailable::dependsOnStock($id_product);
     if (!$depends_on_stock) {
         $id_stock_available = (int) StockAvailable::getStockAvailableIdByProductId($id_product, $id_product_attribute, $id_shop);
         if ($id_stock_available) {
             $stock_available = new StockAvailable($id_stock_available);
             PP::setQty($stock_available, $quantity);
             $stock_available->update();
         } else {
             $out_of_stock = StockAvailable::outOfStock($id_product, $id_shop);
             $stock_available = new StockAvailable();
             $stock_available->out_of_stock = (int) $out_of_stock;
             $stock_available->id_product = (int) $id_product;
             $stock_available->id_product_attribute = (int) $id_product_attribute;
             PP::setQty($stock_available, $quantity);
             if ($id_shop === null) {
                 $shop_group = Shop::getContextShopGroup();
             } else {
                 $shop_group = new ShopGroup((int) Shop::getGroupFromShop((int) $id_shop));
             }
             if ($shop_group->share_stock) {
                 $stock_available->id_shop = 0;
                 $stock_available->id_shop_group = (int) $shop_group->id;
             } else {
                 $stock_available->id_shop = (int) $id_shop;
                 $stock_available->id_shop_group = 0;
             }
             $stock_available->add();
         }
         Hook::exec('actionUpdateQuantity', array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'quantity' => $stock_available->quantity + $stock_available->quantity_remainder));
     }
     Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $id_product . '*');
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:41,代码来源:StockAvailable.php


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