This one’s a long winding journey through all the javascript code involved when Magento updates the Shipping Rates section of the checkout application. The specifics here are Magento 2.1.1 – and I know for a fact there are some small differences in the 2.0.x branch w/r/t to how the validation listeners get setup. Concepts [...]
astorm
This one’s a follow up to my Magento 2: Understanding the Web API Architecture post. In that post I gloss over Magento’s oAuth implementation, and what I did say got several details wrong. This article aims to fix that. To understand Magento’s oAuth features, you need to understand the (related) integrations feature. To [...]
astorm
A quick code-point mention #File: app/code/Magento/Catalog/Model/Product/Image.php public function resize() { if ($this->getWidth() === null && $this->getHeight() === null) { return $this; } $this->getImageProcessor()->resize($this->_width, $this->_height); return $this; } This method is where Magento 2 will [...]
astorm
If Magento 2 is your first introduction to PHP namespaces, here’s one small thought technology that might help. Consider the following namespace FooBaz; class Bar { } The above does not define a class named Bar. It defines a class named “FooBazBar”. That’s how PHP sees the class internally, and once you start [...]
astorm
If you’re trying to use the browser setup workflow in the Magento 2 beta released in December of 2014, make sure your web server is using the index.php in the root of the project and not the pub/index.php file. It’s unclear which index.php is “the right” file to point to – the pub folder seems to be an [...]
astorm
If you’re using Vagrant to manage your Magento 2 installations, you’ll want to be careful with file permissions. By default, it appears that Vagrant’s synced folder setup won’t allow the apache/web user to create folders with permissions elevated higher than the default sync share. Dropping in some custom mount [...]
astorm
Somewhere in the past few dev releases Magento 2 got rid of the MagentoAppDir class/object. The MagentoFilesystem object (and its getPath method) seem to be a reasonable replacement
astorm
Magento 2 Development Update Video of the Magento 2 conference call from yesterday. Covers a lot of the formal reasons for the changes in Magento 2.
astorm
If you’re working in a PHP file that’s namespaced, and you’ve setup a simple try/catch block like this try { //do something that might throw an exception } catch(Exception $e) { echo "Caught you!"; } You may be surprised when your program doesn’t catch the thrown exception. That’s because Exceptions are [...]
astorm
The Magento 2 team just threw dev-54 over the wall. One change you’ll notice quickly is they’ve removed the isAdmin method from the store object. This is the method that, in theory, allows a Magento client programmer to know if Magento is or is not running in the backend admin console. I say in theory, because “running [...]
astorm
Pop quiz: You’ve got your head wrapped around Magento 2’s dependency injection. You’re taking a stroll through the code base, and you see this constructor. #File: lib/Magento/PubSub/Event/QueueHandler.php public function __construct(MagentoPubSubEventQueueReaderInterface $eventQueue, MagentoPubSubJobQueueWriterInterface [...]
astorm
While the concept of The Global Config still exists in Magento, a module’s etc/config.xml is no longer the place where developers will enter most of a module’s configuration. In fact, if you try to use a Magento 1 config.xml file in Magento 2 and turn on developer mode, you’ll be greeted by the following. Invalid XML in [...]
astorm
Magento 2: Translation Mechanism An explanation of Magento 2’s translation mechanism. (Pro Tip; European developers will love your open source project forever it it’s easily translatable)
astorm
Not a comprehensive guide, and as always, let the core module’s be your guide. Router configuration has been moved from config.xml to etc/frontend/routes.xml and etc/backend/routes.xml There’s still a routerName/frontName distinction, although the router’s name is specified with an id attribute instead of the node name [...]
astorm
Magento 2: Auto Dependency Injection: No Comments Required Something something assumptions. It turns out the Magento 2 automatic dependency injection does not rely on PHPDoc comments. Instead, it (appears) to be reflection based. ALso worth noting — the core team is strongly discouraging direct use of the object manager.
astorm
Class rewrites were, in many ways, that killer developer feature of Magento 1. Killer as in “Woah, awesomely powerful thing PHP developers don’t normally get to do”, and killer as in “Oh crud, we’ve killed the site with too many rewrites that are conflicting with each other”. One of the promises of [...]
astorm
I looks like eBay threw another Magento 2 release over the wall into GitHub today. I’m going to start tagging entries here with a specific dev release tag as well as the generic magento2 tag. First big change? The object manager we’ve been discussing is a different class. When you want to grab an instance of it, you can use [...]
astorm
In Magento 1 there were three “types” of classes which you could instantiate via Magento’s various object factories: Models, Blocks, and Helpers Mage::getModel('group/class'); Mage::helper('group/class'); Mage::getSingleton('core/layout')->createBlock('group/class'); In Magento 2, all classes are available to the [...]
astorm
Another consequence of losing the global Mage class in Magento 2 is the loss of the getBaseDir method. Fortunatly, the team behind Magento 2 has a solution, the MagentoAppDir object. You can use this object to get the base directory of your Magento system. $object_manager = MagentoCoreModelObjectManager::getInstance(); $dir = [...]
astorm
Magento 1 was littered with translation functions. Helper objects, block objects, and the PHP global namespace all had a __ function or method. Magento 2 does away with this. Core team developers have removed the __ method from the base block and helper classes, leaving only the global __ function for translations. If that didn’t [...]
astorm