browse the blogs

[ 15 Jan 2018 ]

Magento 2’s Starting Order/Invoice/Shipment/Credit IDs:

While there were a number of extensions for Magento 1 that let you change the IDs generated and printed for Magento’s orders, invoices, shipments, and credit memos, I haven’t seen one emerge for. This post from Classy Llama jumps down into M2’s database table and tries to figure out where Magento 2 generates these IDs.

[ 10 Jan 2018 ]

Chrome Redirecting .dev to HTTPS:

The latest version of Google Chrome (Chrome 63) will redirect any domain that ends in .dev and .foo to an https URL automatically. It sounds like Google felt they could do this since they bought the entire .dev and .foo global top-level domains (gTLD). I joke complained about this on Twitter before, but it seems like my Chrome finally auto-updated to version 63 in the past few days. A handful of important web applications I run directly on my computer, plus almost all my client dev sites, stopped working. It’s not hard to pick a different gTLD and change the […]

[ 8 Jan 2018 ]

Just Enough C for PHP: Using C Variables:

Last time we ambushed you with a bunch of information about how C manages memory when you declare variables in your programs. Today we’re going to stick to int, float, and char variables, but get into the nitty gritty of actually using them. To start, let’s consider our original hello world program. #include int main() { printf(“Hello World\n”); return 0; } This program uses a function named printf. The f in printf stands for format. While you can use printf to print a string (as we have above), the real power of printf is in its ability to print strings […]

[ 31 Dec 2017 ]

No Clear Wins:

Two of the biggest mind shifts I’ve had to make in coming back to C programming have been strings and variable scope/lifetime. This Stack Overflow question is a nice encasulation of both. First off — strings aren’t a first class type in C. They’re just a char array of individual characters, with a NULL character as the final element. This might not seem that bad, until you remember that arrays aren’t the simple “lists of stuff” you might be used to in higher level languages. In C, an array is a literal allocation of “N” bytes of RAM. Arrays are […]

[ 28 Dec 2017 ]

The Odd Semantics of Magento 2’s referenceBlock:

In Magento 1, it was pretty common to write a bit of layout update XML that looked like the following. This XML translates roughly into the following PHP pseudo code $block = $layout->getBlock(‘head’); $block->setLabel(‘skin_js’); Or, in plain english, Magento fetches a reference to the already instantiated block object named head, and then calls this block’s setLabel method. This syntax has survived, mostly, into the Magento 2 era. Although the Magento provided “dev docs” say the syntax is “not recommended“, action methods still work Does this Work […]

[ 26 Dec 2017 ]

Layout XML Merging in Magento 2:

One of the bigger changes to Magento 2’s layout system is how a end-user-programmer uses layout handles. In Magento 1, layout handles were top level configuration nodes in a set of layout update xml files In Magento 2, layout handles are individual XML files (which I’ve been calling layout handle XML files) #File: path/to/module/view/layout/handle_name.xml One interesting side effect of this is, unlike Magento 1, Magento 2’s layout XML files are susceptible to node level merging. i.e. — consider this core XML file #File: vendor/magento/module-catalog-search/view/frontend/layout/default.xml […]

[ 24 Dec 2017 ]

Magento 2’s Poorly Named Layout Argument Nodes:

Magento 2 introduced a new node type to its Layout XML DSL — the and node. #File: vendor/magento/module-shipping/view/frontend/layout/sales_guest_view.xml Track your order Like so much of Magento — the names of these new nodes hide their purpose from developers. All the nodes do ensure a value will be set on the final block object. i.e. The above code will set a label property on the tracking-info-link block (instantiated from the PHP class Magento\Shipping\Block\Tracking\Link). This means you can access the property from your phtml […]

[ 19 Dec 2017 ]

Getting out of the Block Business:

This in an interesting Magento layout technique that came my way via Vinai Kopp (of fame). Magento 2’s automatic constructor dependency injection system presents a problem for class trees with multiple levels of inheritance. First, programmers end up needing to call parent constructors with the right arguments, and in the right order. Second, class hierarchies also create confusion w/r/t the object manager’s configuration — namely, which constructor should the object manager reference when looking for arguments to instantiate and inject? Magento 1’s block class hierarchy has a lot of inheritance. Magento 1 plugins modeled on the core code also […]

[ 6 Dec 2017 ]

Just Enough C for PHP: Variables and Types:

This entry is part 3 of 3 in the series Just Enough C for PHP. Earlier posts include Just Enough C for PHP, and Just Enough C for PHP: Running C Programs. This is the most recent post in the series. Today’s episode of Just Enough C for PHP is light on code and heavy on core concepts. First, we’re going to describe using basic variables in a C program. Then, we’re going to take a detour into how C manages the computer’s memory for those variables. You may be tempted to skip the second part, but we recommend you […]

[ 5 Dec 2017 ]

Never Worry about Symlink Argument Order Again:

One long time resident of my ~/bin folder is lns lns — a friendly program for making symbolic links For whatever reason I’ve never been able to get the argument order to ln -s memorized. The lns perl script (which has always run out of the box on system provided perl without issue) make it so I never need to. Whether you lns path/to/file path/to/new-link or lns path/to/new-link path/to/file the script does the right thing and creates the symlink, or tells you in plain english why it can’t. Mentioning the script here mainly because google seems less and less able […]