Magento 2 Developer's Guide

Book description

Harness the power of Magento 2 ? The most recent version of the world's favourite e-Commerce platform for your online store

About This Book

  • Set up, configure, and power up your Magento environment from development to production
  • Master the use of Web API to communicate with the Magento system and create custom services
  • Create custom modules from scratch to extend the core functionality of the Magento system

Who This Book Is For

This book is intended primarily for intermediate to professional-level PHP developers who are interested in Magento development. For backend developers, several topics are covered that will enable you to modify and extend your Magento 2 store. Frontend developers will also find some coverage on how to customize the look of the site in the frontend.

What You Will Learn

  • Set up the development and production environment of Magento 2
  • Understand the new major concepts and conventions used in Magento 2
  • Build a miniature yet fully-functional module from scratch to manage your e-commerce platform efficiently
  • Write models and collections to manage and search your entity data
  • Dive into backend development such as creating events, observers, cron jobs, logging, profiling, and messaging features
  • Get to the core of frontend development such as blocks, templates, layouts, and the themes of Magento 2
  • Use token, session, and Oauth token-based authentication via various flavors of API calls, as well as creating your own APIs
  • Get to grips with testing Magento modules and custom themes, which forms an integral part of development

In Detail

Magento is one of the most exciting, flexible, and customizable e-commerce systems. It offers you an extensive suite of powerful tools for creating and managing an online store. After years of development, Magento 2 introduces itself with a strong emphasis on modularity, Web API's, automated testing and overall new technology stack platform. The long-awaited Magento 2 release introduces a whole new e-commerce platform to develop online stores. The all new Magento 2 architecture, Web APIs, and a host of other features are equally challenging to master as much as they are exciting to use.

This book will ease the learning curve by offering step-by-step guidance on how to extend the core functionality of your Magento 2 store.

This book is your one-stop guide to build and customize a quality e-commerce website from the latest version of one of the largest, fastest growing, and most popular e-commerce platforms - Magento 2.

We start off with an introduction to the fundamental concepts of Magento to give you a foundation to work from. We then move on to configure the development and basic production environment for Magento. After this, you'll get to grips with the major concepts and conventions that are new to the Magento 2 platform. We then delve deeper to get to the core of automated deployments, persisting data, writing data fixture scripts and applying various backend and frontend modifications. As we near the end of the book, you will learn to make API calls and write automated tests. Finally, you will be guided through building a full-blown helpdesk module from scratch.

By the end of this book, you will have learned a wide range of techniques to extend and customize your Magento 2 store to fit the requirements of your business.

Style and approach

This book is a mix of theoretical and step-by-step approaches, explained in a conversational and easy-to-follow style. Topics are explained sequentially, giving detailed explanations of the basic and advanced features to get you working on Magento 2.

Table of contents

  1. Magento 2 Developer's Guide
    1. Table of Contents
    2. Magento 2 Developer's Guide
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Understanding the Platform Architecture
      1. The technology stack
      2. The architectural layers
      3. The top-level filesystem structure
      4. The module filesystem structure
      5. Summary
    9. 2. Managing the Environment
      1. Setting up a development environment
        1. VirtualBox
        2. Vagrant
        3. Vagrant project
          1. Provisioning PHP
          2. Provisioning MySQL
          3. Provisioning Apache
          4. Provisioning Magento installation
      2. Setting up a production environment
        1. Introduction to Amazon Web Services
        2. Setting up access for S3 usage
          1. Creating IAM users
          2. Creating IAM groups
        3. Setting up S3 for database and media files backup
        4. Bash script for automated EC2 setup
          1. Setting up EC2
          2. Setting up Elastic IP and DNS
      3. Summary
    10. 3. Programming Concepts and Conventions
      1. Composer
      2. Service contracts
      3. Code generation
      4. The var directory
      5. Coding standards
      6. Summary
    11. 4. Models and Collections
      1. Creating a miniature module
        1. Creating a simple model
        2. Creating an EAV model
      2. Understanding the flow of schema and data scripts
      3. Creating an install schema script (InstallSchema.php)
      4. Creating an upgrade schema script (UpgradeSchema.php)
      5. Creating an install data script (InstallData.php)
      6. Creating an upgrade data script (UpgradeData.php)
      7. Entity CRUD actions
      8. Creating new entities
        1. Reading existing entities
        2. Updating existing entities
        3. Deleting existing entities
      9. Managing collections
        1. Collection filters
      10. Summary
    12. 5. Using the Dependency Injection
      1. The object manager
      2. Dependency injection
      3. Configuring class preferences
      4. Using virtual types
      5. Summary
    13. 6. Plugins
      1. Creating a plugin
      2. Using the before listener
      3. Using the after listener
      4. Using the around listener
      5. The plugin sort order
      6. Summary
    14. 7. Backend Development
      1. Cron jobs
      2. Notification messages
      3. Session and cookies
      4. Logging
      5. The profiler
      6. Events and observers
      7. Cache(s)
      8. Widgets
      9. Custom variables
      10. i18n
      11. Indexer(s)
      12. Summary
    15. 8. Frontend Development
      1. Rendering flow
      2. View elements
        1. Ui components
        2. Containers
        3. Blocks
        4. Block architecture and life cycle
        5. Templates
        6. Layouts
        7. Themes
          1. Creating a new theme
        8. JavaScript
          1. Creating a custom JS component
        9. CSS
      3. Summary
    16. 9. The Web API
      1. User types
      2. Authentication methods
      3. REST versus SOAP
      4. Hands-on with token-based authentication
      5. Hands-on with OAuth-based authentication
      6. OAuth-based Web API calls
      7. Hands-on with session-based authentication
      8. Creating custom Web APIs
        1. API call examples
          1. The getById service method call examples
          2. The getList service method call examples
          3. The save (as new) service method call examples
          4. The save (as update) service method call examples
          5. The deleteById service method call examples
      9. Search Criteria Interface for list filtering
      10. Summary
    17. 10. The Major Functional Areas
      1. CMS management
        1. Managing blocks manually
        2. Managing blocks via code
        3. Managing blocks via API
        4. Managing pages manually
        5. Managing pages via code
        6. Managing pages via API
      2. Catalog management
        1. Managing categories manually
        2. Managing categories via code
        3. Managing categories via API
        4. Managing products manually
        5. Managing products via code
        6. Managing products via API
      3. Customer management
        1. Managing customers manually
        2. Managing customers via code
        3. Managing customers via an API
        4. Managing customer address via code
        5. Managing customers address via an API
      4. Products and customers import
      5. The custom product types
      6. Custom offline shipping methods
      7. Custom offline payment methods
      8. Summary
    18. 11. Testing
      1. Types of tests
      2. Unit testing
      3. Integration testing
      4. Static testing
      5. Integrity testing
      6. Legacy testing
      7. Performance testing
      8. Functional testing
      9. Writing a simple unit test
      10. Summary
    19. 12. Building a Module from Scratch
      1. Module requirements
      2. Registering a module
      3. Creating a configuration file (config.xml)
      4. Creating e-mail templates (email_templates.xml)
      5. Creating a system configuration file (system.xml)
      6. Creating access control lists (acl.xml)
      7. Creating an installation script (InstallSchema.php)
      8. Managing entity persistence (model, resource, collection)
      9. Building a frontend interface
        1. Creating routes, controllers, and layout handles
        2. Creating blocks and templates
        3. Handling form submissions
      10. Building a backend interface
        1. Linking the access control list and menu
        2. Creating routes, controllers, and layout handles
        3. Utilizing the grid widget
        4. Creating a grid column renderer
        5. Creating grid column options
        6. Creating controller actions
      11. Creating unit tests
      12. Summary
    20. Index

Product information

  • Title: Magento 2 Developer's Guide
  • Author(s): Branko Ajzele
  • Release date: December 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781785886584