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.
Permission issues with static generated files in pub directory · Issue #2412 · magento/magento2 I built my first website in 1995 – which means I’ve had over 20 years of battling unix file permissions. Or, more appropriatly, fighting the software world’s myriad ways of dealing and not dealing with them.
astorm
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
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
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
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
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
Early Stage Plugins/Interceptors Don’t Work in Developer Mode · Issue #2674 · magento/magento2 This one was fun to track down. I was trying to plugin to Magento’s logger (MagentoFrameworkLoggerMonolog) but my plugin wasn’t working. Being new to Magento, I assumed the problem was an incorrect configuration, but [...]
astorm
If you’re seeing the following error in Magento 2 Invalid Base URL. Value must be a URL or one of placeholders: {{base_url}} The problem may the lack of a trailing slash on your base URLs http://example.com vs. http://example.com/ There’s some questionable URL validation going on in #File: [...]
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