Search code examples
phpmagentomagento-1.9

Custom Block in Megento not working on live server


I have a block in my site which is working fine in local host but when I have uploaded it to Linux sever its not working. I have gone through other suggestions to have same case in file name and paths but its not applicable.

Please review the code and let me know where I am missing something

  1. Adding new module

    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. Frontend File recentproducts.phtml

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

    <p>HEllo</p>
    
  6. After creating all files, I have created a CMS page and added code to content to show block

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

Solution

  • I think you need to uppercase the first letter of your folder. like sciffer will be Sciffer and same for the recentroducts, so that autoloader can find the path.