Category: Programming Quickies
Back in they day, I ran a Tumblr blog named Magento Quickies where I’d post shorter, less in-depth posts about my travels through Magento’s source code. This Programming Quickies categories is the successor to that Tumblr blog. You’ll find all the old Magento Quickies content here, as well as new short posts about programming in general.
This section has its own RSS feed, the old Magento Quickies feed should should be redirecting, and we’re cross posting notifications for new posts over to magento-quickies.tumblr.com. In other words, you shouldn’t need to know any of this, but the duct tape that keeps the internet held together isn’t aging well, so your mileage may vary.
Below you'll find all the Programming Quickies articles on the site,
followed by a chronological listing of the same.
You may also browse the
7
series directly via the following links.
Pestle, Four Steps to Async Iterators, Checking in on OpenMage and Magento in 2020, Text Encoding and Unicode, Shopware's Development Environment, A Sentimental Gen-X Programmer Culls his Tech Books, and, Containers, Containers, Containers.
Magento 2: Approximating Local Code Pool Overrides Not sure if I like the idea of this becoming a common practice, but if you know your composer autoloading you can replace any class in Magento with a version of your own.
astorm
Knockoutjs context debugger Chrome extension for peeking at a node’s KnockoutJS context. Useful if you’re doing frontend Magento work and hewing to their view of the world. via Daniel Sloof.
astorm
Another javascript debugging snippet for the intrepid Magento 2 javascript programmer. The Magento_Ui/js/core/app RequireJS module/application/program is an important part of Magento 2’s UI Component system. This is the program that registers KnockoutJS views and makes them available for use in the (custom to Magento 2) Knockout.js [...]
astorm
Magento 2: Syncing Backend and Frontend State/Cache Haven’t had time to check this out yet, but this is a far more cogent explaination of Magento 2’s mysterious sections.xml than anything I’ve seen so far.
astorm
When I started work on pestle’s Magento 2 code generation, I deliberately left the the <preference/> feature of Magento’s di.xml files off the list of commands. This was, in short, to help encourage the use of plugins over preferences. i.e. to encourage developers to use the system that allowed multiple extensions to [...]
astorm
This one’s more interesting than it is useful (or its main use is as a debugging exercise), but while I was working on a UI Component tutorial I wanted to turn off the XSD validation for ui_component files. It turns out there’s a dedicated object that can control whether the XSD validations are applied [...]
astorm
For folks using pestle, my PHP command line frameworking + Magento code generation tool, I’ve just added a selfupdate command. This will make a backup of your current version, grab the latest version, and update your local copy (permissions allowing, of course) $ pestle.phar selfupdate Downloaded to /private/tmp/pestle_DZOXou [...]
astorm
I’m knee deep in a rewrite of No Frills Magento Layout for Magento 2 – I know the systems well enough to use them, but I’m still coming up to speed on the underlying object implementations. This is important, since my approach in No Frills is Here’s how you’d do this in PHP, here’s how to do the same [...]
astorm
Although the technique still works, various members of Magento’s engineering team have discouraged using Magento 1’s <action method="..."/> syntax to call methods on blocks from layout update XML files. <block ...> <action method="addTab"> <argument name="name" [...]
astorm
Magento 2 module creator and code generator | Mage2Gen Haven’t had a chance to check this out yet, but it looks like another Magento 2 module generation tool. This one seems to be an “everything and the kitchen sink” approach (vs. pestle which lets you build only the parts you need) but that approach does mean you get a [...]
astorm
Can’t Add a new UI Component Type · Issue #5647 · magento/magento2 An interesting side effect of the new XML schemas – the definition.xml files for UI components have their top nodes locked down, which means developers can’t add their own UI component types.
astorm
Formatting Dates in Magento Javascript If you’re doing any work in Magento’s RequireJS based javascript modules and see a dateFormat string defaults: { dateFormat: 'MMM d, YYYY h:mm:ss A' }, Chances are its a Moment.js date format string. You can pull in the main moment function via a RequireJS shim define(['moment'], [...]
astorm
Demystifying Plugins (MageTitans Italy 2016) Concise explanation of the code involved in using a Magento 2 Plugin to change core system behavior, with the talk over here if you’re the sort who likes context.
astorm
I’ve been digging through Magento’s UI Components this week and hit a stumbling block. The main KnockoutJS template that kicks off rendering (vendor/magento//module-ui/view/base/web/templates/collection.html) looks like this <each args="data: elems, as: 'element'"><render [...]
astorm
I just updated pestle with a new magento2:generate:ui:grid command. Magento 2.1+ only, not likely to be ported backwards to the 2.0.x branch. A longer article over on alanstorm.com is forthcoming, but here’s the quickie version. Here’s the arguments to use to create a UI Component Listing. $ pestle.phar [...]
astorm
If you’re following along with Magento 2 development, you’ve probably heard the drum beat that the Model/Resource Model/Collections are old and tired, and the Repository classes are new and wired. While the move towards repositories is is a Good Thing™, a Magento 2 developers still needs to know the old CRUD system, and that [...]
astorm
How Interceptors are Generated TLDR; The object manager appends Interceptor to the class name you asked for if there’s a plugin. Then a second PHP Autoloader will look for Interceptor at the end of a classes name, and if it can’t find a definition via normal means, the autoloader generates the class.
astorm
One of the things Magento 2.1 doesn’t bring to the table is the ability to symlink your modules and other components. It’s hard to tell if this is a deliberate omission, or just something that’s not a priority for the development team and keeps getting lost in the shuffle. If you checkout the Context section of this [...]
astorm
This is another one of those 10,000 foot view posts, as much to get my own head straight about something as anything else. In programming, the term scope usually means If I’ve defined variable X “here”, where else can I access it? Magento’s core team have borrowed the term scope to described Magento’s [...]
astorm
How Can I Resolve a RequireJS Alias in Magento 2? A quick command line that will, usually, resolve those RequireJS map/shim/alias things that often obscure where a file lives in Magento 2. Spoilers find vendor/magento/ -name requirejs-config.js -exec grep addToCart '{}' +
astorm