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

Best Seller Module with Configurable Products
 
jemoon
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2008-09-30
Gdansk, Poland
 

Hi,
I’m trying to add a Best Seller module and I’m using laurent’s class from this topic http://www.magentocommerce.com/boards/viewthread/9058/. My problem is that most of my stock is fullfiled with configurable products and as you can see here:

Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
the class is filtering products by visibility (but my single products which are attached to configurable are not visible). If I get rid of this filtr I can see all bestsellers but as single products and here is my question. Is there any way to show configurable products which are parents for those, showed, single products.
Thanks in advance for any clues.
 
Magento Community Magento Community
Magento Community
Magento Community
 
chris_
Jr. Member
 
Total Posts:  27
Joined:  2009-03-18
 

hello,

have you found a solution to filtering out the configurable products yet ?
or how to link the simple products to the configurable ?

regards chris

 
Magento Community Magento Community
Magento Community
Magento Community
 
mirelon
Member
 
Total Posts:  41
Joined:  2008-11-04
 

I made my custom bestseller template for configurable products. I will explain it in parts:
reports/product has the property ordered_qty, so i created an array $downloads with indexes of configurable products and values of number of ordered children (I called it downloads because i run a shop with only downloadable products, but they are in fact SimpleConfigurable (an extension))

<?php
$storeId 
Mage::app()->getStore()->getId();
$_productCollection Mage::getResourceModel('reports/product_collection')
                              ->
addAttributeToSelect('*')
                              ->
addOrderedQty();
?>
<?php 
foreach($_productCollection as $product): ?>
  <?php $parents 
$product->loadParentProductIds()->getParentProductIds();?>
  <?php 
if(!isset($downloads[$parents[0]]))$downloads[$parents[0]]=0 ?>
  <?php $downloads[$parents[0]] 
+= (int)$product->ordered_qty;?>
<?php 
endforeach; ?>

Next I iterate through configurable products:

<?php foreach($downloads as $id=>$count): ?>
  <?php $_product 
Mage::getModel('catalog/product')->load($id?>
  
...
  
//now, $_product is configurable product which children have been ordered $count times
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top