We can use Repository \Magento\InventoryApi\Api\SourceRepositoryInterface to get the source by code when we have a source code with us if we want to get the source name we may call a block function to load the source name with the source Id Block Code Phtml File
Tag: Magento
Get Region Code by Region name in Magento 2
Magento 2 You can get Region Code by Region name using Directory Module. You can get region code from region name by Magento\Directory\Model\ResourceModel\Region\CollectionFactory object. Let’s check with Region name is California and we want to get region code CA from California. Call $this->getRegionCode(“California”); The result will be, by this we can also get the region id from the… Continue reading Get Region Code by Region name in Magento 2
Check whitespaces and remove in the First Name Customer Registration in FE, BE
Once a new customer is being registered and Add New Customer in Admin the extension checks the First Name field. If the First Name field has whitespaces, they must be removed, so the customer entity is saved without whitespaces in the First Name property. All checks and modifications must be performed on the server side.… Continue reading Check whitespaces and remove in the First Name Customer Registration in FE, BE
Product Collection Methods: addFieldToSelect() vs. addAttributeSelect()
What is the difference between ->addFieldToSelect(‘name’) and ->addAttributeToSelect(‘name’)? addAttributeToSelect() is used to select EAV collections. (like https://devdocs.magento.com/guides/v2.3/extension-dev-guide/attributes.html#customer-eav-attribute) addFieldToSelect() is used to select Non-EAV collections.
How to add a pop-up window to Magento 2 front page?
use pop-up solution I could use to put up a message to visitors Inside your theme add below file in path app\design\frontend\your\theme\Magento_Cms\layout\cms_index_index.xml And Inside your theme add below file in path app\design\frontend\your\theme\Magento_Cms\templates\popup.phtml
Magento 2 create order programmatically
Here we are discussing how to create order programmatically in magetno Code for creating a quote Continuing to declare the order in the module helper file by the following function:
NetSuite gets API trigger twice when called a CURLOPT_URL
Sometimes when we are posting some values to Netsuite through their API, the API is triggered twice because we may posting the params to the response as the same response from NetSuite. Avoid printing the params in the response. Try this instead of :
Observer to remove all cart items based on a condition
Sometimes when we submit a quote we may need to reset the cart with clearing all submitted quote fields, So we need to use an event Observer code to remove all items Repos must be added in the observer to get the data
Observer to block qty update in the minicart based on a condition
Here we can implement a observer to block minicart to update qty based on condition firing a event before <event name=”checkout_cart_update_items_before”> Observer code:-
Disable Cache for Category TopMenu
Updates from NS to the category header or name will not be worked on the real-time so for that, the layout should be having cacheable false setting. We can achieve the option in the following method.Create a custom module for the changes app/code/VendorName/ModuleName/registration.php app/code/VendorName/ModuleName/etc/module.xml app/code/VendorName/ModuleName/etc/di.xml app/code/VendorName/ModuleName/Block/Html/Topmenu.php