Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Class Magento:自定义模块错误(Layout.php中找不到类)_Class_Magento_Module_Block_Fatal Error - Fatal编程技术网

Class Magento:自定义模块错误(Layout.php中找不到类)

Class Magento:自定义模块错误(Layout.php中找不到类),class,magento,module,block,fatal-error,Class,Magento,Module,Block,Fatal Error,我试图在Magento中创建一个新的自定义模块(块),它将在产品详细信息页面上显示来自制造商的其他产品。当我加载产品详细信息页面时,我得到: Fatal error: Class 'AimIT_ManufacturerBlock_Block_Manufacturerblock' not found in ..\app\code\core\Mage\Core\Model\Layout.php on line 491 我创造了: 1) \app\etc\modules\AimIT\u Manufa

我试图在Magento中创建一个新的自定义模块(块),它将在产品详细信息页面上显示来自制造商的其他产品。当我加载产品详细信息页面时,我得到:

Fatal error: Class 'AimIT_ManufacturerBlock_Block_Manufacturerblock' not found in ..\app\code\core\Mage\Core\Model\Layout.php on line 491
我创造了:

1) \app\etc\modules\AimIT\u ManufacturerBlock.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <modules>
    <AimIT_ManufacturerBlock>
      <!-- Whether our module is active: true or false -->
        <active>true</active>
        <!-- Which code pool to use: core, community or local -->
          <codePool>local</codePool>
        </AimIT_ManufacturerBlock>
      </modules>
    </config>

真的
地方的
2) \app\code\local\AimIT\ManufacturerBlock\etc\config.xml

<?xml version="1.0"?>
<config>
  <global>
    <blocks>
      <aimitmanufacturerblock>
        <class>AimIT_ManufacturerBlock_Block</class>
      </aimitmanufacturerblock>
    </blocks>
  </global>
</config>

AimIT_制造块
3) \app\code\local\AimIT\ManufacturerBlock\Block\ManufacturerBlock.php

<?php
class AimIT_ManufacturerBlock_Block_Manufacturerblock extends Mage_Core_Block_Template 
{    
    public function getManufacturerProducts($manufacturer)
    {
        $collection = Mage::getModel('catalog/product')->getCollection();
        $collection->addAttributeToFilter('manufacturer',$manufacturer);
        $collection->addAttributeToSelect('manufacturer');

        return $collection;
    }
}
?>

4) \app\design\frontend\default\respond\template\aimit\manufacturerblock\manufacturerblock.phtml

<?php $_products = $this->getManufacturerProducts('cukrarna-u-vanku') ?>
<?php print_r($_products); ?>

5) 在catalog\product\view.phtml中,我放置了以下代码:

<?php echo $this->getLayout()->createBlock('aimitmanufacturerblock/manufacturerblock')->setTemplate('aimitmanufacturerblock/manufacturerblock.phtml')->toHtml(); ?>


创建模块时我忽略了什么?

将“aimitmanufacturerblock/manufacturerblock”转换为类名时,Magento生成了
AimIT\u manufacturerblock\u Block\u manufacturerblock
,但找不到该名称下的类,因为块的类名实际上是“AimIT\u manufacturerblock\u manufacturerblock”这是一个错误的案例

将您的类重命名为

class AimIT_ManufacturerBlock_Block_Manufacturerblock extends Mage_Core_Block_Template 
{

将类文件
ManufacturerBlock
.php重命名为
ManufacturerBlock.php

谢谢您的回答。但似乎没用。我试过了,出现了同样的消息。你的商店是在Windows还是Linux上运行的?我在我的Windows机器上也遇到了类似的问题——我在一个与Linux服务器共享的文件夹中编辑代码库,商店实际上就在这个文件夹中运行。如果我在Windows中重命名文件,并且只更改字母大小写,Linux服务器并不总是会发现这一点,并且错误仍然存在。我必须删除该文件并用正确的名称重新创建它。好的,我删除并重新创建了它,现在它似乎可以工作了。看来这就是命名。非常感谢你的帮助!