Younio Posted July 24, 2012 Share Posted July 24, 2012 Hello, I am new to PHP and to Magento. So complete newbie here. I found the extension to display the bestselling block on my website, but it only displays products that have default attribute set (only a few products). So I need to change it so that it displays bestselling products form all attribute sets. Here is the code that displays bestselling products with default attribute sets: <?php $_products = $this->getProductCollection(); /* $collection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('song_artist_1', '124') ; //$_products = $collection->addAttributeToFilter('manufacturer', 'HTC'); echo "<pre>"; print_r($collection->getData()); exit; */ //echo "<pre>"; var_dump(Mage::registry('current_category')); ?> <?php $_coreHelper = $this->helper('core'); $_taxHelper = $this->helper('tax'); ?> <div class="block block-compare"> <div class="block-title"> <strong><?php echo $this->__('Bestselling products') ?></strong> </div> <div class="block-content"> <?php if(count($_products) > 0): ?> <ol id="best-sidebar" class="mini-products-list"> <?php foreach ($_products as $_item): ?> <?php $_finalPrice = $_taxHelper->getPrice($_item, $_item->getFinalPrice()); ?> <li class="item"> <a class="product-image" href="<?php echo $_item->getProductUrl() ?>"> <img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(50) ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" width="50" height="50" /> </a> <div class="product-details"> <p class="product-name"> <a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a> </p> <?php echo $_coreHelper->formatPrice($_finalPrice); //echo $this->getPriceHtml($_item, true) ?> </div> </li> <?php endforeach ?> </ol> <script> decorateList('best-sidebar', 'none-recursive') </script> <div class="actions"> <button onclick="setLocation('<?php echo Mage::getBaseUrl() ?>bestselling')" class="button" title="<?php echo $this->__('View All') ?>" type="button"><span><span><?php echo $this->__('View All') ?></span></span></button> </div> <?php else: ?> <div class="empty"><?php echo $this->__('No items for this category') ?></div> <?php endif ?> </div> </div> I would be great-full if anyone could help me with this. Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted July 24, 2012 Share Posted July 24, 2012 If the data you're starting out with isn't what you want, then you need to investigate $_products = $this->getProductCollection(); and determine how to get it where you want it. You haven't provided anybody with enough information help in that regard. Quote Link to comment Share on other sites More sharing options...
Younio Posted July 25, 2012 Author Share Posted July 25, 2012 Thank you for your answer, You haven't provided anybody with enough information help in that regard. Maybe you could tell me what additional information do I need to provide and where could I get it from? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.