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


PHP StockAvailable类代码示例

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


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

示例1: hookHeader

 public function hookHeader($params)
 {
     $shop_id = $this->getShopId();
     $buttons_code = $this->client->getButtonsCode();
     if (Configuration::get('ADDSHOPPERS_OPENGRAPH') == '1') {
         $this->context->smarty->assign('buttons_opengraph', $buttons_code['buttons']['open-graph']);
     }
     if (Configuration::get('ADDSHOPPERS_BUTTONS') == '1') {
         $this->context->smarty->assign('buttons_social', $buttons_code['buttons']['button2']);
     }
     $id_lang = (int) Tools::getValue('id_lang', (int) Configuration::get('PS_LANG_DEFAULT'));
     $this->context->smarty->assign(array('shop_id' => Tools::safeOutput($shop_id), 'default_account' => $shop_id == $this->client->getDefaultShopId(), 'social' => Tools::safeOutput(Configuration::get('ADDSHOPPERS_BUTTONS')), 'opengraph' => Tools::safeOutput(Configuration::get('ADDSHOPPERS_OPENGRAPH')), 'actual_url' => Tools::safeOutput($this->_getCurrentUrl()), 'absolute_base_url' => Tools::safeOutput($this->_getAbsoluteBaseUrl()), 'id_lang' => (int) $id_lang));
     if (Tools::isSubmit('id_product')) {
         $product = new Product((int) Tools::getValue('id_product'));
         if (Validate::isLoadedObject($product)) {
             $currency = new Currency((int) $this->context->cookie->id_currency);
             $this->context->smarty->assign(array('id_product' => (int) $product->id, 'stock' => isset($product->available_now) ? Tools::safeOutput(AddshoppersClient::WIDGET_STOCK_IN_STOCK) : Tools::safeOutput(AddshoppersClient::WIDGET_STOCK_OUT_OF_STOCK), 'price' => Tools::safeOutput($currency->sign) . number_format((double) $product->getPrice(), 2), 'product_name' => Tools::safeOutput($product->name[$id_lang]), 'product_description' => Tools::safeOutput($product->description[$id_lang]), 'is_product_page' => true));
             $quantity = (int) StockAvailable::getQuantityAvailableByProduct((int) $product->id);
             if ($quantity > 0) {
                 $this->context->smarty->assign('instock', (int) $quantity);
             }
             $images = Image::getImages((int) $id_lang, (int) $product->id);
             if (is_array($images) && isset($images[0])) {
                 $this->context->smarty->assign('id_image', (int) $images[0]['id_image']);
             }
         } else {
             $this->context->smarty->assign('is_product_page', false);
         }
     } else {
         $this->context->smarty->assign('is_product_page', false);
     }
     return $this->display(__FILE__, 'header.tpl');
 }
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:33,代码来源:addshoppers.php

示例2: updatePackQuantity

 /**
  * This will update a Pack quantity and will decrease the quantity of containing Products if needed.
  *
  * @param Product $product A product pack object to update its quantity
  * @param StockAvailable $stock_available the stock of the product to fix with correct quantity
  * @param integer $delta_quantity The movement of the stock (negative for a decrease)
  * @param integer|null $id_shop Opional shop ID
  */
 public function updatePackQuantity($product, $stock_available, $delta_quantity, $id_shop = null)
 {
     $configuration = Adapter_ServiceLocator::get('Core_Business_ConfigurationInterface');
     if ($product->pack_stock_type == 1 || $product->pack_stock_type == 2 || $product->pack_stock_type == 3 && $configuration->get('PS_PACK_STOCK_TYPE') > 0) {
         $packItemsManager = Adapter_ServiceLocator::get('Adapter_PackItemsManager');
         $products_pack = $packItemsManager->getPackItems($product);
         $stockAvailable = new Core_Business_Stock_StockManager();
         $stockManager = Adapter_ServiceLocator::get('Adapter_StockManager');
         $cacheManager = Adapter_ServiceLocator::get('Adapter_CacheManager');
         foreach ($products_pack as $product_pack) {
             $productStockAvailable = $stockManager->getStockAvailableByProduct($product_pack, $product_pack->id_pack_product_attribute, $id_shop);
             $productStockAvailable->quantity = $productStockAvailable->quantity + $delta_quantity * $product_pack->pack_quantity;
             $productStockAvailable->update();
             $cacheManager->clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $product_pack->id . '*');
         }
     }
     $stock_available->quantity = $stock_available->quantity + $delta_quantity;
     if ($product->pack_stock_type == 0 || $product->pack_stock_type == 2 || $product->pack_stock_type == 3 && ($configuration->get('PS_PACK_STOCK_TYPE') == 0 || $configuration->get('PS_PACK_STOCK_TYPE') == 2)) {
         $stock_available->update();
     }
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:29,代码来源:Core_Business_Stock_StockManager.php

示例3: delete

 public function delete()
 {
     if (!parent::delete()) {
         return false;
     }
     // Removes the product from StockAvailable, for the current shop
     StockAvailable::removeProductFromStockAvailable((int) $this->id_product, (int) $this->id);
     if (!$this->hasMultishopEntries() && !$this->deleteAssociations()) {
         return false;
     }
     return true;
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:12,代码来源:Combination.php

示例4: 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

示例5: checkProductStock

 protected function checkProductStock($product, $id_order_state)
 {
     if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR')) {
         $update_quantity = true;
         $qty = PP::resolveQty($product['cart_quantity'], $product['cart_quantity_fractional']);
         if (!StockAvailable::dependsOnStock($product['id_product'])) {
             $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -$qty);
         }
         if ($update_quantity) {
             $product['stock_quantity'] -= $qty;
         }
         if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
             $this->outOfStock = true;
         }
         Product::updateDefaultAttribute($product['id_product']);
     }
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:17,代码来源:OrderDetail.php

示例6: checkProductStock

 /**
  * Check the order status
  * @param array $product
  * @param int $id_order_state
  */
 protected function checkProductStock($product, $id_order_state)
 {
     $this->outOfStock = false;
     return;
     //TODO
     if ($id_order_state != Configuration::get('PS_OS_CANCELED') && $id_order_state != Configuration::get('PS_OS_ERROR')) {
         $update_quantity = false;
         if (!StockAvailable::dependsOnStock($product['id_product'])) {
             $update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int) $product['cart_quantity']);
         }
         if ($update_quantity) {
             $product['stock_quantity'] -= $product['cart_quantity'];
         }
         if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
             $this->outOfStock = true;
         }
         Product::updateDefaultAttribute($product['id_product']);
     }
 }
开发者ID:paolobattistella,项目名称:aphro,代码行数:24,代码来源:AphOrderDetail.php

示例7: processGenerate

 public function processGenerate()
 {
     if (!is_array(Tools::getValue('options'))) {
         $this->errors[] = Tools::displayError('Please select at least one attribute.');
     } else {
         $tab = array_values(Tools::getValue('options'));
         if (count($tab) && Validate::isLoadedObject($this->product)) {
             AdminAttributeGeneratorController::setAttributesImpacts($this->product->id, $tab);
             $this->combinations = array_values(AdminAttributeGeneratorController::createCombinations($tab));
             $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations));
             // @since 1.5.0
             if ($this->product->depends_on_stock == 0) {
                 $attributes = Product::getProductAttributesIds($this->product->id, true);
                 foreach ($attributes as $attribute) {
                     StockAvailable::removeProductFromStockAvailable($this->product->id, $attribute['id_product_attribute'], Context::getContext()->shop);
                 }
             }
             SpecificPriceRule::disableAnyApplication();
             $this->product->deleteProductAttributes();
             $this->product->generateMultipleCombinations($values, $this->combinations);
             // @since 1.5.0
             if ($this->product->depends_on_stock == 0) {
                 $attributes = Product::getProductAttributesIds($this->product->id, true);
                 $quantity = str_replace(',', '.', Tools::getValue('quantity'));
                 foreach ($attributes as $attribute) {
                     StockAvailable::setQuantity($this->product->id, $attribute['id_product_attribute'], $quantity);
                 }
             } else {
                 StockAvailable::synchronize($this->product->id);
             }
             SpecificPriceRule::enableAnyApplication();
             SpecificPriceRule::applyAllRules(array((int) $this->product->id));
             Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts') . '&id_product=' . (int) Tools::getValue('id_product') . '&updateproduct&key_tab=Combinations&conf=4');
         } else {
             $this->errors[] = Tools::displayError('Unable to initialize these parameters. A combination is missing or an object cannot be loaded.');
         }
     }
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:38,代码来源:AdminAttributeGeneratorController.php

示例8: resetStockAvailable

 public function resetStockAvailable()
 {
     $products = WarehouseProductLocation::getProducts((int) $this->id);
     foreach ($products as $product) {
         StockAvailable::synchronize((int) $product['id_product']);
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:7,代码来源:Warehouse.php

示例9: createEntityStockAvailable

 public function createEntityStockAvailable($identifier, array $data, array $data_lang)
 {
     $stock_available = new StockAvailable();
     $stock_available->updateQuantity($data['id_product'], $data['id_product_attribute'], $data['quantity'], $data['id_shop']);
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:5,代码来源:xmlLoader.php

示例10: _checkProducts

 private function _checkProducts($productsNode)
 {
     $available = true;
     foreach ($productsNode->Product as $product) {
         if (strpos($product->SKU, '_') !== false) {
             $skus = explode('_', $product->SKU);
             $quantity = StockAvailable::getQuantityAvailableByProduct((int) $skus[0], (int) $skus[1]);
             if ($quantity - $product->Quantity < 0) {
                 StockAvailable::updateQuantity((int) $skus[0], (int) $skus[1], (int) $product->Quantity);
             }
         } else {
             $quantity = StockAvailable::getQuantityAvailableByProduct((int) $product->SKU);
             if ($quantity - $product->Quantity < 0) {
                 StockAvailable::updateQuantity((int) $skus[0], 0, (int) $product->Quantity);
             }
         }
     }
     return $available;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:19,代码来源:shoppingfluxexport.php

示例11: postProcess

 /**
  * AdminController::postProcess() override
  * @see AdminController::postProcess()
  */
 public function postProcess()
 {
     parent::postProcess();
     // Checks access
     if (Tools::isSubmit('addStock') && !($this->tabAccess['add'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have the required permission to add stock.');
     }
     if (Tools::isSubmit('removeStock') && !($this->tabAccess['delete'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have the required permission to delete stock');
     }
     if (Tools::isSubmit('transferStock') && !($this->tabAccess['edit'] === '1')) {
         $this->errors[] = Tools::displayError('You do not have the required permission to transfer stock.');
     }
     if (count($this->errors)) {
         return;
     }
     // Global checks when add / remove / transfer product
     if ((Tools::isSubmit('addstock') || Tools::isSubmit('removestock') || Tools::isSubmit('transferstock')) && Tools::isSubmit('is_post')) {
         // get product ID
         $id_product = (int) Tools::getValue('id_product', 0);
         if ($id_product <= 0) {
             $this->errors[] = Tools::displayError('The selected product is not valid.');
         }
         // get product_attribute ID
         $id_product_attribute = (int) Tools::getValue('id_product_attribute', 0);
         // check the product hash
         $check = Tools::getValue('check', '');
         $check_valid = md5(_COOKIE_KEY_ . $id_product . $id_product_attribute);
         if ($check != $check_valid) {
             $this->errors[] = Tools::displayError('The selected product is not valid.');
         }
         // get quantity and check that the post value is really an integer
         // If it's not, we have nothing to do
         $quantity = Tools::getValue('quantity', 0);
         if (!is_numeric($quantity) || (int) $quantity <= 0) {
             $this->errors[] = Tools::displayError('The quantity value is not valid.');
         }
         $quantity = (int) $quantity;
         $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
         $redirect = self::$currentIndex . '&token=' . $token;
     }
     // Global checks when add / remove product
     if ((Tools::isSubmit('addstock') || Tools::isSubmit('removestock')) && Tools::isSubmit('is_post')) {
         // get warehouse id
         $id_warehouse = (int) Tools::getValue('id_warehouse', 0);
         if ($id_warehouse <= 0 || !Warehouse::exists($id_warehouse)) {
             $this->errors[] = Tools::displayError('The selected warehouse is not valid.');
         }
         // get stock movement reason id
         $id_stock_mvt_reason = (int) Tools::getValue('id_stock_mvt_reason', 0);
         if ($id_stock_mvt_reason <= 0 || !StockMvtReason::exists($id_stock_mvt_reason)) {
             $this->errors[] = Tools::displayError('The reason is not valid.');
         }
         // get usable flag
         $usable = Tools::getValue('usable', null);
         if (is_null($usable)) {
             $this->errors[] = Tools::displayError('You have to specify whether the product quantity is usable for sale on shops or not.');
         }
         $usable = (bool) $usable;
     }
     if (Tools::isSubmit('addstock') && Tools::isSubmit('is_post')) {
         // get product unit price
         $price = str_replace(',', '.', Tools::getValue('price', 0));
         if (!is_numeric($price)) {
             $this->errors[] = Tools::displayError('The product price is not valid.');
         }
         $price = round(floatval($price), 6);
         // get product unit price currency id
         $id_currency = (int) Tools::getValue('id_currency', 0);
         if ($id_currency <= 0 || (!($result = Currency::getCurrency($id_currency)) || empty($result))) {
             $this->errors[] = Tools::displayError('The selected currency is not valid.');
         }
         // if all is ok, add stock
         if (count($this->errors) == 0) {
             $warehouse = new Warehouse($id_warehouse);
             // convert price to warehouse currency if needed
             if ($id_currency != $warehouse->id_currency) {
                 // First convert price to the default currency
                 $price_converted_to_default_currency = Tools::convertPrice($price, $id_currency, false);
                 // Convert the new price from default currency to needed currency
                 $price = Tools::convertPrice($price_converted_to_default_currency, $warehouse->id_currency, true);
             }
             // add stock
             $stock_manager = StockManagerFactory::getManager();
             if ($stock_manager->addProduct($id_product, $id_product_attribute, $warehouse, $quantity, $id_stock_mvt_reason, $price, $usable)) {
                 // Create warehouse_product_location entry if we add stock to a new warehouse
                 $id_wpl = (int) WarehouseProductLocation::getIdByProductAndWarehouse($id_product, $id_product_attribute, $id_warehouse);
                 if (!$id_wpl) {
                     $wpl = new WarehouseProductLocation();
                     $wpl->id_product = (int) $id_product;
                     $wpl->id_product_attribute = (int) $id_product_attribute;
                     $wpl->id_warehouse = (int) $id_warehouse;
                     $wpl->save();
                 }
                 StockAvailable::synchronize($id_product);
                 if (Tools::isSubmit('addstockAndStay')) {
//.........这里部分代码省略.........
开发者ID:ortegon000,项目名称:tienda,代码行数:101,代码来源:AdminStockManagementController.php

示例12: renderView

 public function renderView()
 {
     if (!($cart = $this->loadObject(true))) {
         return;
     }
     $customer = new Customer($cart->id_customer);
     $currency = new Currency($cart->id_currency);
     $this->context->cart = $cart;
     $this->context->currency = $currency;
     $this->context->customer = $customer;
     $this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->id);
     $products = $cart->getProducts();
     $customized_datas = Product::getAllCustomizedDatas((int) $cart->id);
     Product::addCustomizationPrice($products, $customized_datas);
     $summary = $cart->getSummaryDetails();
     /* Display order information */
     $id_order = (int) Order::getOrderByCartId($cart->id);
     $order = new Order($id_order);
     if (Validate::isLoadedObject($order)) {
         $tax_calculation_method = $order->getTaxCalculationMethod();
         $id_shop = (int) $order->id_shop;
     } else {
         $id_shop = (int) $cart->id_shop;
         $tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id);
     }
     if ($tax_calculation_method == PS_TAX_EXC) {
         $total_products = $summary['total_products'];
         $total_discounts = $summary['total_discounts_tax_exc'];
         $total_wrapping = $summary['total_wrapping_tax_exc'];
         $total_price = $summary['total_price_without_tax'];
         $total_shipping = $summary['total_shipping_tax_exc'];
     } else {
         $total_products = $summary['total_products_wt'];
         $total_discounts = $summary['total_discounts'];
         $total_wrapping = $summary['total_wrapping'];
         $total_price = $summary['total_price'];
         $total_shipping = $summary['total_shipping'];
     }
     foreach ($products as $k => &$product) {
         if ($tax_calculation_method == PS_TAX_EXC) {
             $product['product_price'] = $product['price'];
             $product['product_total'] = $product['total'];
         } else {
             $product['product_price'] = $product['price_wt'];
             $product['product_total'] = $product['total_wt'];
         }
         $image = array();
         if (isset($product['id_product_attribute']) && (int) $product['id_product_attribute']) {
             $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . (int) $product['id_product_attribute']);
         }
         if (!isset($image['id_image'])) {
             $image = Db::getInstance()->getRow('SELECT id_image FROM ' . _DB_PREFIX_ . 'image WHERE id_product = ' . (int) $product['id_product'] . ' AND cover = 1');
         }
         $product_obj = new Product($product['id_product']);
         $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct($product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, (int) $id_shop);
         $image_product = new Image($image['id_image']);
         $product['image'] = isset($image['id_image']) ? ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $image_product->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['id_product'] . (isset($product['id_product_attribute']) ? '_' . (int) $product['id_product_attribute'] : '') . '.jpg', 45, 'jpg') : '--';
     }
     $helper = new HelperKpi();
     $helper->id = 'box-kpi-cart';
     $helper->icon = 'icon-shopping-cart';
     $helper->color = 'color1';
     $helper->title = $this->l('Total Cart', null, null, false);
     $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id);
     $helper->value = Tools::displayPrice($total_price, $currency);
     $kpi = $helper->generate();
     $this->tpl_view_vars = array('kpi' => $kpi, 'products' => $products, 'discounts' => $cart->getCartRules(), 'order' => $order, 'cart' => $cart, 'currency' => $currency, 'customer' => $customer, 'customer_stats' => $customer->getStats(), 'total_products' => $total_products, 'total_discounts' => $total_discounts, 'total_wrapping' => $total_wrapping, 'total_price' => $total_price, 'total_shipping' => $total_shipping, 'customized_datas' => $customized_datas);
     return parent::renderView();
 }
开发者ID:zangles,项目名称:lennyba,代码行数:69,代码来源:AdminCartsController.php

示例13: setProductCurrentStock

 /**
  *
  * This method allow to add stock information on a product detail
  *
  * If advanced stock management is active, get physical stock of this product in the warehouse associated to the ptoduct for the current order
  * Else get the available quantity of the product in fucntion of the shop associated to the order
  *
  * @param array &$product
  */
 protected function setProductCurrentStock(&$product)
 {
     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && (int) $product['advanced_stock_management'] == 1 && (int) $product['id_warehouse'] > 0) {
         $product['current_stock'] = StockManagerFactory::getManager()->getProductPhysicalQuantities($product['product_id'], $product['product_attribute_id'], (int) $product['id_warehouse'], true);
     } else {
         $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], (int) $this->id_shop);
     }
 }
开发者ID:TheTypoMaster,项目名称:neotienda,代码行数:17,代码来源:NeoExchanges.php

示例14: 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

示例15: attributeImportOne


//.........这里部分代码省略.........
                        AttributeGroup::cleanPositions();
                    }
                }
            }
        }
        $product->checkDefaultAttributes();
        if (!$product->cache_default_attribute && !$validateOnly) {
            Product::updateDefaultAttribute($product->id);
        }
        if ($id_product_attribute) {
            if (!$validateOnly) {
                // now adds the attributes in the attribute_combination table
                if ($id_product_attribute_update) {
                    Db::getInstance()->execute('
						DELETE FROM ' . _DB_PREFIX_ . 'product_attribute_combination
						WHERE id_product_attribute = ' . (int) $id_product_attribute);
                }
                foreach ($attributes_to_add as $attribute_to_add) {
                    Db::getInstance()->execute('
						INSERT IGNORE INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute)
						VALUES (' . (int) $attribute_to_add . ',' . (int) $id_product_attribute . ')', false);
                }
            }
            // set advanced stock managment
            if (isset($info['advanced_stock_management'])) {
                if ($info['advanced_stock_management'] != 1 && $info['advanced_stock_management'] != 0) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management has incorrect value. Not set for product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id);
                } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $info['advanced_stock_management'] == 1) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot enable on product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id);
                } elseif (!$validateOnly) {
                    $product->setAdvancedStockManagement($info['advanced_stock_management']);
                }
                // automaticly disable depends on stock, if a_s_m set to disabled
                if (!$validateOnly && StockAvailable::dependsOnStock($product->id) == 1 && $info['advanced_stock_management'] == 0) {
                    StockAvailable::setProductDependsOnStock($product->id, 0, null, $id_product_attribute);
                }
            }
            // Check if warehouse exists
            if (isset($info['warehouse']) && $info['warehouse']) {
                if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, warehouse is not set on product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id);
                } else {
                    if (Warehouse::exists($info['warehouse'])) {
                        $warehouse_location_entity = new WarehouseProductLocation();
                        $warehouse_location_entity->id_product = $product->id;
                        $warehouse_location_entity->id_product_attribute = $id_product_attribute;
                        $warehouse_location_entity->id_warehouse = $info['warehouse'];
                        if (!$validateOnly) {
                            if (WarehouseProductLocation::getProductLocation($product->id, $id_product_attribute, $info['warehouse']) !== false) {
                                $warehouse_location_entity->update();
                            } else {
                                $warehouse_location_entity->save();
                            }
                            StockAvailable::synchronize($product->id);
                        }
                    } else {
                        $this->warnings[] = sprintf($this->trans('Warehouse did not exist, cannot set on product %1$s.', array(), 'Admin.Parameters.Notification'), $product->name[$default_language]);
                    }
                }
            }
            // stock available
            if (isset($info['depends_on_stock'])) {
                if ($info['depends_on_stock'] != 0 && $info['depends_on_stock'] != 1) {
                    $this->warnings[] = sprintf($this->trans('Incorrect value for "Depends on stock" for product %1$s ', array(), 'Admin.Notifications.Error'), $product->name[$default_language]);
                } elseif ((!$info['advanced_stock_management'] || $info['advanced_stock_management'] == 0) && $info['depends_on_stock'] == 1) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot set "Depends on stock" for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language]);
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:AdminImportController.php


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