I am currently porting our IntegerNet_Solr extension to Magento 2. This extension integrates Solr as a product search in your Magento frontend, providing an extensive autosuggest function and fuzzy search results, which are a lot faster and better than Magento’s standard product search. It’s a complex module, tightly coupled with the Magento core: like indexer, search, layered navigation or category view. So the first step was to reduce this coupling and make most of the code independent of Magento. My goal is to reuse it in the Magento 2 module and have as little Magento specific code as possible.

I already worked with this framework independent (aka framework agnostic) approach before, and presented it at Meet Magento DE 2015 (see presentation slides – German) in the context of unit testing. Implementing business logic independent of the framework enables Test Driven Development and clean, performant unit tests.

This article series introduces useful design patterns for decoupled Magento extensions, which are divided in two parts: the Magento module and a framework independent library, that is reusable for Magento 1 and Magento 2.

Diagram of Magento 2 Extension Dependencies for Framework Agnostic Modules

It will not cover the refactoring process, that’s a different topic and I am going to talk about it at Developers Paradise 2016 in Croatia. Stay tuned!

All Parts:


Start reading


Glossary (or: “What?”)

In case I lost you with the technical terms, find some definitions below:

  • Coupling: A term to describe interdependency between software components. Accordingly, decoupling describes the act of making components independent from each other.
  • Framework independent code: In our case, the framework is Magento, and all code that is not directly using features of Magento (does not make any calls to Magento classes), is framework independent.
  • Business logic: Simply stated, the code that constitutes features (business needs), isolated from technical details like database operations and the user interface.
  • Module and Library: When I am talking about modules, I refer to the Magento module, which is the part of the extension in /app that interacts with Magento, whereas the library is the independent component which will be used by the module and lives in /lib or /vendor.
  • Design Patterns: Solutions for recurring problems in software development. Most importantly, patterns define a common language between developers.
  • Refactoring: Rewriting code to improve code quality characteristics (like maintainability and extensibility) without changing its behavior.


Start reading

Fabian Schmengler

Author: Fabian Schmengler

Fabian Schmengler is Magento developer and trainer at integer_net. His focus lies in backend development, conceptual design and test automation.

Fabian was repeatedly selected as a Magento Master in 2017 and 2018 based on his engagements, active participation on StackExchange and contributions to the Magento 2 core.

More Information · Twitter · GitHub