2
Mage_Sales_Model_Quote_Item Object ( [_eventPrefix:protected] => sales_quote_item [_eventObject:protected] => item [_quote:protected] => Mage_Sales_Model_Quote Object ( [_eventPrefix:protected] => sales_quote [_eventObject:protected] => quote [_cacheTag:protected] => quote [_customer:protected] => Mage_Customer_Model_Customer Object ( [_eventPrefix:protected] => customer [_eventObject:protected] => customer [_errors:protected] => Array ( ) [_attributes:protected] => [_addresses:protected] => [_addressesCollection:protected] => [_isDeleteable:protected] => 1 [_isReadonly:protected] => [_cacheTag:protected] => customer [_resourceName:protected] => customer/customer [_resource:protected] => [_resourceCollectionName:protected] => customer/customer_collection [_dataSaveAllowed:protected] => 1 [_isObjectNew:protected] => [_data:protected] => Array ( [website_id] => 1 [entity_id] => 2 [entity_type_id] => 1 [attribute_set_id] => 0 [email] => [email protected] [group_id] => 1 [increment_id] => [store_id] => 1 [created_at] => 2014-12-31T22:04:47-08:00 [updated_at] => 2015-01-01 06:24:25 [is_active] => 1 [disable_auto_group_change] => 0 [firstname] => Vaibhav [lastname] => Ahalpara [password_hash] => 7104e363950a3001347bfb592061ba9a:IbYSYS9uHK34kq6hZQJN3SxcGnv8MyZk [created_in] => English [default_billing] => 1 [default_shipping] => 1 [tax_class_id] => 3 ) [_hasDataChanges:protected] => 1 [_origData:protected] => Array ( [website_id] => 1 [entity_id] => 2 [entity_type_id] => 1 [attribute_set_id] => 0 [email] => [email protected] [group_id] => 1 [increment_id] => [store_id] => 1 [created_at] => 2014-12-31T22:04:47-08:00 [updated_at] => 2015-01-01 06:24:25 [is_active] => 1 [disable_auto_group_change] => 0 [firstname] => Vaibhav [lastname] => Ahalpara [password_hash] => 7104e363950a3001347bfb592061ba9a:IbYSYS9uHK34kq6hZQJN3SxcGnv8MyZk [created_in] =>

how can i get value of attribute like

[lastname] => Ahalpara

how can i echo value of [lastname]

2

3 Answers 3

0

You can get customer first name and last name only when your quote have Mage_Sales_Quote_Address.If Mage_Sales_Quote_Address Object have Customer first name last name then you can get customer details,other wise you can not get customer first name last name..

in Mage_Sales_Model_Quote_Item class object is not give any Quote address object thus you can not ant direct function which is give proper customer details object

See at class Mage_Sales_Model_Quote_Item **

public function getQuote()
    {
        ....
    }

**

So ,you can get Quote object by 




$QuoteObject= $itemObject->getQuote();

After that you can get customer first ans last name. $QuoteObject->getCustomer()->getLastname();

Also you can get from Quote Billing object

$QuoteObject->getBillingAddress()->getFirstname();

But all depends on if you will goes to check step and fill customer data

1

I can't understand what you mean by only getLastname() but please try with $item->getQuote()->getCustomer()->getLastname() or directly $item->getQuote()->getCustomerLastname().

2
  • not Working..... Commented Jan 1, 2015 at 10:16
  • Would you please paste the whole code, not the var_dump.
    – michael
    Commented Jan 1, 2015 at 13:59
1
public function updatePrice( Varien_Event_Observer $observer ) 
 {
    $event = $observer->getEvent();
    $quote_item = $event->getQuoteItem();
    $product_id=$quote_item->getProduct_id();
    $_product=Mage::getModel('catalog/product')->load($product_id);
    $newprice=$_product->getPrice();
    $newprice=$newprice*10;
    $new_price =$newprice;
    $quote_item->setOriginalCustomPrice($new_price);
    $quote_item->save();
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.