Results 1 to 10 of 21

Threaded View

  1. #1
    Join Date
    Dec 2005
    Location
    Cincinnati Ohio
    Posts
    1,026
    Plugin Contributions
    13

    Default 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:
    Code:
     case 'move_category_confirm':
    Add Directly Before With:
    Code:
          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'); ?>

    Code:
    <?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:
    Code:
                       <?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:
    Code:
                     <?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:
    Code:
    define('TEXT_NOEMAIL', 'No Email');
    Directly Below Add:
    Code:
    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
    Last edited by knuckle-101; 11 Nov 2012 at 09:59 PM.
    PCI Certified Web Hosting - ControlScan, Security Metrics (Platinum Partner), McAfee, TrustKeeper
    Business Class Web Hosting - Linux and cPanel Powered

 

 

Similar Threads

  1. Copy Sub Categories To Multiple Main Categories
    By InSoMnIa in forum Setting Up Categories, Products, Attributes
    Replies: 18
    Last Post: 27 Jul 2012, 10:46 AM
  2. Copy Attributes to multiple categories?
    By LRS in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 31 Aug 2011, 06:16 PM
  3. How do i copy categories?
    By lizar5- in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Sep 2007, 09:58 PM
  4. Copy product to multiple categories
    By Drake in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 3 Mar 2007, 02:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg