Magento2
Power your online business with the most flexible and scalable ecommerce platform
How to apply the Magento 2 patches?
Most of Magento developer want to know exactly how they should apply the security patches on their websites
in this article we are going to talk about *.patch files
There are two ways to do this
1- using git command
git apply patch_filename.patch
or
2- using patch command
patch -p1 < patch_filename.patch
I hope this will be useful for you
Use Redis for session storage
with standard parameters, you can use this command after you are in Command line (SSH)
bin/magento setup:config:set --session-save=redis --session-save-redis-host=127.0.0.1 --session-save-redis-log-level=3 --session-save-redis-db=2
References
Backing up Magento2 using command line
To backup your store using the command line please login to your root magento server (SSH), then execute this command
magento setup:backup --code --media --db
restore canceled order in Magento2
Imagine that some of your team cancel an order in Magento by mistake, What is the solution?
By the below code you can restore the cancelation, hope it will help you
Magento 2: How to get customer collection
<?php
protected $_customerFactory;
public function __construct(
...
\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory $customerFactory
...
Create Invoice Via REST API for Magento2 for Bundle Product
To create an invoice for an order that contain bundle product you have to prepare the good json.
Basically Magento has two different types of bundle products: dynamic and fixed. That's why I need to add clarification for Expected Result:
I) Bundle dynamic product:
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