A quick, semi-regular roundup of open Magento 2 technical questions. How to use ui_component Magento introduces a new layout handle XML node named uiComponent that lets you insert specific user interface elemnts into your application. Unfortunately, documentation on how to use this is woefully incomplete. The documentation that does [...]
astorm
I’m seeing the following error a lot when running bin/magento setup:upgrade Missing write permissions to the following directories: ’/Users/alanstorm/Sites/magento-2-with-keys/magento2/pu b/static’ Extra frustratingly – if I look at every file and directory in pub/static, they all have fully world readable, [...]
astorm
These methods aren’t, as of 2.01, marked as @api safe so they may go away. That said, they’re pretty integral to how the layout works so I feel like they have a good shot of sticking around. If you want to add a frontend asset to your page layout programmatically and not render the <link/>/<script/> tags yourself, [...]
astorm
Not strictly a Magento 2 thing, but if you have code that looks like this in your extension namespace FooBazBar; //... if( $node instanceof SimpleXMLElement) {} You’ll need to make sure that SimpleXMLElement is actually used in your current namespace. namespace FooBazBar; use SimpleXMLElement //... if( $node instanceof [...]
astorm
As promised, today we're going to show you how to add javascript and CSS files to your Magento module without needing to worry about how their paths are rendered or how Magento serves them. While you may find this article useful on its own
astorm
Quick heads up if you’re using Magento 2’s __ function to translate strings in your extensions. Magento 1’s translation functions allowed you to use sprintf style replacement tokens. Mage::helper('module')->__('Hello %s', $string); $this->__('Hello %s', $string); Magento two opts to use a globally accesible __ [...]
astorm
Using PHP Code to Generate Asset URLs in Magento 2 Question and answer from yours truly on using the asset repository to get the full URL to Magento 2 frontend asset files. The short version – inject a MagentoFrameworkViewAssetRepository, use $repository->createAsset('Vendor_Module::path/to/file.js') to create an asset object, [...]
astorm
We interrupt your regularly scheduled Magento tutorial for a quick announcement about a new (Magento related project) I've been working on.
astorm
Based on some early theme conversion work in Magento 2 – it looks like the view.xml theme fallback is an all or other thing. If your new theme’s view.xml file is missing an image that’s defined in the parent theme file, Magento explodes when trying to find the parent image file.
astorm
Can’t Create URLs Shorter than Three Characters · Issue #2910 · magento/magento2 Reminder: In Magento 2 (as in Magento 1) a route’s name is how Magento internally identifies the route, and uses it for creating things like layout handles. The front name is what shows up in the URL bar. These are very often the same, but [...]
astorm
Genmato/M2_Sample Nice sample extension with a lot of Magento 2 features.
astorm
Can’t Create URLs with Single Dashes · Issue #2910 · magento/magento2 One of the downsides of creating a new framework is you end up creating the same problems that have already been solved in other frameworks. For some reason Magento 2 wants all URL “front names” (the first URL segment) to be three characters long, and [...]
astorm
Magento 2: Different static-asset Files Per Locale? To save you a click view/[area]/web/hello.js view/[area]/web/i18n/fr_FR/hello.js
astorm
Last time we discussed how Magento serves and generates front end (javascript, css) files to end users from its own modules. Like most of Magento's feature, if it's done in a core module, third party developers can do it in their own modules. This
astorm
Workaround for Magento 2 static asset/symlink bugs Hackish workaround for the problem of static asset generating and serving not working with symlink-ed modules.
astorm
I did a quick review of Magento 2 questions I’ve asked on Stack Exchange recently. Most had answers, but there were still some that remained unanswered, or whose answers were incomplete. If you’re looking for something to do during your corporate by week tracking down answers to these would be a big help. Magento’s [...]
astorm
A quick word of warning – if you’re going to blow away the pub/static folder and regenerate your assets (either dynamically with in developer mode, or statically with setup:static-content:deploy) don’t forget to restore the .htaccess file at pub/static/.htaccess. Magento won’t be able to do its automatic developer [...]
astorm
When Magento 1 was initially released, "front end development" as it exists today was barely a thing. CSS was still largely written by hand, and jQuery vs. PrototypeJS was still a legitimate question for a new software project. Magento 2 enters a world where
astorm
One of the interesting changes betweem Magento 2’s merchant beta and their official release was/is the registration.php file. Every module now needs this file at its root folder for Magento to identify it as a module. You can see the list of folders Magento scans for modules (i.e. registration.php) here #File: [...]
astorm
I’m seeing some behavior in Magento 2’s cookie management that has my “I’ve been at this too long” hackles raised. Different areas (adminhtml, frontend) still have separate session cookies, but the adminhtml area’s is named admin, and the frontend area’s uses the default PHPSESSID. It’s [...]
astorm