$product = new Varien_Object(); $product->setData('sku', '12345'); $product->setData('name', 'Test Product'); $product->setData('price', '10.00'); echo $product->getData('sku'); // outputs 12345 echo $product->getData('name'); // outputs Test Product echo $product->getData('price'); // outputs 10.00
class My_Object extends Varien_Object { public function getFullName() { return $this->getData('first_name') . ' ' . $this->getData('last_name'); } } $user = new My_Object(); $user->setData('first_name', 'John'); $user->setData('last_name', 'Doe'); echo $user->getFullName(); // outputs John DoeThis example extends the Varien_Object class and adds a custom method getFullName, which returns the first name and last name combined. Then it creates a new instance of this class and sets some data. The package library used in Magento is Magento_Core.