I cannot find an location where i can print_r the object.
Do you have an a file and line number for me?
into that address template file, where that address form
Everytime when var_dump an object the browser crashes, i'm doing something wrong.
But what. Magento 2 is starting to be frustrating for me.
you need to do getData() on that object otherwise your browser cache
like
echo "<pre>";
print_r($address->getData());
exit;
Oke i'm editing vendor/magento/module-customer/view/frontend/templates/address/edit.phtml and i'm getting the following error:
Fatal error: Call to undefined method Magento/Customer/Model/Data/Address::getData()
I feel so stupid, but i really dont know what you ask of me.
echo "<pre>";
print_R($block->getAddress()->getData());
exit;
Stil the same error
Fatal error: Call to undefined method Magento\Customer\Model\Data\Address::getData() in vendor/magento/module-customer/view/frontend/templates/address/edit.phtml on line 18
In my di.xml i added the following lines
<preference for="Magento\Customer\Model\Data\Address" type="Custom\Module\Model\Rewrite\Customer\Data\Address" /> <preference for="Custom\Module\Api\Rewrite\Customer\Data\AddressInterface" type="Magento\Customer\Model\Data\Address" />
Address.php
<?php namespace Custom\Module\Model\Rewrite\Customer\Data; class Address extends \Magento\Customer\Model\Data\Address implements \Custom\Module\Api\Rewrite\Customer\Data\AddressInterface { /** * Get the house number * @return int */ public function getNumber() { return $this->_get(self::NUMBER); } /** * Get the house number addon * @return string */ public function getNumberAddon() { return $this->_get(self::NUMBER_ADDON); } /** * Set house number * @param int $number * @return $this */ public function setNumber($number) { return $this->setData(self::NUMBER, $number); } /** * Set house number addon * @param string $numberAddon * @return $this */ public function setNumberAddon($numberAddon) { return $this->setData(self::NUMBER_ADDON, $numberAddon); } }
AddressInterface.php
<?php namespace Custom\Module\Api\Rewrite\Customer\Data; use Magento\Customer\Api\Data\AddressInterface as MainAddressInterface; interface AddressInterface extends MainAddressInterface { /**#@+ * Constants for keys of data array. Identical to the name of the getter in snake case */ const NUMBER = 'number'; const NUMBER_ADDON = 'number_addon'; /**#@-*/ /** * Get the house number * @return int */ public function getNumber(); /** * Get the house number addon * @return string */ public function getNumberAddon(); /** * Set house number * @param int $number * @return $this */ public function setNumber($number); /** * Set house number addon * @param string $numberAddon * @return $this */ public function setNumberAddon($numberAddon); }
Now I can retrieve the data, but now I can't save the data to the database.
Hey!
Did you get any response? I have the same situation with Magento CE 2.1.10.
Thanks!
Sorry we still did not get answer for it