Pregunta 1
Pregunta
You see this code in etc/adminhtml/routes.xml:
<route id="mymodule" frontName="user-subscriptions">
<module name="MyCompany_MyModule" />
</route> You have placed a controller in Controller/Index/Subscribe.php. If you want to create layout XML instructions for this controller, what would be the layout XML's filename?
Respuesta
-
mymodule_index_subscribe.xml
-
mymodule_subscribe_[ACTION NAME].xml
-
user_subscriptions_index_subscribe.xml
-
user_subscriptions_subscribe_[ACTION NAME].xml
Pregunta 2
Pregunta
You have created a new product type, sample, and need to customize how it renders on the shopping cart page. Keeping maintainability in mind, how do you add a new renderer?
Respuesta
-
Create the layout file, checkout_cart_item_renderers.xml, reference the checkout.cart.item.renderers block and add a new block with an as="sample" attribute.
-
Override the cart/form.phtml template and add logic for the sample product type.
-
Create the layout file, checkout_cart_index.xml, and reference the checkout.cart.renderers block and add a block with the as="sample" attribute.
-
Create the layout file, checkout_cart_index.xml, and update the cart page's uiComponent to appropriately render the sample product type.
Pregunta 3
Pregunta
You are building an tool that imports products from an ERP. There are 20 columns of additional information that are associated with each product. This extra information must also be associated with an update time to know when to refresh the data. Keeping maintainability in mind, how do you build this into Magento?
Respuesta
-
Utilize an extension attribute.
-
Override the Product model and add the fields.
-
Create a separate model and build code to associate the two record types.
-
Create 20 EAV attributes and check their updated_at column.
Pregunta 4
Pregunta
What interface should a frontend controllers action implement?
Respuesta
-
\Magento\Framework\App\ActionInterface
-
\Magento\Frontend\Controller\ActionInterface
-
\Magento\Frontend\Controller\ControllerInterface
-
\Magento\Framework\App\ControllerInterface
Pregunta 5
Pregunta
You are making some major adjustments to a core Magento class (ClassA). These adjustments are only necessary when utilized from a specific Magento class (ClassB). You have created MyClass that contains the needed customizations.
Keeping upgradeability in mind, how do you configure di.xml to make the substitution happen?
Respuesta
-
Ensure that MyClass extends ModuleA and set the <argument/>, for ModuleB to point to your new class in di.xml.
-
Set a <preference/> for ModuleA to be replaced by MyClass
-
Create a rewrite node that injects MyClass into ClassB.
-
Create a virtual type that extends ModuleB, specifying an <argument/> for MyClass.
Pregunta 6
Pregunta
You are customizing the display of product details page. On this page ur customer need to change the url in which the product category name will be appear as http://mystore.com/women/tops-women/helena-hooded-fleece.html , Keeping ,maintainability in mind ,How to get product url with category?
Respuesta
-
Admin -> Stores -> Configuration -> Catalog -> Catalog -> Search Engine Optimization -> "Use Categories Path for Product URLs" set to "Yes"
-
It is not possible to display Categories name on product url
-
$product->setCategoryId($categoryId)->getProductUrl();
-
You Can Build category URL path \vendor\magento\module-catalog-url-rewrite\Model\CategoryUrlPathGenerator.php
Pregunta 7
Pregunta
You are building a new module to add extra functionality to the Magento application. What files are required?
Respuesta
-
registration.php
-
etc/module.xml
-
composer.json
-
Setup/InstallSchema.php
-
etc/config.xml
Pregunta 8
Pregunta
You need to add the Google Tag Manager (GTM) to every page. What three steps do you take to accomplish this in MyCompany_MyModule?
Respuesta
-
Add into view/frontend/layout/default.xml.
-
Create view/frontend/layout/default.xml.
-
Create view/frontend/templates/script.phtml and add GTM code.
-
Run bin/magento create:module:template script.phtml
-
Copy vendor/module-catalog/view/template/script.phtml to view/template/script.phtml and add GTM script.
Pregunta 9
Pregunta
You need to control access to a custom controller action. How do you tell Magento about this new control option?
Respuesta
-
Create etc/acl.xml and add <resource id="MyCompany_MyModule::customAction" ... />
-
In the controller, implement the _isAllowed method.
-
Create etc/adminhtml/acl.xml and add <acl id="MyCompany_MyModule::customAction" ... />
-
Use the CLI to add the new resource option.
Pregunta 10
Pregunta
You are trying to determine why a product is not appearing in a category. What table does Magento on the frontend to locate the relationship between a category and its products?
Pregunta 11
Pregunta
How do you instruct Magento to enable a new module?
Respuesta
-
bin/magento module:enable MyCompany_MyModule
-
Magento automatically enables all new modules.
-
Go to Admin > System > Module Management.
-
Add MyCompany_MyModule to the setup_module table.
Pregunta 12
Pregunta
As you are scanning folder in the vendor/module-catalog directory, you see a directory that is named Ui.
What is this folder's purpose?
Respuesta
-
It contains UI component data providers and component information.
-
It contains templates, CSS and JS pertinent to the module.
-
It contains the block PHP files that render HTML onto the frontend.
-
It is not a normal folder and further investigation is necessary to determine the purpose.
Pregunta 13
Pregunta
You are updating a module to add extra functionality to the Magento application, Where would Magento look for modules?
Respuesta
-
app/code/VendorName/ModuleName
-
vendor/vendor-name/module-name
-
app/vendor/vendor-name/module-name
-
lib/vendor-name/module-name
Pregunta 14
Pregunta
You are reviewing a module to some special functionality to the Magento 2 application, You see directory /Console, What task you think in this directory contain script for this modules?
Respuesta
-
contains CLI commands
-
contains any PHP classes exposed to the API
-
contains cron job definitions.
-
contains section files
-
open directory /Console & check script what code contaib
Pregunta 15
Pregunta
You are reviewing a module to some special functionality to the Magento 2 application, You see directory /CustomerData, What task you think in this directory contain script for this modules?
Respuesta
-
Contains section files that works with the data stored on the client side.
-
contains aggregated functionality.
-
contains localization files.
-
contains view files, including static view files, design templates, email templates, and layout files.
Pregunta 16
Pregunta
You are building a new module to add extra functionality to the Magento application.You want to works with CustomerData the data stored on the client side. Where initialized sections Cart and Directory-data are on the server side via the classes ?
Respuesta
-
Magento\Checkout\CustomerData\Cart and Magento\Checkout\CustomerData\DirectoryData
-
Magento\Checkout\Api\Cart and Magento\Checkout\Api\DirectoryData
-
Magento\Checkout\Block\Cart and Magento\Checkout\Block\DirectoryData
-
Magento\Checkout\Plugin\Cart and Magento\Checkout\Plugin\DirectoryData
Pregunta 17
Pregunta
Magento and third-party developers can find it difficult to track and report the dependencies that customized extensions have on other extensions. To address these issues, the Magento system introduces service contracts. What is a Service Contracts - Data interfaces ?
Respuesta
-
set of PHP interfaces that are defined for a module includes data interfaces
-
set of API interfaces that are defined for a module includes web APIs
-
set of UI Library that are defined for a module includes ui content
-
set of JS Library that are defined for a module includes js Library
Pregunta 18
Pregunta
You have created a module to show manufacturer-list, but in your page need to show Pagination that already ready in your block. Keeping maintainability in mind, where you call echo $block->getPagerHtml(); ?
Respuesta
-
/Manufacturer/view/frontend/templates/content.phtml
-
/Manufacturer/Block/Index.php
-
/Manufacturer/Controller/Index/Index.php
-
/Manufacturer/view/frontend/layout/manufacturer_index_index.xml
Pregunta 19
Pregunta
You have created a module to show manufacturer-list,Your customer need url as www.storeurl/manufacturer which file are mendatory to show correct url?
Respuesta
-
Controller: /Manufacturer/Controller/Index/Index.php
-
Block: /Manufacturer/Block/Index.php
-
Layout: Manufacturer/view/frontend/layout/manufacturer_index_index.xml
-
Templates:/Manufacturer/view/templates/content.phtml
-
Layout: Manufacturer/view/frontend/layout/index_index.xml
-
Layout: Manufacturer/view/frontend/layout/manufacturer.xml
Pregunta 20
Pregunta
You are facing a bug, which is supposedly caused by the customization of \Magento\Catalog\Api\ProductRepositoryInterface::save(). To resolve the issue, you decide to find all logic which customizes this method. Which two places do you search for customization declarations? (Choose 2)
Respuesta
-
*/di.xml
-
*/events.xml
-
*/config.xml
-
*/plugins.xml
Pregunta 21
Pregunta
You are implementing a customization of the sales management within a module MyCompany_MySalesProcess. You have created several event observers to add the custom functionality. Each observer is a separate class, but they require some common functionality.
How do you implement the common functionality in the event observers, keeping maintainability and testability in mind?
Respuesta
-
You create a regular class implementing the common functionality as public methods and use constructor injection to make them available to the observers.
-
You create a trait with the common methods and use the trait in the observer classes.
-
You create a regular class implementing the common functionality as public static methods and call those from the observers.
-
You create an abstract class AbstractObserver with the common methods and extend the observer classes from it.
Pregunta 22
Pregunta
A custom module is performing an optimized custom query for quote items. The class applies the query customizations on the select object of a quote item collection instance.
public function __construct(
\Magento\Quote\Model\ResourceModel\Quote\Item\Collection $collection) {
$this->collection = $collection;
}
public function fetchData() {
$select = $this->collection->getSelect();
... code modifying $select...
return $this->collection->getData();
}
You are tasked to resolve an issue where the query sometimes does not deliver the expected results. You have debugged the problem and found another class is also using a quote item collection and is loading the collection before the custom module. How do you resolve the issue, keeping maintainability in mind
Respuesta
-
You change the argument type to \Magento\Quote\Model\ResourceModel\Quote\Item\CollectionFactory and
instantiate the collection using $collectionFactory->create();
-
You remove the constructor argument and use ObjectManager::getInstance()-
>create(\Magento\Quote\Model\ResourceModel\Quote\Item\Collection::class) to instantiate the collection instead.
-
You inject \Magento\Framework\DB\Select instead of the collection and perform the desired query independently of the collection.
-
You inject \Magento\Quote\Api\CartItemRepositoryInterface because low level query customizations are not allowed.
Pregunta 23
Pregunta
In a custom module you implement the interface \Magento\Framework\App\Config\DataInterface.
/** Configuration data storage @api */
interface DataInterface {
public function getValue($path);
public function setValue($path, $value);
} What version constraint for magento/framework do you add to your module’s composer.json file?
Pregunta 24
Pregunta
You are building CLI that use the console to create a customer account with our custom command as like
php bin/magento customer:user:create --customer-firstname="Mahin" --customer-lastname="Rahman" --customer-email="mahin@example.com" --customer-password="mahin@123" --website="1"
using: protected function configure() { $this->setName('customer:user:create') ->setDescription('Create new customer') ->setDefinition($this->getOptionsList()); } protected function getOptionsList(){ return [ ------------------]; } Which below Option are not required in blank? (Choose 2)
Respuesta
-
new InputOption(Customer::KEY_SENDEMAIL, 0, InputOption::VALUE_OPTIONAL, '(1/0) Send email? (default 0)')
-
new InputOption(Customer::KEY_STORE, null, InputOption::VALUE_REQUIRED, '(Required) Store ID'),
-
new InputOption(Customer::KEY_PASSWORD, null, InputOption::VALUE_REQUIRED, '(Required) Customer password'),
-
new InputOption(Customer::KEY_EMAIL, null, InputOption::VALUE_REQUIRED, '(Required) Customer email'),
-
new InputOption(Customer::KEY_LASTNAME, null, InputOption::VALUE_REQUIRED, '(Required) Customer last name'),
-
new InputOption(Customer::KEY_FIRSTNAME, null, InputOption::VALUE_REQUIRED, '(Required) Customer first name'),
-
new InputOption(Customer::KEY_WEBSITE, null, InputOption::VALUE_REQUIRED, '(Required) Website ID'),
Pregunta 25
Pregunta
You are building CLI that use the console to create a customer account with our custom command, Adding a new command to CLI is based on passing on the argument from the XML level to the class . Dependency Injection comes in handy here. you create the file app/code/Mycompany/Customer/etc/di.xml with the following content: <type name="---------------------"> </type> What is the correct in below?
Respuesta
-
Magento\Framework\Console\CommandList
-
Magento\Framework\Console
-
Magento\Framework\CommandList
-
Magento\Framework\CommandList\Console
Pregunta 26
Pregunta
You are creating a new indexer which must run after the targetrule_product_rule index process. When you run bin/magento indexer:reindex, your rule always runs first creating inaccurate data. What is the resolution?
Respuesta
-
Use a dependencies node in your indexer configuration
-
Specify the sortOrder in your indexer configuration.
-
Use a plugin on the IndexManager class to change load order.
-
Create a bash script to execute each indexer in the correct order.
Pregunta 27
Pregunta
You need to render a product attribute’s raw value as a variable in a script tag. This value will be used to initialize an application on the frontend. How do you render this value?
Respuesta
-
<?= $block->escapeJs($value) ?>
-
<?= $block->escapeJsVar($value) ?>
-
<?= $block->renderJs($value) ?>
-
<?= $block->escapeHtml($value) ?>
Pregunta 28
Pregunta
You need to add a new column to the sales_shipment and the sales_shipment_grid tables. Other than utilizing the default addColumn methods, what way is automatic?
Respuesta
-
Utilize the SalesSetup class’ addAttribute method.
-
On the default EavSetup class, utilize the addColumn method.
-
On the ModuleDataSetupInterface, call $setup->getSales()->addColumn().
-
Ensure your UpgradeSchema class extends CoreSetup and call $this->addSalesColumns().
Pregunta 29
Pregunta
You are creating a module that will be sold on the Magento Marketplace. You wish for this module to be easily extensible, and decide to add the capability for other developers to utilize extension attributes. What is the minimum update necessary to enable this capability?
Respuesta
-
Add the getExtensionAttributes() method and implement ExtensionAttributesInterface in each model.
-
Create an ExtensionAttributeInterface for each model.
-
Ensure each model extends Magento\Framework\Model\AbstractExtensibleModel.
-
Configure your models in etc/extension_attributes.xml
Pregunta 30
Pregunta
There is a custom extension called MyCompany_MyModule. It has the following layout customization declared in MyCompany/MyModule/view/frontend/layout/default.xml:
<referenceContainer name=”content”>
<block class=”Magento\Framework\View\Element\Template”
name=”my.block”
template=”MyCompany_MyModule::my_template.phtml”
cacheable=”false”/>
</referenceContainer> What will be the result of the customization?
Respuesta
-
All store front pages will be non-cacheable
-
Only the default landing page will be non-cacheable
-
my.block on the default landing page only will be cached using ESI.
-
my.block on the all store front pages will be cached using ESI