Jump to content

Magento. Display products of all attribute sets


Younio

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.