// fix product live preview and duplication
This commit is contained in:
+3
-3
@@ -432,9 +432,9 @@ if (Tools::getValue('submitPublishProduct'))
|
||||
if (Tools::getIsset('id_product'))
|
||||
{
|
||||
$id_product = (int)(Tools::getValue('id_product'));
|
||||
$id_tab_catalog = (int)(Tab::getIdFromClassName('AdminCatalog'));
|
||||
$token = Tools::getAdminToken('AdminCatalog'.(int)($id_tab_catalog).(int)$context->employee->id);
|
||||
$bo_product_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.$token;
|
||||
$id_tab_catalog = (int)(Tab::getIdFromClassName('AdminProducts'));
|
||||
$token = Tools::getAdminToken('AdminProducts'.(int)($id_tab_catalog).(int)$context->employee->id);
|
||||
$bo_product_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminProducts&id_product='.$id_product.'&updateproduct&token='.$token;
|
||||
|
||||
if (Tools::getValue('redirect'))
|
||||
die($bo_product_url);
|
||||
|
||||
@@ -268,7 +268,7 @@ $(document).ready(function(){
|
||||
<div class="warn draft" >
|
||||
<p>
|
||||
<span style="float: left">
|
||||
<img src="../img/admin/warn2.png" />{l s='Your product will be saved as draft'}</span>
|
||||
{l s='Your product will be saved as draft'}</span>
|
||||
<span style="float:right"><a href="#" class="button" style="display: block" onclick="submitAddProductAndPreview()" >{l s='Save and preview'}</a></span>
|
||||
<input type="hidden" name="fakeSubmitAddProductAndPreview" id="fakeSubmitAddProductAndPreview" />
|
||||
<br />
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
{l s='Enabled'}</label>
|
||||
<br class="clear" />
|
||||
<input style="float:left;" onclick="toggleDraftWarning(true);showOptions(false);" type="radio" name="active" id="active_off" value="0" {if !$product->active}checked="checked"{/if} />
|
||||
<label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="{l s='Disabled'}" title="{l s='Disabled'}" style="float:left; padding:0px 5px 0px 5px" />{l s='Disabled'} {if !$product->active} (<a href="{$preview_url}" alt="" target="_blank">{l s='View product in shop'}</a>){/if}</label>
|
||||
<label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="{l s='Disabled'}" title="{l s='Disabled'}" style="float:left; padding:0px 5px 0px 5px" />{l s='Disabled'} </label>
|
||||
</td>
|
||||
</tr>
|
||||
{if $feature_shop_active}
|
||||
|
||||
@@ -1288,13 +1288,15 @@ class AdminProductsControllerCore extends AdminController
|
||||
$preview_url .= 'adtoken='.$token.'&ad='.$admin_dir;
|
||||
}
|
||||
$this->redirect_after = $preview_url;
|
||||
} else if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') || ($id_image && $id_image !== true)) // Save and stay on same form
|
||||
// Save and stay on same form
|
||||
}
|
||||
else if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') || ($id_image && $id_image !== true)) // Save and stay on same form
|
||||
{// Save and stay on same form
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
||||
$this->redirect_after = self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&addproduct&conf=4&tabs='.(int)(Tools::getValue('tabs')).'&token='.($token ? $token : $this->token);
|
||||
|
||||
// Default behavior (save and back)
|
||||
$this->redirect_after = self::$currentIndex.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&conf=4&token='.($token ? $token : $this->token);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1595,8 +1597,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (empty($this->action))
|
||||
$this->action = 'Informations';
|
||||
|
||||
|
||||
|
||||
if(method_exists($this, 'initForm'.$this->action))
|
||||
$this->tpl_form = 'products/'.strtolower($this->action).'.tpl';
|
||||
|
||||
@@ -1649,7 +1649,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($id_category = (int)Tools::getValue('id_category'))
|
||||
self::$currentIndex .= '&id_category='.$id_category;
|
||||
$this->getList($this->context->language->id, !$this->context->cookie->__get($this->table.'Orderby') ? 'position' : null, !$this->context->cookie->__get($this->table.'Orderway') ? 'ASC' : null, 0, null, $this->context->shop->getID(true));
|
||||
|
||||
|
||||
if (!empty($this->_list))
|
||||
{
|
||||
$id_category = Tools::getValue('id_category', 1);
|
||||
@@ -1660,19 +1660,19 @@ class AdminProductsControllerCore extends AdminController
|
||||
$root_categ = Category::getRootCategory();
|
||||
$children = $root_categ->getAllChildren();
|
||||
$category_tree = array();
|
||||
|
||||
|
||||
// Add category "all products" to tree
|
||||
$all_categ = new Category();
|
||||
$all_categ->name = 'All products';
|
||||
$all_categ->selected = $this->_category->id_category == $all_categ->id;
|
||||
$all_categ->dashes = '';
|
||||
$category_tree[] = $all_categ;
|
||||
|
||||
|
||||
// Add root category to tree
|
||||
$root_categ->selected = $this->_category->id_category == $root_categ->id;
|
||||
$root_categ->dashes = str_repeat(' - ',$root_categ->level_depth);
|
||||
$category_tree[] = $root_categ;
|
||||
|
||||
|
||||
foreach ($children as $k => $categ)
|
||||
{
|
||||
$categ = new Category($categ['id_category'],$this->context->language->id);
|
||||
@@ -1681,7 +1681,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$category_tree[] = $categ;
|
||||
}
|
||||
$this->tpl_list_vars['category_tree'] = $category_tree;
|
||||
|
||||
|
||||
// used to build the new url when changing category
|
||||
$this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token;
|
||||
}
|
||||
@@ -1779,7 +1779,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
$content = '<div class="warn draft" style="'.($active ? 'display:none' : '').'">
|
||||
<p>
|
||||
<span style="float: left">
|
||||
<img src="../img/admin/warn2.png" />
|
||||
'.$this->l('Your product will be saved as draft').'
|
||||
</span>
|
||||
<span style="float:right"><a href="#" class="button" style="display: block" onclick="submitAddProductAndPreview()" >'.$this->l('Save and preview').'</a></span>
|
||||
|
||||
@@ -87,7 +87,7 @@ class ProductControllerCore extends FrontController
|
||||
*/
|
||||
if (!$this->product->isAssociatedToShop()
|
||||
|| ((!$this->product->active && ((Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct'.$this->product->id))
|
||||
|| !file_exists(dirname(__FILE__).'/../'.Tools::getValue('ad').'/ajax.php')))))
|
||||
|| !file_exists(_PS_ROOT_DIR_.'/'.Tools::getValue('ad').'/ajax.php')))))
|
||||
{
|
||||
header('HTTP/1.1 404 page not found');
|
||||
$this->errors[] = Tools::displayError('Product is no longer available.');
|
||||
|
||||
+1
-1
@@ -865,7 +865,7 @@ function showOptions(show)
|
||||
function submitAddProductAndPreview()
|
||||
{
|
||||
$('#fakeSubmitAddProductAndPreview').attr('name','submitAddProductAndPreview');
|
||||
$('#product').submit();
|
||||
$('#product_form').submit();
|
||||
}
|
||||
|
||||
function submitAddcmsAndPreview()
|
||||
|
||||
Reference in New Issue
Block a user