<?php
$attribute = Mage::getModel(‘eav/config’)->getAttribute(‘catalog_product’, ‘color’);
foreach ($attribute->getSource()->getAllOptions(true) as $option) {
echo $option[‘label’] . ‘ ‘ . $option[‘value’] . “<br />”;
}
?>
Monthly Archives: March 2013
Get configurable products attributes Magento
<?php
$obj = Mage::getModel(‘catalog/product’);
$_product = $obj->load(19);
$configurableAttributeCollection=$_product->getTypeInstance()->getConfigurableAttributes();
foreach($configurableAttributeCollection as $attribute){
echo “Attr-Code:”.$attribute->getProductAttribute()->getAttributeCode() .” – “;
echo “Attr-Label:”.$attribute->getProductAttribute()->getFrontend()->getLabel().” – “;
echo “Attr-Id:”.$attribute->getProductAttribute()->getId().” <br /> “;
}
?>
Set Limit For Collection Magento
Use ->setPageSize($limit)
svn command revert changes
svn revert PATH...
Validate us zip code Javascript
var isValidZip = /(^d{5}$)|(^d{5}-d{4}$)/.test(zip);
if(isValidZip==false)
alert(“Invalid zip”);
How to get the page identifier – Magento
echo $currentPage = Mage::getBlockSingleton(‘cms/page’)->getPage()->getIdentifier();
Get the CMS page id of a particular page in Magento
echo $currentPageId =$this->getRequest()->getParam(‘page_id’);
Get Category Name From Category Id Magento
$mainCategory = Mage::getModel(‘catalog/category’)->load($categoryId);
$mainCategoryName = $mainCategory->getName();
Product collection with limit Magento
$productCollection = Mage::getResourceModel(‘catalog/product_collection’)
->addCategoryFilter($_category)
->addAttributeToSelect(‘*’)
->setPageSize(5);
$productCollection->load();
Magento subcategories list filtered by category name
$collection = Mage::getModel(‘catalog/category’)->getCollection()
->addFieldToFilter(‘name’,array(‘like’ => ‘%New Arrivals%’))
->addFieldToFilter(‘parent_id’, array(‘eq’=>$categoryId ))
->load();
foreach ($collection as $category):
echo $category->getName();
endforeach;