Magento 2 Overriding Template Files
You can override template files within Magento 2 thanks to its powerful theme inheritance feature. This means you can easily extend themes whilst minimising the maintenance efforts to do so.
For the purpose of this article, we will assume you have already created a basic theme directory structure. In this ...
Magento 2 Register Custom Module
Within Magento 2, we can create custom modules that are built on top of the original framework. Modules allow us to extend, override existing functionality or create new functionality altogether.
So how do we go about registering a module through Magento 2? Firstly, modules should belong in the app/code directory ...
Magento 2 Create Theme
Since the release of Magento 2, one of the first things developers look to do is to find out how to create a theme. As the directory structure and the admin interface is significantly different to Magento 1, it can be difficult to locate exactly where to modify the theme configuration.
The Service Manager is ZF2 is a type of intelligent registry where you pass in a string and receive an instance of the class that was defined in your application. For example, if you want the config service you would make the following call:
$serviceManager->get('config');
Zend\ServiceManager\ServiceManager implements the ServiceLocatorInterface interface.
The interface prescribes two ...
The ZF2 Event Manager is a component designed to implement simple subject/observer patterns, aspect-oriented designs and implementing event-driven architectures.
To start with, it is worth taking a look at the onBootstrap() method of the ZF2 skeleton application within the ‘Application’ module.
// Application/Module.php
<?php
namespace Application;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module
The ZF2 Shared Event Manager provides a way to attach listeners to many event managers. The SharedEventManager is an implementation of SharedEventManagerInterface.
As we saw the previous example (if you haven’t read the Event Manager article, you can do so here), creating an event manager class and trying to listen to an event did not ...
The Zend\Permissions\Acl component provides an access control list (ACL) implementation for privileges management.
Creating an ACL
Use Zend\Permissions\Acl\Acl to create a new instance of an ACL.
use Zend\Permissions\Acl\Acl;
$acl = new Acl();
Resources
A resource is an object to which access is controlled. Any ACL resources defined must implement Zend\Permissions\Acl\Resource\ResourceInterface and contain one method: getResourceId().
Within Magento you’ll have probably come across methods where you can retrieve data from certain entities. For example, to load a simple product you would write the following code below.
And to get data from certain attributes, you might use the example shown below.
You can also set data on certain attributes.
Furthermore, if you ...
The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators.
Basic SimpleXML usage can be used by either loading xml strings by passing the string in to the SimpleXML class or by using the simplexml_load_string() function. We ...
File Uploads in PHP allow users to upload both text and binary files. With PHP’s authentication and file manipulation functions, you have full control over who is allowed to upload and what is to be done with the file once it has been uploaded.
First of all, you’ll need to check that your server’s file_uploads ...