// fix product live preview and duplication

This commit is contained in:
tDidierjean
2011-11-23 18:33:11 +00:00
parent 472fbc4628
commit d529b8a9ed
6 changed files with 16 additions and 17 deletions
+3 -3
View File
@@ -432,9 +432,9 @@ if (Tools::getValue('submitPublishProduct'))
if (Tools::getIsset('id_product')) if (Tools::getIsset('id_product'))
{ {
$id_product = (int)(Tools::getValue('id_product')); $id_product = (int)(Tools::getValue('id_product'));
$id_tab_catalog = (int)(Tab::getIdFromClassName('AdminCatalog')); $id_tab_catalog = (int)(Tab::getIdFromClassName('AdminProducts'));
$token = Tools::getAdminToken('AdminCatalog'.(int)($id_tab_catalog).(int)$context->employee->id); $token = Tools::getAdminToken('AdminProducts'.(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; $bo_product_url = dirname($_SERVER['PHP_SELF']).'/index.php?tab=AdminProducts&id_product='.$id_product.'&updateproduct&token='.$token;
if (Tools::getValue('redirect')) if (Tools::getValue('redirect'))
die($bo_product_url); die($bo_product_url);
+1 -1
View File
@@ -268,7 +268,7 @@ $(document).ready(function(){
<div class="warn draft" > <div class="warn draft" >
<p> <p>
<span style="float: left"> <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> <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" /> <input type="hidden" name="fakeSubmitAddProductAndPreview" id="fakeSubmitAddProductAndPreview" />
<br /> <br />
@@ -138,7 +138,7 @@
{l s='Enabled'}</label> {l s='Enabled'}</label>
<br class="clear" /> <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} /> <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> </td>
</tr> </tr>
{if $feature_shop_active} {if $feature_shop_active}
@@ -1288,13 +1288,15 @@ class AdminProductsControllerCore extends AdminController
$preview_url .= 'adtoken='.$token.'&ad='.$admin_dir; $preview_url .= 'adtoken='.$token.'&ad='.$admin_dir;
} }
$this->redirect_after = $preview_url; $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')) 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); $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) // 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); $this->redirect_after = self::$currentIndex.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&conf=4&token='.($token ? $token : $this->token);
}
} }
} }
else else
@@ -1595,8 +1597,6 @@ class AdminProductsControllerCore extends AdminController
if (empty($this->action)) if (empty($this->action))
$this->action = 'Informations'; $this->action = 'Informations';
if(method_exists($this, 'initForm'.$this->action)) if(method_exists($this, 'initForm'.$this->action))
$this->tpl_form = 'products/'.strtolower($this->action).'.tpl'; $this->tpl_form = 'products/'.strtolower($this->action).'.tpl';
@@ -1779,7 +1779,6 @@ class AdminProductsControllerCore extends AdminController
$content = '<div class="warn draft" style="'.($active ? 'display:none' : '').'"> $content = '<div class="warn draft" style="'.($active ? 'display:none' : '').'">
<p> <p>
<span style="float: left"> <span style="float: left">
<img src="../img/admin/warn2.png" />
'.$this->l('Your product will be saved as draft').' '.$this->l('Your product will be saved as draft').'
</span> </span>
<span style="float:right"><a href="#" class="button" style="display: block" onclick="submitAddProductAndPreview()" >'.$this->l('Save and preview').'</a></span> <span style="float:right"><a href="#" class="button" style="display: block" onclick="submitAddProductAndPreview()" >'.$this->l('Save and preview').'</a></span>
+1 -1
View File
@@ -87,7 +87,7 @@ class ProductControllerCore extends FrontController
*/ */
if (!$this->product->isAssociatedToShop() if (!$this->product->isAssociatedToShop()
|| ((!$this->product->active && ((Tools::getValue('adtoken') != Tools::encrypt('PreviewProduct'.$this->product->id)) || ((!$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'); header('HTTP/1.1 404 page not found');
$this->errors[] = Tools::displayError('Product is no longer available.'); $this->errors[] = Tools::displayError('Product is no longer available.');
+1 -1
View File
@@ -865,7 +865,7 @@ function showOptions(show)
function submitAddProductAndPreview() function submitAddProductAndPreview()
{ {
$('#fakeSubmitAddProductAndPreview').attr('name','submitAddProductAndPreview'); $('#fakeSubmitAddProductAndPreview').attr('name','submitAddProductAndPreview');
$('#product').submit(); $('#product_form').submit();
} }
function submitAddcmsAndPreview() function submitAddcmsAndPreview()