geschrieben von
am 7. Februar 2017 - 22:15

For backend UI Components, the rendered x-magento-init JSON argument contains two top level keys: types and components

{ "*": { "Magento_Ui/js/core/app": { "types": {/*...*/}, "components": {/*...*/} } } }

The Magento_Ui/js/core/app module/application uses the data in components to instantiated a nested tree of uiClass based objets and register them as KnockoutJS view models (accessible via Magento’s customer KnockoutJS scope binding). It was never clear to me what the types information was for. I’ve sort of figured that out – or at least enough that I’m not mystified anymore.

In a components object, I came across the following configuration for a UI Component.

"components": { /*...*/ "cms_page_form": { "type": "cms_page_form", "name": "cms_page_form", "children": {...}, "dataScope": "data", "config": { "namespace": "…
geschrieben von Brendan Tull
am 7. Februar 2017 - 22:10
How to Change Magento 2 Increment ID for Orders, Invoices, Credit Memos and Shipments

Some merchants want to customize order numbers or invoice numbers to be different than what Magento 2 produces by default. They might want the numbers to contain more information, or they might have an existing format that shouldn’t be changed. Perhaps the numbers need to pick up where they left off from a previous website (or maybe they just don’t look pretty enough). These numbers each have an Increment ID, and the values used to create them are stored in the database and are not configurable from admin, so we’ll need a little SQL to make our customizations. Without further ado…

We can individually adjust the following properties of increment IDs for Orders, Invoices, Creditmemos, & Shipments:

  • Prefix
  • Suffix
  • Step
  • Start-value
  • Pad-length

The Prefix, Suffix, Start-value, and Step are stored in the…

geschrieben von Stjepan Udovicic
am 7. Februar 2017 - 13:32

Session is something that PHP developers use in their everyday work. But how many of you did took some time to actually consider where are they stored and how does that impact your application? Should you even care? Does number of sessions influence performance of your application?

Setting up the test for file-based sessions

To test this, lets create some code. Keep in mind that same apply to larger applications such us Magento as well, but for the purposes of this article, we will keep it simple:

<?php   // Start profiling $start = microtime(true);   // Set header header('Content-type: text/plain');   // Adjust session config ini_set('session.save_path', __DIR__ . '/sessions/'); ini_set('session.gc_probability', 1); ini_set('session.gc_divisor', 10); ini_set('session.gc_maxlifetime', 3000);   // Init session session_start();   // End profiling $duration = (microtime(true) - $…
geschrieben von Fabian Schmengler
am 7. Februar 2017 - 9:19
This is my weekly Kata post. Read the first one to learn what it is all about.

Last week: Karate Chop

This is going to be a longer post because my goal was to follow the kata description and try out five different approaches. I will explain all of them:

Approach 1: Object oriented PHP

My goal in this approach was to use as little PHP functions as possible and implement the algorithm in an object oriented way

The final solution had the following classes:

interface IntegerHaystack { public function positionOf(int $needle) : int; public function isEmpty() : bool; } class SortedIntegers implements IntegerHaystack { public function __construct(int ...$integers) { ... } ... } class SortedIntegersRange implements IntegerHaystack { public function __construct(SortedIntegers $sortedIntegers, int $indexFrom, int $indexTo) { ... } ... } class…
geschrieben von
am 7. Februar 2017 - 6:39
mattwellss/magento-composer-autoloader:

For folks still playing “wait and see” with Magento 2, (i.e. most current Magento systems), and who are using some sort of Composer workflow (not most Magento 1 systems), this is a small autoloader optimization that fixes Magento 1’s selfish “if I try to load someone else’s class and it doesn’t exist I’ll explode” autoloader.

geschrieben von
am 4. Februar 2017 - 6:17

So, over the summer I covered how to invoke a function returning RequireJS modules via an x-magento-init script. Today I discovered there’s a syntax for doing this with an object returning RequireJS module. If you’ve got an x-magento-init that looks like this

<script type="text/x-magento-init"> { "*": { "Package_Namespace\/js\/example": {/* ... config object ... */} } } </script>

just define a module that looks like this

#File: app/code/Package/Namespace/view/web/frontend/js/example.js define([], function(){ return { /* ... other methods and properties */, 'Package_Namespace\/js\/example':function(configObject){ //magento will call this function } } });

That is – if your RequireJS module returns a non-function, and that non-function is an object with a…

geschrieben von
am 3. Februar 2017 - 23:24

One of the challenges Magento 2, (and all “full stack” oriented frameworks), face is data synchronization between the front end and the server. Server data will always represent the “source of truth” for any particular piece of data, but good front end developers will always be looking to reduce to number of round trips they make to the server. Magento 2 faces an additional cultural challenge in that it remains a PHP framework, and most developers doing Magento 2 work are going to rely on its many code injection features to change how server side data is saved. In other words, reducing a client side round trip may work out of the box, but may result in stale data if new server side code runs during ajax requests.

I’ve notice that, whenever a developer asks for help along these lines the mysterious sections.xml files are often…

geschrieben von
am 3. Februar 2017 - 20:44
How to clear billing form validation errors when using Magento UI components:

A “quick” (har har) answer from me on how to reset a form field’s validation state in the Magento 2 checkout application. This is also a nice example of how, no matter how far we progress with computers doing things for us, it’s always going to be useful to reason about how a computer does the things it does. Without the Magento 2 documentation I’ve written, or the tooling I’ve built, there’s no way this question gets answered without an individual developer spending days or weeks on it.

If you want to be successful with any customizable/programmatic information system – hire developers who know what they’re doing…

geschrieben von
am 3. Februar 2017 - 1:42

A useful code snippet that came out of a discussion on the Patreon slack today.

requirejs([ 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/shipping-rate-registry' ], function(quote, rateRegistry){ //get address from quote observable var address = quote.shippingAddress(); //changes the object so observable sees it as changed address.trigger_reload = new Date().getTime(); //create rate registry cache //the two calls are required //because Magento caches things //differently for new and existing //customers (a FFS moment) rateRegistry.set(address.getKey(), null); rateRegistry.set(address.getCacheKey(), null); //with rates cleared, the observable listeners should //update everything when the rates are updated quote.shippingAddress(address); });

The program, (which could be (and should be) easily ported into a define module) will trigger an update…

geschrieben von Fabian Schmengler
am 1. Februar 2017 - 0:10
This is my weekly Kata post. Read the first one to learn what it is all about.

Last week: Word Wrap

In PHP/Behat I learned about scenario outlines, which remove a lot of repetition in feature files. Full result:

Feature: Word Wrap In order to display text on tiny screens I want to wrap lines of a long text Scenario Outline: Wrap text When I wrap <text> at <col> columns Then I should retrieve the wrapped string <wrapped> Examples: | text | col | wrapped | | | 1 | | | word | 2 | wo\nrd | | word | 3 | wor\nd | | word | 4 | word | | word | 5 | word | | word word | 4 | word\nword | | word word | 5 | word\nword | | word word | 7 | word\nword | | word word | 8 | word\nword | | word word | 9 | word word | | abcdefg hij klmno p qurstuvwx yz | 4 | abcd\nefg\nhij\nklmn\…
geschrieben von Kostyantyn Systalyuk
am 31. Januar 2017 - 16:01

Most of the testing tools are too complicated. For a long time we’ve been looking for an automatic testing framework to meet our needs. We tried a lot of frameworks like Selenide and CasperJS but they were not exactly what we’ve been looking for. Not so long ago, we’ve discovered a tool Codeception and I want to introduce you to it.

Codeception is a powerful but at the same time, a very simple tool that covers your projects with auto-tests. It was created based on a famous testing framework – PHPUnit.

There are three types of tests: Acceptance tests, Functional tests, and Unit tests.

In this blog post I will cover acceptance tests, which can help you emulate a customer behavior on your web store and check different scenarios in order to make sure that the website works properly.

How to…
geschrieben von Adrian Bece
am 31. Januar 2017 - 13:43

OroCommerce application version 1.0 has been released last month with a premise that it will „disrupt B2B Online Commerce“ and „change the world of B2B eCommerce“. With the noticeable rise of Business-To-Business eCommerce in the recent years, it was only a matter of time when the supporting B2B applications and platforms would show up and we at Inchoo are excited to see what OroCommerce brings to the table. We will be taking a look at the installation process and some useful tips on getting started with recently fully-released OroCommerce B2B platform.

Installing OroCommerce on localhost

In this article, I am going to cover general steps when installing OroCommerce on a local development machine. I have successfully installed OroCommerce on both AMPPS and XAMPP local development environments on MacOS and Windows respectively and I will be listing some common general errors that you could encounter and how to fix them.

Step 1: Preparation – Domain and Config

geschrieben von Fabian Schmengler
am 27. Januar 2017 - 15:57

Common convention for namespaces in PHP is to start with Vendor\Package, capitalized (CamelCase) with “vendor” and “package” analogous to the composer package name.

There is a bad habit I see often, probably coming from the ZF1 and Pear days, where every word in the class name is a new sub namespace (and a new subdirectory), or child classes are moved into a namespace with the name of the parent class. All this is leading to deeply nested namespaces and class names that have no meaning without their namespace.

Examples from Zend Framework 1 (pseudo namespaces):
  • Zend_Db_Table_Row_Abstract an abstract base class for Zend_Db_Table_Row, representing a database table row. There are also Zend_Db_Table and Zend_Db.
  • Zend_Pdf_FileParser_Font_OpenType_TrueType a parser for true type font files. The class extends Zend_Pdf_FileParser_Font_OpenType which extends Zend_Pdf_FileParser_Font which…
geschrieben von Igor Furseev
am 27. Januar 2017 - 14:57

Magento 2 is becoming more and more popular day after day. Many vendors decide to use this platform for their eCommerce business. Migrating data from other platforms and services has always been a popular task, but it is even more needed today. In this blog post I will show you how to easily import product images from an external URL.

Magento 2 import handles saving product images pretty well, but the images should already be located on your server. With the service, described below, I will show you how to grab an image URL and turn it into a product image. All the necessary logic is wrapped into this service, so it can be called from your controllers, observers, via import plugins or from any other kind of entry point that you want.

I assume that you’ve already registered your extension like VendorName_ExtensionName and it is located in the app/code/VendorName/ExtensionName. The code of the service:

<?php /** * file location: *…
geschrieben von
am 26. Januar 2017 - 0:05

One the curious/frustrating bits of approaching Magento 2 as a traditional, full-stack Magento 1 developer, is the seemingly incomplete php bin/magento. While this command allows you to clear your Magento cache

php bin/magento cache:clean

and a command to generate “static content” (front end javascript, css, etc. files not generated by the PHP code in the application)

php bin/magento setup:static-content:deploy

It doesn’t contain commands that clear out the Less CSS cache in var/view_preprocessed. The problem? The PHP team at Magento seems to have shifted that responsibility to grunt, the front end build tool for Magento.

The Magento dev docs site has decent instructions (for 2.0 and 2.1) on setting up grunt (which has a precursor…

geschrieben von
am 24. Januar 2017 - 21:37

Progress continues on No Frills Magento 2 Layout, with Patrons receiving full access to the rough draft and initial source code samples. I just finished the section on Magento 2’s Less handling – basically an update to my article on the same topic last year. Here’s an excerpt that wraps up the section.

For folks working for a certain sort of interactive agency, Magento 2’s choice of Less was somewhat disappointing. Other processors like Sass and Stylus seem more popular with this set of developers. Because of this, we’ve seen some efforts to create alternate CSS workflows using these systems.

While these are interesting projects, and do create a workable alternative for folks heavily invested in these stacks, these projects (along with things like “headless” API only implementations) end up sacrificing a huge…

geschrieben von Olena Sadoma & Ksenia Oliynyk
am 24. Januar 2017 - 18:06

An office manager is an obvious hire for any company. The very definition of an office manager implies that there needs to be an office. Thus if you have one, there is no question whether you need a person, who provides day-to-day comfort and maintenance of the working environment. But when it comes to remote or distributed companies, the question is not that easy to answer. And since Atwix is a distributed company with both remote-only and in-house employees, we decided to share our experience with having an office manager, who manages not only a physical office, but something else. This is what we are going to learn from Ksenia, our office manager.

Ksenia, what were your expectations of your future work when you applied for this position?

As it is obvious from the title, an office manager is responsible of any operational process in the office. While the teams have their own processes and management rules, I was expecting to be in charge of making the office…

geschrieben von Vanja Devcic
am 24. Januar 2017 - 13:23

Sass has four different CSS output style. By changing setting for :style option or using the --style command-line flag.

I will show you how Sass outputs this piece of SCSS code in all style options with style option explanation.

main { padding: 12px 24px; margin-bottom: 24px; }   article { background-color: #00ff00; color: red; border: 1px solid blue;   p { font-size: 18px; font-style: italic; margin-bottom: 12px; } }

:nested

Nested style is the default Sass style because it reflects the structure of the CSS styles in which each property has its own line, but the indentation is based on how deeply it’s nested. Example bellow:

main { padding: 12px 24px; margin-bottom: 24px; }   article { background-color: #00ff00; color: red; border: 1px solid blue; } article p { font-size: 18px; font-style: italic; margin-bottom: 12px; }

geschrieben von
am 24. Januar 2017 - 4:02
After update from 2.1.2 to 2.1.3 causes store to redirect to wrong domain · Issue #8245 · magento/magento2:

On the other end of the spectrum, it sounds like Magento 2.1.3 broke how the System Configure system handles fallback values. The lack of a clear response from Magento means we don’t know if they consider this new behavior a regression or fixing the old behavior.

geschrieben von
am 24. Januar 2017 - 1:00

Choice is good, right? The more product lines we list on our online stores, the more options we give our visitors, then the greater the likelihood that visitors will buy something and our conversion rates will improve. Yes? Well, not necessarily.

Adding more product lines to an ecommerce store should deliver increased customer satisfaction and increased sales for you but there are pitfalls of managing a large product catalogue. I'll take a look at the benefits of a large product range, some of the questions you should be asking yourself and then share proven ways you can support your product range to provide the greatest chance of success.

The Benefits of Ranging More Products

Increasing the size of your product catalogue is not the answer for every company. However, there are commercial opportunities available, a few of which being:

  • To cater for consumers' individual needs and wants. Variations in colour, size and price are common to many products. So…