Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getSubCatsAction($params){
- $parentCatId = $this->getRequest()->getPost();
- $parentCat = Mage::getModel('catalog/category')->load($parentCatId['id']);
- $allChildren = $parentCat->getAllChildren();
- $allChildren = explode(',', $allChildren);
- //var_dump($allChildren);
- $subCategories = Mage::getModel('catalog/category')->getCollection()
- ->addAttributeToSelect('*')
- ->addAttributeToFilter('include_in_menu','1')
- ->addAttributeToFilter('is_active','1')
- ->addAttributeToFilter('entity_id', array('in' => $allChildren));
- $text = '<select id="search-field-sub-category" name="search-field-sub-category">';
- foreach($subCategories as $subCat){
- if($parentCatId['id'] != $subCat->getId()){
- $text.='<option value="'.$subCat->getId().'">'.$subCat->getName().'('.$subCat->getDynamicProductsCount().')'."</option>";
- }
- else if($parentCatId['id'] == $subCat->getId()){
- $text.='<option value="'.$subCat->getId().'"> All '.$subCat->getName().' ('.$subCat->getDynamicProductsCount().')'."</option>";
- }
- }
- $text.= '</select>';
- $this->getResponse()->setHeader('Content-type', 'application/json',true);
- $this->getResponse()->setBody(json_encode($text));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement