RSS

Monthly Archives: July 2015

Magento: How to get attribute name and value?

/**
* get attribute collection
*/
$attribute = $_product->getResource()->getAttribute(‘my_attribute’);
/**
* get attribute type
*/
$attribute->getAttributeType();
/**
* get attribute Label
*/
$attribute->getFrontendLabel();
/**
* get attribute default value
*/
$attribute->getDefaultValue();
/**
* check if the attribute is visible
*/
$attribute->getIsVisible();
/**
* check if the attribute is required
*/
$attribute->getIsRequired();
/**
* get attribute value
*/
$attributeValue = Mage::getModel(‘catalog/product’)->load($_product->getId())->getMyAttribute();

 

Get value from a select box attribute

The attribute code is supposed to be ‘my_attribute

Load any particular attribute by attribute code

Get all option value list for the particular attribute

You can see above that I got attribute information by attribute code. My attribute information is stored as $attributeInfo. See code above.

Here is the code to get all option values for my attribute $attributeInfo.

Get all options of any attribute

Getting all options of attribute with attribute-code “color“.

Get attribute’s option information by option id

I have my attribute as $attributeInfo.
I have my attribute’s option value array as $attributeOptions.
See code above.

Suppose, I want to get detail information of any option listed in strong>$attributeOptions array. Here is the code to do so:-

Get attribute of particular entity type

Here, I am going to get information about ‘order_id‘ attribute of ‘invoice‘ entity type.

Get attribute options of Configurable product

Hope this helps. Thanks.

soruce From:http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/

 
Leave a comment

Posted by on July 2, 2015 in magento

 

Disable HTML Right-click, Copy & Paste using Javascript

//below javascript is used for Disabling right-click on HTML page
document.oncontextmenu=new Function(“return false”);//Disabling right-click

//below javascript is used for Disabling text selection in web page
document.onselectstart=new Function (“return false”); //Disabling text selection in web page
if (window.sidebar){
document.onmousedown=new Function(“return false”);
document.onclick=new Function(“return true”) ;

//Disable Cut into HTML form using Javascript
document.oncut=new Function(“return false”);

//Disable Copy into HTML form using Javascript
document.oncopy=new Function(“return false”);

//Disable Paste into HTML form using Javascript
document.onpaste=new Function(“return false”);
}

http://teqsnacks.com/2014/01/27/disable-html-copy-paste-javascript/
http://www.ondeweb.in/disable-right-click-and-copy-paste-using-javascript/

 
Leave a comment

Posted by on July 2, 2015 in Javascript