Denys Tsymbal
- 12 min read
The Magento admin panel is a backend system that helps store owners manage products, orders, customers and much more from one place. However, the default admin panel is not always enough to meet the unique needs of your business.
But there is a solution — a сustom Magento admin panel. You can add new functionality to your backend to make it simpler to use, thus improving the team's workflow.
In this guide, you'll explore how to set up the Magento admin according to your requirements. You'll find out how to make it more convenient to navigate and manage.
A bonus is one of our that can make some of these processes faster and easier.
Why Customisation of Magento Admin Panel Matters?
The Magento admin panel is the engine that drives your online store. It's a place where your team spends most of their time managing products, configuring settings, and more.
Yet, a lot of store owners continue using the simple default panel. They simply don't realise that a personalised backend can make all ofihor
- 5 min read
Every time you need to do some testing, roll out an update or fix a bug, you need to enable the Magento 2 maintenance mode. It initiates the display of the "Service Temporarily Unavailable" messages across all your website pages.
So, regardless of other , the maintenance mode causes the most inconvenience for both merchants and users. Especially if they don't know what that mode is about.
That's why today you'll get all the answers about what is Magento maintenance mode, why it matters and how to use it properly. We'll also share some secrets about enabling maintenance mode in Magento without downtime.
Intrigued? Let's get started!
What is Magento 2 Maintenance Mode?
Magento 2 maintenance mode is a process of temporarily disabling users from accessing your website while you perform updates, customizations, or other improvements. If you enable maintenance mode, website visitors will see a maintenance page with a custom message.
Some exceptions exist when users from certain IPs can accessihor
- 3 min read
Magento 2 catalog price rules allow you to create encouraging offers and prompt your customers to finalize the purchase. Unlike , catalog rules are applied to the entire catalog, not just the shopping cart.
Traditionally, you via the admin panel. That's where you specify the rule information and conditions for the discounts to be applied. But you can perform all these steps using coding, too.
So, today you'll learn how to create a catalog price rule in Magento 2 programmatically.
Create Magento 2 Catalog Price Rule Using Dependency Injection
One of the safest methods to go for is dependency injection. To apply this method, use the code below:
<?phpdeclare(strict_types=1);namespace Vendor\Module;use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface;use Magento\CatalogRule\Model\RuleFactory;use Magento\Framework\Exception\CouldNotSaveException;use Psr\Log\LoggerInterface;class CreateCatalogPriceRule{ protected $ruleFactory; protected $catalogRuleRepository; protected $logger;ihor
- 2 min read
Magento 2 categories help make your store organized and easy to browse through. They enhance navigation greatly since customers can jump from one category to another without looking for some item in the entire catalogue.
As you know, you can easily in the admin panel. That's the most common way. But there is also a different approach.
You can also create a category in Magento 2 programmatically. In this guide, you'll find two methods to do so.
Create Magento 2 Category Using Dependency Injection
One of the methods to create a category programmatically is to use dependency injection. Here is the code you have to run:
<?phpdeclare(strict_types=1);namespace Vendor\Module;use Magento\Store\Model\StoreManagerInterface;use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;use Magento\Catalog\Model\CategoryRepository;use Magento\Framework\Exception\NoSuchEntityException;use Magento\Framework\Exception\CouldNotSaveException;use Psr\Log\LoggerInterface;class CreateCategoryService{ protectedihor
- 2 min read
Providing high-quality customer service is one of the pillars of a successful business. Magento 2 offers you extensive features for out of the box. Thus, you can configure customer name, address, login, , and more.
However, the default options are not always sufficient if you need to gather some specific info. That said, you'll need to create custom customer attributes.
Unfortunately, Magento 2 doesn't offer the simple admin panel setup of this functionality. So, you need to add customer attributes programmatically.
Don't know how? No worries, you're about to find out!
1. Create a Magento 2 module
Magento handles customer attributes using the EAV model structure and the Data Patches to alter the info. Thus, this is what we'll apply today.
So, before adding customer attributes, you need to . If you already have a suitable one, you can just use it.
The method below requires you to have a module to run the code. So make sure you have it.
2. Create the InstallData.php file
The next stepihor
- 2 min read
are mostly created on the frontend by customers themselves. However, there may be cases when store managers need to create customer accounts from the admin panel.
Nonetheless, creating customer accounts manually may be time-consuming if you need to create a few. Thus, it may be more convenient to create customer in Magento 2 programmatically.
It's exactly what you'll learn today.
Create Customer Using Dependency Injection
To begin with, you can create a customer programmatically using the dependency injection method. Just use the code below:
<?phpdeclare(strict_types=1);namespace Vendor\Module\Model;use Magento\Store\Model\StoreManagerInterface;use Magento\Customer\Api\Data\CustomerInterfaceFactory;use Magento\Customer\Api\CustomerRepositoryInterface;use Magento\Framework\Encryption\EncryptorInterface;class CreateCustomerService{ /** * @var StoreManagerInterface */ protected $storeManager; /** * @var CustomerInterfaceFactory */ protected $customerFactory; /** * @var CustomerRepositoryInterfaceihor
- 2 min read
Making the content of your store responsive and easy to browse through guarantees improved customer experience and seamless shopping. With this thought in mind, will probably be your first resort.
To assign products to categories you need to select them manually in the Products in Category section in the admin panel. However, this may get rather tedious especially if you have an extensive catalog.
Thus, you might want to optimize this process and today you'll learn how. Keep reading to learn how to add products to category programmatically in Magento 2.
Add Products to Category Using Dependency Injection
One of the most common methods of adding products to categories is dependency injection. Just use the code below.
<?phpdeclare(strict_types=1);namespace Vendor\Module\Model;use Magento\Catalog\Api\CategoryLinkManagementInterface;use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;class AssignProductsToCategoryService{ /** * @var CategoryLinkManagementInterfaceihor
- 3 min read
One of the many steps in the workflow is creating an order. In most cases, customers place orders from the frontend. Yet it happens sometimes that this task falls on the store managers. They might need to assist customers, apply custom prices or just merely test the process.
That said, you can . That's one option. Yet it is also possible to create orders in Magento 2 programmatically. In this article, you'll learn two ways to do that.
So, let's get right to them.
Create Order Using Dependency Injection
One of the safest ways to go is to use the dependency injection. The code below will help you create an order programmatically in Magento 2.
<?phpnamespace Magefan\OrderEdit\Model;use Magento\Framework\Exception\NoSuchEntityException;use Magento\Store\Model\StoreManagerInterface;use Magento\Quote\Api\CartManagementInterface;use Magento\Customer\Api\CustomerRepositoryInterface;use Magento\Quote\Model\QuoteFactory;use Magento\Catalog\Api\ProductRepositoryInterface;use Magento\Customer\Api\AddressRepositoryInterface;classihor
- 2 min read
As much as store owners would like to have no refunds, this is not entirely possible. Customers may purchase the wrong size, colour, etc., receive incorrect items or change their minds unexpectedly. Merchants too may oversee various order-related details. Thus, a refund policy is a necessity to ensure reliable store-customer relations.
In Magento 2, a refund is referred to as a credit memo. It defines the amount of money a customer is supposed to receive back. Usually, . Yet, you can also do this using code.
So in this article, you'll learn how to create a credit memo in Magento 2 programmatically.
Create Credit Memo Using Dependency Injection
One of the recommended options to go for is the dependency injection method. The following code will help you create a credit memo programmatically.
<?phpnamespace Venodr\MyModule\Model;use Magento\Sales\Api\OrderRepositoryInterface;use Magento\Framework\Exception\NoSuchEntityException;use Magento\Sales\Model\RefundOrder;use Magento\Sales\Model\Order\Creditmemo\ItemCreationFactory;classihor
- 2 min read
Having your customers divided into groups can benefit your sales greatly. This helps to find a personalized approach and target the right customers with the right messages. To say nothing of the enhanced store performance and shopping experience.
You can certainly create in the admin panel. Yet, if you'd like to manage this task through coding, there is an option for you too. And in this article, you'll learn how to create a customer group in Magento 2 programmatically.
Create Customer Group Using Dependency Injection
Using dependency injection, create a file in your module, and then call the execute function of that class CreateCustomerGroup in any place of your code to create a customer group.
<?php
namespace Vendor\Extension\Model;use Magento\Customer\Model\GroupFactory;class CreateCustomerGroup{ protected $groupFactory; public function __construct(GroupFactory $groupFactory) { $this->groupFactory = $groupFactory; } public function execute(string $customerCodeihor
- 2 min read
The way your blog pages appear on social media definitely influences the clicks they get. Besides, once you in Shopify, you need to make sure they are displayed properly.
Shopify usually handles OG tags on a theme level. So, for them to appear on some specific pages, like blog, you need to make certain changes to the theme.
In this article, you'll learn how to do that step by step and make your pages more attractive and clickable on social media.
To enable OG tags for the Shopify blog:
1. Navigate to Sales channels > Online Store.
2. Go to Themes, click on the three dots (near the Edit theme button), and select the Edit code option.
3. Find the theme.liquid file and open it.
4. Find in theme.liquid file row with the {% render 'meta-tags' %} code. All you need is to move OG tags from the meta-tags file to the theme.liquid file so our Blog app can use the OG tags.
5. Insert the following code before the {% render 'meta-tags' %}:
<meta property="og:title" content="{{ page_title |ihor
- 2 min read
The process of in Magento 2 consists of numerous steps. One of the last ones is creating a shipment. It is a relatively simple task, but it's useful to know how to cope with it as quickly as possible.
On one hand, you can . This method is entirely manageable and not time-consuming. On the other hand, you might prefer an alternative — create a shipment in Magento programmatically. And in this article, you'll learn more about it.
Create a Shipment Using Dependency Injection
It is one of the most common ways to create a shipment. So, in order to create a shipment in Magento 2 programmatically using dependency injection, use the below code:
<?php
namespace Vendor\ModuleName;
class ClassName
{ public $orderRepository;
public $convertOrder;
public $shipmentNotifier;
public function __construct(
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
) {
$this->productRepository = $productRepository;
}
public functionihor
- 2 min read
As a Magento 2 developer, you know that some coding is inevitable for successful store operations. There are many tasks you need to do programmatically, especially when it comes to getting some information like or .
One of them also is getting product by SKU in Magento 2. And in this article, you'll learn more about two possible ways of doing that.
Get Product by SKU Using Dependency Injection
Dependency injection is one of the most common solutions when it comes to getting product by SKU in Magento. It's quite simple, yet no less effective.
So, to apply the dependency injection method, go to your phtml block file and create a _construct function:
<?php
namespace Vendor\ModuleName;
class ClassName
{
public $productRepository;
public function __construct( \Magento\Catalog\Api\ProductRepositoryInterface $productRepository ) { $this->productRepository = $productRepository; } public function getProductBySky($sku) { ihor
- 2 min read
Magento 2 is a flexible ECommerce platform that provides you with various options to customize your store to your needs. Thus, as a developer, you have to be aware of the coding matters to make everything works as flawlessly as possible.
There may be dozens of tasks that have to be solved programmatically, for instance, or . However, it always goes down to configuration. So, it might also be useful to know how to get config value in Magento 2. And this is exactly what you'll learn today.
There are two ways to get config value in Magento 2. Let's have a look at both in more detail.
Get Config Value Using Dependency Injection
One of the most common methods to get configuration value in Magento is dependency injection.
In order to apply it, you need to go to the phtml block file and create a _construct function:
<?php
namespace Vendor\ModuleName;
class ClassName
{
public $scopeConfig;
public function __construct( \Magento\Framework\App\Config\ScopeConfigInterfaceihor

