Welcome to your fortnightly “Open Magento 2 Technical Questions” post. If you’ve got an answer to any of the following please use the provided Stack Exchange thread to answer, or say hello via email if public communication isn’t possible. First off, we’ve got a slew of new questions. After that, some follow [...]
astorm
This one deserves a longer post, but my schedule is not forgiving. This assumes you’ve read and understand the concepts from my Magento object manager series. Many Magento provided classes have a special context object in their constructor. #File: vendor/magento/module-catalog/Controller/Product/View.php //... use [...]
astorm
Magestead – A Vagrant LEMP Stack for Magento Developers Magestead looks like another contender in the “geting a Magento 2 system up and running using vagrant and VMs”. Homestead inspired, it may be worth checking out.
astorm
Request: .user.ini files for FPM config · Issue #705 · magento/magento2 Somehow I’d always assumed nginx worked hard to be apache compatible. It doesn’t sound like that’s the case, which is a shame. I also found this on the official nginx wiki Stop using .htaccess. It’s horrible for performance. NGINX is designed to be [...]
astorm
For over a decade I’ve kept most my development work confined to the physical Macintosh OS X laptop I use every day, running server software using the OS X unix/bsd/darwin internals. I pick a stable version of PHP and install the php-osx package (previously the entropy.ch package), install MySQL via MySQL/Oracle’s OS X [...]
astorm
I’m not super conversant in the less CSS preprocessor, so I’m not sure how useful they are, but Magento 2 ships with some useful looking UI library docs in lib/web/css/docs/index.html You won’t be able to browse to these files via HTTP – you’ll need to open them directly in a web browser.
astorm
Magento 2 Marketplace Upload Validation Tool (Quick Note) Magento’s lead architect, Alan Kent, just posted a small command line program to validate a “composer zip archive” for Magento Marketplace. Magento Marketplace is the replacement for Magento Connect, and although its details remain a secret, its assumed to be an [...]
astorm
Thanks to some late, post merchant beta changes made to Magento, distributing modules via Composer (PHP’s de-facto package/dependency manager) has never been easier. While we’re all interested to see how the new Marketplace turns out, thanks to Magento 2’s architecture changes we should all be able to distribute our [...]
astorm
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