0

D:\xampp\htdocs\products\app\code\local\Sahara\Recentproducts\etc\config.php

<?xml version="1.0"?>
<config>
  <modules>
    <Sahara_Recentproducts>
      <version>1.0</version>
    </Sahara_Recentproducts>
  </modules>
    <frontend>
    <routers>
      <recentproducts>
        <use>standard</use>
        <args>
          <module>Sahara_Recentproducts</module>
          <frontName>recentproducts</frontName>
        </args>
      </recentproducts>
    </routers>

    <layout>
        <updates>
        <recentproducts>
        <file>sahara_recentproducts.xml</file>
        </recentproducts>
        </updates>
    </layout>
</frontend>

<global>
<resources>
      <recentproducts_setup>
        <setup>
          <module>sahara_recentproducts</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </recentproducts_setup>
      <recentproducts_write>
        <connection>
          <use>core_write</use>
        </connection>
      </recentproducts_write>
      <recentproducts_read>
        <connection>
          <use>core_read</use>
        </connection>
      </recentproducts_read>
    </resources>
<models>
<recentproducts>
<class>Sahara_Recentproducts_Model</class>
</recentproducts>
</models>

<blocks>
<recentproducts>
<class>Sahara_Recentproducts_Block</class>
</recentproducts>
</blocks>
<helpers>

<recentproducts>
<class>Sahara_Recentproducts_Helper</class>
</recentproducts>
</helpers>
</global>
</config>

D:\xampp\htdocs\products\app\code\local\Sahara\Recentproducts\controllers\ProductsController.php

<?php

class Sahara_Recentproducts_ProductsController extends Mage_Core_Controller_Front_Action{

   /**
   * Index action
   *
   * @access public

   * @return void
   */

   public function indexAction() {


   $this->loadLayout();


   $this->getLayout()->getBlock('head')->setTitle($this->__('Recent Products'));
   $this->renderLayout();

   }

   /**

    * Done it again
    *
    * @access public
    * @return void
    */

}

?>

D:\xampp\htdocs\products\app\code\local\Sahara\Recentproducts\Model\Recentproducts.php

<?php
// app/code/local/Envato/Recentproducts/Model/Recentproducts.php
class Sahara_Recentproducts_Model_Recentproducts extends Mage_Core_Model_Abstract {

 public function _construct()
    {
        $this->_init('recentproducts/recentproducts');
       // parent::_construct();
    }
 public function getRecentproducts()
 {
     $products= Mage::getModel("catalog/product")
                ->getCollection();
     return $products;
 }
}

D:\xampp\htdocs\products\app\code\local\Sahara\Recentproducts\Block\Recentproducts.php (block class)

<?php
 class Sahara_Recentproducts_Block_Recentproducts extends Mage_Core_Block_Template {
public function getRecentproducts()
{

 $products = Mage::getModel("recentproducts/recentproducts")­>getRecentproducts();
 return $products;
}

}

D:\xampp\htdocs\products\app\design\frontend\default\theme692\layout\sahara_recentproducts.xml

<?xml version="1.0" encoding="UTF-8"?>


<layout version="0.1.0">

<recentproducts_products_index>
    <reference name="head">
            <action method="setTitle"><title>Products</title></action>          
     </reference>
    <reference name="content">
       <block type="recentproducts/recentproducts" name="recentproducts_recentproducts" template="recentproducts/recentproducts.phtml"/>
        <action method="setTemplate"><template>recentproducts/recentproducts.phtml</template></action>
    </reference>
</recentproducts_products_index>

</layout>

D:\xampp\htdocs\products\app\design\frontend\default\theme692\template\recentproducts

<?php
// app/design/frontend/default/default/template/recentproducts/recentproducts.phtml
$products = $this­>getRecentproducts();
//echo get_class_methods(get_class($this));
?>

<div id="product_list">
  <h1>Recent Products</h1>
  <?php if (is_array($products) && count($products)) { ?>
    <?php foreach($products as $product) { ?>
      <div>
        <a href="<?php echo $product->getName(); ?>"><?php echo $product->getProductUrl(); ?></a>
      </div>
    <?php } ?>
  <?php } ?>
</div>
1

Seems to be a typo ...

Replace:

$products = Mage::getModel("recentproducts/recentproducts")­>getRecentproducts();

With:

$products = Mage::getModel("recentproducts/recentproducts")->getRecentproducts();

(the - before >getRecentproducts() seems to be some special char(?) )

2
  • I fixed this problem but even same error is showing. – Hitesh Balpande May 18 '18 at 4:42
  • @hiteshbalpande can you please check your php code with: phpcodechecker.com ? – sv3n May 18 '18 at 6:32
0

Looks like some special character written inpplace of - where it should be -> as given below

<?php
class Sahara_Recentproducts_Block_Recentproducts extends Mage_Core_Block_Template {
 public function getRecentproducts()
  {

 $products = Mage::getModel("recentproducts/recentproducts")->getRecentproducts();
 return $products;
 }
}
1
  • Check source ... there is something like a dash, but it is something else :) – sv3n May 17 '18 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.