Skip to content

Magento 2 Challenge

This is a challenge to prove your level of skill with Magento 2.

  • Junior developers: Expect you to achieve level 1
  • Senior developers: Expect you to achieve level 3.

Your task is to do the following

  • Create two new product attributes called x-axis and y-axis
  • On the product page check to see if the product has values for both of these attributes
  • If so display the multiplication table in a tab using the values
  • If not, do not display the tab or grid
  • When the product is bought, a comment should be added to the order stating the values of the x and y axis, if they exist

The challenge is split into 3 levels. The first level is the very minimum. The following levels are extras.

To fully complete the challenge you should try to complete all the levels.

General Requirements

The following points apply to all levels and should always be followed.

  • Magento provide their own Programming Best Practices that should be followed at all times.
  • The code should be valid according to the coding standards Coding Standards
  • Code should be written in a testable manner
  • The code should adhere to the technical guidelines as much as possible
  • In addition, all PHP code should be strictly typed, strict comparisons should always be used, and unless prohibited by class contracts strict parameter and return types must be used.
  • Fully qualified class names should always be imported and short class names used
  • The completed code should run without error in all cases.
  • Deprecated or legacy functional denoted by Magento should not be used
  • Where necessary, code comments should be used
  • Method and class annotations should be used where necessary to describe parameters and return types

Level One: Basic Requirements

This section describes the minimum level you can work towards to pass this challenge

Module Setup

  • The module should run successfully on the latest version of Magento 2
  • Coding standards and guidelines should be aligned with the latest available Magento version.
  • All code should be placed in a module called EdmondsCommerce/MultiplicationTables

Attribute Management

  • The attributes should be created using a data patch
  • The values should be validated to ensure that they are either
    • Both set as positive integers
    • Neither are set
  • If neither of these conditions are met then an error message should be displayed, and the product is not saved

Product Page

  • If both attributes are present a tab will be displayed
  • This tab will be called Multiplication Table by default
  • When clicked, a multiplication table will be displayed using the values from the product
  • If the values are not present, or the values are invalid, then no tab will be displayed and no error will be displayed

Order Comment

  • This should be handled using an event listener
  • The comment should only be added once
  • It should say $productName was ordered with these dimensions $xAxis by $yAxis
  • If there are multiple products in the order with the attributes, then each product should appear on a new line within a single comment

Level Two: Configuration, Documentation, and Basic Testing

To complete the challenge to a higher standard, you should implement these requirements

Module Configuration

  • Within the Configuration menu in the admin, there will be a tab called Edmonds Commerce
  • Within this there will be a section called Multiplication Tables
  • This section will contain these options
    • The ability to enable and disable the module. When disabled no multiplication tables should be displayed on the front end and orders should not be affected by the multiplication code when placed.
    • The ability to change the title of the tab on the product page

Documentation

You should create, in Markdown format as a README.md file in the root of your module, a set of instructions that cover both developer and user level documentation. * How to install it * How to configure it * How to run the tests

Basic Testing

Unit tests should be created for parts of the code that are free of dependencies. These should cover all paths through the code under test and ensure that it gracefully handles success and failure conditions.

Level Three: Quality Assurance

For an even higher standard of completion, you should implement these requirements

Integration Testing

  • The module should be mainly covered with Integration Tests
  • Other test types can be created if useful
  • Fixtures should be used where appropriate.
  • Feel free to make use of our testing module to help with this
  • Tests should pass both with and without the TESTS_CLEANUP flag being set
  • They should confirm that the code is able to do what is asked when given the correct inputs
  • They should also confirm that the code is able to handle things going wrong gracefully

Additional Static Checks

Magento ships with additional static checks alongside the Code Sniffer rules used for the coding standards. The following tools should pass using the Magento standards.

Static Code Analysis Documentation PHPStan Static Analysis

  • PHP CS Fixer - Rules defined here
  • PHP Mess Detector - Rules defined here
  • PHP Stan - Rules defined here

These definition files are part of the Magento 2 distribution and provided by default - the tools are installed as part of the Magento 2 dev dependencies and can be configured as part of the project.