59 Practice Questions & Answers
When creating a custom module in Adobe Commerce, which file is required to define the module's basic configuration?
-
A
config.xml
-
B
di.xml
-
C
system.xml
-
D
module.xml
✓ Correct
Explanation
The module.xml file is required for every Adobe Commerce module and contains the module's basic configuration including name, version, and dependencies.
In Adobe Commerce, what is the primary purpose of the Interceptor plugin system?
-
A
To modify or extend method behavior without altering original class code through before, after, and around plugins
✓ Correct
-
B
To encrypt sensitive customer information in transit
-
C
To manage database transaction rollbacks during checkout
-
D
To validate customer input data before database operations
Explanation
Interceptor plugins (before, after, and around) allow developers to modify method behavior without changing the original class, following the Open/Closed Principle.
Which Adobe Commerce feature allows you to define dynamic data based on conditions and render it without modifying core files?
-
A
Layout Handles
-
B
XML Layout Updates
✓ Correct
-
C
Database Views
-
D
Custom Helper Classes
Explanation
XML Layout Updates enable developers to conditionally add blocks and modify page structure declaratively, supporting dynamic rendering based on specific conditions.
When implementing a custom payment gateway integration in Adobe Commerce, which interface must your payment method class implement?
-
A
\Magento\Framework\Model\ResourceModel\Db\AbstractDb
-
B
\Magento\Sales\Api\OrderPaymentRepositoryInterface
-
C
\Magento\Payment\Model\MethodInterface
✓ Correct
-
D
\Magento\Payment\Api\PaymentInterface
Explanation
The MethodInterface is the standard interface that all payment method implementations must extend to provide required payment processing functionality.
What is the correct way to programmatically create a customer in Adobe Commerce while ensuring all validations are applied?
-
A
Execute raw SQL INSERT statements to the customer_entity table
-
B
Directly instantiate CustomerFactory and set attributes using setData()
-
C
Use CustomerRepositoryInterface::save() after setting customer data through a proper data object that validates according to extension attributes
✓ Correct
-
D
Call the Customer model's validate() method before save
Explanation
Using CustomerRepositoryInterface ensures all validations, interceptors, and extension attributes are properly processed during customer creation.
In Adobe Commerce, how does the Declarative Schema system differ from InstallSchema/UpgradeSchema scripts?
-
A
Declarative Schema only supports InnoDB tables while scripts support all storage engines
-
B
Declarative Schema uses XML to define database structure and automatically manages changes, while scripts require manual versioning
✓ Correct
-
C
Scripts are easier to understand and should be preferred over Declarative Schema
-
D
InstallSchema scripts are deprecated and should never be used in Commerce 2.3+
Explanation
Declarative Schema (db_schema.xml) is the modern approach that automatically manages upgrades, rollovers, and versioning without manual script management.
Which mechanism in Adobe Commerce is responsible for serializing and deserializing extension attributes?
-
A
The Converter Pool
-
B
The ExtensionAttributesFactory and ExtensionInterface implementations
✓ Correct
-
C
Custom JSON serialization in observers
-
D
The Data Model layer with getters and setters
Explanation
ExtensionAttributesFactory automatically handles serialization/deserialization of extension attributes through generated extension interfaces.
What is the correct order of execution for events during an order placement in Adobe Commerce?
-
A
sales_model_service_quote_submit_before, sales_order_place_after, checkout_submit_before, checkout_submit_after
✓ Correct
-
B
sales_order_place_before, checkout_submit_before, sales_order_place_after, checkout_submit_after
-
C
checkout_submit_before, sales_order_place_after, sales_model_service_quote_submit_before, checkout_submit_after
-
D
checkout_submit_before, checkout_submit_after, sales_order_place_after, sales_model_service_quote_submit_before
Explanation
The proper event sequence during order placement is: sales_model_service_quote_submit_before, then sales_order_place_after, followed by checkout and cart events.
In Adobe Commerce GraphQL development, what is the purpose of the @api directive in schema definitions?
-
A
To restrict access to authenticated users only
-
B
To encrypt sensitive data in GraphQL responses
-
C
To enforce caching rules at the field level
-
D
To mark types and fields as part of the public API contract available for external consumption
✓ Correct
Explanation
The @api directive indicates that a field or type is part of the stable public API and should be treated as a contractual obligation for backward compatibility.
How does Adobe Commerce handle product attribute values for different store views?
-
A
By duplicating product records for each store view
-
B
Through the store_id column in attribute value tables, allowing store-specific values to override global defaults
✓ Correct
-
C
Using a separate database per store view
-
D
All attributes are global and shared across all store views without differentiation
Explanation
Adobe Commerce stores attribute values in entity attribute tables with store_id column, enabling store-specific values while maintaining a global fallback.
What is the recommended approach for adding custom attributes to the sales/order entity in Adobe Commerce?
-
A
Use InstallData script with EAV pattern or Declarative Schema with extension attributes
✓ Correct
-
B
Create a custom order status to store additional data
-
C
Modify the sales_order table directly using ALTER TABLE statements
-
D
Add columns to catalog_product_entity_* tables
Explanation
Extension attributes or Declarative Schema are the proper methods for extending order entity functionality without core table modifications.
In Adobe Commerce, which class is responsible for managing the product indexing process?
-
A
\Magento\Indexer\Model\Indexer
-
B
\Magento\Framework\Indexer\IndexerInterface
✓ Correct
-
C
\Magento\Catalog\Model\Product\Indexer
-
D
\Magento\Framework\Search\IndexerInterface
Explanation
IndexerInterface defines the contract for indexer implementations, while the Indexer class orchestrates the indexing process across all registered indexers.
What does the di.xml file's 'preference' node accomplish in Adobe Commerce dependency injection?
-
A
It defines which concrete implementation should be injected when an interface is requested as a dependency
✓ Correct
-
B
It determines the order in which plugins are executed
-
C
It specifies database connection preferences for different modules
-
D
It sets the default timezone preference for the application
Explanation
The preference node maps interface types to their concrete implementations, enabling dependency injection to resolve interface dependencies to specific classes.
How can you ensure that a custom module's database changes are applied in the correct sequence across multiple store installations?
-
A
By creating a single monolithic setup script that handles all changes
-
B
By manually executing setup scripts in alphabetical order
-
C
By using timestamps in script filenames to guarantee execution order
-
D
By using semantic versioning in module.xml and relying on sequence declarations for module dependencies
✓ Correct
Explanation
The sequence element in module.xml defines module load order, ensuring database changes are applied in the correct dependency order.
In Adobe Commerce, what is the primary benefit of using Repository Pattern instead of directly querying models?
-
A
Repositories provide a data access abstraction layer, enabling loose coupling and easier testing with mock implementations
✓ Correct
-
B
Repositories automatically cache all query results
-
C
Repositories are faster than direct model queries
-
D
Repositories eliminate the need for database indexes
Explanation
Repositories abstract data access logic, allowing implementations to change without affecting business logic, improving testability and maintainability.
Which Adobe Commerce feature allows you to conditionally load JavaScript or CSS resources based on page type or customer segment?
-
A
Asset versioning in requirejs-config.js
-
B
The Resource HTTP Client library
-
C
Layout handles with conditional block declarations and custom layout updates
✓ Correct
-
D
Query parameters in static file URLs
Explanation
Layout handles and conditional block statements enable targeted loading of resources based on page context, customer attributes, and custom conditions.
What is the correct method to programmatically retrieve a product's custom attribute value while respecting store view scope?
-
A
Using $product->getAttributeText('attribute_code') after loading the product with appropriate store context
✓ Correct
-
B
Directly querying the catalog_product_entity_varchar table with a raw SQL statement
-
C
Using getCustomAttribute() on the product without loading additional store data
-
D
Calling ProductAttributeRepository::getList() without any filters
Explanation
getAttributeText() respects store scope and attribute configuration when retrieving values, while raw queries bypass important context handling.
In Adobe Commerce quote and order flow, when should you use the Sales Rule collection versus iterating through individual rules?
-
A
Collections and individual queries perform identically and choice is purely aesthetic
-
B
Sales Rule collections should always be avoided in favor of single rule queries
-
C
Use collections when you need to filter or retrieve multiple rules at once; individual rule loading is better for single rule operations
✓ Correct
-
D
Individual rule iteration is always more efficient regardless of the number of rules needed
Explanation
Collections allow filtered queries and bulk operations, reducing database calls, while individual loading is appropriate for single rule scenarios.
What is the purpose of the 'app/code/Magento' directory structure versus custom module placement in 'app/code/VendorName'?
-
A
Magento core modules can be freely modified while custom modules cannot
-
B
The directory structure has no functional impact on module behavior
-
C
Custom modules must always override core modules
-
D
Core modules in 'Magento' namespace are part of the platform; custom modules use vendor namespaces to avoid conflicts and enable proper versioning
✓ Correct
Explanation
The Magento namespace is reserved for platform code; custom modules use vendor namespaces to maintain clear separation and enable independent versioning.
How does Adobe Commerce's flat catalog feature impact attribute loading and product performance?
-
A
Flat catalog provides no performance benefit and should never be used
-
B
When enabled, flat catalog denormalizes attribute data into flat tables, improving read performance but reducing attribute flexibility and increasing database size
✓ Correct
-
C
Flat catalog is always enabled and cannot be disabled
-
D
Flat catalog only affects search results, not frontend product loading
Explanation
Flat catalog denormalizes data for faster queries but limits EAV functionality and requires reindexing when attributes change, so it's suitable for stable catalogs.
In Adobe Commerce, what is the correct way to add a new option to an existing product attribute programmatically?
-
A
Use the Attribute Option API through OptionManagement interface or directly manipulate the eav_attribute_option table
✓ Correct
-
B
Create a new attribute with the desired options instead of modifying existing ones
-
C
Use ProductAttributeRepository to update the attribute definition
-
D
Attributes cannot have options added programmatically and must be modified through the admin panel only
Explanation
The OptionManagement interface or direct EAV table manipulation allows programmatic option addition while maintaining data integrity and proper attribute associations.
What does the 'virtual' attribute type in Adobe Commerce signify, and how does it differ from regular attributes?
-
A
Virtual attributes can only be used in the admin panel and never display on the frontend
-
B
Virtual attributes are stored in a separate encrypted database table
-
C
Virtual attributes do not have database columns; they are calculated or derived from other data on-the-fly using sourceModel or custom logic
✓ Correct
-
D
Virtual attributes are deprecated and should be converted to regular attributes
Explanation
Virtual attributes are computed dynamically rather than stored, useful for derived values like formatted dates or calculated prices without database overhead.
In Adobe Commerce REST API development, how should you handle pagination and filtering for large result sets?
-
A
Use SearchCriteria with filter groups, pageSize, and currentPage parameters to implement server-side pagination and reduce response payloads
✓ Correct
-
B
Disable pagination for REST endpoints to improve performance
-
C
Implement client-side pagination by returning raw data and letting frontend handle chunking
-
D
Always return all results regardless of size to ensure data consistency
Explanation
SearchCriteria provides standard pagination and filtering, reducing server load and network bandwidth while maintaining API consistency.
What is the relationship between Magento\Framework\App\Config and the system configuration values stored in core_config_data?
-
A
The Config class reads from core_config_data but bypasses caching
-
B
Config provides an abstraction layer that retrieves configuration from core_config_data through scope-aware queries with caching support
✓ Correct
-
C
They are completely unrelated systems with no interaction
-
D
Core_config_data is deprecated and Config loads from files only
Explanation
The Config class abstracts configuration access, caching values and handling scope (global, website, store) when retrieving data from the configuration tables.
When implementing custom business logic in observers, what is the critical consideration regarding order of execution when multiple modules register for the same event?
-
A
Observer order can only be controlled by numeric IDs in the events.xml file
-
B
Observer execution order is random and should not be relied upon
-
C
Observers execute in alphabetical order by module name automatically
-
D
Module sequence in module.xml determines observer execution order; modules should declare dependencies to ensure predictable sequencing
✓ Correct
Explanation
Module dependencies defined in sequence ensure predictable observer execution order, preventing race conditions and unpredictable behavior.
Which file is responsible for defining product attributes in Adobe Commerce?
-
A
eav_attributes.xml
-
B
attributes.xml
-
C
catalog_product.xml
✓ Correct
-
D
product_attributes.xml
Explanation
The catalog_product.xml file is used to define and configure product attributes in Adobe Commerce. This XML file is typically located in the etc directory of a module.
What is the primary purpose of the ProductRepository class in Adobe Commerce?
-
A
To handle product image processing and compression
-
B
To manage product cache invalidation only
-
C
To manage product database migrations
-
D
To provide a service layer interface for product data retrieval and manipulation
✓ Correct
Explanation
ProductRepository implements the service layer pattern and provides methods for getting, saving, and deleting products without direct database access, following repository design principles.
In Adobe Commerce, what does the term 'EAV' stand for?
-
A
External-Attribute-Vector
-
B
Enhanced-Attribute-Version
-
C
Entity-Attribute-Value
✓ Correct
-
D
Enterprise-Application-Validation
Explanation
EAV (Entity-Attribute-Value) is a data model used in Adobe Commerce to store flexible product attributes. This model allows products to have different attributes without requiring separate database columns.
Which observer event is triggered after a product is saved successfully?
-
A
catalog_product_updated
-
B
catalog_product_save_after
✓ Correct
-
C
product_save_commit_after
-
D
catalog_product_before_save
Explanation
The catalog_product_save_after event is dispatched after a product has been successfully saved to the database, making it ideal for post-save operations.
What is the correct way to get the current store ID in a controller?
-
A
$GLOBALS['store_id']
-
B
Store::getCurrentStoreId()
-
C
Mage::app()->getStore()->getId()
-
D
$this->_storeManager->getStore()->getId()
✓ Correct
Explanation
Using dependency injection to access StoreManagerInterface is the recommended approach in Adobe Commerce. The _storeManager property should be injected via the constructor.
Which XML file defines the structure of database tables in a module?
-
A
db_schema.xml
✓ Correct
-
B
schema.xml
-
C
table_structure.xml
-
D
database.xml
Explanation
The db_schema.xml file is used in Adobe Commerce to declare and manage database table structures declaratively, replacing the older InstallSchema.php approach.
What does the di.xml file configure in Adobe Commerce?
-
A
Database connections and credentials
-
B
Dependency injection container and object configurations
✓ Correct
-
C
Direct input form validation rules
-
D
Design and layout settings
Explanation
The di.xml file defines the dependency injection configuration, including class preferences, constructor arguments, and plugin definitions in Adobe Commerce.
In Adobe Commerce, which interface should custom plugins implement when intercepting method calls?
-
A
ObserverInterface
-
B
PluginInterface
-
C
No interface is required; only follow the naming convention
✓ Correct
-
D
InterceptorInterface
Explanation
Adobe Commerce plugins don't require implementing an interface. Instead, plugins follow a naming convention with beforeMethod, afterMethod, or aroundMethod in the plugin class.
Which method in CollectionFactory is used to create a product collection?
-
A
createNew()
-
B
create()
✓ Correct
-
C
getInstance()
-
D
instantiate()
Explanation
The create() method of CollectionFactory returns a new instance of a product collection that can be filtered and queried.
What is the purpose of the 'preference' element in di.xml?
-
A
To set default configuration values
-
B
To define user interface preferences
-
C
To configure cache preferences
-
D
To specify which class should be used when a particular interface is requested
✓ Correct
Explanation
The preference element in di.xml allows you to specify concrete implementations for interfaces, enabling loose coupling and easy substitution of dependencies.
Which class should be used to load a customer by their email address in Adobe Commerce?
-
A
Customer model with loadByEmail() method
-
B
CustomerFactory with createFromEmail() method
-
C
CustomerRepository with customerEmail parameter
-
D
Customer collection with addFieldToFilter() on email
✓ Correct
Explanation
While CustomerRepository is the recommended approach, it requires using a collection with addFieldToFilter('email', $email) or using the newer methods if available in your version.
What does the events.xml file configure in Adobe Commerce?
-
A
Frontend event tracking and analytics
-
B
API endpoint event streaming configuration
-
C
Scheduled cron jobs and task scheduling
-
D
Observer declarations for specific events
✓ Correct
Explanation
The events.xml file registers observer classes that listen to and react to specific events fired throughout the Adobe Commerce application.
In Adobe Commerce, what is the correct way to add custom validation to a form?
-
A
Use DataObject->validate() in the form processor
-
B
Create a custom validator class and register it in di.xml
✓ Correct
-
C
Add JavaScript validation only on the frontend template
-
D
Add validation rules in the admin grid XML
Explanation
Custom validators in Adobe Commerce should be implemented as classes registered through dependency injection, allowing for both frontend and backend validation.
Which method retrieves the current product object in a product view controller?
-
A
$product = $this->productRepository->getById($id)
-
B
$this->getProduct()
-
C
Registry::registry('current_product')
✓ Correct
-
D
Mage::registry('product')
Explanation
The Registry::registry('current_product') call retrieves the current product that was set during page initialization, commonly used in product controllers.
What is the purpose of the layout XML file in Adobe Commerce?
-
A
To manage resource file permissions
-
B
To configure database table layouts
-
C
To specify CSS class naming conventions
-
D
To define the visual structure and block rendering of pages
✓ Correct
Explanation
Layout XML files define how blocks are structured, ordered, and rendered on pages, controlling the visual presentation of content in Adobe Commerce.
Which configuration file is used to define custom admin grid columns?
-
A
adminhtml_grid.xml
-
B
grid.xml
-
C
ui_component declaration with columns configuration
✓ Correct
-
D
system.xml for admin grids
Explanation
Modern Adobe Commerce uses UI Components for admin grids, defined through XML files that declare columns, filters, and other grid properties.
What does the getAttributes() method return when called on a product instance?
-
A
A collection of selected attributes
-
B
An array of attribute names only
-
C
An associative array of Attribute objects keyed by attribute code
✓ Correct
-
D
An AttributeSet object
Explanation
getAttributes() returns an array of Attribute objects indexed by their code, allowing access to attribute metadata and values for the product.
In Adobe Commerce, which class is responsible for managing quote data?
-
A
QuoteRepository and QuoteInterface
✓ Correct
-
B
OrderRepository
-
C
ShoppingCartItem collection
-
D
CartManagement service
Explanation
QuoteRepository provides the service layer interface for managing quote (shopping cart) data, while QuoteInterface defines the quote entity contract.
What is the correct syntax for declaring a plugin 'around' method in Adobe Commerce?
-
A
public function beforeAndAfterMethod($args)
-
B
public function aroundMethod(Subject $subject, Proceed $proceed)
-
C
public function pluginAroundMethod($proceed, ...$args)
-
D
public function aroundMethod(Subject $subject, callable $proceed, ...$args)
✓ Correct
Explanation
An 'around' plugin method receives the subject, a callable $proceed reference to the original method, and the original method arguments, allowing full control over execution.
Which method adds an item to a customer's shopping cart in Adobe Commerce?
-
A
$cart->insertItem($product, $qty)
-
B
Quote::addItem($product, Qty)
-
C
CartManagement::addToCart($cartId, $cartItem)
-
D
$quote->addProduct($product, $qty)
✓ Correct
Explanation
The addProduct() method on a Quote object adds a product to the shopping cart with the specified quantity.
In Adobe Commerce, what is the purpose of the module.xml file?
-
A
To set module-specific cache configuration
-
B
To declare module metadata and dependencies
✓ Correct
-
C
To define module configuration and settings
-
D
To configure module routing rules
Explanation
The module.xml file declares essential module information including its name, version, sequence (dependencies), and other metadata required for Adobe Commerce to load the module.
Which event is fired when a customer logs into the storefront?
-
A
customer_auth_success
-
B
customer_session_init
-
C
customer_login_success
-
D
customer_login_after
✓ Correct
Explanation
The customer_login_after event is dispatched after a customer successfully authenticates and logs into the storefront.
What does the 'sortOrder' attribute control in configuration XML files?
-
A
The alphabetical ordering of configuration sections
-
B
The database query execution order
-
C
The priority order of loading configuration files
-
D
The display sequence of elements in the admin interface
✓ Correct
Explanation
The sortOrder attribute determines the rendering order of elements in admin sections, tabs, and groups, allowing control over visual presentation.
In Adobe Commerce, how should observer dependencies be injected?
-
A
Through static Mage helper methods
-
B
Through global $_GET and $_POST variables
-
C
By directly instantiating dependencies with the new keyword
-
D
Through the constructor of the observer class via dependency injection
✓ Correct
Explanation
Observer classes should use constructor injection to receive dependencies, following the same dependency injection principles as other Adobe Commerce classes.
You are implementing a custom GraphQL query in Adobe Commerce. Which file structure is correct for defining a custom query resolver?
-
A
app/code/Vendor/Module/GraphQL/Query/Custom.php with no configuration file needed
-
B
The query must be defined directly in the module's registration.php file
-
C
Custom queries can only be added through the admin panel configuration
-
D
app/code/Vendor/Module/etc/graphql.xml followed by Model/Resolver/QueryClass.php
✓ Correct
Explanation
Adobe Commerce GraphQL requires queries to be defined in graphql.xml configuration files, with corresponding resolver classes in the Model/Resolver directory following the resolver pattern.
When implementing plugin interceptors for a protected method in Adobe Commerce, what is the correct approach?
-
A
Use beforePlugin, aroundPlugin, and afterPlugin to intercept protected methods the same way as public methods
✓ Correct
-
B
You cannot intercept protected methods; only public methods can be intercepted
-
C
Protected methods require a special ProtectedInterceptor class in your di.xml configuration
-
D
You must use event observers instead of plugins for protected methods
Explanation
Adobe Commerce plugins can intercept both public and protected methods using the standard before/around/after plugin pattern defined in di.xml, with no special handling required for visibility modifiers.
What is the primary purpose of the etc/extension_attributes.xml file in an Adobe Commerce module?
-
A
It configures environment-specific attribute encryption settings
-
B
To define custom attributes that extend standard entity models without modifying their database tables
✓ Correct
-
C
It stores all CSS and JavaScript attribute configurations for the frontend
-
D
To manage session attributes and cookie handling across the application
Explanation
Extension attributes (defined in extension_attributes.xml) allow developers to add custom attributes to existing entities through composition rather than modifying the core table structure.
You need to add a custom column to the sales_order table while maintaining upgrade compatibility. What is the best practice approach?
-
A
Create a data patch in Setup/Patch/Data or Schema that properly declares the column addition with proper rollback logic
✓ Correct
-
B
Use the admin panel to add the column and export the database structure
-
C
Create an observer that dynamically adds the column at runtime when needed
-
D
Directly modify the sales_order table using an ALTER TABLE statement in your setup script
Explanation
Adobe Commerce best practice uses declarative schema patches (Setup/Patch/Schema or Data) which provide proper version tracking, rollback capabilities, and maintenance of the schema version history.
In the context of Adobe Commerce service contracts, what is the primary difference between @api and non-@api interfaces?
-
A
@api requires additional authentication layers while non-@api does not
-
B
@api interfaces can only be accessed from third-party extensions, while non-@api are internal only
-
C
@api interfaces are stable and guaranteed backward compatibility across minor versions, while non-@api can change without notice
✓ Correct
-
D
There is no functional difference; @api is only a documentation marker with no technical impact
Explanation
The @api annotation indicates stable, supported interfaces that maintain backward compatibility across Adobe Commerce versions. Non-@api interfaces are internal and may change without warning.
You are developing a module that needs to modify checkout behavior. Which approach best leverages Adobe Commerce architecture for maximum extensibility?
-
A
Use checkout_cart_product_add_after event and modify the quote items in your observer
-
B
Override the Magento_Checkout module files directly in your theme directory
-
C
Create a plugin for the relevant service contract methods or use checkout-specific layout events and plugins for UI changes
✓ Correct
-
D
Create a custom REST API endpoint that replaces the standard checkout endpoint entirely
Explanation
The extensible approach uses service contract plugins and checkout layout handles to modify behavior without overriding core files, allowing multiple modules to coexist and upgrade cleanly.
What does the etc/webapi.xml configuration file define in an Adobe Commerce module?
-
A
The web server configuration including SSL certificates and domain settings
-
B
All webhook configurations for third-party integrations
-
C
The API rate limiting and throttling rules for the entire store
-
D
Routes and configuration for REST and SOAP API endpoints that expose service contract methods
✓ Correct
Explanation
The webapi.xml file defines which service contract methods are exposed through REST and SOAP APIs, including routes, HTTP methods, and required permissions.
When implementing observer-based functionality, under what circumstances should you use synchronous observers instead of asynchronous (queued) observers?
-
A
The choice between synchronous and asynchronous has no performance impact and is purely a stylistic decision
-
B
Synchronous observers should always be used for consistency; asynchronous is never recommended
-
C
Asynchronous observers are only available in Adobe Commerce Cloud and cannot be used in on-premise installations
-
D
Use synchronous for critical operations requiring immediate processing (like validation), and asynchronous for non-blocking tasks (like logging or notifications) to improve performance
✓ Correct
Explanation
Synchronous observers block execution until complete, suitable for validation and critical logic. Asynchronous observers via message queues improve performance for non-critical operations like email sending or reporting.
You need to add custom validation to a product attribute during save. What is the most maintainable approach in Adobe Commerce?
-
A
Add validation logic directly to the Product model save() method by overriding it
-
B
Use a catalog_product_save_before event observer to check the attribute value and throw an exception if invalid
-
C
Create a custom validator class and use a plugin on the product repository's save method to validate before persisting
✓ Correct
-
D
Implement validation in the admin controller that handles product saving requests
Explanation
Using a service contract plugin with a dedicated validator class is most maintainable, allowing the validation logic to be reusable across API and admin contexts without duplicating code.
In Adobe Commerce, what is the purpose of the Magento\Framework\Api\SearchCriteriaBuilder and how does it relate to collection filtering?
-
A
It provides an API-friendly way to build filter criteria for service contract repository methods, independent of collection implementation details
✓ Correct
-
B
SearchCriteriaBuilder directly manipulates database collections and should replace all collection-based filtering
-
C
It is used exclusively for Elasticsearch queries and has no effect on standard SQL collections
-
D
It is an internal utility used only by the admin grid and cannot be used in custom code
Explanation
SearchCriteriaBuilder constructs standardized search criteria objects used by repositories to filter results, providing a consistent API layer abstracted from underlying collection implementation.