2

I Try to make a link in my custom module where I can show my all product with some information. But It show a error. There just install magento with sample data. my output

337-Aviator Sunglasses(ace000) 338-Jackie O Round Sunglasses(ace001)

.....

.....

.....

399-Madison 8GB Digital Media Player(hde012)

400-Compact mp3 Player(hde013)

Fatal error: Call to undefined method Mage_Catalog_Model_Product_Type_Simple::getUsedProducts() in \app\code\core\Mage\Catalog\Model\Resource\Product\Type\Configurable\Attribute\Collection.php on line 160

My code

config.xml

<config>
    <modules>
        <Abdus_Allproduct>
            <version>1.0.0</version>
        </Abdus_Allproduct>
    </modules>
    <frontend>
        <routers>
            <allproduct>
                <use>standard</use>
                <args>
                    <module>Abdus_Allproduct</module>
                    <frontName>allproduct</frontName>
                </args>
            </allproduct>
        </routers>
    </frontend>
</config>

IndexController.php

<?php
  class Abdus_Allproduct_IndexController extends Mage_Core_Controller_Front_Action{
      public function indexAction(){
          $collection = Mage::getModel('catalog/product');
            $col=$collection->getCollection()->addAttributeToFilter('visibility',array('in'=>array(2,3,4)));
            foreach($col as $c){
                $collection->load($c->getId());
                echo $collection->getId().'-'.$collection->getName().'('.$collection->getSku().')<br>'; 
            }
      }
  }
3

Please try bellow code

    $collection = Mage::getModel('catalog/product')->getCollection()
        ->addMinimalPrice()
        ->addFinalPrice()
        ->addTaxPercents()
        ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
        ->addUrlRewrite()
        ->addAttributeToFilter('visibility',array('in'=>array(2,3,4)));
    foreach($collection as $product){
        echo $product->getId().'-'.$product->getName().'('.$product->getSku().')<br>'; 
    }
  • I don't understand why you use ->addMinimalPrice() ->addFinalPrice() ->addTaxPercents() ->addUrlRewrite() I need all product without any filter. – Abdus Salam Nov 9 '15 at 6:37
  • for the product price with tax or not taxable product and product url – Abdul Nov 9 '15 at 6:40
  • 1
    if you are use above then output :: [price] => 1.0000 [final_price] => 1.0000 [minimal_price] => 1.0000 [min_price] => 1.0000 [max_price] => 1.0000 [tier_price] => [visibility] => 4 [small_image] => no_selection [thumbnail] => no_selection [name] => COIN,NAVY W/BOX DG110 [url_key] => coin-navy-w-box-dg110 [request_path] => coin-navy-w-box-dg110.html – Abdul Nov 9 '15 at 6:47
  • 1
    Otherwise, you don't get below fields in the output [final_price] => 1.0000 [minimal_price] => 1.0000 [min_price] => 1.0000 [max_price] => 1.0000 [tier_price] => [request_path] => coin-navy-w-box-dg110.html – Abdul Nov 9 '15 at 6:50

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.