How to get country collection in magento2

  • How to get country collection in magento2

    To get country collection in toOptionArray, you need to add following code in your file: First you need to inject a \Magento\Directory\Model\ResourceModel\Country\CollectionFactory in your class constructor: protected $_countryFactory; public function __construct( \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryFactory ) { $this->_countryFactory= $countryFactory; } Then in your class you can do: public function getAllOptions() { return $options = $this->getCountryCollection()->toOptionArray(); } public […]

  • How to load quote by quote id in Magento 2

  • Magento 2: Assign/Remove Products from Categories Programmatically

  • Magento 2: Setup Multiple Stores and Websites

  • Magento 2 Get Product Collection

  • Magento 2 Get Product Collection

    This blog shows how we can get product collection in Magento 2. Using Dependency Injection (DI) Below is a block class of my custom module (Mtutorials_HelloWorld). I have injected object of \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory class in the constructor of my module’s block class. app/code/Mtutorials/HelloWorld/Block/HelloWorld.php <?php namespace Mtutorials\HelloWorld\Block; class HelloWorld extends \Magento\Framework\View\Element\Template { protected $_productCollectionFactory;   public function […]

  • Magento 2 Error 503 backend fetch failed

  • Magento 2 show address on customer register page

  • Magento 2 show address on customer register page

    Magento 2 show address on customer register page

    If you want to show customer address fields on registration form page. Than you need to set true to show.address.fields in your customer_account_create.xml. See Below Steps for this example: 1). First you need to Create below file in your custom theme: app/design/frontend/Select_theme_folder/Magento_Customer/layout/customer_account_create.xml 2). Now put below code in this xml file. <?xml version=”1.0″?> <page xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” […]

  • Magento 2 Get Currency Symbol from Currency Code

  • magento 2 Parse error: syntax error, unexpected ‘ ‘ (T_STRING)

  • 1 2