browse the blogs

[ 26 Jul 2017 ]

One thing I breezed by in my recent Modifying a jQuery Widget in Magento 2 article was the whole returns two widgets RequireJS module thing. We mentioned that modules like the mage/menu module will do this.

//File: vendor/magento/magento2-base/lib/web/mage/menu.js
define([
    "jquery",
    "matchMedia",
    "jquery/ui",
    "jquery/jquery.mobile.custom",
    "mage/translate"
], function ($, mediaCheck) {
    'use strict';

    $.widget(/*...*/);


    $.widget(/*...*/);

    return {
        menu: $.mage.menu,
        navigation: $.mage.navigation
    };
});

However, we never got into what it means for a RequireJS modules to return two widgets. We …

[ 17 Jul 2017 ]

Re: A Declarative Approach for Database Schema Upgrades:

It sounds like Magento’s planning a pretty radical overhaul of how it handles schema and data upgrades between versions. The looks to be a fiat from on high (vs. the community driven approach they’ve been using for bug fixes). If you’re making schema/data changes that aren’t in Magento’s core or Marketplace code bases, you’ll want to pay attention to this – your deck chairs may need shifting about.

[ 17 Jul 2017 ]

Menu Editor to Replace Category Based Menus in Magento 2.:

Feels like I can recommend checking out stuff from SnowdogApps, sight unseen.

[ 10 Jul 2017 ]

Create a PHPUnit Dashboard With New Relic:

Not strictly Magento related, but if you’re using New Relic it looks like they can automatically detect test runs and give you useful metrics about your tests. Neat!

[ 20 Jun 2017 ]

oddyssey/mailtrap:

A simple mailtrap extension for Magento 2. Mailtrap is a service that lets you point your development instances at an SMTP server that accepts mail, but doesn’t deliver it. Instead mailtrap collects all the mail in a single INBOX. If you’ve ever accidentally emailed an entire customer list with a subject line like

Subject: Testing, hope this s——t works.

you’ll instantly see the value.

The Magento extension is also a simple example of how to hook into the Magento\Framework\Mail\Transport class with a custom preference and change the behavior of the email system.

[ 1 Jun 2017 ]

Reserved Words in Magento 2 URL  Paths:

A StackExchange self answer where I use a plugin to work around the reserved-PHP-symbol-in-class-name problem that can plague Magento 2 URL routing. What’s extra baffling about this is Magento has a fix coded up, but only applies it to one URL segment.

I suspect this is less baffling if you can gives up the idea that Magento 2 should retain its the rapid application prototyping roots of its ancestors.

[ 1 Jun 2017 ]

Magento 2 – Form Validation:

A StackExchange post that contains most (all?) of the CSS classes that can control Magento 2’s form validation. Magento seems to apply the validation rules on all form submits – although I haven’t dug too deeply into that one so caveat emptor etc.

Also, a bonus for folks who read these Tumblr desciptions — here’s a quick bit of javascript that will take M1 style HTML and make all the fields required in an M2 context.

require(['jquery'], function($){
    $('.required-entry').each(function(key, element){
        $(element).attr('required','required');
    });        
});

Useful if you have a complex form built with a combination of raw …

[ 26 May 2017 ]

Magento custom Knockout.js bindings | Magento 2 Developer Documentation:

It might have taken 11 months, but it looks like Magento finally gave its dev docs team the resources they needed to document the UI Component Knockout JS custom bindings.

[ 24 May 2017 ]

JavaScript unit testing with Jasmine | Magento 2 Developer Documentation:

Jasmine’s a testing framework for javascript code – I didn’t know until today that Magento 2 had setup a framework for these tests.

(Via the tremendous Vinai)