Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

restructuring categories
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

hi,

i have an annoying problem:
when i would like to move one of my subcategories to an another category, the new parent category does not show the products which are in the child categories.
I have checked the http://demo-admin.magentocommerce.com/index.php/admin/catalog_category/index/key/a830d2e9df9b32f58a3a1fe0753b6cd1/.

and here it works. i have the same version of magento.

also, if I add a new product, and i select the categories, i select only the subcategories, and magento should automatically select the parent categories right? but it does not select..

what could be the problem?

thanks, szotyi

 
Magento Community Magento Community
Magento Community
Magento Community
 
FreakshowMfg
Jr. Member
 
Total Posts:  15
Joined:  2009-12-20
 

You will need to select the parent category as well.

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

ok here is the solution for my second problem:
if you want magento to automatically select the parent categories also in the manage products - categories tab:
app/code/core/Mage/Catalog/Model/Product.php
find: public function setCategoryIds (around line 293)
replace with

public function setCategoryIds($ids)
    
{
      
global $categoryTree;
      
        if (!
is_array($categoryTree)) {
          $categoryTree 
= array();
          
$category Mage::getModel('catalog/category');
          
$categoryCollection $category->getCollection();

          foreach(
$categoryCollection as $category{
             $categoryTree[$category
->getId()str_replace('/'','$category->getPath()).',';
          
}
        }

        
        
if (is_string($ids)) {
            $categoryIDs 
'';
            
$ids explode(','$ids);
            foreach (
$ids as $catID{
                
if (array_key_exists($catID$categoryTree)) {
                    $categoryIDs 
.= $categoryTree[$catID];
                
else {
                    $categoryIDs 
.= $catID.',';
                
}
                   
            }
            $categoryIDs 
substr($categoryIDs0, -1);
            
$categoryIDs array_unique(explode(','$categoryIDs));
            
            
$ids '';
            foreach (
$categoryIDs as $catId{
                
if ($catId != 1$ids .= $catId','// 1 is the ID of the ROOT category
            
}
            $ids 
substr($ids0, -1);     

            
$ids explode(','$ids);
        
elseif (!is_array($ids)) {
            Mage
::throwException(Mage::helper('catalog')->__('Invalid category IDs'));
        
}
        
foreach ($ids as $i=>$v{
            
if (empty($v)) {
                
unset($ids[$i]);
            
}
        }
        $this
->setData('category_ids'$ids);
        return 
$this;
    
}

i am still working on the other problem if i move the category to an another category..

 
Magento Community Magento Community
Magento Community
Magento Community
 
szotyi
Sr. Member
 
Total Posts:  153
Joined:  2008-11-29
 

solution: http://www.magentocommerce.com/boards/viewthread/72579/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top