Magento2 – How to load Quote by Quote id
Use \Magento\Quote\Api\CartRepositoryInterface Repository as a dependency to create its instance and load the quote using id. Alternatively you can also get quote using \Magento\Quote\Model\QuoteFactory model. But this has
Magento2 – How to get store information
By default store manager loads current store information. You can get store information by `store_id` parameter. You must create an instance of \Magento\Store\Model\StoreManagerInterface class to get store information.
Magento2 – How to get Current Url
To get url of the current page, the code below works everywhere: $objectManagerInstance = \Magento\Framework\App\ObjectManager::getInstance(); $url = objectManagerInstance -> get('Magento\Framework\UrlInterface'); echo $url -> getCurrentUrl(); From a .phtml template
Magento2 – How to get Directory of a Module
Here is the code how to load your module directory:
Magento2 – How to get Current locale Programmatically
Inject Resolver Dependency and get locale in your phtml And in your phtml:
Magento2 – How to Get Country Name Using Country Code
Create Instance to Object Manager then inject dependency to perform your query: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); Now load your country by the following code: While AE is the country
Magento2 How to Get Country Code Collection
To get country list data, you need to create instance of Country collection model `Magento\Directory\Model\ResourceModel\Country\CollectionFactory`. Once instance is created, you can load it by current store.
Magento Load Product By Id
To load product by id, use the load($id) function by providing product id as parameter following the Product Model Class Mage_Catalog_Product_Model. A single product with object array will
Magento Get Product Data Programmatically
To retrieve product data programmatically, we will use resource model to get product collection. Resource Models contains the collection query directly with database to behalf of the model.
Magento Formating Price
Magento provides build-in method to support the price formatting accordingly. There are the couple of methods in magento to format price. The method below is easiest to get
Magento get base url, skin url, media url, store url
1. Path Retrieval in Static Block or CMS Page Get Base Url: Get Store Url: Get Media Url: Get Skin Url: 2. Path Retrieval in phtml files