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


PHP Warehouse::getPackWarehouses方法代码示例

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


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

示例1: getProductWarehouseList

 /**
  * For a given {product, product attribute} gets warehouse list
  *
  * @param int $id_product ID of the product
  * @param int $id_product_attribute Optional, uses 0 if this product does not have attributes
  * @param int $id_shop Optional, ID of the shop. Uses the context shop id (@see Context::shop)
  * @return array Warehouses (ID, reference/name concatenated)
  */
 public static function getProductWarehouseList($id_product, $id_product_attribute = 0, $id_shop = null)
 {
     // if it's a pack, returns warehouses if and only if some products use the advanced stock management
     if (Pack::isPack($id_product)) {
         $warehouses = Warehouse::getPackWarehouses($id_product);
         $res = array();
         foreach ($warehouses as $warehouse) {
             $res[]['id_warehouse'] = $warehouse;
         }
         return $res;
     }
     $share_stock = false;
     if ($id_shop === null) {
         if (Shop::getContext() == Shop::CONTEXT_GROUP) {
             $shop_group = Shop::getContextShopGroup();
         } else {
             $shop_group = Context::getContext()->shop->getGroup();
             $id_shop = (int) Context::getContext()->shop->id;
         }
         $share_stock = $shop_group->share_stock;
     } else {
         $shop_group = Shop::getGroupFromShop($id_shop);
         $share_stock = $shop_group['share_stock'];
     }
     if ($share_stock) {
         $ids_shop = Shop::getShops(true, (int) $shop_group->id, true);
     } else {
         $ids_shop = array((int) $id_shop);
     }
     $query = new DbQuery();
     $query->select('wpl.id_warehouse, CONCAT(w.reference, " - ", w.name) as name');
     $query->from('warehouse_product_location', 'wpl');
     $query->innerJoin('warehouse_shop', 'ws', 'ws.id_warehouse = wpl.id_warehouse AND id_shop IN (' . implode(',', array_map('intval', $ids_shop)) . ')');
     $query->innerJoin('warehouse', 'w', 'ws.id_warehouse = w.id_warehouse');
     $query->where('id_product = ' . (int) $id_product);
     $query->where('id_product_attribute = ' . (int) $id_product_attribute);
     $query->where('w.deleted = 0');
     $query->groupBy('wpl.id_warehouse');
     return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:48,代码来源:Warehouse.php

示例2: removeProduct


//.........这里部分代码省略.........
							ORDER BY sm.`date_add` DESC');
                        while ($row = Db::getInstance()->nextRow($resource)) {
                            // break - in FIFO mode, we have to retreive the oldest positive mvts for which there are left quantities
                            if ($warehouse->management_type == 'FIFO') {
                                if ($row['qty'] == 0) {
                                    break;
                                }
                            }
                            // converts date to timestamp
                            $date = new DateTime($row['date_add']);
                            $timestamp = $date->format('U');
                            // history of the mvt
                            $stock_history_qty_available[$timestamp] = array('id_stock' => $stock->id, 'id_stock_mvt' => (int) $row['id_stock_mvt'], 'qty' => (int) $row['qty']);
                            // break - in LIFO mode, checks only the necessary history to handle the global quantity for the current stock
                            if ($warehouse->management_type == 'LIFO') {
                                $left_quantity_to_check -= (int) $row['qty'];
                                if ($left_quantity_to_check <= 0) {
                                    break;
                                }
                            }
                        }
                    }
                    if ($warehouse->management_type == 'LIFO') {
                        // orders stock history by timestamp to get newest history first
                        krsort($stock_history_qty_available);
                    } else {
                        // orders stock history by timestamp to get oldest history first
                        ksort($stock_history_qty_available);
                    }
                    // checks each stock to manage the real quantity to decrement for each of them
                    foreach ($stock_history_qty_available as $entry) {
                        if ($entry['qty'] >= $global_quantity_to_decrement) {
                            $quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $global_quantity_to_decrement;
                            $global_quantity_to_decrement = 0;
                        } else {
                            $quantity_to_decrement_by_stock[$entry['id_stock']][$entry['id_stock_mvt']] = $entry['qty'];
                            $global_quantity_to_decrement -= $entry['qty'];
                        }
                        if ($global_quantity_to_decrement <= 0) {
                            break;
                        }
                    }
                    // for each stock, decrements it and logs the mvts
                    foreach ($stock_collection as $stock) {
                        if (array_key_exists($stock->id, $quantity_to_decrement_by_stock) && is_array($quantity_to_decrement_by_stock[$stock->id])) {
                            $total_quantity_for_current_stock = 0;
                            foreach ($quantity_to_decrement_by_stock[$stock->id] as $id_mvt_referrer => $qte) {
                                $mvt_params = array('id_stock' => $stock->id, 'physical_quantity' => $qte, 'id_stock_mvt_reason' => $id_stock_mvt_reason, 'id_order' => $id_order, 'price_te' => $stock->price_te, 'sign' => -1, 'referer' => $id_mvt_referrer, 'id_employee' => (int) $context->employee->id ? (int) $context->employee->id : $employee->id);
                                // saves stock mvt
                                $stock_mvt = new StockMvt();
                                $stock_mvt->hydrate($mvt_params);
                                $stock_mvt->save();
                                $total_quantity_for_current_stock += $qte;
                            }
                            $stock_params = array('physical_quantity' => $stock->physical_quantity - $total_quantity_for_current_stock, 'usable_quantity' => $is_usable ? $stock->usable_quantity - $total_quantity_for_current_stock : $stock->usable_quantity);
                            $return[$stock->id]['quantity'] = $total_quantity_for_current_stock;
                            $return[$stock->id]['price_te'] = $stock->price_te;
                            // saves stock in warehouse
                            $stock->hydrate($stock_params);
                            $stock->update();
                        }
                    }
                    break;
            }
            if (Pack::isPacked($id_product, $id_product_attribute)) {
                $packs = Pack::getPacksContainingItem($id_product, $id_product_attribute, (int) Configuration::get('PS_LANG_DEFAULT'));
                foreach ($packs as $pack) {
                    // Decrease stocks of the pack only if pack is in linked stock mode (option called 'Decrement both')
                    if (!((int) $pack->pack_stock_type == 2) && !((int) $pack->pack_stock_type == 3 && (int) Configuration::get('PS_PACK_STOCK_TYPE') == 2)) {
                        continue;
                    }
                    // Decrease stocks of the pack only if there is not enough items to constituate the actual pack stocks.
                    // How many packs can be constituated with the remaining product stocks
                    $quantity_by_pack = $pack->pack_item_quantity;
                    $stock_available_quantity = $quantity_in_stock - $quantity;
                    $max_pack_quantity = max(array(0, floor($stock_available_quantity / $quantity_by_pack)));
                    $quantity_delta = Pack::getQuantity($pack->id) - $max_pack_quantity;
                    if ($pack->advanced_stock_management == 1 && $quantity_delta > 0) {
                        $product_warehouses = Warehouse::getPackWarehouses($pack->id);
                        $warehouse_stock_found = false;
                        foreach ($product_warehouses as $product_warehouse) {
                            if (!$warehouse_stock_found) {
                                if (Warehouse::exists($product_warehouse)) {
                                    $current_warehouse = new Warehouse($product_warehouse);
                                    $return[] = $this->removeProduct($pack->id, null, $current_warehouse, $quantity_delta, $id_stock_mvt_reason, $is_usable, $id_order, 1);
                                    // The product was found on this warehouse. Stop the stock searching.
                                    $warehouse_stock_found = !empty($return[count($return) - 1]);
                                }
                            }
                        }
                    }
                }
            }
        }
        // if we remove a usable quantity, exec hook
        if ($is_usable) {
            Hook::exec('actionProductCoverage', array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'warehouse' => $warehouse));
        }
        return $return;
    }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:101,代码来源:StockManager.php

示例3: initContentForQuantities


//.........这里部分代码省略.........
         ${${"GLOBALS"}["ldfuknydnzr"]} = array();
         ${${"GLOBALS"}["ymshseez"]} = array();
         ${"GLOBALS"}["lztnksxrb"] = "group_shop";
         foreach (${${"GLOBALS"}["vyyogyvfbtx"]} as ${${"GLOBALS"}["aofqmvff"]}) {
             $rvrxkz = "product_designation";
             $ycvvjwmxtnm = "attribute";
             $dxuqsu = "available_quantity";
             ${$dxuqsu}[${${"GLOBALS"}["iixdipeiyldv"]}["id_product_attribute"]] = StockAvailable::getQuantityAvailableByProduct((int) $this->object->id, ${$ycvvjwmxtnm}["id_product_attribute"]);
             ${$rvrxkz}[${${"GLOBALS"}["iixdipeiyldv"]}["id_product_attribute"]] = rtrim($this->object->name[$this->context->language->id] . " - " . ${${"GLOBALS"}["iixdipeiyldv"]}["attribute_designation"], " - ");
         }
         ${${"GLOBALS"}["ueicxl"]} = true;
         ${$khzorwi} = Shop::getContext();
         ${${"GLOBALS"}["lztnksxrb"]} = $this->context->shop->getGroup();
         $wktpughd = "pack_quantity";
         ${"GLOBALS"}["eukvwdf"] = "advanced_stock_management_warning";
         if (${${"GLOBALS"}["klqbahrije"]} == Shop::CONTEXT_ALL) {
             ${$tfowlgstly} = false;
         } elseif (${${"GLOBALS"}["ohyfjtkcy"]} == Shop::CONTEXT_GROUP) {
             if (!$group_shop->share_stock) {
                 ${${"GLOBALS"}["ueicxl"]} = false;
             }
         } else {
             $eksumjgu = "show_quantities";
             if ($group_shop->share_stock) {
                 ${$eksumjgu} = false;
             }
         }
         self::$smarty->assign("ps_stock_management", Configuration::get("PS_STOCK_MANAGEMENT"));
         self::$smarty->assign("has_attribute", $this->object->hasAttributes());
         if (Combination::isFeatureActive()) {
             self::$smarty->assign("countAttributes", (int) Db::getInstance()->getValue("SELECT COUNT(id_product) FROM " . _DB_PREFIX_ . "product_attribute WHERE id_product = " . (int) $this->object->id));
         }
         ${${"GLOBALS"}["eukvwdf"]} = false;
         if (Configuration::get("PS_ADVANCED_STOCK_MANAGEMENT") && $this->object->advanced_stock_management) {
             ${"GLOBALS"}["awunkp"] = "p_attributes";
             ${"GLOBALS"}["qxobmbos"] = "warehouses";
             ${"GLOBALS"}["cjtetqei"] = "warehouses";
             $ukjfpwyojlf = "p_attribute";
             ${${"GLOBALS"}["iczelyves"]} = Product::getProductAttributesIds($this->object->id);
             ${"GLOBALS"}["kcjlbgqb"] = "advanced_stock_management_warning";
             ${"GLOBALS"}["dlsnuhn"] = "warehouses";
             ${${"GLOBALS"}["qxobmbos"]} = array();
             ${"GLOBALS"}["ojmjigmfve"] = "p_attributes";
             if (!${${"GLOBALS"}["awunkp"]}) {
                 ${${"GLOBALS"}["mdrvdmghqrtc"]}[] = Warehouse::getProductWarehouseList($this->object->id, 0);
             }
             foreach (${${"GLOBALS"}["ojmjigmfve"]} as ${$ukjfpwyojlf}) {
                 ${"GLOBALS"}["uevlubu"] = "ws";
                 ${"GLOBALS"}["fpbyfow"] = "warehouses";
                 ${"GLOBALS"}["inddsyj"] = "ws";
                 ${${"GLOBALS"}["yrbmurnh"]} = Warehouse::getProductWarehouseList($this->object->id, ${${"GLOBALS"}["bhprusfblhn"]}["id_product_attribute"]);
                 if (${${"GLOBALS"}["uevlubu"]}) {
                     ${${"GLOBALS"}["fpbyfow"]}[] = ${${"GLOBALS"}["inddsyj"]};
                 }
             }
             ${${"GLOBALS"}["dlsnuhn"]} = array_unique(${${"GLOBALS"}["cjtetqei"]});
             if (empty(${${"GLOBALS"}["mdrvdmghqrtc"]})) {
                 ${${"GLOBALS"}["kcjlbgqb"]} = true;
             }
         }
         if (${${"GLOBALS"}["uucoxnutvd"]}) {
             $this->displayWarning($this->getMessage("If you wish to use the advanced stock management, you have to:"));
             $this->displayWarning("- " . $this->getMessage("associate your products with warehouses"));
             $this->displayWarning("- " . $this->getMessage("associate your warehouses with carriers"));
             $this->displayWarning("- " . $this->getMessage("associate your warehouses with the appropriate shops"));
         }
         ${${"GLOBALS"}["qbmqjuoutyh"]} = null;
         if (Pack::isPack($this->object->id)) {
             ${"GLOBALS"}["wdcmwsfvsft"] = "pack_quantity";
             $mdjqucflf = "items";
             ${${"GLOBALS"}["wfbswtei"]} = Pack::getItems((int) $this->object->id, Configuration::get("PS_LANG_DEFAULT"));
             $mhikkwxp = "pack_quantities";
             ${"GLOBALS"}["kamnnzyptd"] = "pack_quantities";
             ${${"GLOBALS"}["kamnnzyptd"]} = array();
             foreach (${$mdjqucflf} as ${${"GLOBALS"}["gpnqjgaosuld"]}) {
                 if (!$item->isAvailableWhenOutOfStock((int) $item->out_of_stock)) {
                     $gkwutr = "pack_id_product_attribute";
                     ${${"GLOBALS"}["wkyidmmlbbc"]} = Product::getDefaultAttribute($item->id, 1);
                     ${${"GLOBALS"}["pnfrmcr"]}[] = Product::getQuantity($item->id, ${$gkwutr}) / ($item->pack_quantity !== 0 ? $item->pack_quantity : 1);
                 }
             }
             $oissvbm = "pack_quantities";
             ${${"GLOBALS"}["wdcmwsfvsft"]} = ${$oissvbm}[0];
             foreach (${$mhikkwxp} as ${${"GLOBALS"}["kzwkbwmzgtl"]}) {
                 ${"GLOBALS"}["iwrwjuvdmi"] = "value";
                 if (${${"GLOBALS"}["qbmqjuoutyh"]} > ${${"GLOBALS"}["iwrwjuvdmi"]}) {
                     ${${"GLOBALS"}["qbmqjuoutyh"]} = ${${"GLOBALS"}["kzwkbwmzgtl"]};
                 }
             }
             if (!Warehouse::getPackWarehouses((int) $this->object->id)) {
                 $this->displayWarning($this->getMessage("You must have a common warehouse between this pack and its product."));
             }
         }
         ${${"GLOBALS"}["lixyhrpqnh"]} = new Language($this->id_language);
         self::$smarty->assign("iso_code", $lang->iso_code ? $lang->iso_code : "en");
         self::$smarty->assign(array("attributes" => ${$gmgclvkrjy}, "available_quantity" => ${${"GLOBALS"}["ldfuknydnzr"]}, "pack_quantity" => ${$wktpughd}, "stock_management_active" => Configuration::get("PS_ADVANCED_STOCK_MANAGEMENT"), "product_designation" => ${${"GLOBALS"}["ymshseez"]}, "show_quantities" => ${${"GLOBALS"}["ygzeqkb"]}, "order_out_of_stock" => Configuration::get("PS_ORDER_OUT_OF_STOCK")));
     } else {
         $this->displayWarning($this->getMessage("You must save this product before managing quantities."));
     }
 }
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:sellerproductdetailbase.php


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