"Magento 2"

Advanced Development with RequireJS (+ Magento 2 Tutorial)

- Fire development, Magento 2

How to set up RequireJS with Magento 2

Below, I shed light on such useful technology as RequireJS and compare it with the closest competitors. Since here on the Firebear blog we are passionate about Magento 2,  I also explain how to configure and adjust RequireJS with the second version of the ecommerce platform. The article itself combines real world coding experience, notes from the official documentation, code snippets, and materials from reliable sources. You will find a complete resource list in the end of this blog post. Continue Reading

Magento 2 vs Shopify

- E-Commerce, Magento 2

Why Magento 2 is better than Shopify

Being in business since 2006, Shopify has gathered more than 50 thousand retailers around the ecommerce platform. Despite Magento is a little bit younger, it is the leading ecommerce solution. It was first introduced in 2008, and in 2011 Ebay purchased the company. Unlike Shopify with its proprietary code, Magento is an open source ecommerce platform.

On Firebear, I’ve already compared Magento and Shopify. You can find that blog post here: Magento vs Shopify. Now, it is time to pay attention to differences between Magento 2 and Sopify. The following blog post discusses pros and cons related to both platforms. Let’s start with Shopify.

The Ultimate Magento 2 Guide

Magento 2 Demo

Continue Reading

Magento 2 Command Line Tool (/bin/magento)

- Magento 2

Magento 2 CLI

Since Magento 2 provides a very useful implementation of Symfony’s Console component, you can easily perform tons of important actions from a command line interface. It is possible to reindex, clean cache, generate code, create database backups, and run other commands with the help of this instrument. Moreover, you can easily enhance the existing solution with your own commands aimed at your Magento 2 extensions. Below, I explain how to use Magento 2 CLI tool and what commands to run. Continue Reading

How to Uninstall Magento 2 Modules and Restore Magento 2 Backups (Rollbacks)

- Magento 2

Uninstall Magento 2 Extensions; Restore Magento 2 Rollbacks

In this Magento 2 tutorial, I explain how to uninstall Magento 2 modules. You have several uninstallation options, such as removing the modules’ code, database data, and database schema. I highly recommend you to create backups before doing any changes, because you will leave a chance to recover the data if something goes wrong.

Magento 2 tutorials, features, and rumours on Firebear

Continue Reading

How to instantiate a custom block in Magento 2

- Magento 2

Magento 2 Development

Unfortunately, the process is not as easy as in Magento 1 ($crumbs = Mage::app()->getLayout->getBlock(‘breadcrumbs’);). In Magento 2, it depends on where you are going to instantiate it from. To create an instance from another block, use the following code:

from a controller:

from a model and a helper:

Please note that in a case of the model you have to create _blockFactory (a protected member), and inject a \Magento\Framework\View\Element\BlockFactory instance in the constructor, assigning it to the member var. For instance:

Continue Reading

How to instantiate a model in Magento 2

- Magento 2

Magento 2 Development

Since Magento strictly discourages the use of ObjectManager, there are service classes for abstracting it for all scenarios. Thus, you should use factory for all models (non-injectables):

You only have to ask a desired model’s factory in a constructor. Hence, it will be automatically generated, while you run compiler or Magento. Continue Reading

How to get the сollection of custom Magento 2 modules

- Magento 2

Magento 2 Development

Take your constructor and inject the model collection factory into it:

It is possible to use it in any class method:

$collection = $this->mymodulemodelFactory->create(); Continue Reading