trunglv / mage2-dev
了解Magento2的一些工具
dev-main
2024-08-03 06:19 UTC
Requires
- php: >=8.0
This package is auto-updated.
Last update: 2024-10-03 06:55:01 UTC
README
安装
1. 克隆并将源代码复制到app/code/Betagento文件夹中
2. 通过Composer安装
composer require trunglv/mage2-dev:dev-main [Recommend]
调试工具
-1. 依赖注入检查
** !!! 需要先运行setup:di:compile以加载DI配置(用于首选项)并创建各种拦截器和工厂类。 **
php bin/magento beta_dev:check_di -t "Magento\Quote\Model\QuoteManagement"
----------------------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+ | checkoutSession | Magento\Checkout\Model\Session | Check possible interfaces. A class that relies on another class should interact with it through an interface! | Magento\Framework\Session\SessionManagerInterface | | | | Magento\Framework\Session\SessionManagerInterface | ---> Magento\Framework\Session\Generic\Interceptor | | | | Magento\Framework\ObjectManager\ResetAfterRequestInterface | Magento\Framework\ObjectManager\ResetAfterRequestInterface | | | | | ---> Magento\Framework\ObjectManager\ResetAfterRequestInterface | +----------------------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+ +----------------------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+ | customerSession | Magento\Customer\Model\Session | Check possible interfaces. A class that relies on another class should interact with it through an interface! | Magento\Framework\Session\SessionManagerInterface | | | | Magento\Framework\Session\SessionManagerInterface | ---> Magento\Framework\Session\Generic\Interceptor | | | | Magento\Framework\ObjectManager\ResetAfterRequestInterface | Magento\Framework\ObjectManager\ResetAfterRequestInterface | | | | | ---> Magento\Framework\ObjectManager\ResetAfterRequestInterface | +----------------------------+-----------------------------------------------------+----------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------+
0. 列出所有插件及其监听器类型[before, around, after]
示例
bin/magento beta_dev:show_plugins_by_listener_type -t around
------Plugins for Scope graphql------ +------------------------------------------------------------------+-----------------------------------------------------------------------+-----------------+--------------------------------------------------------------------------------------------------------------------+ | class | code | original_method | instance | +------------------------------------------------------------------+-----------------------------------------------------------------------+-----------------+--------------------------------------------------------------------------------------------------------------------+ | Magento\Framework\GraphQl\Query\ResolverInterface | cacheResolverResult | resolve | Magento\GraphQlResolverCache\Model\Plugin\Resolver\Cache | | Magento\Framework\Mail\Template\TransportBuilder | graphQlEmulateEmail | getTransport | Magento\StoreGraphQl\Plugin\LocalizeEmail | | Magento\Framework\App\FrontControllerInterface | front-controller-builtin-cache | dispatch | Magento\PageCache\Model\App\FrontController\BuiltinPlugin | | Magento\InventoryIndexer\Model\ResourceModel\GetStockItemData | inventory_catalog_get_legacy_stock_item_data_from_stock_registry | execute | Magento\InventoryCatalog\Plugin\InventoryIndexer\Model\ResourceModel\GetLegacyStockStatusDataFromStockRegistry | | Magento\InventoryIndexer\Model\ResourceModel\GetStockItemsData | inventory_catalog_get_bulk_legacy_stock_item_data_from_stock_registry | execute | Magento\InventoryCatalog\Plugin\InventoryIndexer\Model\ResourceModel\GetBulkLegacyStockStatusDataFromStockRegistry | | Magento\InventoryConfiguration\Model\GetLegacyStockItem | inventory_catalog_get_legacy_stock_item_from_stock_registry | execute | \Magento\InventoryCatalog\Plugin\InventoryConfiguration\Model\GetLegacyStockItemFromStockRegistry | | Magento\ConfigurableProduct\Model\Product\Type\Configurable | used_products_cache_graphql | getUsedProducts | Magento\ConfigurableProduct\Model\Plugin\Frontend\UsedProductsCache | | Magento\InventorySales\Model\AreProductsSalable | are_products_salable | execute | Magento\InventoryIndexer\Plugin\InventorySales\AreProductsSalable | | Magento\ReCaptchaValidationApi\Api\ValidatorInterface | graphql_recaptcha_validation_override | isValid | Magento\ReCaptchaWebapiGraphQl\Plugin\ValidationOverrider | | Magento\CatalogGraphQl\Model\Resolver\Layer\DataProvider\Filters | add_swatch_data_to_filters | getData | Magento\SwatchesGraphQl\Plugin\Filters\DataProviderPlugin | +------------------------------------------------------------------+-----------------------------------------------------------------------+-----------------+--------------------------------------------------------------------------------------------------------------------+
1. 列出类的所有插件
示例
bin/magento beta_dev:show_plugins -t "Magento\InventorySales\Model\AreProductsSalableForRequestedQty"
结果示例
bin/magento beta_dev:show_plugins -t 'Magento\Quote\Api\CartManagementInterface' ------Plugins for Scope global------ Plugins for type Magento\Quote\Api\CartManagementInterface +--------------------+-----------------+--------------------+--------------------------------------------------+---------------+ | code | original_method | plugin_method_type | instance | method_exists | +--------------------+-----------------+--------------------+--------------------------------------------------+---------------+ | order_cancellation | placeOrder | around | PayPal\Braintree\Plugin\OrderCancellation | method is ok | | order_update | placeOrder | before | Magento\PaymentServicesPaypal\Plugin\OrderUpdate | method is ok | +--------------------+-----------------+--------------------+--------------------------------------------------+---------------+ Plugins for type Magento\Quote\Model\QuoteManagement +----------------------------------+-----------------+--------------------+------------------------------------------------------------+---------------+ | code | original_method | plugin_method_type | instance | method_exists | +----------------------------------+-----------------+--------------------+------------------------------------------------------------+---------------+ | update_bundle_quote_item_options | submit | before | Magento\Bundle\Plugin\Quote\UpdateBundleQuoteItemOptions | method is ok | | validate_purchase_order_number | submit | before | Magento\OfflinePayments\Plugin\ValidatePurchaseOrderNumber | method is ok | | coupon_uses_increment_plugin | submit | around | Magento\SalesRule\Plugin\CouponUsagesIncrement | method is ok | +----------------------------------+-----------------+--------------------+------------------------------------------------------------+---------------+ ----- END Plugins for Scope ------global -- No specific scoped plugins injected for Magento\Quote\Api\CartManagementInterfaces in frontend -- -- No specific scoped plugins injected for Magento\Quote\Api\CartManagementInterfaces in adminhtml -- -- No specific scoped plugins injected for Magento\Quote\Api\CartManagementInterfaces in webapi_rest -- -- No specific scoped plugins injected for Magento\Quote\Api\CartManagementInterfaces in graphql --
当找到接口'Magento\Quote\Api\CartManagementInterface'的插件时,它将显示注入到接口本身和首选项具体类'Magento\Quote\Model\QuoteManagement'的插件。
2. 列出事件的观察者
bin/magento beta_dev:show_observers -e catalog_product_get_final_price
Usage:
beta_dev:show_observers [options]
Options:
-e, --event=EVENT Event code : --e catalog_product_get_final_price
-s, --scope_code[=SCOPE_CODE] Scope : -s global|frontend|adminhtml|crontab|webapi_rest|webapi_soap|graphql
3. 按范围显示所有控制器操作
bin/magento beta_dev:show_controller_action -f checkout -a frontend
Description:
Show all controller actions per a scope
Usage:
beta_dev:show_controller_action [options]
Options:
-f, --frontname=FRONTNAME Frontname : --m catalog
-a, --area=AREA Area Code: --a frontend|adminhtml
示例结果
4. 反射API服务
Description:
Refection for API Services
Usage:
beta_dev:api_reflection [options]
Options:
-a, --api=API API ID : -a : /V1/carts/:cartId/shipping-information
-m, --http_method[=HTTP_METHOD] HTTP Method: -m POST
示例
bin/magento beta_dev:api_reflection --api "/V1/carts/:cartId/shipping-information" -m POST
一般信息
输入数据反射
输出数据反射
部署静态文件(JavaScript, CSS, HTML, Js-translation, requirejs-config.js)
在运行以下CLI命令之前 - 请确保您已删除文件夹var/view_proccessed(一些静态文件存储在该文件夹中)
bin/magento beta_dev:deploy_static -h Description: Deploy a static file. ---> Deploy static files from a/an module/extension. E.g. bin/magento beta_dev:deploy_static -f js/view/shipping-address/address-renderer/default.js -t Magento/luna -m Magento_Checkout ---> Deploy Css files base on a theme base Magento-Luna architecure. E.g. bin/magento beta_dev:deploy_static -f css/styles-l.css -t Magento/luna E.g. bin/magento beta_dev:deploy_static -f css/styles-m.css -t Magento/luna ---> Deploy JS Translation Json File base on a theme base Magento-Luna architecure. E.g. bin/magento beta_dev:deploy_static -t Magento/blank -f js-translation.json Usage: beta_dev:deploy_static [options] Options: -f, --file_path=FILE_PATH File Path/ Directory Path: for specific file -f js/view/shipping-address/address-renderer/default.js OR for a specific folder -f js -t, --theme_path=THEME_PATH Theme path: -t Magento/luna -a, --area=AREA Area Code: -a frontend|adminhtml -m, --module_name[=MODULE_NAME] Module name: -m Magento_Checkout -l, --locale_code[=LOCALE_CODE] Locale code: -l da_DK
1. 部署来自/a/扩展/模块的CSS/JavaScript文件
bin/magento beta_dev:deploy_static -m Magento_Checkout -f js/view/shipping-address/address-renderer/default.js -t Magento/luna
-- 能够部署Adminhtml主题并对目录完全部署
bin/magento beta_dev:deploy_static -t Magento/backend -a adminhtml -m Magento_Catalog -f js
2. 部署js-translation.json
示例
bin/magento beta_dev:deploy_static-t Magento/luna -f js-translation.json
3. 部署css/styles-m.css, css/styles-l.css
bin/magento beta_dev:deploy_static-t Magento/luna -f css/styles-l.css
bin/magento beta_dev:deploy_static -t Magento/luna -f css/styles-m.css
RequireJS配置
部署requirejs-config.js
示例
bin/magento beta_dev:deploy_requirejs -t Magento/luna
我喜欢编码
@Trung,lv - skype: beta.trunglv@outlook.com - email : luuvantrung@gmail.com