0

I adding my product to bx slider... i calling data from catalog model .... how can i get price on slider... my magento code is ..

    <?php 
     $category = new Mage_Catalog_Model_Category();
    $category->load(6);
    $_products  = $category->getProductCollection();

    $_products->addAttributeToSelect('*');
    $_products->addAttributeToFilter('status', 1);
    $_products->addFieldToFilter(array(array('attribute'=>'visibility', 'neq'=>"1" )));

    $_products->getSelect()->limit(30);
      ?>

my slider html..
----------------

<div class="sale_slide_women">
                <?php $i=0; foreach ($_products->getItems() as $_product): $i++; ?>
                    <div class="slide <?php if(($i == 4 && $_products->getSize() < 5) || ($i == $_products->getPageSize())) echo 'last'?>">
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(210) ?>" width="210" height="210" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
                        <div class="new-description text-center">
                            <div class="labels-container"><?php include('view/labels.phtml'); ?></div>
                            <h3><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo Mage::helper('core/string')->truncate($this->htmlEscape($_product->getName()), $length = 30, $etc = '...', $remainder = '', $breakWords = true); ?></a></h3>
                            <?php echo $this->getPriceHtml($_product, true) ?>
                            <div style="clear: both;"></div>
                        </div>
                    </div>
                <?php endforeach; ?>

</div>

2 Answers 2

3

<?php echo $this->getPriceHtml($_product, true) ?> is not work because did not call price block

you need to call price block

remove this code and below try this

<?php echo $this->getLayout()->createBlock('catalog/product_price')
            ->setTemplate('catalog/product/price.phtml')
            ->setProduct($_product)
            ->setDisplayMinimalPrice(true)
            ->setIdSuffix($idSuffix='amit')
            ->toHtml(); ?>

You need set price.phtml and check you price.phtml is your price phtml

1

The code that you're using to show price:

<?php echo $this->getPriceHtml($_product, true) ?>

Is for default taking template from file app/design/frontend/your_template/your_template/catalog/product/price.html

For testing purposes try to replace upper code with this:

<?php echo $_product->getPrice(); ?>

And see if price is displayed. If yes then the template file is your reason for not displaying price and we should try to look in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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