I want to copy categories with sub categories and add it to another categories with same mangento with different stores.

For Example:

Store One Category
      Category 1
         Sub Category 1
         Sub Category 2
      Category 2
         Sub Category 1
         Sub Category 2

Store Two Category

Now from this I want to add all Categories of Store One Category to Store Two Category without any extention.

  • Personally i am using extension for that and it works perfectly for me. – Mr. Frog Aug 4 '16 at 11:43
  • if you don't want an extension how do you expect to do it? – Marius Aug 4 '16 at 11:43
  • It can be possible using code ? – Hardik Visa Aug 4 '16 at 11:50

Here, I got solve for this question.

    require_once 'app/Mage.php';
    $categories  = Mage::getModel('catalog/category')->load('id')->getChildrenCategories(); //here id of category which you want to copy categories.

    $parentCategory = Mage::getModel('catalog/category')->load('id'); //here id of category which you want to paste categories.
    foreach ($categories as $category) 
        echo $category->getId()."<br>";
        $collection = $category->getProductCollection();
        $category = Mage::getModel('catalog/category')->load($category->getId());

        $copy = clone $category;

        foreach ($collection as $product) 
           $cate = $product->getCategoryIds();
           $cate[] = $parentCategory->getId();
           $cate[] = $copy->getId();
        echo $copy->getId()."<br>";
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.