Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / go back to 1st page after deleting a product in the categories/products

go back to 1st page after deleting a product in the categories/products

5 Jan 2016, 3:31 PM
#1
sungmo avatar

sungmo

New Zenner

Join Date:
Jan 2010
Posts:
79
Plugin Contributions:
0

Post #1 by sungmo

I have almost 500 products.

so sometimes I need to delete some products.

Let's Imagine that the products are located 5th page.

so if I delete one of them located 5th page, it goes back to 1st page.

and then I need to click 5th page to remove other products.

there is a solution to solve this problem?

thank you guys...

5 Jan 2016, 8:14 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #2 by mc12345678

sungmo:

I have almost 500 products.

so sometimes I need to delete some products.

Let's Imagine that the products are located 5th page.

so if I delete one of them located 5th page, it goes back to 1st page.

and then I need to click 5th page to remove other products.

there is a solution to solve this problem?

thank you guys...

If the file has not been modified, then if you go to line 367 (ZC 1.5.1) and change:

        <?php echo '<a href="' . zen_href_link($type_handler, 'cPath=' . $cPath . '&product_type=' . $products->fields['products_type'] . '&pID=' . $products->fields['products_id'] . '&action=delete_product') . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>
        <?php echo '<a href="' . zen_href_link($type_handler, 'cPath=' . $cPath . '&product_type=' . $products->fields['products_type'] . '&pID=' . $products->fields['products_id'] . '&action=delete_product' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>

You will get the desired result.

If this is something that you need to do en masse, may I suggest possibly a "faster" tool such as EasyPopulate V4 or some other mass management product.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jan 2016, 5:57 PM
#3
sungmo avatar

sungmo

New Zenner

Join Date:
Jan 2010
Posts:
79
Plugin Contributions:
0

Post #3 by sungmo

mc12345678:

If the file has not been modified, then if you go to line 367 (ZC 1.5.1) and change:

    <?php echo '<a href="' . zen_href_link($type_handler, 'cPath=' . $cPath . '&product_type=' . $products->fields['products_type'] . '&pID=' . $products->fields['products_id'] . '&action=delete_product') . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>
> ```
        <?php echo '<a href="' . zen_href_link($type_handler, 'cPath=' . $cPath . '&product_type=' . $products->fields['products_type'] . '&pID=' . $products->fields['products_id'] . '&action=delete_product' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>

You will get the desired result.

If this is something that you need to do en masse, may I suggest possibly a "faster" tool such as EasyPopulate V4 or some other mass management product.

Hi mc12345678

thank you for your answer...

but which file do I need to edit?

can you answer me again?

thank you and have a good one...

6 Jan 2016, 6:11 PM
#4
sungmo avatar

sungmo

New Zenner

Join Date:
Jan 2010
Posts:
79
Plugin Contributions:
0

Post #4 by sungmo

Hi mc12345678

I found the file.

/admin/panicroom/includes/modules/category_product_listing.php

and then I replaced it with your code but result is same.

<?php echo '<a href="' . zen_href_link($type_handler, 'cPath=' . $cPath . '&product_type=' . $products->fields['products_type'] . '&pID=' . $products->fields['products_id'] . '&action=delete_product' . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')) . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>

after deleting a product located 5th, it goes to 1st page again...

can you check it for me?

thank you and have a good one...

6 Jan 2016, 7:36 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #5 by mc12345678

Filename I had was:**admin/includes/modules/category_product_listing.php.

**So I didn't use the option, I only saw that it was in the URI and appeared that it would carry through the transaction. If you hover over the X button, you do see the page=5 for example in the popup uri, correct?

Sorry I had forgotten to include the filename in my previous post. Somewhat knew there was something missing. :)

I'll create and delete a product with that code included to see what's going on.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jan 2016, 7:57 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #6 by mc12345678

Apparently there was more bouncing of the ball after that first "delete".

So.. Open: admin/includes/modules/delete_product_confirm.php

And find the below or similar at line 67:

  if ($action == 'delete_product_confirm')  zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

make it look like this or similar:

  if ($action == 'delete_product_confirm') zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')  ));

Should also look in each of the folders related to product type to see if there is a file with the same name and if so, if it includes the above line/can be updated as provided. The $_GET statement above is in no way filtered, but that is the case as provided in the admin of ZC, so not sure if additional filtering should be applied or if fine as is... Definitely wouldn't handle that the same on the store front side...

Anyways, happy deleting! :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Jan 2016, 8:33 PM
#7
sungmo avatar

sungmo

New Zenner

Join Date:
Jan 2010
Posts:
79
Plugin Contributions:
0

Post #7 by sungmo

Hi mc12345678

thank you so much...~~~~~ ^^;

you solved this problem..

I appreciated it again...

have a good one :)

7 Jan 2016, 8:03 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #8 by mc12345678

sungmo:

Hi mc12345678

thank you so much...~~~~~ ^^;

you solved this problem..

I appreciated it again...

have a good one :)

Glad it worked for you. :) Not entirely sure/don't remember how the system responds if that product will be the last product on that page before deletion, but my guess is that it will go back to the "new" last page.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jan 2016, 8:14 PM
#9
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Heerenveen, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Post #9 by design75

mc12345678:

Glad it worked for you. :) Not entirely sure/don't remember how the system responds if that product will be the last product on that page before deletion, but my guess is that it will go back to the "new" last page.
It goes back to the first page, since $_GET['page'] is a non existing value.

7 Jan 2016, 8:58 PM
#10
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #10 by mc12345678

Design75:

It goes back to the first page, since $_GET['page'] is a non existing value.

Just ran a "test" on an admin screen where there were more than one page, if the group only had 2 pages, I changed to the second page, then came back to the first and the uri had &page=1 in it, I then entered &page=4 or any number larger than the number of pages and the result was to come back to the last page of the listing... So not sure why the $_GET['page'] would be considered a non-existing value.

Tried the page parameter on ZC 1.5.1 and 1.5.4 both providing the same result, if the page parameter is present in the uri then a page number greater than the maximum results in providing the maximum available page number.

Sure I could have done that test before posting what my thoughts were, but does show the level of detail put into the program to provide a logical response rather than just go Pbbbbtttt. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...