$data = array( 'name' => 'John', 'age' => 25, 'email' => 'john@example.com' ); $obj = new Varien_Object($data); echo $obj->getData('name'); // Output: John echo $obj->getData('age'); // Output: 25 echo $obj->getData('email'); // Output: john@example.com
$product = Mage::getModel('catalog/product')->load($productId); echo $product->getData('name'); // Output: Product Name echo $product->getData('price'); // Output: 10.99 echo $product->getData('status'); // Output: 1In this example, we load a Magento product model using the getModel() method and specifying the 'catalog/product' model. We then use the getData() method to retrieve and output the product name, price, and status. Both examples use the Varien_Object class from the Magento library.