| Data Accessing Methods from Within Various Scopes |
joomla template, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart, mootools, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart, jQuery, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart, mootools, virtuemart, phpBB styles, virtuemart, drupal theme, virtuemart, phpBB styles, virtuemart
Introduction
This ongoing article is meant to be a reference for basic data-fetching tasks in the Mage environment as well as a learn-by-example tutorial. Please add to it as you can...
Accessing a Product in the Cart
Current Scope:
An extension of Mage_Payment_Model_Method_Abstract (payment module Model) or anywhere with an getOrder() method
Desired Entity:
Mage_Catalog_Model_Product of an item in the cart
Code:
Gets the Mage_Catalog_Model_Product of the first item in the cart...
Notes:
An “item” is another class altogether and lacks methods for returning a product or accessing things like custom product attributes.
Accessing the Value of a Product's Custom Attribute
Current Scope:
Mage_Catalog_Model_Product
Desired Entity:
Value of a product’s custom attribute as set by an administrator in the backend
Code:
Notes:
Mage implements dynamic methods for its (custom) attributes. There are four methods you can use for an attribute: get, set, uns (unset), and has. (see lib/Varien/Object.php, __call() method) To use them, just add the action to the attribute code. For example, using the code “my_attribute_code” - which becomes “MyAttributeCode”, you can call:
Accessing the Text of a Custom Attribute's Dropdown
Current Scope:
Anywhere
Desired Entity:
Text of a dropdown option selected by an administrator for a custom product or category attribute (i.e. “Text” in Text)
Code:
Notes:
Magento assigns enumerated integers for an attribute’s dropdown/select box’s values depending on how many options there are in total and what order they are in on the page, i.e. its a bit arbitrary as the value assigned to each option depends on what order you created the custom attributes. Use this code to get the literal value displayed to the admin user.
Recommended Web Hosting For Bloggers and Designers
I recoomended Webhostings for Bloggers and Designers because I am freelancer, working with thousand clients in the worlds. Most of them will use those hosts.
Hostting Features:
- Fast, Reliable, Affordable
- 100% Satisfaction Guarantee
- And More...

