Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to show Upsell-Icons on list page ? in other words: Why does getUpsellProducts() WONT WORK ??? 
 
topoe
Jr. Member
 
Total Posts:  4
Joined:  2008-09-24
 

Hi,

maybe anyone has an idea. For showing litlle icons of upselling products of a product in the list view I added a little code snippet into the list.phtml file. Tries to include the upsell.pthml into catalog.xml didn´t work, probably because no data could´ be transfered into.

Anyway - this part works almost perfect....

<div class="upsell-products">
            
<?php $_upsellproducts $_product->getUpSellProducts(); ?>
            <?php 
if (sizeof($_upsellproducts)<5{$_maxSize sizeof($_upsellproducts);else {$_maxSize=5;} ?>
                <?php 
for($_j=0;$_j<$_maxSize;$_j++): ?>
                <?php $_link 
$_upsellproducts[$_j]?>
                    
<div class="upsell-product">
                        <
class="product-image">
                            <
a href="<?php echo $_link->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(65) ?>" width="65" height="65" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>
                        </
p>
                    </
div>
            
<?php endfor; ?>
        
</div>

The only thing is, that always the fail-over image is used, because the one product out of the array returned by getUpsellProducts() doesn´t contain the information about images. I compared this array with the main product array, which contains image file names. the $product->getSmallImage() function returns same “no-image"-images.

A little hint would brighten up my day wink !!

Thanks
To

 
Magento Community Magento Community
Magento Community
Magento Community
 
topoe
Jr. Member
 
Total Posts:  4
Joined:  2008-09-24
 

hi once again,

ok - I helped myself by replacing getUpsellProducts due using the getUpsellProductCollection()
I found that out by inspecting the upsell.php file in combination with the upsell.phtml in magento/core/… or magento/design....

for comfort-reasons I mix up core-with design, may I outsource it later little bit. Maybe anyone has an idea to bind the upsell.php functions while configuring catalog.xml. For me it didn´t work because I don´t know how to set the Product Id which is taken from the mage-registry.
In List mode probably no product-id is set there.

Clear solutions for not coding things twice are very welcome wink

And here the working (around) code:

<div class="upsell-products">                    
            
<?php $_upsellProductsCollection $_product->getUpSellProductCollection()
                   ->
addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
                ->
addAttributeToSort('position''asc')
                ->
addStoreFilter()
                ->
addMinimalPrice()
                
//don´t hide prodcts. in cart ->addExcludeProductFilter(Mage::getSingleton('checkout/cart')->getProductIds())
            
;
                
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($_upsellProductsCollection);
            
?>
            
            <?php $_items 
$_upsellProductsCollection->getItems(); ?>
            <?php 
if (ceil(count($_items))<6{$_maxSize ceil(count($_items));else {$_maxSize=6;} ?>
            <?php 
for($_j=0;$_j<$_maxSize;$_j++): ?>
                <?php $_link 
current($_items); ?>
                <?php next
($_items); ?>
                
<div class="upsell-product">
                    <
class="product-image">
                        <
a href="<?php echo $_link->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(30) ?>" width="30" height="30" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>
                    </
p>
                </
div>
            
<?php endfor; ?>
        
</div>

Thanks folks and good night!
To

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top