本文整理汇总了PHP中Shop::getContextShopGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::getContextShopGroup方法的具体用法?PHP Shop::getContextShopGroup怎么用?PHP Shop::getContextShopGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::getContextShopGroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCurrentShopInfoMsg
protected function getCurrentShopInfoMsg()
{
$shop_info = null;
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
$shop_info = sprintf($this->l('The modifications will be applied to shop: %s'), $this->context->shop->name);
} else {
if (Shop::getContext() == Shop::CONTEXT_GROUP) {
$shop_info = sprintf($this->l('The modifications will be applied to this group: %s'), Shop::getContextShopGroup()->name);
} else {
$shop_info = $this->l('The modifications will be applied to all shops');
}
}
return '<div class="alert alert-info">' . $shop_info . '</div>';
}
示例2: 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);
}
示例3: addSqlShopParams
/**
* Add sql params for shops fields - specific to StockAvailable
*
* @param array $params Reference to the params array
* @param int $id_shop Optional : The shop ID
*
*/
public static function addSqlShopParams(&$params, $id_shop = null)
{
$context = Context::getContext();
$group_ok = false;
// if there is no $id_shop, gets the context one
// get shop group too
if ($id_shop === null) {
if (Shop::getContext() == Shop::CONTEXT_GROUP) {
$shop_group = Shop::getContextShopGroup();
} else {
$shop_group = $context->shop->getGroup();
$id_shop = $context->shop->id;
}
} else {
$shop = new Shop($id_shop);
$shop_group = $shop->getGroup();
}
// if quantities are shared between shops of the group
if ($shop_group->share_stock) {
$params['id_shop_group'] = (int) $shop_group->id;
$params['id_shop'] = 0;
$group_ok = true;
} else {
$params['id_shop_group'] = 0;
}
// if no group specific restriction, set simple shop restriction
if (!$group_ok) {
$params['id_shop'] = (int) $id_shop;
}
}
示例4: initContentForCombinations
public function initContentForCombinations()
{
${${"GLOBALS"}["vmqqtmkyw"]} = $this->object;
if (!Combination::isFeatureActive()) {
$this->displayWarning($this->getMessage("This feature has been disabled, you can activate this feature at this page:") . $this->getMessage("link to Performances"));
return;
}
${"GLOBALS"}["weevwwkl"] = "product";
if (Validate::isLoadedObject(${${"GLOBALS"}["weevwwkl"]})) {
self::$smarty->assign("country_display_tax_label", $this->context->country->display_tax_label);
$zsahvowoo = "lang";
self::$smarty->assign("tax_exclude_taxe_option", Tax::excludeTaxeOption());
self::$smarty->assign("id_tax_rules_group", $product->id_tax_rules_group);
self::$smarty->assign("tax_rules_groups", TaxRulesGroup::getTaxRulesGroups(true));
${$zsahvowoo} = new Language($this->id_language);
self::$smarty->assign("iso_code", $lang->iso_code);
self::$smarty->assign("combinationImagesJs", $this->getCombinationImagesJs());
if ($product->is_virtual) {
$tpkpvyor = "product";
self::$smarty->assign("product", ${$tpkpvyor});
$this->displayWarning($this->getMessage("A virtual product cannot have combinations."));
} else {
${"GLOBALS"}["qqjbnscylsi"] = "attribute_js";
${"GLOBALS"}["nqxaoftbn"] = "attribute";
$bcesaxqdqqq = "images";
${"GLOBALS"}["zcxmuajd"] = "ps_stock_mvt_reason_default";
$vmytjghdfi = "attribute_js";
$nrkrfhirkx = "attributes";
${${"GLOBALS"}["qqjbnscylsi"]} = array();
$cappytc = "k";
${"GLOBALS"}["jyaoxpe"] = "attribute";
${$nrkrfhirkx} = Attribute::getAttributes($this->context->language->id, true);
foreach (${${"GLOBALS"}["ecblflvypvt"]} as ${$cappytc} => ${${"GLOBALS"}["jyaoxpe"]}) {
${$vmytjghdfi}[${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute_group"]][${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute"]] = ${${"GLOBALS"}["nqxaoftbn"]}["name"];
}
${"GLOBALS"}["higiwiyuxd"] = "k";
${${"GLOBALS"}["sxexnhlq"]} = new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT"));
self::$smarty->assign("attributeJs", ${${"GLOBALS"}["xenfvrjowsy"]});
self::$smarty->assign("attributes_groups", AttributeGroup::getAttributesGroups($this->context->language->id));
self::$smarty->assign("currency", ${${"GLOBALS"}["sxexnhlq"]});
${"GLOBALS"}["xzqtsdnlkv"] = "images";
${$bcesaxqdqqq} = Image::getImages($this->context->language->id, $product->id);
self::$smarty->assign("tax_exclude_option", Tax::excludeTaxeOption());
$rbxbrbxg = "product";
self::$smarty->assign("ps_weight_unit", Configuration::get("PS_WEIGHT_UNIT"));
self::$smarty->assign("ps_use_ecotax", Configuration::get("PS_USE_ECOTAX"));
self::$smarty->assign("field_value_unity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "unity"));
${"GLOBALS"}["vpcuib"] = "image_type";
self::$smarty->assign("reasons", ${${"GLOBALS"}["nqegxbae"]} = StockMvtReason::getStockMvtReasons($this->context->language->id));
self::$smarty->assign("ps_stock_mvt_reason_default", ${${"GLOBALS"}["zcxmuajd"]} = Configuration::get("PS_STOCK_MVT_REASON_DEFAULT"));
self::$smarty->assign("minimal_quantity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") ? $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") : 1);
self::$smarty->assign("available_date", $this->getFieldValue(${$rbxbrbxg}, "available_date") != 0 ? stripslashes(htmlentities(Tools::displayDate($this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "available_date"), version_compare(_PS_VERSION_, "1.5.5", ">=") ? null : $this->context->language->id))) : "0000-00-00");
${${"GLOBALS"}["tqkkuicfgax"]} = 0;
${"GLOBALS"}["ucamhp"] = "product";
self::$smarty->assign("imageType", ImageType::getByNameNType("small_default", "products"));
self::$smarty->assign("imageWidth", (isset(${${"GLOBALS"}["rvkjjxqs"]}["width"]) ? (int) ${${"GLOBALS"}["vpcuib"]}["width"] : 64) + 25);
foreach (${${"GLOBALS"}["xzqtsdnlkv"]} as ${${"GLOBALS"}["higiwiyuxd"]} => ${${"GLOBALS"}["inpuwydsyk"]}) {
$cshrlmyryz = "image";
${${"GLOBALS"}["dhvuermstcbs"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["obj"] = new Image(${$cshrlmyryz}["id_image"]);
$kcvbkys = "i";
++${$kcvbkys};
}
self::$smarty->assign("images", ${${"GLOBALS"}["dhvuermstcbs"]});
self::$smarty->assign(array("combinationArray" => $this->getCombinations(${${"GLOBALS"}["ucamhp"]}, ${${"GLOBALS"}["sxexnhlq"]}), "product" => ${${"GLOBALS"}["vmqqtmkyw"]}, "id_category" => $product->getDefaultCategory(), "token_generator" => "tokengenerator", "combination_exists" => Shop::isFeatureActive() && Shop::getContextShopGroup()->share_stock && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0));
}
} else {
self::$smarty->assign("product", ${${"GLOBALS"}["vmqqtmkyw"]});
$this->displayWarning($this->getMessage("You must save this product before adding combinations."));
}
}
示例5: getCurrentShopInfoMsg
protected function getCurrentShopInfoMsg()
{
$shop_info = null;
if (Shop::isFeatureActive()) {
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
$shop_info = sprintf($this->getTranslator()->trans('The modifications will be applied to shop: %s', array(), 'Modules.ImageSlider'), $this->context->shop->name);
} else {
if (Shop::getContext() == Shop::CONTEXT_GROUP) {
$shop_info = sprintf($this->getTranslator()->trans('The modifications will be applied to this group: %s', array(), 'Modules.ImageSlider'), Shop::getContextShopGroup()->name);
} else {
$shop_info = $this->getTranslator()->trans('The modifications will be applied to all shops and shop groups', array(), 'Modules.ImageSlider');
}
}
return '<div class="alert alert-info">' . $shop_info . '</div>';
} else {
return '';
}
}
示例6: 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 . '*');
}