magentomagento-1.8

Calling testimonial module in magento using code


I am trying to show Testimonial on home page using PHP code in Magento

I already tried code below with getCollection or without getCollection function

$collection = Mage::getModel('turnkeye/testimonial');

May i calling correct Model ??


Solution

  • Module init code should be turnkeye_testimonial/testimonial instead of turnkeye/testimonial if you want field by individual item then you can do this by primary key of testimonial table .

    $collection $model = Mage::getModel('turnkeye_testimonial/testimonial')>load(id);
    

    if you want to fetch multiple items then you need Resource Collection

    Mage::getResourceModel('turnkeye_testimonial/testimonial')->addFieldToSelect('*');
    

    or

    $collection = Mage::getModel('turnkeye_testimonial/testimonial')->getCollection();
    

    for Random Collection

    $collection=Mage::getModel('turnkeye_testimonial/testimonial')->getCollection();
     $collection->getSelect()->order('rand()');