Magento 中的自定义块无法在实时服务器上运行

Custom Block in Megento not working on live server

我的站点中有一个块,它在本地主机上运行良好,但是当我将其上传到 Linux 时,它无法正常工作。我已经通过其他建议在文件名和路径中使用相同的案例,但它不适用。

请检查代码并让我知道我遗漏了什么

  1. 添加新模块

    app/etc/modules/sciffer_All.xml

     <config>
         <modules>
         <sciffer_recentproducts>
             <active>true</active>
             <codePool>local</codePool>
         </sciffer_recentproducts>
         </modules>
     </config>
    
  2. Config.xml

    app/code/local/sciffer/recentproducts/etc/config.xml

     <?xml version="1.0" ?>
     <config>
     <modules>
         <sciffer_build>
             <version>1.0</version>
         </sciffer_build>
     </modules>
     <global>
         <blocks>
                 <build>
                     <class>sciffer_build_Block</class>
                 </build>
         </blocks>
         <models>
                 <build>
                     <class>sciffer_build_Model</class>
                 </build>
         </models>
     <events>
             <controller_action_predispatch_checkout_cart_add>
                 <observers>
                     <sciffer_build_log_cart_add>
                         <type>singleton</type>
                         <class>build/Observer</class>
                         <method>checkQuantity</method>
                     </sciffer_build_log_cart_add>
                 </observers>
             </controller_action_predispatch_checkout_cart_add>
    
         </events>
     </global>
     </config>
    
  3. Block/recentproducts.php

    app/code/local/sciffer/recentproducts/Block/recentproducts.php

    class sciffer_recentproducts_Block_recentproducts extends            Mage_Core_Block_Template
     {
      public function getRecentProducts()
     {
           $arr_categorys=array();
           $categorys=Mage::getModel("recentproducts/recentproducts")->getRecentProducts();
           foreach($categorys as $category)
           {
             $arr_categorys[]=array(
             'id'=>$category->getId(),
             'name'=> $category->getName(),
             'url'=>$category->getUrl($category),
             'menu'=>!$category->getIncludeInMenu());
            }
            return $arr_categorys;
    
        }
     }
    
  4. Module/recentproducts.php

    app/code/local/sciffer/recentproducts/Module/recentproducts.php

    class sciffer_recentproducts_Model_recentproducts extends Mage_Core_Model_Abstract
    {
     public function getRecentProducts()
     {  
    
         $categorys=Mage::getModel("catalog/category")
             ->getCollection()
             //->addAttributeToSelect('*')
             ->addAttributeToSelect('name')
             ->addAttributeToSelect('is_active')
             ->addUrlRewriteToResult()
             ->setOrder('entity_id','DESC')
             ->addAttributeToFilter('level',2)
             ->addAttributeToFilter('include_in_menu',0);
    
         return $categorys;
     }
    }
    
  5. 前端文件recentproducts.phtml

    App/design/frontend/base/default/template/recentproducts/recentproducts.phtml

    <p>HEllo</p>
    
  6. 创建所有文件后,我创建了一个 CMS 页面并向内容添加了代码以显示块

      {{block type="recentproducts/recentproducts"name="recentproducts_recentproducts"template="recentproducts/recentproducts.phtml"}}
    

我认为您需要将文件夹的第一个字母大写。像 sciffer 将是 Sciffer 并且与最近的产品相同,以便自动加载器可以找到路径。