How to generate auto invoice by payment_action for custom payment methods in magento 2?

You can Generate an auto invoice after the order is placed successfully in Magento with the simple configuration.

You can use <payment_action> configuration in the config.xml file to set auto invoice for your custom payment method.

You can check programmatically Convert Order to Invoice Programmatically in Magento 2.

Using payment_action, You don’t need to generate manual action to create an invoice for the order.

You have to just create a config.xml file under your module etc directory. Continue reading “How to generate auto invoice by payment_action for custom payment methods in magento 2?”

How to pass data from Controller to View Template files in Magento 2?

You can pass data from the Controller action to the Template files in Magento via Block Class.

You can’t directly pass controller data to view the template files but using the Block class you can achieve it successfully.

By use of the Magento interface, Magento\Framework\App\Request\DataPersistorInterface We are able to store data by key with the set(), get() method. Continue reading “How to pass data from Controller to View Template files in Magento 2?”

How to rename file programmatically Magento 2?

You can rename the file names in Magento by providing the source path and destination path.

I have tested the given functionality to rename the file names under the pub directory. You can do it for outside pub directory but you need to change __construct() method $this->directory argument value.

$this->directory = $filesystem->getDirectoryWrite(DirectoryList::PUB); Continue reading “How to rename file programmatically Magento 2?”