Posts

Showing posts from August, 2020

Magento 2: How to login as Customer and place new order via REST APIs

In order to place a new order as a logged in customer using REST APIs in Magento 2, please follow below steps: You can Download the Postman Tool from here: www.postman.com Now, Open Post man and create below Requests: MAGENTO 2 REST APIs: CUSTOMER LOGIN: CREATING CUSTOMER QUOTE: ADD ITEMS TO CART COLLECT CART TOTALS GET AVAILABLE SHIPPING METHODS & ESTIMATING SHIPPING CHARGES SET BILLING AND SHIPPING ADDRESS OF ORDER PLACE ORDER Now check your admin panel and there will be a new COD order placed.

Magento 2: How to create new indexer for your custom module

For this tutorial we will consider an example of a custom module called Vendor_ModuleName. Create below files to generate a new VSBridge indexer and Elastic Index for your own module: Vendor_ModuleName\etc\indexer.xml Vendor_ModuleName\etc\mview.xml Vendor\ModuleName\Model\Indexer\CustomIndexer.php Now, open console and run below command: You will now see following: A new indexer job for your module in Magento admin panel > System > Tools > Index Management A new index in elastic You can refresh your indexer with php bin/magento indexer:reindex my_custom_indexer

Magento 2 - Vue Storefront PWA Integration: How to create a new VSBridge indexer job and Elastic Index for your custom module

For this tutorial we will consider an example of a custom module called Vendor_ModuleName . You need to have the module divante/magento2-vsbridge-indexer installed and configured in your project, in order for it to work with your Vue StoreFront PWA website. You can do this with below command: Once you have the module installed and configured correctly, create below files to generate a new VSBridge indexer and Elastic Index for your own module: Vendor_ModuleName\etc\indexer.xml Vendor_ModuleName\etc\mview.xml Vendor_ModuleName\etc\vsbridge_indices.xml Vendor\ModuleName\Model\Indexer\CustomIndexer.php Vendor\ModuleName\Model\Indexer\Mapping\CustomIndexer.php Vendor\ModuleName\etc\di.xml Now, open console and run below command: You will now see following: A new indexer job for your module in Magento admin panel > System > Tools > Index Management A new index in elastic You can refresh your indexer with php bin/magento indexer:reindex vsbr

Magento 2: How to create new import entity

If you want to add a custom import feature in your Magento 2 site, you can do this by following steps. This will add a new entity in ADMIN PANEL > SYSTEM > DATA TRANSFER > IMPORT Vendor\Module\etc\import.xml Vendor\Module\Model\Import.php Vendor\Module\Files\Sample\mycustomimport.csv Now, Open your console and run below command: Navigate to ADMIN PANEL > SYSTEM > DATA TRANSFER > IMPORT > IMPORT SETTINGS > Click on the dropdown >. Your custom import entity will appear here.

Magento 2: How to automatically generate Postman Schema for Default Magento 2 APIs

In order to automatically generate the Postman Schema for all of the Default Magento 2 APIs, follow below steps: Open your console, and trigger following CURL requests. This will generate a JSON file in your root directory. Now, Open Postman app > File > Import > Select the JSON file generated above and Voila, you now have the Schema of all Magento 2 APIs.

Magento2: How to stop a product from getting added to cart programmatically?

If youn want to stop a product from getting addded to cart programmatically, add below files to your module: Vendor_Module\etc\di.xml Vendor_Module\Model\Checkout\Cart\AddProduct.php

Magento2: How to add new grid in Category Listing Page

Here is a tutorial on how to add new Grid in Category Listing Page. For this example we will assume we want to add a grid same as Product Category Positions for Category Brands. It should look something like below: Assume that you have a custom module called Namespace_Module. You will create following files in your module: Namespace_Module\view\adminhtml\ui_component\category_form.xml Namespace_Module\Block\Adminhtml\Category\MyCustomGrid.php Namespace_Module\view\adminhtml\templates\catalog\category\edit\assign.phtml Namespace_Module\view\adminhtml\web\catalog\category\edit\assign.js Namespace_Module\Controller\Adminhtml\Category\Assign.php Namespace_Module\Block\Adminhtml\Category\Tab\MyCustomGrid.php For saving, updating and deleting the positions you need to create plugin on category save which takes the posted json, compares with original json and performs the required operation.

Magento 2: How to create your own Patch File and apply it through composer

Magento releases new patches for it's framework from time to time. Here is a tutorial of how to create your own patch file in Magento. Although I personally am not a huge fan of patches, due to various drawbacks, there are desperate times when you need to apply a patch. I would suggest to use this approach as less as possible and instead opt going the standard magento way of versioned modules that store your changes. But, In case there are times when you are forced to create a patch, or just for self-knowledge on how it's done, you can follow below tutorial. STEP 1: In your magento root directory create a folder called "patches". STEP 2: Create a sub-directory with the name Namespace_Module for the module which you want to create a patch for. So the path will look like this: < >\patches\Namespace_Module STEP 3: Add your patch file in the directory you created in Step 2 of this tutorial. HOW TO CREATE A PATCH FILE: Create a backup of the ori

Magento 2: Add new button on Category Edit Page in Admin Panel

For this example we will assume you have a custom module. Let's call it Namespace_Module. Now, create files as below: Namespace_Module\view\adminhtml\ui_component\category_form.xml Namespace_Module\Block\Adminhtml\Category\Edit\Button\AssignButton.php Namespace_Module\Controller\Adminhtml\Category\Assign.php Voila !! That's it. Now, clear all caches and check the category page in admin panel. There will be a new button called "Assign".

5 Things IT Start-ups SHOULD do

There are a lot of blog-posts all over the internet with the list of points which startups should not do. However, from my experience of working as an advisor to so many startups, i can figure out that, what they actually need is a list of "TO-DOs". Because most of the time, believe me, start-ups have absolutely no idea as to what to do and where to start from. If you too are facing the same dilemm, you are in the right place. I am here to help you get started. Sometimes, not having the correct tools, or missing the basics can prove to be a very expensive mistake. It could be in the form of potential clients rejecting the quotations and good candidates rejecting your job-offers. Following 5 points will not only help you get the correct personnel but also a good client-base to start with. RESEARCH: Research your competitors in the same domain. It's hard to be impartial, but try to look at their wo

Magento 2: How to add custom discount in cart programmatically?

Refer to how Magento2 applies sales-rule discounts. I applied similar approach to apply custom discount, by creating following files in my module: Namespace_Module\etc\sales.xml Namespace_Module\Model\Quote\Discount.php Namespace_Module\view\frontend\layout\checkout_cart_index.xml Namespace_Module\view\frontend\layout\checkout_index_index.xml If Fetch is not showing the custom discount description, it was a core magento bug, see this ticket for patch details: https://github.com/magento/magento2/issues/3594

MAGENTO 2: How to get HTTP Request Params

Also Check my blogpost here on getting API Request params: http://parekhreena.blogspot.com/2020/08/magento-get-rest-api-request-params.html

MAGENTO 2: Get REST API Request Params

MAGENTO: How to add a button in store configuration

For this illustration, we will add a button in store configuration called "Assign Button". When this button is clicked it will call a controller and perform the necessary function. We will first need to have a custom module where we can manage all this code. For this example we will use Namespace_Module . This will add button in store configuration.

MAGENTO 2-PWA KUBERNETES: How to put your elastic search behind username and password

For this illustration I am using Magernto, Vue Store Front PWA, Elastic Search and Kubernetes. First goto console and type This will ask you to enter the password. Enter the password which you wish to set for elastic authentication. After this is done run below command: Copy the contents of the file. Now, In your nginx.yaml file add the following:

How to lock your profile picture on Facebook so no one can like or comment, just view.

Image
You can lock your Facebook profile picture so that it can only be viewed and no one can like, comment or download it. Here are the steps to achieve this: Login to your Facebook account Goto your profile page. You can do this in following ways depending on your platform: For Desktop Facebook: By clicking on your name on the top right if you are on Desktop. For Mobile Facebook: By clicking on three horizontal lines on the top right and then clicking on your name if you are on Mobile App of Facebook. Now, Click on your profile picture. It will open in a picture viewer of Facebook. On the right side below your name, near the date, there will be a symbol (by default the globe symbol). Click on this globe symbol, a drop-down of "Who should see this ?" will appear. From this d