本文整理汇总了PHP中ShopGroup::add方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopGroup::add方法的具体用法?PHP ShopGroup::add怎么用?PHP ShopGroup::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopGroup
的用法示例。
在下文中一共展示了ShopGroup::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createShop
public function createShop($shop_name)
{
// Create default group shop
$shop_group = new ShopGroup();
$shop_group->name = 'Default';
$shop_group->active = true;
if (!$shop_group->add()) {
$this->setError($this->language->l('Cannot create group shop') . ' / ' . Db::getInstance()->getMsgError());
return false;
}
// Create default shop
$shop = new Shop();
$shop->active = true;
$shop->id_shop_group = $shop_group->id;
$shop->id_category = 2;
$shop->id_theme = 1;
$shop->name = $shop_name;
if (!$shop->add()) {
$this->setError($this->language->l('Cannot create shop') . ' / ' . Db::getInstance()->getMsgError());
return false;
}
Context::getContext()->shop = $shop;
// Create default shop URL
$shop_url = new ShopUrl();
$shop_url->domain = Tools::getHttpHost();
$shop_url->domain_ssl = Tools::getHttpHost();
$shop_url->physical_uri = __PS_BASE_URI__;
$shop_url->id_shop = $shop->id;
$shop_url->main = true;
$shop_url->active = true;
if (!$shop_url->add()) {
$this->setError($this->language->l('Cannot create shop URL') . ' / ' . Db::getInstance()->getMsgError());
return false;
}
return true;
}
示例2: create_group
public static function create_group($name, $shareCustomers, $shareStock, $shareOrders, $active = true)
{
if (!Validate::isBool($shareCustomers)) {
return false;
}
if (!Validate::isBool($shareStock)) {
return false;
}
if (!Validate::isBool($shareOrders)) {
return false;
}
if (!Validate::isBool($active)) {
return false;
}
$shopGroup = new ShopGroup();
$shopGroup->name = $name;
$shopGroup->active = $active;
$shopGroup->share_customer = $shareCustomers;
$shopGroup->share_stock = $shareStock;
$shopGroup->share_order = $shareOrders;
// todo: echo shopgroupid
if ($shopGroup->add()) {
echo "Shop group {$name} successfully created\n";
return true;
} else {
echo "Error, could not create shop group {$name}\n";
return false;
}
}