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
Magento 2, KnockoutJS ViewModels, and Scope Binding A self answer from me over on the Magento StackExchange. The short version – Magento applies knockout bindings without a default view model. The Magento_Ui/js/core/app module/program, embeded via x-magento-init, adds view model objects to the uiRegistry. Finally, Magento has [...]
astorm
Magento 2’s core javascript library ships with a basic implementation of a class based object system, and the uiComponent feature uses these classes and objects extensively. The base class is the Magento_Ui/js/lib/core/class module/object/function, and you create a new instance of the class using javascript build-in new keyword. [...]
astorm
KnockoutJS: What Does Calling applyBindings Without Arguments do? Getting into Magento 2’s KnockoutJS implementation, and being slightly annoyed at the JS world. Knockout’s a great framework, but by positioning themselves as an MVVM framework they create the impression that Knockout itself is enough to contain your entire [...]
astorm
First, lets bask in the awful yet accurate glory of my original title for this quickie: Dependency Injection Argument Specific Instance Objects. If you’ve worked your way through my Magento 2 Object Manager series, you know its possible to tell Magento’s object system that a particular object should be instantiated every time [...]
astorm
Magento’s documentation tells you to run tests with the following php bin/magento dev:tests:run unit This isn’t wrong, but it pretty time consuming. You’re running every test in the suite. This one liner will let you run an individual test vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist [...]
astorm
Magento 2: Sort Order gets Weird for “Around” Plugins Interesting bit of insight from Anton Kril on plugin firing order. My naive assumption on how this would work was All before plugins fire The around plugin chaining happens All after plugins fire However, based on what Anton’s said here, it sounds like an around [...]
astorm
If you grab the latest version of pestle (updated minutes ago) you should be able to use the following set of commands to create a base module with a working admin route. $ pestle.phar generate_module Pulsestorm HelloAdminPestle2 0.0.1 $ php bin/magento module:enable Pulsestorm_HelloAdminPestle2 $ php bin/magento setup:upgrade $ [...]
astorm
While phrases like “should we be be doing this in 2016” abound in engineering discussions, down in the trenches an arbitrary SQL query is often the fastest, most expedient way to get at the data you want. While I still regularly encourage developers new to Magento to embrace using the models and API resource models when [...]
astorm
Two good Stack Exchange answers from Raphael at Digital Pianism covering how to add a custom icon to your Magento Admin Menu Items. In short – these menu items use a custom font character, defined in svg file that’s (somehow? via LESS CSS?) converted to an embedded OpenType font. This custom font uses the Private Use Area of [...]
astorm
Creating an MCV/MVVM landing page for Magento 2’s frontend cart application is relatively simple. You create a routes.xml file so your module can “claim” a frontname, then then create a controller class that’s named correctly to catch a particular URL pattern. This is even easier with pestle, my PHP CLI module [...]
astorm
One last bit on the area setting object in Magento 2. There were times in Magento 1 where it was necessary to temporarily pretend you were running code in one area, even though you were in another. One famous example of this was using Magento’s catalog/product objects to directly save product information while on the frontend. In [...]
astorm
Carved out some time this weekend to add Repository generating code to pestle’s generate_crud_model command. Now, in addition to creating your standard Magento 2 Model/ResourceModel/Collection objects, you’ll also get a repository for your object with the de-facto standard save, getById, getList, delete, and deleteById [...]
astorm
I touched on this in my longer Magento 2: Understanding Object Repositories tutorial, but it’s worth repeating. The relationship between individual filters and filter groups in Magento 2 repositories is inconsistent. There’s some tribal wisdom floating around that filters should be applied as OR conditions, and filter groups [...]
astorm
MageScotch — A Magento 1 and Magento 2 Vagrant box Another “ready to go” Magento 2 (also Magento 1!) vagrant VM – although this one is offered and maintained by Joshua Warren, so it’s worth more than a casual look. It seems to be based on the Scotch Box vagrant project, which purports to offer a ready to go [...]
astorm
I recently started a new series over on my main website that sets out to explain everything a Magento 2 developer would need to know about composer. The first article covers setting up a satis mirror of repo.magento.com, Magento 2’s official composer repository. An ideal deployment system wouldn’t just mirror Magento [...]
astorm
If you’re giving Magento’s new Marketplace feature a spin for the first time, you may be surprised to find that it requires you have your three Magento 2 cron jobs running. There’s a few reasons for this. The first is a clever solution to the perennial PHP permissions problems when running commands and creating files as [...]
astorm
If you’re trying out Magento’s new Marketplace feature (essentially a ground up redesign, both backend and UX, for Magento Connect), you may run into a 404 error when you try to access the “Web Setup Wizard” (which is where you can access Component Manager, which is what lets you add purchases to your system). [...]
astorm
Sometimes, when you’re working with a Magento 2 command line script, you’ll see an uncaught exception that looks like the following. Area code not set: Area code must be set before starting a session Areas in Magento refer to different sections of an application (like frontend cart, or the adminhtml admin console) available [...]
astorm
If you’re being a good Magento 2 programmer, you’re not directly accessing an object manager instance. You’re using dependency injection to inject your objects in a constructor so future programmers will have a clear place to see a class’s dependencies, and change them if need be. But we know good programmers [...]
astorm