// Fix carrier lang copy when a new shop is created + can duplicate data when editing a shop

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8094 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-08-17 13:37:15 +00:00
parent 549d5be0c7
commit 51f2bf2617
2 changed files with 57 additions and 52 deletions
+56 -51
View File
@@ -66,6 +66,12 @@ class AdminShop extends AdminTab
if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData)) if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData))
$newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData); $newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData);
} }
public function afterUpdate($newShop)
{
if (Tools::getValue('useImportData') && ($importData = Tools::getValue('importData')) && is_array($importData))
$newShop->copyShopData((int)Tools::getValue('importFromShop'), $importData);
}
public function postProcess() public function postProcess()
{ {
@@ -170,58 +176,57 @@ class AdminShop extends AdminTab
<div class="small"><sup>*</sup> '.$this->l('Required field').'</div> <div class="small"><sup>*</sup> '.$this->l('Required field').'</div>
</fieldset><br /><br />'; </fieldset><br /><br />';
if (Tools::getValue('addshop') !== false) $importData = array(
{ 'carrier' => $this->l('Carriers'),
$importData = array( 'carrier_lang' => $this->l('Carriers lang'),
'carrier' => $this->l('Carriers'), 'category_lang' => $this->l('Category lang'),
'category_lang' => $this->l('Category lang'), 'cms' => $this->l('CMS page'),
'cms' => $this->l('CMS page'), 'contact' => $this->l('Contact'),
'contact' => $this->l('Contact'), 'country' => $this->l('Countries'),
'country' => $this->l('Countries'), 'currency' => $this->l('Currencies'),
'currency' => $this->l('Currencies'), 'discount' => $this->l('Discounts'),
'discount' => $this->l('Discounts'), 'image' => $this->l('Images'),
'image' => $this->l('Images'), 'lang' => $this->l('Langs'),
'lang' => $this->l('Langs'), 'manufacturer' => $this->l('Manufacturers'),
'manufacturer' => $this->l('Manufacturers'), 'module' => $this->l('Modules'),
'module' => $this->l('Modules'), 'hook_module' => $this->l('Modules hook'),
'hook_module' => $this->l('Modules hook'), 'hook_module_exceptions' => $this->l('Modules hook exceptions'),
'hook_module_exceptions' => $this->l('Modules hook exceptions'), 'meta_lang' => $this->l('Meta'),
'meta_lang' => $this->l('Meta'), 'module_country' => $this->l('Payment module country restrictions'),
'module_country' => $this->l('Payment module country restrictions'), 'module_group' => $this->l('Payment module customer group restrictions'),
'module_group' => $this->l('Payment module customer group restrictions'), 'module_currency' => $this->l('Payment module currency restrictions'),
'module_currency' => $this->l('Payment module currency restrictions'), 'product' => $this->l('Products'),
'product' => $this->l('Products'), 'product_lang' => $this->l('Products lang'),
'product_lang' => $this->l('Products lang'), 'scene' => $this->l('Scenes'),
'scene' => $this->l('Scenes'), 'stock' => $this->l('Stock'),
'stock' => $this->l('Stock'), 'store' => $this->l('Stores'),
'store' => $this->l('Stores'), 'zone' => $this->l('Zones'),
'zone' => $this->l('Zones'), );
);
echo '<fieldset><legend>'.$this->l('Import data from another shop').'</legend>'; $checked = (Tools::getValue('addshop') !== false) ? true : false;
echo '<label>'.$this->l('Import data from another shop').'</label>'; echo '<fieldset><legend>'.$this->l('Import data from another shop').'</legend>';
echo '<div class="margin-form">'; echo '<label>'.$this->l('Import data from another shop').'</label>';
echo '<input type="checkbox" value="1" checked="checked" name="useImportData" onclick="$(\'#importList\').slideToggle(\'slow\')" /> '; echo '<div class="margin-form">';
echo $this->l('Duplicate data from shop'); echo '<input type="checkbox" value="1" '.(($checked) ? 'checked="checked"' : '').' name="useImportData" onclick="$(\'#importList\').slideToggle(\'slow\')" /> ';
echo ' <select name="importFromShop">'; echo $this->l('Duplicate data from shop');
foreach (Shop::getTree() as $gID => $gData) echo ' <select name="importFromShop">';
{ foreach (Shop::getTree() as $gID => $gData)
echo '<optgroup label="'.$gData['name'].'">'; {
foreach ($gData['shops'] as $sID => $sData) echo '<optgroup label="'.$gData['name'].'">';
echo '<option value="'.(int)$sID.'" '.($sID == Configuration::get('PS_SHOP_DEFAULT') ? 'selected="selected"' : '').'">'.$sData['name'].'</option>'; foreach ($gData['shops'] as $sID => $sData)
echo '</optgroup>'; echo '<option value="'.(int)$sID.'" '.($sID == Configuration::get('PS_SHOP_DEFAULT') ? 'selected="selected"' : '').'">'.$sData['name'].'</option>';
} echo '</optgroup>';
echo '</select>'; }
echo '<div id="importList" style=""><ul>'; echo '</select>';
foreach ($importData as $table => $lang) echo '<div id="importList" style="'.((!$checked) ? 'display: none' : '').'"><ul>';
echo '<li><label><input type="checkbox" name="importData['.$table.']" checked="checked" /> '.$lang.'</label></li>'; foreach ($importData as $table => $lang)
echo '</ul></div>'; echo '<li><label><input type="checkbox" name="importData['.$table.']" checked="checked" /> '.$lang.'</label></li>';
echo '<p>'.$this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop').'</p>'; echo '</ul></div>';
echo '</div><div class="margin-form"> echo '<p>'.$this->l('Use this option to associate data (products, modules, etc.) the same way as the selected shop').'</p>';
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" /> echo '</div><div class="margin-form">
</div>'; <input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
echo '</fieldset>'; </div>';
} echo '</fieldset>';
echo '</form>'; echo '</form>';
} }
+1 -1
View File
@@ -737,7 +737,7 @@ class ShopCore extends ObjectModel
unset($res[$row['primary']]); unset($res[$row['primary']]);
$keys = implode(', ', array_keys($res)); $keys = implode(', ', array_keys($res));
$sql = 'INSERT INTO `'._DB_PREFIX_.$table_name.'` ('.$keys.', '.$id.') $sql = 'INSERT IGNORE INTO `'._DB_PREFIX_.$table_name.'` ('.$keys.', '.$id.')
(SELECT '.$keys.', '.(int)$this->id.' FROM '._DB_PREFIX_.$table_name.' (SELECT '.$keys.', '.(int)$this->id.' FROM '._DB_PREFIX_.$table_name.'
WHERE `'.$id.'` = '.(int)$old_id.')'; WHERE `'.$id.'` = '.(int)$old_id.')';
Db::getInstance()->Execute($sql); Db::getInstance()->Execute($sql);