我是編碼方面的新手,也是Magento方面的超級新手。我已經按照這些說明創建了一個自定義載體。https://devdocs.magento.com/guides/v2.4/howdoi/checkout/checkout-add-custom-carrier.html#create-configuration,它運行得非常好。 然后,我試圖通過復制和重命名我的Vendor檔案夾,再創建一個自定義載體。我還修改了代碼中的一些內容:
在registration.php中
我還修改了代碼中的一些內容。
在registration.php中
<?php
use MagentoFrameworkComponentComponentRegistrar;
組件注冊器::register(
ComponentRegistrar::MODULE,
'Vendor2_CustomShipping'。
__DIR__.
);
在composer.json中
{
"name"。"vendor2/custom-shipping",
"description": "自定義發貨模塊"。
"require": {
"php": "~7.2.0||~7.3.0",
"Magento/framework": "102.0.*",
"Magento/module-backend": "101.0.*",
"Magento/module-catalog": "103.0.*",
"magento/module-config": "101.1.*",
"magento/module-directory": "100.3.*",
"magento/module-quote": "101.1.*",
"Magento/module-sales": "102.0.*",
"Magento/module-sales-rule": "101.1.*",
"Magento/module-shipping": "100.3.*",
"Magento/module-store": "101.0.*".
},
"type": "magento2-module"。
"許可證": [
"OSL-3.0"。
"AFL-3.0"。
],
"autoload": {
"files": [
"registration.php"。
],
"psr-4": {
"Vendor2CustomShipping": ""。
}
},
"version": "1.0.0"。
在module.xml中:
<?xml version="1.0"? >
<config xmlns:xsi="http://www.w3. org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor2_CustomShipping"/span> >
<sequence>
<module name="Magento_Store"/>
<module name="Magento_Sales"/>/span>
<module name="Magento_Quote"/span>/>
<module name="Magento_SalesRule"/>/span>
</sequence>/span>
</module>/span>
</config>
在config.xml中:
<?xml version="1.0"? >
<config xmlns:xsi="http://www.w3. org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<carriers>/span>
<customshipping>>
<active>0</active>/span>
<title>Custom Shipping Title</title>
<name>自定義發貨方法名稱</name>/span>
<shipping_cost>10</shipping_cost>/span>
<sallowspecific>0</sallowspecific>/span>
<sort_order>/span>15</sort_order>/span>
<model>Vendor2CustomShippingModelCarrierCustomshipping</model>
</customshipping>/span>
</carriers>/span>
</default>/span>
</config>/span>
而在Customshipping.php中:
namespace Vendor2CustomShippingModelCarrier。
我成功地啟用了新的模塊并升級了Magento,但是當我進入我的管理系統時,我只能看到一個可用的自定義載體選項。我還試著洗掉了第一個創建的模塊,這使得第二個模塊出現。我想這是一個沖突,但我不知道如何解決它。 謝謝
。uj5u.com熱心網友回復:
第二種運輸方式正在覆寫第一種運輸方式。為了防止這種情況,還需要做一些改變:
在etc/adminhtml中,我們可以看到 "第二種發貨方式"。
在etc/adminhtml/system.xml中把<group id="customshipping" ...>改為<group id="customshipping2" ...> 。
同時在etc/config.xml中把<customshipping>改為<customshipping2>。
在Model/Carrier/Customshipping.php中把protected $_code = 'customshipping';改為protected $_code = 'customshipping2';。
通過這些改變,你應該能夠在Magento管理中看到兩種新的運輸方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/320564.html
標籤:
上一篇:從電子表格制作谷歌折線圖
