$collections= Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('is_active',1)->addAttributeToFilter('parent_id',5)->addOrderField('position');
Tuesday, 18 February 2014
How to get all category in magento
<?php $category_model = Mage::getModel('catalog/category')->load($categoryid);
$all_child_categories = $category_model->getResource()->getAllChildren($category_model );
foreach ($all_child_categories as $child_id){
}
//===============OR=====================
$categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addIsActiveFilter();
foreach($categories as $ubcat){
$catId=$ubcat->getId();
}
?>
How to get product images on magento
<?$_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();?>
<?if($_images){?>
<?$i=0; foreach($_images as $_image){ $i++;?>
<a href="#"><img src="<?=$this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(200, 130); ?>" width="200" height="130" alt="<?=$this->htmlEscape($_image->getLabel());?>" title="<?=$this->htmlEscape($_image->getLabel());?>" /></a>
<?}?>
<?}?>
<?$_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();?>
<?if($_images){?>
<?$i=0; foreach($_images as $_image){ $i++;?>
<a href="#"><img src="<?=$this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(200, 130); ?>" width="200" height="130" alt="<?=$this->htmlEscape($_image->getLabel());?>" title="<?=$this->htmlEscape($_image->getLabel());?>" /></a>
<?}?>
<?}?>
Wednesday, 12 February 2014
Create category attribute select option
<?php require_once('app/Mage.php');
Mage::app()->setCurrentStore(M age::getModel('core/store')->l oad(Mage_Core_Model_App::ADMIN _STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute = array(
'type' => 'int',
'label'=> 'Featured Category',
'input' => 'select',
'source' => 'eav/entity_attribute_source_ boolean',
'global' => Mage_Catalog_Model_Resource_ Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 0,
'group' => "General Information"
);
$installer->addAttribute(' catalog_category', 'featured_category', $attribute);
$installer->endSetup();
?>
Subscribe to:
Comments (Atom)