Magento2
Power your online business with the most flexible and scalable ecommerce platform
Get Customer's Orders using Magento2 API REST
in this code you will see how to get all Customer's Orders from Magento2 using the REST API
Disable/Hide Recently Ordered Block in Magento 2
To hide the recently ordered product block from the left side
Create default.xml in your module or theme's view/layout folder and paste the below code.
How to enable profiler in magento2
To enable the profiler we can add it from index.php or apache/nginx conf file.
Enable/Disable Profiler from Command Line:
# Enable the profiler.
php bin/magento dev:profiler:enable
# Disable the profiler.
php bin/magento dev:profiler:disable
Enable Profiler from index.php:
Flash Catalog Images Cache Magento2
To flash the Catalog Images cache, first of all instantiate the Object and Event Manager in your constructor
private $objectManager; private $eventManager; public function __construct( \Magento\Framework\ObjectManagerInterface $objectManager, \Magento\Framework\Event\Manager $eventManager ){ $this->objectManager = $objectManager; $this->eventManager = $eventManager; }
After that you can clean the catalog images cache by using this two code lines
How to Disable/Enable Modules in Magento 2.x
Log in to your Magento directory using SSH.
Disable RMA
- bin/magento module:disable Aheadworks_Rma
- bin/magento setup:upgrade
- rm -rf var/cache/*
- rm -rf var/page_cache/*
- rm -rf generated/*
Enable RMA
- bin/magento module:enable Aheadworks_Rma
- bin/magento setup:upgrade
- rm -rf var/cache/*
- rm -rf var/page_cache/*
- rm -rf generated/*
Add Order Attribute to Custom Attributes on Magento 2 Rest API?
Step 1: Create new column and set value for the existing order
Firstly, you need to create a new column in table sales_order in your installer file
$setup->getConnection()->addColumn($setup->getTable('sales_order'), 'order_attribute', 'varchar(1)');
In this post, we named it “order_attribute”.
Step 2: Create extension_attributes.xml file
Magento2 gallery afterLoad callback
If you need to do any JavaScript code after Magento gallery is loaded you can use this event in your code
Magento2 Refresh Cache for Single Product
Magento’s cache management system saves loaded data, configuration, instructions, images, assets, and more for increased performance loading and rapid access on the storefront. It offers increased stability on your website during heavy user load and greater customer browsing activity. Having a slow-performing website can also negatively impact your conversion
You can use this code to refresh the cache for single product
Magento2 indexes
First of all you need to change the directory to shell folder under magento root
Checking for the status of all indexes
php bin/magento indexer:status
Re-indexing a single index
Each index has its own index key that you can use to reference it when asking Magento to re-index. To get these keys, you can use the following command:
php bin/magento indexer:info
Magento2 Create Shipment for Order Direclty By PHP code
Kindly i am share with you the code of how to make partial Shipment for existing Order in Magento2
I will write the code that can be executed external of magento files
First Create new file and name it as you want , For me i named it (create-shipment-magento2.php)
add this code to the file