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

Front end product count? 
 
chrisandy
Sr. Member
 
Total Posts:  92
Joined:  2007-10-17
 

I have several bundled products that contain everything from 48 to 248 sub items.

The idea is that the customer (wholesale in this case) must choose an exact amount of sub items to get the bundle.

Is there a way of showing the number of sub items that have been checked as a running total?

Or is there a different approach to this?

Many thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brent W Peterson
Moderator
 
Avatar
Total Posts:  3217
Joined:  2009-02-26
Minneapolis MN
 

This may help, I wrote this to count the options on a product for a configurable.

public function countProductOption($productId)
    
{
        $select 
null;
        
$resource Mage::getSingleton('core/resource');
        
$read $resource->getConnection('catalog_read');
        
        
$CatalogProductSuperLink $resource->getTableName('catalog/product_super_link');
        
        
$select $read->select('product_id')->from(array('cpsl'=>$CatalogProductSuperLink))
            ->
where('cpsl.parent_id=?'$productId);            
        
        
$val $read->fetchAll($select);
    
        return 
count($val);
                    
    
}

Then I found another function that selects the linked products.

public function _getLinkedProducts($productId)
    
{
        $select 
null;
        
$resource Mage::getSingleton('core/resource');
        
$read $resource->getConnection('catalog_read');
        
        
$CatalogProductSuperLink $resource->getTableName('catalog/product_super_link');
        
        
$select $read->select('product_id')->from(array('cpsl'=>$CatalogProductSuperLink))
            ->
where('cpsl.parent_id=?'$productId);            
        
        return 
$val $read->fetchAll($select);
    
}

You could try the second and return

count($val )
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top