我尝试通过 url_key 在 Magento 2.0 中获取一个类别。
现在我有:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$categoryFactory = $objectManager->create('Magento\Catalog\Model\CategoryFactory');
$category = $categoryFactory->create()
->addAttributeToFilter('url_key','my_category_url_key');
Run Code Online (Sandbox Code Playgroud)
它返回给我这个错误:
过滤模板错误:无效方法 Magento\Catalog\Model\Category\Interceptor::addAttributeToFilter(Array ( [0] => url_key [1] => my_category_url_key ) )
谢谢。
我试图覆盖
供应商\的magento \模块multishipping \视图\前端\模板\结帐\ addresses.phtml
我创建了布局
应用程序\代码\我\ CustomModule \图\前端\布局\ multishipping_checkout_addresses.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Multishipping\Block\Checkout\Addresses" name="checkout_addresses" template="My_CustomModule::checkout/addresses.phtml" cacheable="false">
</block>
</referenceContainer>
</body>
</page>
Run Code Online (Sandbox Code Playgroud)
和模板
应用程序\代码\我\ CustomModule \图\前端\模板\结账\ addresses.phtml
<h1>It works </h1>
Run Code Online (Sandbox Code Playgroud)
它不起作用......请帮帮我!谢谢.