Tuesday, 26 May 2015

Create custom category attribute in magento

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_category', 'category_color', array(
'group' => 'General',
'input' => 'select', //type of attribute here
'type' => 'varchar',
'label' => 'Show On Home',
'option' => array ('value' => array('optionone'=>array(0=>'No'),'optiontwo'=>array(0=>'Yes'))),
'backend' => 'eav/entity_attribute_backend_array',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
$installer->endSetup();

How to Get Product details Using Product Id in Magento

If you got the product id then you can get details of a product by using the following method in magento.

$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id); // Enter your Product Id in $product_id
// get Product's name
echo $_product->getName();
//get product's short description
echo $_product->getShortDescription();
//get Product's Long Description
echo $_product->getDescription();
//get Product's Regular Price
echo $_product->getPrice();
//get Product's Special price
echo $_product->getSpecialPrice();
//get Product's Url
echo $_product->getProductUrl();
//get Product's image Url
echo $_product->getImageUrl();


about new GraphQL freature in Magento2

GraphQL: GraphQL is a data query language developed internally by Facebook in 2012 before being publicly released in 2015. Magento impleme...