Magento Asked on November 30, 2021
I get all data from checkout, with the next code:
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cart = $objectManager->get('MagentoCheckoutModelCart');
$shippingAddress = $cart->getQuote()->getShippingAddress();
$perri = $shippingAddress->getData();
But i want to get only postcode and country_id from my object, if i use the next code, i can get the specific element:
$perri = $shippingAddress->getData('postcode');
If i use the next code, the log show an error:
$perri = $shippingAddress->getData('postcode');
$perri = $shippingAddress->getData('country_id');
How can i get both items?
Magento recommends using API interfaces
to fetch data.
You can use MagentoQuoteApiDataAddressInterface
to get postcode
and country_id
Using ObjectManager directly is not a good practice.
You can read more about API and interfaces at http://vinaikopp.com/2017/02/18/magento2_repositories_interfaces_and_webapi/
Answered by Anshu Mishra on November 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP