// MERGE product_multistore branch : product fields are now editable per shop
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14682 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -348,7 +348,7 @@ class HelperCore
|
||||
|
||||
public static function renderShopList()
|
||||
{
|
||||
if (!Shop::isFeatureActive())
|
||||
if (!Shop::isFeatureActive() || count(Shop::getShops(false, null, true)) < 2)
|
||||
return null;
|
||||
|
||||
$tree = Shop::getTree();
|
||||
@@ -358,7 +358,7 @@ class HelperCore
|
||||
if (Shop::getContext() == Shop::CONTEXT_ALL)
|
||||
$value = '';
|
||||
else if (Shop::getContext() == Shop::CONTEXT_GROUP)
|
||||
$value = 'g-'.Shop::getContextGroupShopID();
|
||||
$value = 'g-'.Shop::getContextShopGroupID();
|
||||
else
|
||||
$value = 's-'.Shop::getContextShopID();
|
||||
|
||||
@@ -369,7 +369,7 @@ class HelperCore
|
||||
$html .= '<option value="" class="first">'.translate('All shops').'</option>';
|
||||
foreach ($tree as $gID => $group_data)
|
||||
{
|
||||
if (!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP)
|
||||
if ((!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP) && count($group_data['shops']) > 1)
|
||||
$html .= '<option class="group" value="g-'.$gID.'" '.(($value == 'g-'.$gID) ? 'selected="selected"' : '').'>'.translate('Group:').' '.htmlspecialchars($group_data['name']).'</option>';
|
||||
else
|
||||
$html .= '<optgroup class="group" label="'.translate('Group:').' '.htmlspecialchars($group_data['name']).'">';
|
||||
|
||||
@@ -137,8 +137,10 @@ class HelperFormCore extends Helper
|
||||
break;
|
||||
|
||||
case 'shop' :
|
||||
case 'group_shop' :
|
||||
$params['html'] = $this->renderAssoShop($params['type']);
|
||||
$shops = Shop::getShops(true, null, true);
|
||||
if (count($shops) == 1)
|
||||
unset($this->fields_form[$fieldset_key]['form']['input'][$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -186,69 +188,59 @@ class HelperFormCore extends Helper
|
||||
/**
|
||||
* Render an area to determinate shop association
|
||||
*
|
||||
* @param string $type 'shop' or 'group_shop'
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderAssoShop($type = 'shop')
|
||||
public function renderAssoShop()
|
||||
{
|
||||
if (!Shop::isFeatureActive())
|
||||
return;
|
||||
|
||||
if ($type != 'shop' && $type != 'group_shop')
|
||||
$type = 'shop';
|
||||
|
||||
$assos = array();
|
||||
if ((int)$this->id)
|
||||
{
|
||||
$sql = 'SELECT `id_'.$type.'`, `'.bqSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.bqSQL($this->table).'_'.$type.'`
|
||||
$sql = 'SELECT `id_shop`, `'.bqSQL($this->identifier).'`
|
||||
FROM `'._DB_PREFIX_.bqSQL($this->table).'_shop`
|
||||
WHERE `'.bqSQL($this->identifier).'` = '.(int)$this->id;
|
||||
|
||||
foreach (Db::getInstance()->executeS($sql) as $row)
|
||||
$assos[$row['id_'.$type]] = $row['id_'.$type];
|
||||
$assos[$row['id_shop']] = $row['id_shop'];
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Shop::getContext())
|
||||
{
|
||||
case Shop::CONTEXT_SHOP :
|
||||
if ($type == 'shop')
|
||||
$assos[Shop::getContextShopID()] = Shop::getContextShopID();
|
||||
else
|
||||
$assos[Shop::getContextGroupShopID()] = Shop::getContextGroupShopID();
|
||||
break;
|
||||
|
||||
case Shop::CONTEXT_GROUP :
|
||||
if ($type == 'shop')
|
||||
foreach (Shop::getShops(false, Shop::getContextGroupShopID(), true) as $id_shop)
|
||||
foreach (Shop::getShops(false, Shop::getContextShopGroupID(), true) as $id_shop)
|
||||
$assos[$id_shop] = $id_shop;
|
||||
else
|
||||
$assos[Shop::getContextGroupShopID()] = Shop::getContextGroupShopID();
|
||||
break;
|
||||
|
||||
default :
|
||||
if ($type == 'shop')
|
||||
foreach (Shop::getShops(false, null, true) as $id_shop)
|
||||
$assos[$id_shop] = $id_shop;
|
||||
else
|
||||
foreach (Shop::getTree() as $group_shop)
|
||||
$assos[$group_shop['id']] = $group_shop['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = $this->createTemplate('assoshop.tpl');
|
||||
$tree = Shop::getTree();
|
||||
$nb_shop = 0;
|
||||
foreach ($tree as $value)
|
||||
$nb_shop += count($value['shops']);
|
||||
$tpl->assign(array(
|
||||
'input' => array(
|
||||
'type' => $type,
|
||||
'values' => Shop::getTree(),
|
||||
'type' => 'shop',
|
||||
'values' => $tree,
|
||||
),
|
||||
'fields_value' => array(
|
||||
'shop' => $assos
|
||||
),
|
||||
'form_id' => $this->id,
|
||||
'table' => $this->table
|
||||
'table' => $this->table,
|
||||
'nb_shop' => $nb_shop
|
||||
));
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class HelperOptionsCore extends Helper
|
||||
if (!isset($languages))
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
$use_multishop = false;
|
||||
foreach ($option_list as $category => $category_data)
|
||||
{
|
||||
if (!is_array($category_data))
|
||||
@@ -125,7 +126,12 @@ class HelperOptionsCore extends Helper
|
||||
}
|
||||
|
||||
// Multishop default value
|
||||
$field['multishop_default'] = (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !$isInvisible);
|
||||
$field['multishop_default'] = false;
|
||||
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL && !$isInvisible)
|
||||
{
|
||||
$field['multishop_default'] = true;
|
||||
$use_multishop = true;
|
||||
}
|
||||
|
||||
// Assign the modifications back to parent array
|
||||
$category_data['fields'][$key] = $field;
|
||||
@@ -151,6 +157,7 @@ class HelperOptionsCore extends Helper
|
||||
'languages' => isset($languages) ? $languages : null,
|
||||
'currency_left_sign' => $this->context->currency->getSign('left'),
|
||||
'currency_right_sign' => $this->context->currency->getSign('right'),
|
||||
'use_multishop' => $use_multishop,
|
||||
));
|
||||
|
||||
return parent::generate();
|
||||
|
||||
Reference in New Issue
Block a user