└── README.md
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 
4 |
5 |
6 |
7 | Magento 2 Developer Certification Exam Notes
8 |
9 |
10 | A collection of notes for the Magento 2 certified developer exams.
11 |
12 |
13 |
14 |
15 | 
16 | 
17 |
18 |
19 |
20 | ---
21 |
22 |
23 |
24 | [](https://paypal.me/pykettk)
25 |
26 |
27 |
28 | ---
29 |
30 |
31 |
32 | ## 📝 Table of Contents
33 | - [Tips & Useful Information](#tips--useful-information)
34 | - [Exam Structure](#exam-structure)
35 | - [Exam Content](#exam-content)
36 | - [Magento Architecture & Customisation Techniques](#10-magento-architecture--customisation-techniques)
37 | - [Request Flow Processing](#20-request-flow-processing)
38 | - [Customising Magento UI](#30-customising-the-magento-ui)
39 | - [Working with Magento Databases](#40-working-with-databases-in-magento)
40 | - [Developing with Adminhtml](#50-developing-with-adminhtml)
41 | - [Customising Magento Business Logic](#60-customising-magento-business-logic)
42 | - [References](#references)
43 |
44 |
45 |
46 | ## 🧐 Tips & Useful Information
47 | The exam includes questions relating to Magento Admin - more than you would expect. It is worth knowing some of the more common features and areas:
48 | - Marketing & SEO
49 | - Category management
50 | - Scopes (Global, Website, Store, and Store View)
51 |
52 | The questions are typically structured in two parts. They first gives a bit of background information, usually in the form of "you have been asked to do...", then ask you the question they want answering. Make sure to read the questions **carefully** as the background information often includes key words that might trip you up and trick you into answering the wrong question.
53 |
54 | Quite a few answers are very similar, make sure you are confident in the exact file paths of files.
55 |
56 | It may be beneficial to set up a throwaway Magento environment to test some of the things that you revise - such as managing the database using the Declarative Schema; something introduced within Magento 2.3. There were quite a few questions which involved knowledge regarding Data and Schema patches and being aware when to use them.
57 |
58 |
59 |
60 | ## ⛏️ Exam Structure
61 | ### Associate Developer
62 | | | |
63 | | :---: | :---: |
64 | | Magento Version | 2.4.x |
65 | | Magento Theme | Luma |
66 | | Number of Questions | 60 |
67 | | Time Limit | 90 Minutes |
68 | | Passing Grade | 68% |
69 |
70 |
71 |
72 | ## ✍️ Exam Content
73 | ### 1.0. Magento Architecture & Customisation Techniques
74 | | Certification | Exam Content |
75 | | :-----------: | :----------: |
76 | | Associate Developer | 33% |
77 | | Professional Developer | 18% |
78 |
79 | #### 1.1. Describe the Magento Module-Based Architecture
80 | > What are the significant steps to add a new module?
81 |
82 | You need to create the following files:
83 | - `registration.php`
84 | - `module.xml`
85 |
86 | ##### `registration.php`
87 | This file is included by the Composer autoloader and is added to the static list of components in `Magento\Framework\Component\ComponentRegistrar`. Example:
88 |
89 | ```PHP
90 |
111 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | ```
121 |
122 | ---
123 | > What are the different Composer package types?
124 |
125 | | Name | Package Type | Description |
126 | | :--: | :----------: | :---------- |
127 | | Metapackage | metapackage | Technically, a Composer package type, not a Magento component type. A metapackage consists of only a `composer.json` file that specifies a list of components and their dependencies. For example, both Magento Open Source and Magento Commerce are metapackages. |
128 | | Module | magento2-module | Code that modifies Magento application behavior. You can upload a single module to the Magento Marketplace or your module can be dependent on some parent package. |
129 | | Theme | magento2-theme | Code that modifies the look and feel of the storefront or Magento Admin. |
130 | | Language Package | magento2-language | Translations for the storefront or Admin. |
131 |
132 | ---
133 | > When would you place a module in the app/code folder versus another location?
134 |
135 | Custom built modules and modules you build to extend other functionality are placed in the `app/code/` directory.
136 | Other modules, including extensions and the Magento 2 core modules, are placed in the `vendor/` directory as they
137 | are installed via Composer.
138 |
139 | ---
140 | > How do different modules interact with each other?
141 |
142 |
143 |
144 | ---
145 | > What side effects can come from this interaction?
146 |
147 |
148 |
149 | ---
150 | #### 1.2. Describe the Magento Directory Structure
151 | > How do you locate different files in Magento?
152 |
153 | All of the core Magento files are located in the `vendor/magento/` directory with some supporting JavaScript and CSS files being stored in `lib/`.
154 |
155 | Third-party files can be found in their respective `vendor/vendor-name/module-name/` directories.
156 |
157 | For your customisations:
158 | - For modules, use `app/code`.
159 | - For storefront themes, use `app/design/frontend`.
160 | - For Admin themes, use `app/design/adminhtml`.
161 | - For language packages, `use app/i18n`.
162 |
163 | ##### `/Api`: Service Contracts
164 | The `/Api` directory stores the contracts or interfaces that are exposed to the API. An example of this would be `Magento\Catalog\Api\CategoryListInterface`.
165 |
166 | ##### `/Api/Data`: Data Service Contracts
167 | This folder contains interfaces that represent data. Examples of this would be a
168 | product interface, a category interface, or a customer interface. The concrete
169 | implementations of these interfaces usually do little more than provide getters and
170 | setters for data.
171 |
172 | See `Magento\Catalog\Api\Data\ProductInterface` for an example.
173 |
174 | ##### `/Block`: View Models
175 | Blocks can be considered as template assistants. Very little functionality or business logic should be done in templates - that is the responsibility of the Block.
176 |
177 | ##### `/Console`: Console Commands
178 | When running `bin/magento` on the command line, a list of available commands
179 | to run is output. The code for commands should be placed inside the `/Console` directory.
180 |
181 | ##### `/Controller`: Web Request Handlers
182 | This directory stores controller classes for web requests.
183 |
184 | ##### `/Cron`: Cron Job Classes
185 | Definitions for cron jobs are stored here.
186 |
187 | ##### `/etc`: Configuration Files
188 | Any files directly within this directory are applied *globally*. You can restrict the *area* these files belong to by placing it in the relevant sub-directory - `etc/frontend/`, `etc/adminhtml/` etc.
189 | - **NB:** Some files **MUST** be placed within a particular area whilst others **MUST** be global.
190 |
191 | ##### `/Helper`: Aggregated Functionality
192 | Small, reusable snippets of code should be stored in a helper class.
193 |
194 | ##### `/i18n`: Localisation Files
195 | This directory contains the translation CSV files for the module. These CSV files contain two columns, `from` and `to`.
196 |
197 | ##### `/Model`: Data Handling & Data Structures
198 | A self-explanatory directory.
199 |
200 | ##### `/Model/ResourceModel`: Database Interactions
201 | The classes stored in this directory dictate how data is stored and retrieved from the database. Any *direct* database interaction should be done within these files.
202 |
203 | See `vendor/magento/module-catalog/Model/ResourceModel/Product.php` for an example.
204 |
205 | ##### `/Observer`: Event Listeners
206 | When Magento fires an event, certain observers are called - decoupling the system. Magento Commerce integrates with RabbitMQ which allows even more control and reliability to this process. Event data should be able to be stored and then run in a queue at a later time.
207 |
208 | Observers **MUST** implement the `Magento\Framework\Event\ObserverInterface`. The PHP class should follow the stand of using TitleCase while the event name should be snake_case.
209 |
210 | Observers should not contain any business logic. This logic should instead be placed in another class and injected into your observer.
211 |
212 | ##### `/Plugin`
213 | This directory stores your module's plugins. These are covered in more detail in a later section.
214 |
215 | ##### `/Setup`: Database Modification
216 | Stores the following files:
217 | - `InstallSchema.php`
218 | - Sets up table and column schema when the module is installed.
219 | - `UpgradeSchema.php`
220 | - Modifies table and column schema when the module version is upgraded.
221 | - `Recurring.php`
222 | - Runs after every install or upgrade.
223 | - `InstallData.php`
224 | - Sets up data when the module is installed. An example would be adding a custom CMS block.
225 | - `UpgradeData.php`
226 | - Modifies data after the module is installed and when the module version is upgraded.
227 | - `RecurringData.php`
228 | - Applies to data after every install or upgrade.
229 |
230 | ##### `/Test`: Module Tests
231 | This directory stores your module's tests. Tests can be run via the command line using `bin/magento dev:tests:run`.
232 |
233 | ##### `/Ui`: Data Generation Files
234 |
235 | ##### `/view/[area]/templates`: Block Templates
236 | The counterpart to a Block is a template to render the HTML for the block. Whilst the block (in `/Block`) represents the business logic, the template represents how the results of the business logic are shown to the user.
237 |
238 | ##### `/view/[area]/web`: Web Assets
239 | Web assets such as images, CSS, JavaScript, LESS, and SCSS are stored in this directory.
240 |
241 | ##### `view/[area]/web/template`: JavaScript Templates
242 | HTML templates that can be requested asynchronously via JavaScript are stored in this directory. These files often contain KnockoutJS declarative bindings.
243 |
244 | ##### `/view/adminhtml/ui_component`: Adminhtml UI Components
245 | This directory contains the XML configuration for UI components. They are used to represent distinct UI elements, such as grids and forms, and are designed to provide flexible user interface rendering. Most Magento Admin grids (such as the Catalog Product grid and the Customer grid) are composed with UI components. The
246 | checkout on the frontend is also a UI component.
247 |
248 | ---
249 | > What are the naming conventions, and how are namespaces established?
250 |
251 | ---
252 | > How can you identify the files responsible for some functionality?
253 |
254 | ---
255 | #### 1.3. Utilise Configuration and Configuration Variables Scope
256 | > Which configuration files are important in the development cycle?
257 |
258 | ##### `acl.xml`
259 | Defines permissions for accessing protected resources.
260 |
261 | ##### `config.xml`
262 | Loads configuration values into `Stores > Configuration` in the Magento Admin. This file can also encrypt configuration entries.
263 |
264 | ##### `crontab.xml`
265 | Defines cron job scheduling.
266 |
267 | ##### `di.xml`
268 | This file configures dependency injection for your module. It defines plugins, preferences, concrete classes for interfaces, virtual types, and constructor argument modifications.
269 |
270 | ##### `email_templates.xml`
271 |
272 | ##### `events.xml`
273 | This file registers observers.
274 |
275 | ##### `indexer.xml`
276 | This file configures Magento indexers.
277 |
278 | ##### `module.xml`
279 | This file is **required** by Magento.
280 |
281 | ##### `mview.xml`
282 | Triggers a type of event when data is modified in a database column - most often used for indexing.
283 |
284 | ##### `view.xml`
285 | This file is similar to `config.xml` but is used to specify the default values for design configuration.
286 |
287 | ##### `webapi.xml`
288 | Configures API access and routes.
289 |
290 | ##### `widget.xml`
291 | Configures widgets to be used in products, CMS blocks, and CMS pages.
292 |
293 | ##### `[area]/routes.xml`
294 | This file tells Magento that this area accepts web requests. The route node configures the first part of the layout handle (route ID) and the front name (first segment in the URL after the domain name).
295 |
296 | ##### `adminhtml/menu.xml`
297 | Configuration for the menu in Magento Admin.
298 |
299 | ##### `adminhtml/system.xml`
300 | Configures tabs, sections, groups, and fields found in `Store > Configuration` in Magento Admin.
301 |
302 | ---
303 | > How do you identify the configuration scope for a given variable?
304 |
305 | ---
306 | > How do native Magento scopes (for example, price or inventory) affect development and decision-making processes?
307 |
308 | ---
309 | > How can you fetch a system configuration value programmatically?
310 |
311 | You can use the functions contained within the `Magento\Framework\App\Config\ScopeConfigInterface` class, passing the
312 | configuration path as the minimum required parameter e.g. `web/secure/base_url`.
313 |
314 | ---
315 | > How can you override system configuration values for a given store using XML configuration?
316 |
317 | ---
318 | #### 1.4. Demonstrate How To Use Dependency Injection
319 | > How are objects realized in code?
320 |
321 | Since dependency injection happens automatically through the constructor, Magento
322 | must handle class creation - either at the time of injection or via a factory.
323 |
324 | ##### Class Creation During Injection
325 | First the object manager locates the proper class type. If an interface is requested, hopefully an entry in `di.xml` will provide a concrete class for the interface (if not, an exception will be thrown).
326 |
327 | Then the parameters for the constructor are loaded and recursively parsed meaning that the dependencies for the initially requested class are loaded as well as the dependencies of those dependencies as well.
328 |
329 | The deploy mode (`bin/magento deploy:mode:show)` determines which class loader is used:
330 | - `vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php`
331 | - `vendor/magento/framework/ObjectManager/Factory/Dynamic/Production.php`
332 |
333 | ##### Class Creation Via Factories
334 |
335 | ---
336 | > Why is it important to have a centralized object creation process?
337 |
338 | Having a centralised process to create objects makes testing much easier. It also
339 | provides a simple interface to substitute objects as well as modify existing ones.
340 |
341 | ---
342 | > How can you override a native class, inject your class into another object, and use other techniques available in `di.xml` (for example, `virtualTypes`)?
343 |
344 | ##### Overriding Native Classes
345 | Preferences are used to substitute entire classes. They can also be used to specify concrete classes for interfaces:
346 | ```XML
347 |
350 | ```
351 |
352 | ##### Injecting Your Class into Other Objects
353 | Specify a `` entry with your class as an ``:
354 | ```XML
355 |
356 |
357 |
358 | Path\To\Your\Injected\Class
359 |
360 |
361 |
362 | ```
363 |
364 | ##### Virtual Types
365 | A virtual type allows you to create an instance of an existing class that has custom constructor arguments. This is useful in cases where you need a “new” class only because the constructor arguments need to be changed. This is used frequently in Magento to reduce redundant PHP classes.
366 |
367 | ---
368 | > How would you obtain a class instance from different places in the code?
369 |
370 | ---
371 | #### 1.5. Demonstrate Ability To Use Plugins
372 | > How are plugins used in core code? How can they be used for customizations?
373 |
374 | A plugin is a class that modifies the behavior of public class functions by intercepting a function call and running code before, after, or around that call. This allows you to customise or extend the behavior of original, public methods for any class or interface.
375 |
376 | ##### Before Plugin
377 | Before plugins are used when you want to modify the function input. To modify the input of a function:
378 | ```PHP
379 | public function beforeFunctionName(
380 | Class\Containing\The\Function $subject,
381 | $normalFunctionInput1,
382 | $normalFunctionInput2,
383 | ) {
384 | // ...
385 |
386 | return [$normalFunctionInput1, $normalFunctionInput2];
387 | }
388 | ```
389 |
390 | The `return` value determines the array of arguments being passed into the next plugin or targeted function.
391 |
392 | ##### After Plugin
393 | After plugins are used when you want to modify the function output. To modify the output of a function:
394 | ```PHP
395 | public function afterFunctionName(
396 | Class\Containing\The\Function $subject,
397 | $result
398 | ) {
399 | // ...
400 |
401 | return $result;
402 | }
403 | ```
404 |
405 | The `return` value determines the output of the function being passed into the next plugin or targeted function.
406 |
407 | ##### Around Plugin
408 | Around plugins give you full control over the function, it's inputs, and it's output. To use an around plugin to replace a function:
409 | ```PHP
410 | public function aroundFunctionName(
411 | Class\Containing\The\Function $subject,
412 | callable $proceed
413 | ) {
414 | // ...
415 |
416 | $result = $proceed();
417 |
418 | // ...
419 |
420 | return $result;
421 |
422 | }
423 | ```
424 |
425 | ##### Declaring Plugins
426 | To declare a plugin, add a `` to your module's `di.xml`:
427 | ```XML
428 |
429 |
434 |
435 | ```
436 |
437 | ##### Plugin Limitations
438 | Plugins have the following limitations:
439 | - Only work with **public** functions
440 | - **Do not** work with `final` classes or functions
441 | - **Do not** work with `static` functions
442 |
443 | ---
444 | > How do multiple plugins interact?
445 |
446 | The `sortOrder` from the plugins declared in `di.xml` determines the plugin’s prioritisation when more than one plugin is observing the same method.
447 |
448 | The `Magento\Framework\Interception\PluginListInterface` which is implemented by `Magento\Framework\Interception\PluginList\PluginList`
449 | is responsible to define when to call the `befor`e, `around`, or `after` methods respecting this prioritisation.
450 |
451 | If two or more plugins have the same `sortOrder` value or do not specify it, the component load order declared in the `` node from
452 | `module.xml` and the area will define the merge sequence. The component load order can be checked in `app/etc/config.php`.
453 |
454 | Magento executes plugins using these rules during each plugin execution in two main flows:
455 |
456 | 1. Before the execution of the observed method, starting from lowest to highest `sortOrder`.
457 | - Magento executes the current plugin’s `before` method.
458 | - Then the current plugin’s `around` method is called.
459 | - The first part of the plugin’s `around` method is executed.
460 | - The `around` method executes the callable.
461 | - If there is another plugin in the chain, all subsequent plugins are wrapped in an independent sequence loop and the execution starts another flow.
462 | - If the current plugin is the last in the chain, the observed method is executed.
463 | - The second part of the `around` method is executed.
464 | - Magento moves on to the next plugin.
465 |
466 | 2. Following the execution flow, starting from lowest to highest `sortOrder` in the current sequence plugins loop.
467 | - The current plugin’s `after` method is executed.
468 | - Magento moves on to the next plugin.
469 |
470 | As a result of these rules, the execution flow of an observed method is affected not only by the prioritisation of the plugins,
471 | but also by their implemented methods.
472 |
473 | Examples of how this prioritisation is realised can be found in the [Magento 2 dev docs regarding plugins and interceptors])https://devdocs.magento.com/guides/v2.4/extension-dev-guide/plugins.html#examples.
474 |
475 | ---
476 | > How can the plugin execution order be controlled?
477 |
478 | The `sortOrder` attribute defines the order in which to execute plugins, starting from the lowest and working through to the highest.
479 |
480 | ---
481 | > How do you debug a plugin if it doesn’t work?
482 |
483 |
484 |
485 | ---
486 | > What are the limitations of using plugins for customization?
487 |
488 | Plugins can not be used on the following:
489 | - Final methods
490 | - Final classes
491 | - Non-public methods
492 | - Class methods (such as static methods)
493 | - `__construct`
494 | - Virtual types
495 | - Objects that are instantiated before `Magento\Framework\Interceptio`n is bootstrapped
496 |
497 | ---
498 | > In which cases should plugins be avoided?
499 |
500 |
501 |
502 | ---
503 | #### 1.6. Configure Event Observers & Scheduled Jobs
504 | Observers listen for events that are triggered in Magento. Scheduled jobs perform an action at a specified interval.
505 |
506 | Observers **MUST** implement the `Magento\Framework\Event\ObserverInterface`.
507 |
508 | ---
509 | > How are observers registered?
510 |
511 | Create an `` node in your `etc/[area]/events.xml` file:
512 | ```XML
513 |
514 |
517 |
518 | ```
519 |
520 | ---
521 | > How are they scoped for frontend or backend?
522 |
523 | Place the `events.xml` file in the `etc/frontend/` and `etc/adminhtml/` directories respectively.
524 |
525 | ---
526 | > How are automatic events created, and how should they be used?
527 |
528 | Events should be used when you do not want to change the data. They can be triggered by injecting an instance of `Magento\Framework\Event\ManagerInterface` into the constructor and calling: `$this->eventManager->dispatch('event_name', [params]);`.
529 |
530 | ---
531 | > How are scheduled jobs configured?
532 |
533 | To configure a scheduled job you need to assign it a name, specify the function it should execute, the class that function belongs to, and set the schedule using the regular cron schedule notatation. Scheduled jobs are specified in the `etc/crontab.xml` file:
534 | ```XML
535 |
537 |
538 |
541 | */5 * * * *
542 |
543 |
544 |
545 | ```
546 |
547 | ---
548 | > Which parameters are used in configuration?
549 |
550 |
551 |
552 | ---
553 | > How can configuration interact with server configuration?
554 |
555 |
556 |
557 | ---
558 | > Identify the function and proper use of automatically available events, for example *_load_after, etc.
559 |
560 |
561 |
562 | ---
563 | #### 1.7. Utilise the CLI
564 | > Which commands are available?
565 |
566 | A full list of commands can be found by running `bin/magento`. All of the commands listed below can be run from within the `magento/` directory via the command line, prefixed with `bin/magento`.
567 | ```
568 | Usage:
569 | command [options] [arguments]
570 |
571 | Options:
572 | -h, --help Display this help message
573 | -q, --quiet Do not output any message
574 | -V, --version Display this application version
575 | --ansi Force ANSI output
576 | --no-ansi Disable ANSI output
577 | -n, --no-interaction Do not ask any interactive question
578 | -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
579 |
580 | Available commands:
581 | help Displays help for a command
582 | list Lists commands
583 | admin
584 | admin:user:create Creates an administrator
585 | admin:user:unlock Unlock Admin Account
586 | app
587 | app:config:dump Create dump of application
588 | app:config:import Import data from shared configuration files to appropriate data storage
589 | app:config:status Checks if config propagation requires update
590 | cache
591 | cache:clean Cleans cache type(s)
592 | cache:disable Disables cache type(s)
593 | cache:enable Enables cache type(s)
594 | cache:flush Flushes cache storage used by cache type(s)
595 | cache:status Checks cache status
596 | catalog
597 | catalog:images:resize Creates resized product images
598 | catalog:product:attributes:cleanup Removes unused product attributes.
599 | config
600 | config:sensitive:set Set sensitive configuration values
601 | config:set Change system configuration
602 | config:show Shows configuration value for given path. If path is not specified, all saved values will be shown
603 | cron
604 | cron:install Generates and installs crontab for current user
605 | cron:remove Removes tasks from crontab
606 | cron:run Runs jobs by schedule
607 | customer
608 | customer:hash:upgrade Upgrade customer's hash according to the latest algorithm
609 | deploy
610 | deploy:mode:set Set application mode.
611 | deploy:mode:show Displays current application mode.
612 | dev
613 | dev:di:info Provides information on Dependency Injection configuration for the Command.
614 | dev:profiler:disable Disable the profiler.
615 | dev:profiler:enable Enable the profiler.
616 | dev:query-log:disable Disable DB query logging
617 | dev:query-log:enable Enable DB query logging
618 | dev:source-theme:deploy Collects and publishes source files for theme.
619 | dev:template-hints:disable Disable frontend template hints. A cache flush might be required.
620 | dev:template-hints:enable Enable frontend template hints. A cache flush might be required.
621 | dev:tests:run Runs tests
622 | dev:urn-catalog:generate Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.
623 | dev:xml:convert Converts XML file using XSL style sheets
624 | encryption
625 | encryption:payment-data:update Re-encrypts encrypted credit card data with latest encryption cipher.
626 | i18n
627 | i18n:collect-phrases Discovers phrases in the codebase
628 | i18n:pack Saves language package
629 | i18n:uninstall Uninstalls language packages
630 | indexer
631 | indexer:info Shows allowed Indexers
632 | indexer:reindex Reindexes Data
633 | indexer:reset Resets indexer status to invalid
634 | indexer:set-dimensions-mode Set Indexer Dimensions Mode
635 | indexer:set-mode Sets index mode type
636 | indexer:show-dimensions-mode Shows Indexer Dimension Mode
637 | indexer:show-mode Shows Index Mode
638 | indexer:status Shows status of Indexer
639 | info
640 | info:adminuri Displays the Magento Admin URI
641 | info:backups:list Prints list of available backup files
642 | info:currency:list Displays the list of available currencies
643 | info:dependencies:show-framework Shows number of dependencies on Magento framework
644 | info:dependencies:show-modules Shows number of dependencies between modules
645 | info:dependencies:show-modules-circular Shows number of circular dependencies between modules
646 | info:language:list Displays the list of available language locales
647 | info:timezone:list Displays the list of available timezones
648 | maintenance
649 | maintenance:allow-ips Sets maintenance mode exempt IPs
650 | maintenance:disable Disables maintenance mode
651 | maintenance:enable Enables maintenance mode
652 | maintenance:status Displays maintenance mode status
653 | module
654 | module:disable Disables specified modules
655 | module:enable Enables specified modules
656 | module:status Displays status of modules
657 | module:uninstall Uninstalls modules installed by composer
658 | queue
659 | queue:consumers:list List of MessageQueue consumers
660 | queue:consumers:start Start MessageQueue consumer
661 | sampledata
662 | sampledata:deploy Deploy sample data modules for composer-based Magento installations
663 | sampledata:remove Remove all sample data packages from composer.json
664 | sampledata:reset Reset all sample data modules for re-installation
665 | setup
666 | setup:backup Takes backup of Magento Application code base, media and database
667 | setup:config:set Creates or modifies the deployment configuration
668 | setup:cron:run Runs cron job scheduled for setup application
669 | setup:db-data:upgrade Installs and upgrades data in the DB
670 | setup:db-declaration:generate-patch Generate patch and put it in specific folder.
671 | setup:db-declaration:generate-whitelist Generate whitelist of tables and columns that are allowed to be edited by declaration installer
672 | setup:db-schema:upgrade Installs and upgrades the DB schema
673 | setup:db:status Checks if DB schema or data requires upgrade
674 | setup:di:compile Generates DI configuration and all missing classes that can be auto-generated
675 | setup:install Installs the Magento application
676 | setup:performance:generate-fixtures Generates fixtures
677 | setup:rollback Rolls back Magento Application codebase, media and database
678 | setup:static-content:deploy Deploys static view files
679 | setup:store-config:set Installs the store configuration. Deprecated since 2.2.0. Use config:set instead
680 | setup:uninstall Uninstalls the Magento application
681 | setup:upgrade Upgrades the Magento application, DB data, and schema
682 | store
683 | store:list Displays the list of stores
684 | store:website:list Displays the list of websites
685 | theme
686 | theme:uninstall Uninstalls theme
687 | ```
688 |
689 | ---
690 | > How are commands used in the development cycle?
691 |
692 | Commands provide a secure method of perfoming tasks that may otherwise be insecure or more time consuming to perform through the Magento Admin. Some of the more commonly used commands during development are listd below:
693 |
694 | ##### `cache:disable`
695 | Disables specific caches. You might use this to disable the `layout`, `block_html`, and `full_page` caches during the development of some frontend templates so Magento always generates the pages you are working on rather than older versions that it has cached. Example:
696 | ```
697 | bin/magento cache:disable layout block_html full_page
698 | ```
699 |
700 | ##### `cache:flush`
701 | Destroys the Magento caches, deleting the cache keys. This can be used to destroy any of the Magento caches in combination. Example:
702 | ```
703 | # destroy all caches
704 | bin/magento cache:flush
705 |
706 | # destroy configuration cache
707 | bin/magento cache:flush config
708 | ```
709 |
710 | ##### `cache:status`
711 | Lists the caches and whether they are enabled or disabled. You might use this prior to using the `cache:disable` or `cache:enable` commands.
712 |
713 | ##### `deploy:mode:set`
714 | Sets your deploy mode. During development you will likely want to set this to `developer` whilst on your live server you will want to set this to `production`. Example:
715 | ```
716 | # developer mode
717 | bin/magento deploy:mode:set developer
718 |
719 | # production mode
720 | bin/magento deploy:mode:set production
721 |
722 | # default mode
723 | bin/magento deploy:mode:set default
724 | ```
725 |
726 | ##### `dev:query-log:enable`
727 | Enables database query logging.
728 |
729 | ##### `indexer:reindex`
730 | Runs the Magento indexers.
731 |
732 | ##### `module:disable`
733 | Disables a specified module. Example:
734 | ```
735 | bin/magento module:disable Module_Name
736 | ```
737 |
738 | ##### `module:enable`
739 | Enables a specified module. Example:
740 | ```
741 | bin/magento module:enable Module_Name
742 | ```
743 |
744 | ##### `module:status`
745 | List all modules and whether they are enabled or disabled.
746 |
747 | ##### `setup:db:status`
748 | Checks whether the Magento database needs to be upgraded.
749 |
750 | ##### `setup:upgrade`
751 | Synchronises module versions in the database with those defined in the codebase.
752 |
753 | ---
754 | #### 1.8. Managing the Cache
755 | > Describe the cache types.
756 |
757 |
758 |
759 | ---
760 | > What tools are there to manage the cache?
761 |
762 |
763 |
764 | ---
765 | > How do you add dynamic content to pages served from the full page cache?
766 |
767 |
768 |
769 | ---
770 | > How would you clean the cache?
771 |
772 |
773 |
774 | ---
775 | > When would you refresh/flush the cache storage?
776 |
777 |
778 |
779 | ---
780 | > How do you clear the cache programmatically?
781 |
782 |
783 |
784 | ---
785 | > What mechanisms are available for clearing all or part of the cache?
786 |
787 |
788 |
789 | ---
790 | ### 2.0 Request Flow Processing
791 | | Certification | Exam Content |
792 | | :-----------: | :----------: |
793 | | Associate Developer | 7% |
794 | | Professional Developer | 12% |
795 |
796 | ---
797 | #### 2.1. Magento 2 Modes & Application Initialisation
798 | > Understand the pros and cons of using developer mode or production mode.
799 |
800 | ##### Production
801 | This mode should be used on your live production server. Production mode leads to an increase in performance by providing all necessary static files at the time of deployment rather than requiring Magento to dynamically locate and create static files during run time.
802 |
803 | In this mode Magento:
804 | - Logs exceptions and **does not** show exceptions on the frontend
805 | - Serves static view files from the cache **only**
806 | - Prevents automatic code compilation meaning that new or updated files are **not** written to the file system
807 | - Prevents you from enabling or disabled cache types via Magento Admin
808 |
809 | ##### Developer
810 | As it's name suggests, this mode is intended to be used during development only. When in this mode, Magento:
811 | - Disables static view file caching instead writing them to `pub/static` every time they are called
812 | - Provides verbose logging in `var/report`
813 | - Enables automatic code compilation
814 | - Displays uncaught exceptions to the frontend
815 | - Enables enhanced debugging
816 | - Shows custom `x-magento-*` HTTP request and response headers
817 | - Performs slower
818 |
819 | ---
820 | > When do you use default mode?
821 |
822 | As its name implies, `default` mode is how Magento operates if no other mode is specified.
823 | It enables you to deploy the Magento application on a single server without changing any settings.
824 | However, `default` mode is not as optimized for production.
825 |
826 | To deploy the Magento application on more than one server or to optimize it for production, change to one of the other modes.
827 |
828 | In `default` mode:
829 | - Errors are logged to the file reports at server, and never shown to a user
830 | - Static view files are cached
831 | - Not optimized for a production environment, primarily because of the adverse performance impact of static files being dynamically generated rather than materialized. In other words, creating static files and caching them has a greater performance impact than generating them using the static files creation tool.
832 |
833 | ---
834 | > How do you enable/disable maintenance mode?
835 |
836 | Maintenance mode can be enabled and disabled via the command line:
837 | ```
838 | # enable maintenance mode
839 | bin/magento maintenance:enable
840 |
841 | # disable maintenance mode
842 | bin/magento maintenance:disable
843 | ```
844 |
845 | ---
846 | > Identify the steps for application initialisation.
847 |
848 |
849 |
850 | ---
851 | > How would you design a customization that should act on every request and capture output data regardless of the controller?
852 |
853 |
854 |
855 | ---
856 | #### 2.2. Demonstrate Ability To Use Frontend Controllers
857 | > Describe front controller responsibilities.
858 |
859 |
860 |
861 | ---
862 | > In which situations will the front controller be involved in execution, and how can it be used in the scope of customizations?
863 |
864 |
865 |
866 | ---
867 | #### 2.3. URL Processing
868 | URL rewrites provide a user-friendly URL to the customer in place of a cumbersome Magento URL. These values are stored in the `url_rewrite` table.
869 |
870 | ---
871 | > How is the user-friendly URL of a product or category defined?
872 |
873 | The product/category `url_key` attribute defines their URL. For each category a product belongs to, Magento will generate a URL based on the category tree before appending the product's `url_key`.
874 |
875 | ---
876 | > How can you change a URL?
877 |
878 | You can change a URL by creating a URL rewrite. The following actions also cause a URL to change:
879 | - Updating a category's `url_key` attribute
880 | - Updating a product's `url_key` attribute
881 | - Modifying the categories a product belongs to
882 |
883 | ---
884 | > How do you determine which page corresponds to a given user-friendly URL?
885 |
886 | In the `url_rewrite` table you will find a row where the `request_path` value is the user-friendly URL. The corresponding `target_path` value is the internal Magento page. The `Magento_UrlRewrite` module contains a router that checks to see whether the given URL can be matched to a `request_path` in the `url_rewrite` table, redirecting to the `target_path` if a match is found.
887 |
888 | ---
889 | > How do you identify which module/controller corresponds to a given URL?
890 |
891 | `https://your-store.com/catalog/product/view/id/42`
892 |
893 |
894 |
895 | ---
896 | > What would you do to create a given URL?
897 |
898 | Set the Category and Product `url_key` attributes. You can also create URL rewrites through the Magento Admin path `Marketing > SEO & Search > URL Rewrites`
899 |
900 | ---
901 | > Describe how action controllers and results function.
902 |
903 |
904 |
905 | ---
906 | > How do controllers interact with each other?
907 |
908 |
909 |
910 | ---
911 | > How are different response types generated?
912 |
913 |
914 |
915 | ---
916 | #### 2.4. Customising Request Routing
917 | > Describe the request routing flow in Magento 2.
918 |
919 |
920 |
921 | ---
922 | > When is it necessary to create a new router or customise an existing router?
923 |
924 |
925 |
926 | ---
927 | > How do you handle custom 404 pages?
928 |
929 |
930 |
931 | ---
932 | #### 2.5. Layout Initialisation Process
933 | > Determine how layout is compiled.
934 |
935 |
936 |
937 | ---
938 | > How would you debug your `layout.xml` files and verify the right layout instructions are used?
939 |
940 |
941 |
942 | ---
943 | > Determine how HTML output is rendered.
944 |
945 |
946 |
947 | ---
948 | > How does Magento flush output?
949 |
950 |
951 |
952 | ---
953 | > What mechanisms exist to access and customise output?
954 |
955 |
956 |
957 | ---
958 | > How do you add new elements to pages introduced by a given module?
959 |
960 |
961 |
962 | ---
963 | > How do you identify which exact `layout.xml` file is processed in a given scope?
964 |
965 |
966 |
967 | ---
968 | > How does Magento treat layout XML files with the same names in different modules?
969 |
970 |
971 |
972 | ---
973 | > Identify the differences between admin and frontend scopes.
974 |
975 |
976 |
977 | ---
978 | > What differences exist for layout initialization for the admin scope?
979 |
980 |
981 |
982 | ---
983 | #### 2.6. Block Template Structures
984 | > Identify and understand root templates, empty.xml, and page_layout.
985 |
986 |
987 |
988 | ---
989 | > How are page structures defined, including number of columns, which basic containers are present, etc.?
990 |
991 |
992 |
993 | ---
994 | > Describe the role of blocks and templates in the request flow.
995 |
996 |
997 |
998 | ---
999 | > In which situations would you create a new block or a new template?
1000 |
1001 |
1002 | ---
1003 | ### 3.0. Customising The Magento UI
1004 | | Certification | Exam Content |
1005 | | :-----------: | :----------: |
1006 | | Associate Developer | 15% |
1007 | | Professional Developer | 10% |
1008 |
1009 | #### 3.1. Customise The Magento UI Using Themes
1010 | > When would you create a new theme?
1011 |
1012 | You would create a new theme when making design changes to the Magento frontend or admin. This typically involves copying and modifying layout files, templates, and styles to achieve your desired design.
1013 |
1014 | ---
1015 | > How do you define theme hierarchy for a project?
1016 |
1017 | The `theme.xml` file can be used to specify the theme's parent using the `` node:
1018 | ```XML
1019 |
1021 | Your Theme Name
1022 | Vendor/Theme
1023 |
1024 | ```
1025 |
1026 | Omitting the `` node dictates that the theme is the base, or default, theme.
1027 |
1028 | ---
1029 | > How do you identify which exact theme file is used in different situations?
1030 |
1031 |
1032 |
1033 | ---
1034 | > How can you override native files?
1035 |
1036 |
1037 |
1038 | ---
1039 | #### 3.2. Blocks & Templates
1040 | > How do you assign a template to a block?
1041 |
1042 | To assign a template to a block:
1043 | ```XML
1044 |
1048 | ```
1049 |
1050 | **NB:** The `path/to/your/template.phtml` starts from the `templates/` directory.
1051 |
1052 | ---
1053 | > How do you assign a different template to a native block?
1054 |
1055 | To assign a template to an existing block, pass an argument to the block:
1056 | ```XML
1057 |
1058 |
1059 |
1060 | Module_Name::path/to/your/template.phtml
1061 |
1062 |
1063 |
1064 | ```
1065 | ---
1066 | > Which objects are accessible from the block?
1067 |
1068 |
1069 |
1070 | ---
1071 | > What is the typical block’s role?
1072 |
1073 |
1074 |
1075 | ---
1076 | > In what cases would you put your code in the `_prepareLayout()`, `_beforeToHtml()`, and `_toHtml()` methods?
1077 |
1078 |
1079 |
1080 | ---
1081 | > How would you use events fired in the abstract block?
1082 |
1083 |
1084 |
1085 | ---
1086 | > Describe how blocks are rendered and cached.
1087 |
1088 |
1089 |
1090 | ---
1091 | > When would you use non-template block types?
1092 |
1093 | | Block Type | Path | Use |
1094 | | :--------: | :--: | :-: |
1095 | | Text | `vendor/magento/framework/View/Element/Text.php` | Printing a string |
1096 | | ListText | `vendor/magento/framework/View/Element/Text/ListTest.php` | Output each of the child blocks |
1097 |
1098 | ---
1099 | > In what situation should you use a template block or other block types?
1100 |
1101 |
1102 |
1103 | ---
1104 | #### 3.3. Magento Layout XML
1105 | > How do you use layout XML directives in your customizations?
1106 |
1107 | Layout XML is what links templates to blocks and there are a number of directives available for use.
1108 |
1109 | ##### ``
1110 | Defines a block. A block is a unit of page output that renders some distinctive content (anything visually tangible for the end-user), such as a piece of information or a user interface element. Blocks are a foundational building unit for layouts in Magento. They are the link between a PHP block class (which contains logic) and a template (which renders content). Blocks can have children and grandchildren (and so on).
1111 |
1112 | | Attribute | Description | Values | Required |
1113 | | :-------: | :---------: | :----: | :------: |
1114 | | `class` | Name of a class that implements rendering of a particular block. An object of this class is responsible for actual rendering of block output. | Class name | No |
1115 | |` name` | Name that can be used to address the block to which this attribute is assigned. The name must be unique per generated page. If not specified, an automatic name will be assigned in the format `ANONYMOUS_n`. | 0-9, A-Z, a-z, underscore (`_`), period (`.`), dash (`-`). Should start with a letter. Case-sensitive. | No |
1116 | | `before` | Used to position the block before an element under the same parent. The element name or alias name is specified in the value. Use dash (`-`) to position the block before all other elements of its level of nesting. | Element name or dash (`-`). | No |
1117 | | `after` | Used to position the block after an element under the same parent. The element name or alias name is specified in the value. Use dash (`-`) to position the block after all other elements of its level of nesting. | Element name or dash (`-`). | No |
1118 | | `template` | A template that represents the functionality of the block to which this attribute is assigned. | Template file name | No |
1119 | | `as` | An alias name that serves as identifier in the scope of the parent element. | Same as `name` | No |
1120 | | `cachable` | Defines whether a block element is cacheable. This can be used for development purposes and to make needed elements of the page dynamic. | `true` or `false` | No |
1121 |
1122 | ```XML
1123 | @TODO: example
1124 | ```
1125 |
1126 | ##### ``
1127 | A structure without content that holds other layout elements such as blocks and containers. A container renders child elements during view output generation. It can be empty or it can contain an arbitrary set of `` and `` elements. If the `` is empty, and there is no child `` available, it will not be displayed in the frontend source code.
1128 |
1129 | | Attribute | Description | Values | Required |
1130 | | :-------: | :---------: | :----: | :------: |
1131 | |` name` | Name that can be used to address the block to which this attribute is assigned. The name must be unique per generated page. If not specified, an automatic name will be assigned in the format `ANONYMOUS_n`. | 0-9, A-Z, a-z, underscore (`_`), period (`.`), dash (`-`). Should start with a letter. Case-sensitive. | No |
1132 | | `label` | An arbitrary name to display in the web browser. | Any | No |
1133 | | `before` | Used to position the block before an element under the same parent. The element name or alias name is specified in the value. Use dash (`-`) to position the block before all other elements of its level of nesting. | Element name or dash (`-`). | No |
1134 | | `after` | Used to position the block after an element under the same parent. The element name or alias name is specified in the value. Use dash (`-`) to position the block after all other elements of its level of nesting. | Element name or dash (`-`). | No |
1135 | | `as` | An alias name that serves as identifier in the scope of the parent element. | Same as `name` | No |
1136 | | `output` | Defines whether to output the root element. If specified, the element will be added to output list. If not specified, the parent element is responsible for rendering its children. | Any value except the obsolete `toHtml`. Recommended value is `1`. | No |
1137 | | `htmlTag` | Output parameter. If specified, the output is wrapped into specified HTML tag. | Any valid HTML5 tag | No |
1138 | | `htmlID` | Output parameter. If specified, the value is added to the wrapper element. If there is no wrapper element, this attribute has no effect. | Any valid HTML5 `id` value | No |
1139 | | `htmlClass` | Output parameter. If specified, the value is added to the wrapper element. If there is no wrapper element, this attribute has no effect. | Any valid HTML5 `class` value | No |
1140 |
1141 | ```XML
1142 | @TODO: example
1143 | ```
1144 |
1145 | ##### `` and ``
1146 | Updates in `` and `` are applied to the corresponding `` or ``. For example, if you make a reference by ``, you are targeting the block ``.
1147 |
1148 | | Attribute | Description | Values | Required |
1149 | | :-------: | :---------: | :----: | :------: |
1150 | | `remove` | Allows you to remove or cancel the removal of the element. When a container is removed, its child elements are removed as well. | `true` or `false` | No |
1151 | | `display` | Allows you to disable rendering of specific block or container with all its children (both set directly and by reference). The block’s/container’s and its children’ respective PHP objects are still generated and available for manipulation. | `true` or `false` | No |
1152 |
1153 | The `remove` attribute is optional and its default value is `false` This implementation allows you to remove a block or container in your layout by setting the remove attribute value to `true`, or to cancel the removal of a block or container by setting the value to `false`.
1154 | ```XML
1155 |
1156 | ```
1157 |
1158 | The `display` attribute is optional and its default value is `true`. You are always able to overwrite this value in your layout. In situation when the remove value is `true`, the `display` attribute is ignored.
1159 | ```XML
1160 |
1161 | ```
1162 |
1163 | ##### ``
1164 | `` is a required container for ``. It does not have its own attributes.
1165 | ```XML
1166 |
1167 | ...
1168 |
1169 | ```
1170 |
1171 | ##### ``
1172 | Information can be passed from layout XML files to blocks using the `` node. These directives must always be enclosed within `` directives. Argument values set in a layout file are added to the block's `data` array and can be accessed in templates using the `getData('argumentName')` and `hasData('argumentName')` functions. The latter returns a boolean defining whether there’s any value set.
1173 |
1174 | | Attribute | Description | Values | Required |
1175 | | :-------: | :---------: | :----: | :------: |
1176 | | `name` | Argument name. | Must be unique. | Yes |
1177 | | `xsi:type` | Argument type. | `string` / `boolean` / `object` / `number` / `null` / `array` / `options` / `url` / `helper` | Yes |
1178 | | `translate` | | `true` or `false` | No |
1179 |
1180 | ```XML
1181 |
1182 |
1183 |
1184 | Some String
1185 |
1186 |
1187 |
1188 |
1189 | true
1190 |
1191 |
1192 |
1193 |
1194 |
1195 | Namespace\To\Your\Class
1196 |
1197 |
1198 |
1199 |
1200 | 42
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 | - First Item
1209 | - Namespace\Of\Your\Class
1210 | ...
1211 |
1212 |
1213 |
1214 |
1215 |
1216 | Namespace\Of\Your\Class
1217 |
1218 |
1219 |
1220 |
1224 |
1225 |
1226 |
1229 | paramValue
1230 |
1231 |
1232 | ```
1233 |
1234 | **NB:** The `helper` can only use public functions.
1235 |
1236 | ##### ``
1237 | Sets the declared block or container element as a child of another element in the specified order.
1238 |
1239 | | Attribute | Description | Values | Required |
1240 | | :-------: | :---------: | :----: | :------: |
1241 | | `element` | Name of the element to move. | Element name | Yes |
1242 | | `destination` | Name of the target parent element. | Element name | Yes |
1243 | | `as` | Alias name for the element in the new location. | 0-9, A-Z, a-z, underscore (`_`), period (`.`), dash (`-`). Case-sensitive. | No |
1244 | | `after` or `before` | Specifies the element’s position relative to siblings. Use dash (`-`) to position the block before or after all other siblings of its level of nesting. If the attribute is omitted, the element is placed after all siblings. | Element name | No |
1245 |
1246 | ```XML
1247 |
1253 | ```
1254 |
1255 | **NB:**
1256 | - `` is skipped if the element to be moved is not defined.
1257 | - If the `as` attribute is not defined, the current value of the element alias is used. If that is not possible, the value of the `name` attribute is used instead.
1258 | - During layout generation, the `` instruction is processed before the removal (set using the `remove` attribute). This means if any elements are moved to the element scheduled for removal, they will be removed as well.
1259 |
1260 | ##### ``
1261 | `` is used only to remove the static resources linked in a page `` section. For removing blocks or containers, use the `remove` attribute for `` and ``.
1262 | ```XML
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 |
1272 | ```
1273 |
1274 | ##### ``
1275 | Includes a certain layout file.
1276 | ```XML
1277 |
1278 | ```
1279 |
1280 | ---
1281 | > How do you register a new layout file?
1282 |
1283 |
1284 |
1285 | ---
1286 | > How do you pass variables from layout to block?
1287 |
1288 | Information can be passed from layout XML files to blocks using the `` node.
1289 | These directives must always be enclosed within `` directives. Argument values set in a layout file
1290 | are added to the block's `data` array and can be accessed in templates using the `getData('argumentName')` and
1291 | `hasData('argumentName')` functions. The latter returns a boolean defining whether there’s any value set.
1292 |
1293 | | Attribute | Description | Values | Required |
1294 | | :-------: | :---------: | :----: | :------: |
1295 | | `name` | Argument name. | Must be unique. | Yes |
1296 | | `xsi:type` | Argument type. | `string` / `boolean` / `object` / `number` / `null` / `array` / `options` / `url` / `helper` | Yes |
1297 | | `translate` | | `true` or `false` | No |
1298 |
1299 | ```XML
1300 |
1301 |
1302 |
1303 | Some String
1304 |
1305 |
1306 |
1307 |
1308 | true
1309 |
1310 |
1311 |
1312 |
1313 |
1314 | Namespace\To\Your\Class
1315 |
1316 |
1317 |
1318 |
1319 | 42
1320 |
1321 |
1322 |
1323 |
1324 |
1325 |
1326 |
1327 | - First Item
1328 | - Namespace\Of\Your\Class
1329 | ...
1330 |
1331 |
1332 |
1333 |
1334 |
1335 | Namespace\Of\Your\Class
1336 |
1337 |
1338 |
1339 |
1343 |
1344 |
1345 |
1348 | paramValue
1349 |
1350 |
1351 | ```
1352 |
1353 | **NB:** The `helper` can only use public functions.
1354 |
1355 | ---
1356 | #### 3.4. Utlise JavaScript in Magento
1357 | > Which JavaScript modules are are suited for which tasks?
1358 |
1359 |
1360 |
1361 | ---
1362 | > In which situation would you use UI Components over a regular JavaScript module?
1363 |
1364 |
1365 |
1366 | ---
1367 | > Describe the use of `requirejs-config.js`, `x-magento-init`, `data-mage-init`.
1368 |
1369 |
1370 |
1371 | ---
1372 | ### 4.0. Working With Databases In Magento
1373 | | Certification | Exam Content |
1374 | | :-----------: | :----------: |
1375 | | Associate Developer | 18% |
1376 | | Professional Developer | 7% |
1377 |
1378 | #### 4.1. Models, Resource Models, And Collections
1379 | > What are the responsibilities of each of the ORM object types?
1380 |
1381 | The Magento ORM elements are:
1382 | - **Models:** Define entities, their data, and their behaviour.
1383 | - **Resource Models:** Data mappers for storage structures.
1384 | - **Collections:** Stores sets of Models and related functionality including filtering, sorting, and pagination.
1385 | - **Resources:** Maintain database connections through adapters.
1386 |
1387 | ---
1388 | > How do they relate to one another?
1389 |
1390 |
1391 |
1392 | ---
1393 | > Describe repositories and data API classes.
1394 |
1395 |
1396 |
1397 | ---
1398 | > How do you obtain an object or set of objects from the database using a repository?
1399 |
1400 |
1401 |
1402 | ---
1403 | > How do you configure and create a SearchCriteria instance using the builder?
1404 |
1405 |
1406 |
1407 | ---
1408 | > How do you use Data/Api classes?
1409 |
1410 |
1411 |
1412 | ---
1413 | > How do you add a new table to the database?
1414 |
1415 |
1416 |
1417 | ---
1418 | > Describe the entity load and save process.
1419 |
1420 |
1421 |
1422 | ---
1423 | > Describe how to extend existing entities. What mechanisms are available to extend existing classes, for example by adding a new attribute, a new field in the database, or a new related entity?
1424 |
1425 |
1426 |
1427 | ---
1428 | > Describe how to filter, sort, and specify the selected values for collections and repositories.
1429 |
1430 | ##### Collections
1431 | **Filter:** `$collection->addFieldToFilter()`
1432 | **Sort:** `$collection->addOrder()`
1433 | **Select Column:** `$collection->addFieldToSelect()`
1434 | **Pagination:** `$collection->setPageSize()` and `$collection->setCurPage()`
1435 |
1436 | ##### Repositories
1437 | https://devdocs.magento.com/guides/v2.2/extension-dev-guide/searching-with-repositories.html
1438 |
1439 | ---
1440 | > How do you select a subset of records from the database?
1441 |
1442 |
1443 |
1444 | ---
1445 | > Describe the database abstraction layer for Magento.
1446 |
1447 |
1448 |
1449 | ---
1450 | > What type of exceptions does the database layer throw?
1451 |
1452 |
1453 |
1454 | ---
1455 | > What additional functionality does Magento provide over Zend_Adapter?
1456 |
1457 |
1458 |
1459 | ---
1460 | #### 4.2. Declarative Schema
1461 | Declarative schema in Magento 2.3 allows developers to declare the final desired state of the database and has the system adjust to it automatically, without performing redundant operations. Developers are no longer forced to write scripts for each new version. Additionally, this approach allows data be deleted when a module is uninstalled - something that previously had to be done separately.
1462 |
1463 | ##### Terminology
1464 | Data Patch
1465 | - A class that contains data modification instructions. It can have dependencies on other data or schema patches.
1466 | - Some data patches can be reverted as a module or patch is uninstalled or deleted. Revertable operations are Data Query Language (DQL) and Data Manipulation Language (DML) operations: `INSERT`, `UPDATE`.
1467 |
1468 | Schema Patch
1469 | - A class that contains custom schema modification instructions. Schema patches are used along with declarative schema, but these patches allow complex operations such as:
1470 | - Adding triggers, stored procedures, or functions
1471 | - Performing data migration with inside DDL operations
1472 | - Renaming tables, columns, and other entities
1473 | - Adding partitions and options to a table
1474 |
1475 | ---
1476 | > How do you add a column using declarative schema?
1477 |
1478 | You can create/modify the `etc/db_schema.xml` file, specifying a `` node for the table you are editing and adding a `` node inside to create the new column.
1479 | ```XML
1480 |
1482 |
1489 |
1490 | ```
1491 |
1492 | You can also create a schema patch file in the `YourCompany\YourModule\Setup\Patch\Schema` namespace:
1493 | ```php
1494 | moduleSchemaSetup = $moduleSchemaSetup;
1514 | }
1515 |
1516 | /**
1517 | * {@inheritdoc}
1518 | */
1519 | public function apply()
1520 | {
1521 | $this->schemaSetup->startSetup();
1522 | $table = $this->schemaSetup->getTable('your_table_name');
1523 | $connection = $this->schemaSetup->getConnection();
1524 |
1525 | if ($connection->isTableExists($table)) {
1526 | // declare new columns to add
1527 | $newColumns = [
1528 | 'shiny_new_column' => [
1529 | 'type' => Table::TYPE_TEXT,
1530 | 'nullable' => true,
1531 | 'comment' => 'Shiny New Column',
1532 | ],
1533 | 'another_shiny_column' => [
1534 | 'type' => Table::TYPE_TEXT,
1535 | 'nullable' => true,
1536 | 'comment' => 'OMG More Shinies! :O',
1537 | ],
1538 | ];
1539 |
1540 | foreach ($newColumns as $newColumn => $columnDescription) {
1541 | $connection->addColumn($table, $newColumn, $columnDescription);
1542 | }
1543 | }
1544 |
1545 | $this->schemaSetup->endSetup();
1546 | }
1547 |
1548 | /**
1549 | * {@inheritDoc}
1550 | */
1551 | public static function getDependencies()
1552 | {
1553 | // return [dependencies]
1554 | }
1555 |
1556 | /**
1557 | * {@inheritDoc}
1558 | */
1559 | public function getAliases()
1560 | {
1561 | // return [aliases]
1562 | }
1563 | }
1564 | ```
1565 |
1566 | **NB:** When adding new columns to a table, you also need to generate the `db_schema_whitelist.json` file.
1567 |
1568 | ---
1569 | > How do you modify a table added by another module?
1570 |
1571 | To modify a table added by another module, create `Your_Company/Your_Module/etc/db_schema.xml` and specify the table name in the `` node:
1572 | ```XML
1573 |
1575 |
1578 |
1579 | ```
1580 |
1581 | ---
1582 | > How do you delete a column?
1583 |
1584 | To remove a column from a table created by your module you can simply remove the corresponding `` node in `Your_Company/Your_Module/etc/db_schema.xml`. To drop a column declared in another module, you must redeclare it and set the `disabled` attribute to `true`:
1585 | ```XML
1586 |
1588 |
1589 | ...
1590 |
1598 | ...
1599 |
1600 |
1601 | ```
1602 |
1603 | ---
1604 | > How do you add an index or foreign key using declarative schema?
1605 |
1606 | ##### Index
1607 | To add an index, declare an `` node in `Your_Company/Your_Module/etc/db_schema.xml`:
1608 | ```XML
1609 |
1611 |
1612 | ...
1613 |
1614 |
1615 |
1616 | ...
1617 |
1618 |
1619 | ```
1620 |
1621 | ##### Foreign Key
1622 | To add a foreign key, declare a `` node with an `xsi:type` of `foreign` in `Your_Company/Your_Module/etc/db_schema.xml`:
1623 | ```XML
1624 |
1626 |
1627 | ...
1628 |
1632 | table="table_name"
1633 |
1634 |
1635 | column="column_name"
1636 |
1637 |
1638 | referenceTable=""
1639 |
1640 |
1641 | referenceColumn=""
1642 |
1643 |
1644 | onDelete="CASCADE"
1645 | />
1646 | ...
1647 |
1648 |
1649 | ```
1650 |
1651 | ---
1652 | > How do you manipulate data using data patches?
1653 |
1654 | ---
1655 | > What is the purpose of schema patches?
1656 |
1657 | Schema patches are used to make custom database schema modifications:
1658 | - Renaming tables
1659 | - Adding/removing columns
1660 | - Setting primary & foreign keys
1661 |
1662 | ---
1663 | > What is the purpose of whitelisting?
1664 |
1665 |
1666 |
1667 | ---
1668 | > How to use Data and Schema patches?
1669 |
1670 |
1671 |
1672 | ---
1673 | > How to manage dependencies between patch files?
1674 |
1675 | Dependencies between patch files are managed via the patch file's `getDependencies` method. This method should
1676 | return an array of all of the patch files that are required to be executed **before** it.
1677 |
1678 | ---
1679 | ### 5.0. Entity-Attribute-Value (EAV)
1680 | #### 5.1. EAV Model Concepts
1681 | > Describe the EAV hierarchy structure.
1682 | > What happens when a new attribute is added to the system?
1683 | > What is the role of attribute sets and attribute groups?
1684 | > How are attributes presented in the admin?
1685 | > Describe how EAV data storage works in Magento.
1686 | > Which additional options do you have when saving EAV entities?
1687 | > How do you create customizations based on changes to attribute values?
1688 | > Describe the key differences between EAV and flat table collections.
1689 | > In which situations would you use EAV for a new entity?
1690 | > What are the pros and cons of EAV architecture?
1691 |
1692 | #### 5.2. EAV Loading & Saving
1693 | > Describe the EAV load and save process and differences from the flat table load and save process.
1694 | > What happens when an EAV entity has too many attributes?
1695 | > How does the number of websites/stores affect the EAV load/save process?
1696 | > How would you customize the load and save process for an EAV entity in the situations described here?
1697 |
1698 | #### 5.3. Attribute Management
1699 | > Describe EAV attributes, including the frontend/source/backend structure.
1700 |
1701 |
1702 |
1703 | ---
1704 | > How would you add dropdown/multiselect attributes?
1705 |
1706 |
1707 |
1708 | ---
1709 | > What other possibilities do you have when adding an attribute (to a product, for example)?
1710 |
1711 |
1712 |
1713 | ---
1714 | > Describe how to implement the interface for attribute frontend models.
1715 |
1716 |
1717 |
1718 | ---
1719 | > What is the purpose of this interface?
1720 |
1721 |
1722 |
1723 | ---
1724 | > How can you render your attribute value on the frontend?
1725 |
1726 |
1727 |
1728 | ---
1729 | > Identify the purpose and describe how to implement the interface for attribute source models.
1730 |
1731 |
1732 |
1733 | ---
1734 | > For a given dropdown/multiselect attribute, how can you specify and manipulate its list of options?
1735 |
1736 |
1737 |
1738 | ---
1739 | > Identify the purpose and describe how to implement the interface for attribute backend models.
1740 |
1741 |
1742 |
1743 | ---
1744 | > How (and why) would you create a backend model for an attribute?
1745 |
1746 |
1747 |
1748 | ---
1749 | > Describe how to create and customize attributes.
1750 |
1751 |
1752 |
1753 | ---
1754 | > How would you add a new attribute to the product, category, or customer entities?
1755 |
1756 |
1757 |
1758 | ---
1759 | > What is the difference between adding a new attribute and modifying an existing one?
1760 |
1761 |
1762 |
1763 | ---
1764 | ### 6.0. Developing With Adminhtml
1765 | | Certification | Exam Content |
1766 | | :-----------: | :----------: |
1767 | | Associate Developer | 11% |
1768 | | Professional Developer | 10% |
1769 |
1770 | #### 6.1. Adminhtml Structure/Architecture
1771 | > Describe the difference between Adminhtml and frontend.
1772 |
1773 |
1774 |
1775 | ---
1776 | > What additional tools and requirements exist in the admin?
1777 |
1778 |
1779 |
1780 | ---
1781 | #### 6.2. Form & Grid Widgets
1782 | > Define form structure, form templates, grids, grid containers, and elements.
1783 |
1784 |
1785 |
1786 | ---
1787 | > What steps are needed to display a grid or form?
1788 |
1789 |
1790 |
1791 | ---
1792 | > How is data provided to the grid or form? How can this be process be customized or extended?
1793 |
1794 |
1795 |
1796 | ---
1797 | > Describe how to create a simple form and grid for a custom entity.
1798 |
1799 |
1800 |
1801 | ---
1802 | > Given a specific entity with different types of fields (text, dropdown, image, file, date, and so on) how would you create a grid and a form?
1803 |
1804 |
1805 |
1806 | ---
1807 | #### 6.3. System Configuration & Scopes
1808 | > How would you add a new system configuration option?
1809 |
1810 | ---
1811 | > What is the difference in this process for different option types (secret, file)?
1812 |
1813 | ---
1814 | > How do you access system configuration options programmatically?
1815 |
1816 | You can use the functions contained within the `Magento\Framework\App\Config\ScopeConfigInterface` class, passing the
1817 | configuration path as the minimum required parameter e.g. `web/secure/base_url`.
1818 |
1819 | ---
1820 | #### 6.4. ACL & User Permissions
1821 | > How do you add a new menu item to a given tab?
1822 |
1823 | Adminhtml menu items are configured in `etc/adminhtml/menu.xml`. To add a new menu item, edit this file:
1824 | ```XML
1825 |
1827 |
1844 |
1845 | ```
1846 |
1847 | ---
1848 | > How do you add a new tab to the Admin menu?
1849 |
1850 | Do not specify a `parent` attribute in the `` node.
1851 |
1852 | ---
1853 | > How are menu items related to ACL permissions?
1854 |
1855 | Menu items are not shown to users with insufficient permissions to access them.
1856 |
1857 | ---
1858 | > How do you add a new user with given set of permissions?
1859 |
1860 | Navigate to `System > Permissions > All Users` in Magento admin, add a new user, and set their role under `User Information > User Role`.
1861 |
1862 | This can also be done programmatically:
1863 | ```PHP
1864 | use Magento\User\Model\UserFactory;
1865 |
1866 | // ...
1867 |
1868 | protected $userFactory;
1869 |
1870 | public function __construct(UserFactory $userFactory)
1871 | {
1872 | $this->_userFactory = $userFactory;
1873 | }
1874 |
1875 | public function execute()
1876 | {
1877 | $user = $this->userFactory->create();
1878 | $user->setData(
1879 | [
1880 | 'username' => 'user.name',
1881 | 'firstname' => 'Forename',
1882 | 'lastname' => 'Surname',
1883 | 'email' => 'admin@test.com',
1884 | 'password' => 'badpassword123',
1885 | 5
1886 | 'is_active' => 1
1887 | ]
1888 | );
1889 |
1890 | $user->setRoleId(1);
1891 | $user->save();
1892 | }
1893 | ```
1894 |
1895 | ---
1896 | ### 11.0. Customising Magento Business Logic
1897 | | Certification | Exam Content |
1898 | | :-----------: | :----------: |
1899 | | Associate Developer | 16% |
1900 |
1901 | #### 11.1. Product Types
1902 |
1903 | | Product Type | Description |
1904 | | :----------: | :---------: |
1905 | | Simple | A simple product is a physical item with a single SKU. Simple products have a variety of pricing and of input controls which makes it possible to sell variations of the product. Simple products can be used in association with grouped, bundle, and configurable products. |
1906 | | Configurable | A configurable product appears to be a single product with lists of options for each variation. However, each option represents a separate, simple product with a distinct SKU, which makes it possible to track inventory for each variation. |
1907 | | Grouped | A grouped product presents multiple, standalone products as a group. You can offer variations of a single product, or group them for a promotion. The products can be purchased separately, or as a group. |
1908 | | Bundle | A bundle product let customers “build their own” from an assortment of options. The bundle could be a gift basket, computer, or anything else that can be customized. Each item in the bundle is a separate, standalone product. |
1909 | | Virtual | Virtual products are not tangible products, and are typically used for products such as services, memberships, warranties, and subscriptions. Virtual products can be used in association with grouped and bundle products. |
1910 | | Downloadable | A digitally downloadable product that consists of one or more files that are downloaded. The files can reside on your server or be provided as URLs to any other server. |
1911 | | Gift Card | There are three kinds of gift cards: virtual gift cards which are sent by email, physical gift cards which are shipped to the recipient, and combined gift cards which are a combination of the two. Each has a unique code, that is redeemed during checkout. Gift cards can also be included in a grouped product. |
1912 |
1913 | ---
1914 | > How would you obtain a product of a specific type?
1915 |
1916 | To obtain a specific product type, build search criteria and retrieve them from the product repository:
1917 | ```PHP
1918 | use Magento\Catalog\Api\Data\ProductInterface;
1919 | use Magento\Bundle\Model\Product\Type;
1920 |
1921 | ...
1922 |
1923 | public function getBundleProducts()
1924 | {
1925 | $searchCriteria = $this->searchCriteriaBuilder
1926 | ->addFilter(ProductInterface::TYPE_ID, Type::TYPE_CODE)
1927 | ->create();
1928 |
1929 | return $this->productRepository->getList($searchCriteria)->getItems();
1930 | }
1931 | ```
1932 |
1933 | ---
1934 | > What tools (in general) does a product type model provide?
1935 |
1936 | The product type model is responsible for:
1937 | - Loading and configuring product options
1938 | - Preparing the product for the cart
1939 | - Processing product data to/from the database
1940 | - Checking whether the product can be sold
1941 | - Loading child products, when applicable
1942 |
1943 | ---
1944 | #### 11.2. Category Properties
1945 | > How do you create and manage categories?
1946 |
1947 | ---
1948 | #### 11.3. Product/Category Relations
1949 | > How do you assign and unassign products to categories?
1950 |
1951 | Navigate to `Catalog > Inventory > Products` in Magento Admin, select the product you wish to add to a category, and use the `Categories` drop down selection options to assign it to categories.
1952 |
1953 | ---
1954 | #### 11.4. Product Behaviour In The Cart
1955 | > How are configurable and bundle products rendered?
1956 |
1957 | `view/frontend/layout/checkout_cart_item_renderers.xml` define how products are rendered in the cart.
1958 |
1959 | Configurable products are shown as a single line item. It is shown with the parent product's title and the simple product option selected by the customer.
1960 |
1961 | Each product in the Bundle product is rendered as a single line item.
1962 |
1963 | ---
1964 | > How can you create a custom shopping cart renderer?
1965 |
1966 | ---
1967 | #### 11.5. Native Shipping Functionality
1968 | > How do you customize the shipment step of order management?
1969 |
1970 | ---
1971 | #### 11.6. Customer Account Area Customisation
1972 | > How would you add another tab in the “My Account” section?
1973 |
1974 | To add an additional menu tab in the customer "My Account" area create the layout file in `Your_Company/Your_Module/view/frontend/layout/customer_account.xml`:
1975 | ```XML
1976 |
1977 |
1978 |
1979 |
1982 |
1983 |
1984 | Your Label
1985 |
1986 |
1987 | path/to/your/module/view/
1988 |
1989 |
1990 | 10
1991 |
1992 |
1993 |
1994 |
1995 |
1996 | How do you customize the order history page?
2001 |
2002 | To customise the "Order History" page create the layout file in `Your_Company/Your_Module/view/frontend/layout/sales_order_history.xml`. The `sales.order.history.info` container is a common location for modifications to be made.
2003 |
2004 | ---
2005 | #### 11.7. Add/Modify Customer Attributes
2006 | > How do you add or modify customer attributes in a setup script?
2007 |
2008 | Create `Your_Company/Your_Module/Setup/UpgradeData.php` with an `upgrade()` function:
2009 | ```PHP
2010 | use Magento\Customer\Model\Customer;
2011 |
2012 | // ...
2013 |
2014 | $attribute = $this->eavConfig->getAttribute(Customer::ENTITY, Attribute::CUSTOMER_PROMOTION_PREFERENCE);
2015 | $attribute->setData('used_in_forms', ['adminhtml_customer', 'customer_account_edit']);
2016 | $attribute->save();
2017 | ```
2018 |
2019 | ---
2020 | #### 11.8. Customising Customer Addresses
2021 | > How do you add another field to the customer address entity using a setup script?
2022 |
2023 | ---
2024 | ## References
2025 | ### Magento 2 Dev Docs
2026 | [Component Load Order](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/build/module-load-order.html)
2027 |
2028 | [Name Your Component](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/build/create_component.html)
2029 |
2030 | [Create Your Component File Structure](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/build/module-file-structure.html)
2031 |
2032 | [Plugins (Interceptors)](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html)
2033 |
2034 | [About Magento Modes](https://devdocs.magento.com/guides/v2.3/config-guide/bootstrap/magento-modes.html)
2035 |
2036 | [Layout Instructions](https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-instructions.html)
2037 |
2038 | [Product Types](https://docs.magento.com/m2/ee/user_guide/catalog/product-types.html)
2039 |
2040 | [Declarative Schema](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/)
2041 |
--------------------------------------------------------------------------------