Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 1 votes

Skip Preview on Product Insert or Update


44 replies to this topic

#1 Chemo

  • Banned
  • 2,486 posts
  • Real Name:Bobby
  • Location:/usa/kentucky/richmond/

Posted 31 May 2005, 12:56

In admin/categories.php find this code:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
...and change it to this:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?
switch($_GET['action']){
	case 'new_product_preview':
  $onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';
  break;
	default:
  $onload = 'SetFocus();';
  break;
}
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>">
...all done.

Now on new product insert or existing product update it will skip the preview page completely (actually, auto submit instantly on page load).

Enjoy!

Bobby

#2 spr1nt

  • Community Member
  • 100 posts
  • Real Name:nick

Posted 04 June 2005, 08:53

chemo....thaaaaaank you. ive been trying to do this but with my limited php knowledge the only results ive been getting are error messages. im sure this will help many others !

#3 kitchenniche

  • Community Member
  • 431 posts
  • Real Name:Sandra
  • Location:Kelowna, Beautiful British Columbia, Canada

Posted 09 June 2005, 22:03

Great! this saves a lot of time!
HIM - Dark Light - Out on 26/09/05

#4 BTBJ

  • Community Member
  • 35 posts
  • Real Name:Laura
  • Location:Toronto, Ontario

Posted 10 June 2005, 17:02

Fabulous ... thanks a lot, love this

#5 bibleman

  • Community Member
  • 87 posts
  • Real Name:Leon
  • Location:South Carolina

Posted 23 July 2005, 22:22

Chemo, on May 31 2005, 07:56 AM, said:

In admin/categories.php find this code:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
...and change it to this:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?
switch($_GET['action']){
	case 'new_product_preview':
  $onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';
  break;
	default:
  $onload = 'SetFocus();';
  break;
}
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>">
...all done.

Now on new product insert or existing product update it will skip the preview page completely (actually, auto submit instantly on page load).

Enjoy!

Bobby

<{POST_SNAPBACK}>


Hi Bobby,

GREAT hack BUT.....

It all worked great but when you double click on a product in the products list under it's catagory then the product gets deleted!

Did anyone else experience this?
I'm having a great Day - hope you are too!

Leon

#6 yello

  • Community Member
  • 35 posts
  • Real Name:yello

Posted 24 July 2005, 03:36

bibleman, on Jul 23 2005, 10:22 PM, said:

Hi Bobby,

GREAT hack BUT.....

It all worked great but when you double click on a product in the products list under it's catagory then the product gets deleted!

Did anyone else experience this?

<{POST_SNAPBACK}>


Yep. I have the same problem

#7 PVK

  • Community Member
  • 259 posts
  • Real Name:Patrick

Posted 24 July 2005, 18:50

Hmmm this was exactly what i was searching for, but the last 2 posts are a bit worrysome, which make me a bit unsure if it is wise to implement this great modification since it is a bit scary that you can actually delete products so easy (which sooner or later is bound to happen!)



Anybody figured it out yet?

#8 Rochdalemark

  • Community Member
  • 468 posts
  • Real Name:Fred Doherty
  • Gender:Male
  • Location:Rochdale U.K

Posted 27 July 2005, 08:17

PVK, on Jul 24 2005, 06:50 PM, said:

Hmmm this was exactly what i was searching for, but the last 2 posts are a bit worrysome, which make me a bit unsure if it is wise to implement this great modification since it is a bit scary that you can actually delete products so easy (which sooner or later is bound to happen!)
Anybody figured it out yet?

<{POST_SNAPBACK}>



Anyone Fixed this yet???

#9 J0hnnyBr4v0

  • Community Member
  • 56 posts
  • Real Name:David

Posted 31 July 2005, 21:24

Rochdalemark, on Jul 27 2005, 09:17 AM, said:

Anyone Fixed this yet???

<{POST_SNAPBACK}>


Yup I also have the same problem.

Mod uninstalled.

#10 pulsecheck

  • Community Member
  • 28 posts
  • Real Name:Azza

Posted 01 August 2005, 03:40

I had to uninstall the mode cause I experienced the same problem

#11 rbartz

  • Community Member
  • 58 posts
  • Real Name:Richard Bartz

Posted 24 August 2005, 09:15

Here is the fix for the problem where the product is "deleted" (actually emptied of data...) when you click the product line to preview it:

Between the </head> and <body....... lines make it like this:

</head>
<?
if ($_GET['read'] != "only") {
switch($_GET['action']){
case 'new_product_preview':
$onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';
break;
case 'new_master_preview':
$onload = isset($_GET['pID']) ? 'document.update_master.submit();' : 'document.insert_master.submit();';
break;
default:
$onload = 'SetFocus();';
break;
}
} else {
$onload = 'SetFocus();';
}
?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="<? echo $onload; ?>">

There! You might want to change the Preview Button to Save....

SORRY about the tabbing and spacing, for some reason I cannot get the input to do it.... I edited it three times trying, I am done. duhhhhh

Edited by rbartz, 24 August 2005, 09:18.


#12 akvario

  • Community Member
  • 28 posts
  • Real Name:yngve
  • Gender:Male
  • Location:Norway

Posted 25 November 2007, 18:22

Thanks, just what i was looking for, confirmed working.

#13 qiang

  • Community Member
  • 8 posts
  • Real Name:qiang

Posted 15 March 2008, 17:02

Thank you so much, it works!!!

#14 melhaa

  • Community Member
  • 113 posts
  • Real Name:melhaa

Posted 23 March 2008, 12:16

Hi
I really want this, but I already have an onload in my body from ajax attribute manager.
Any idea how to get this anyway?

#15 Stevio

  • Community Member
  • 10 posts
  • Real Name:Stevio

Posted 24 June 2008, 15:41

View Postmelhaa, on Mar 23 2008, 02:16 PM, said:

Hi
I really want this, but I already have an onload in my body from ajax attribute manager.
Any idea how to get this anyway?

You can use this (if you're using rbartz fix):

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="goOnLoad();<? echo $onload; ?>">

#16 lviera

  • Community Member
  • 11 posts
  • Real Name:Lo Viera

Posted 05 July 2008, 23:30

I added this code to my file but I still have to preview the items then update.
Here is what my code looks like now. Do you see anything missing?
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<?
if ($_GET['read'] != "only") {switch($_GET['action']){case 'new_product_preview':$onload = isset($_GET['pID']) ? 'document.update_product.submit();' : 'document.insert_product.submit();';break;case 'new_master_preview':$onload = isset($_GET['pID']) ? 'document.update_master.submit();' : 'document.insert_master.submit();';break;default:$onload = 'SetFocus();';break;}} else {$onload = 'SetFocus();';}?>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

#17 steveinjava

  • Community Member
  • 12 posts
  • Real Name:Stephen Howells

Posted 03 December 2008, 17:00

View Postmelhaa, on Mar 23 2008, 12:16 PM, said:

Hi
I really want this, but I already have an onload in my body from ajax attribute manager.
Any idea how to get this anyway?
You can have more than one statement in an onLoad statement- Just separate them with a semicolon...HTH

#18 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 03 December 2008, 17:33

A different method I use that gives the option of instant update instead (adds a tick box)

after (18)

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

add:


 if ($_POST['instant_update'] == 'on') { 
   $products_image = new upload('products_image');
	 $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
		if ($products_image->parse() && $products_image->save()) {
		  $_POST['products_image'] = $products_image->filename;
		} else {
		  $_POST['products_image'] = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
		}
	
	 $action = 'update_product';
 }

after (596)

<tr>
			<td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
			<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>

add:

<tr>
		<td class="main" align="right">Update without preview <?php echo tep_draw_checkbox_field('instant_update', '', false); ?></td>
	  </tr>
   <tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>

simple as that!! B)
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#19 spooks

  • Community Member
  • 7,017 posts
  • Real Name:Sam
  • Gender:Male
  • Location:UK

Posted 03 December 2008, 17:57

Minor Addendum:

I missed something:

 if ($_POST['instant_update'] == 'on') { 
   $products_image = new upload('products_image');
	 $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
		if ($products_image->parse() && $products_image->save()) {
		  $_POST['products_image'] = $products_image->filename;
		} else {
		  $_POST['products_image'] = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
		}
	
	 $action = 'update_product';
}

Should be:

 if ($_POST['instant_update'] == 'on') { 
   $products_image = new upload('products_image');
	 $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
		if ($products_image->parse() && $products_image->save()) {
		  $_POST['products_image'] = $products_image->filename;
		} else {
		  $_POST['products_image'] = (isset($_POST['products_previous_image']) ? $_POST['products_previous_image'] : '');
		}
	
	$action =  (isset($_GET['pID'])) ? 'update_product' : 'insert_product';
}

Oops. :blush:
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#20 LED-Store

  • Community Member
  • 33 posts
  • Real Name:Cosmo Kramer
  • Location:Switzerland

Posted 22 December 2008, 00:27

@ spooks

Great code, better than the previous solution. But now the product_image doesnt get updated. Did anyone else get this error too?

Thanks and regards!