Zen Cart Logo
Forums / All Other Contributions/Addons / Copy Categories 1.6

Copy Categories 1.6

Views: 5,481

Results 1 to 20 of 21
11 Nov 2012, 8:54 PM
#1
knuckle_101 avatar

knuckle_101

Totally Zenned

Join Date:
Dec 2005
Location:
Cincinnati Ohio
Posts:
1,034
Plugin Contributions:
3

Copy Categories 1.6

Copy Categories 1.6 Support Thread. For Zencart 1.5.x

What is "Copy Categories"?

Copy Categories is exactly what its name says, Zen Cart's default category management does not have a "Category Copy Option". Now there is.
This allows the store owner or managers to copy categories to where needed. If a store owner has thousands of categories or sub categories then it can be very time consuming to move or type in new ones one by one. With "Copy Categories" this terminates the the manual moving or creating new categories.

File Edits Required: BACKUP FIRST
YOUR_ADMIN/categories.php
YOUR_ADMIN/includes/modules/category_product_listing.php
YOUR_ADMIN_includes/languages/english.php (Forgot To Add language Instructions in contribution. Once approved I will update the contribution and instructions)

Down Load Link:
Currently Under Review

In the mean time:
Edit /YOUR_ADMIN/categories.php (Fresh Unedited Copy)

Find:

 case 'move_category_confirm':

Add Directly Before With:

      case 'copy_category_confirm':        
      if (isset($_POST['categories_id']) && ($_POST['categories_id'] != $_POST['copy_to_category_id'])) {
        $categories_id = zen_db_prepare_input($_POST['categories_id']);
        $new_parent_id = zen_db_prepare_input($_POST['copy_to_category_id']);
        _copy_categories_tree($categories_id, $new_parent_id);
        zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id));
      } else {
        $messageStack->add_session(ERROR_CANNOT_COPY_CATEGORY_TO_CATEGORY_SELF . $cPath, 'error');
        zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
      }
      break;

**At the end of the categories.php file add the following right after

</html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> ** ``` <?php /** * The function recursively copies the given category and its descriptions in all languages * @param $categories_id category to copy * @param $new_parent_id destination category (it will be parent category) * */ function _copy_categories_tree($categories_id, $new_parent_id){ global $db; $db->Execute(" INSERT INTO ".TABLE_CATEGORIES." (categories_image, parent_id, sort_order, date_added, last_modified, categories_status) SELECT categories_image, '{$new_parent_id}' AS parent_id, sort_order, NOW() AS date_added, NOW() AS last_modified, categories_status FROM ".TABLE_CATEGORIES." WHERE categories_id = '{$categories_id}' "); $copy_id = zen_db_insert_id(); $db->Execute(" INSERT INTO ".TABLE_CATEGORIES_DESCRIPTION." (categories_id, language_id, categories_name, categories_description) SELECT '{$copy_id}' AS categories_id, language_id, categories_name, categories_description FROM ".TABLE_CATEGORIES_DESCRIPTION." WHERE categories_id = '{$categories_id}' "); $childs = $db->Execute("SELECT categories_id FROM ".TABLE_CATEGORIES." WHERE parent_id = '{$categories_id}'"); $childids = array(); while(!$childs->EOF){ $childids[] = $childs->fields['categories_id']; $childs->MoveNext(); } foreach($childids as $child){ _copy_categories_tree($child, $copy_id); } }

?>


Then edit YOUR_ADMIN/includes/modules/category_product_listing.php

**Find:**
               <?php echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories->fields['categories_id'] . '&action=move_category') . '">' . zen_image(DIR_WS_IMAGES . 'icon_move.gif', ICON_MOVE) . '</a>'; ?>

**Directly Below Add:**
             <?php echo '<a href="' . zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories->fields['categories_id'] . '&action=copy_category') . '">' . zen_image(DIR_WS_IMAGES . 'icon_copy_to.gif', ICON_COPY_TO) . '</a>'; ?>   

Language Files: (Forgot To Add langauge Instructions in contribution. Once approved I will update the contribution and instructions)

**Edit YOUR_ADMIN/includes/languages/english.php**

**Find:**

define('TEXT_NOEMAIL', 'No Email');


**Directly Below Add:**

define('TEXT_COPY', 'Copy Category To:');


Once completed log into your Shop Admin go to Catalog => Categories / Products, to your right beside the "Move" icon there should be a copy icon beside it.

Enjoy!!

Like to donate to this do so by going here <http://www.zen-cart.com/content.php?6-donate>
19 Nov 2012, 2:49 PM
#2
sports_guy avatar

sports_guy

Totally Zenned

Join Date:
Apr 2007
Location:
Dayton, Ohio
Posts:
682
Plugin Contributions:
0

Re: Copy Categories 1.6

Knuckle-101,

This mod is much needed for me, but I have one issue. Do you have a version that has copy category and then the "link to" option shows (like in the product copy to button)? Thereby allows us to link the whole category and associated products into the new location?

The reason I ask is I do have many products as well, but I would like to nest existing categories into others via the link function instead of copy to function. So with the current plugin, I can copy all folders to another area (beautiful), but then I also need to link every existing product into these categories from the original categories. And worry about each update matching for both categories. Opening another can of worms.

19 Nov 2012, 4:46 PM
#3
knuckle_101 avatar

knuckle_101

Totally Zenned

Join Date:
Dec 2005
Location:
Cincinnati Ohio
Posts:
1,034
Plugin Contributions:
3

Re: Copy Categories 1.6

sports guy:

Knuckle-101,

This mod is much needed for me, but I have one issue. Do you have a version that has copy category and then the "link to" option shows (like in the product copy to button)? Thereby allows us to link the whole category and associated products into the new location?

The reason I ask is I do have many products as well, but I would like to nest existing categories into others via the link function instead of copy to function. So with the current plugin, I can copy all folders to another area (beautiful), but then I also need to link every existing product into these categories from the original categories. And worry about each update matching for both categories. Opening another can of worms.

You are right about opening another can worms. What your asking for would be a little more extensive requirement of development. But I do not think that it would be a good idea for stability to link categories or categories with products in them to get the products linked to your new category. First it would cause a string of confusion within the code and most likely be a larger mess then just copy the categories themselves. As you notice by default you cannot put categories into a category loaded with products. This system would most likely need by-passed just to link the products over when copied and with that it could and most likely would cause chaos with your products or possible scatter them through out the database or even delete the products entirely causing a bigger mess.

This modification was first created by a blogger cannot recall the name and we just ported it into 1.5.x for a customer. I was aware others asked for such modification through out the Zencart forums so after we ported it into 1.5.x I posted it on the forums hoping to at least help others. As for future modifications none is planned right now but who knows it could progress in time. Never know the Zencart dev team may do something first with future releases of ZenCart. :)

19 Nov 2012, 5:26 PM
#4
knuckle_101 avatar

knuckle_101

Totally Zenned

Join Date:
Dec 2005
Location:
Cincinnati Ohio
Posts:
1,034
Plugin Contributions:
3

Re: Copy Categories 1.6

I put the think cap on for you and remembered a thread about multiple product copying you can visit the main thread here and the download file by Ajeh here. It may or may not work with your version but it is a start to copy multiple products but the linking is still in question. Hope that helps.

19 Nov 2012, 6:28 PM
#5
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

For those looking to do multiple copying, duplicating of products, linking to lots of categories stuff, these are also of great use:

http://www.zen-cart.com/showthread.php?172698-Multiple-Categories-Link-Manager-Sorted

http://www.zen-cart.com/showthread.php?180447-Multiple-Products-%28Copy-Move-Delete%29

It would be nice if all these functionalities were combined in one management page one day...

19 Nov 2012, 6:37 PM
#6
knuckle_101 avatar

knuckle_101

Totally Zenned

Join Date:
Dec 2005
Location:
Cincinnati Ohio
Posts:
1,034
Plugin Contributions:
3

Re: Copy Categories 1.6

torvista:

For those looking to do multiple copying, duplicating of products, linking to lots of categories stuff, these are also of great use:

http://www.zen-cart.com/showthread.php?172698-Multiple-Categories-Link-Manager-Sorted

http://www.zen-cart.com/showthread.php?180447-Multiple-Products-%28Copy-Move-Delete%29

It would be nice if all these functionalities were combined in one management page one day...

I do not believe this one http://www.zen-cart.com/showthread.p...Manager-Sorted will work friendly with the modification of this thread. Exceed extreme caution if trying to combine them. I may look it over and see what can be done.. No promises anytime soon though..

19 Nov 2012, 7:16 PM
#7
knuckle_101 avatar

knuckle_101

Totally Zenned

Join Date:
Dec 2005
Location:
Cincinnati Ohio
Posts:
1,034
Plugin Contributions:
3

Re: Copy Categories 1.6

oops. wrong thread..

8 Jan 2013, 10:08 PM
#8
knuckle_101 avatar

knuckle_101

Totally Zenned

Join Date:
Dec 2005
Location:
Cincinnati Ohio
Posts:
1,034
Plugin Contributions:
3

Re: Copy Categories 1.6

Down Load Link (Update):
Download Fileset here http://www.zen-cart.com/downloads.php?do=file&id=1549

**Functionality Not Mentioned Inside Instruction Document: **Products within the categories are also copied by default. When copying your categories all products within them are also copied over to the new category.

Enjoy!!

Like to donate to this do so by going here http://www.zen-cart.com/content.php?6-donate

26 Oct 2021, 8:00 PM
#9
travbacon avatar

travbacon

Zen Follower

Join Date:
Mar 2015
Posts:
169
Plugin Contributions:
0

Re: Copy Categories 1.6

this was an awesome mod. will it be updated?

26 Oct 2021, 9:08 PM
#10
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

What was the key feature of this you are missing now?

26 Oct 2021, 9:09 PM
#11
travbacon avatar

travbacon

Zen Follower

Join Date:
Mar 2015
Posts:
169
Plugin Contributions:
0

Re: Copy Categories 1.6

torvista:

What was the key feature of this you are missing now?

The coding to change is not updated for 1.5.7c as far as I can tell?

26 Oct 2021, 9:12 PM
#12
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

I have no idea about this mod, hence I asked what functionality you are looking for....maybe it is already available elsewhere.

26 Oct 2021, 9:14 PM
#13
travbacon avatar

travbacon

Zen Follower

Join Date:
Mar 2015
Posts:
169
Plugin Contributions:
0

Re: Copy Categories 1.6

torvista:

I have no idea about this mod, hence I asked what functionality you are looking for....maybe it is already available elsewhere.

It's not available else where as I looked. The functionality is pretty much self explanatory, it allows you to copy categories, it's a pretty cool function, not sure why it's not in the ZC release as standard. Thanks.

27 Oct 2021, 2:33 PM
#14
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

The functionality is pretty much self explanatory, it allows you to copy categories
You mean to say you want to copy the linked products and duplicate the master products into a new category with one action.
That could be useful for many people.

Meanwhile, you can copy products with this:
https://www.zen-cart.com/showthread.php?180447-Multiple-Products-%28Copy-Move-Delete%29

from
https://github.com/torvista/Zen_Cart-Multiple_Products_Copy_Move_Delete

27 Oct 2021, 6:34 PM
#15
travbacon avatar

travbacon

Zen Follower

Join Date:
Mar 2015
Posts:
169
Plugin Contributions:
0

Re: Copy Categories 1.6

thanks, I know about this mod and already have it installed. This does not copy categories

8 Feb 2022, 6:23 PM
#16
rmcp avatar

rmcp

New Zenner

Join Date:
Dec 2007
Posts:
8
Plugin Contributions:
0

Re: Copy Categories 1.6

Hi folks
I was using copy categories only for the category name and description, we sell motorcycle parts so we made category as motorcycle model with info, I used it a lot and am sad its not working anymore, that is i does not work in my 1.56 version with fluorspar. it f.... up de whole cart.

hopefully someone can make another similar , I dont need to copy the content of the category.
Gracias

30 Nov 2022, 10:40 PM
#18
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

OK, early adopters, get your all-new Copy Categories here:

https://github.com/torvista/Zen_Cart-Copy_Categories/tree/zc158

Note only in the zc158 branch for the moment.

No core files modified, multi-language, optionally copies products (as linked) too.

Only tested with Zen Cart 158 but should work on earlier versions given the three notifiers used are implemented as in the example file.

This is an alpha version strictly for testing on a development server only. If you bork your real shop with this alpha code, you were warned/keep it to yourself.

Please report any surprises on Github.

Thanks

15 Jan 2023, 10:59 PM
#19
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

No news is good news, so version 2.0 is available here:

https://github.com/torvista/Zen_Cart-Copy_Categories

Admin: add this Github link to the plugin page please.

23 Feb 2023, 12:51 PM
#20
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,873
Plugin Contributions:
7

Re: Copy Categories 1.6

Bump to link this thread to the plugin and add the Github link.