उस नमूना कोड को पोस्ट करने के लिए धन्यवाद! मैं इसका उपयोग एक समाधान बनाने में कर सका जो हम दोनों के लिए अच्छा काम करे।
मैंने पाया कि विन्यास योग्य उत्पाद बिक्री को सही ढंग से सारांशित किया जा रहा है लेकिन परिणामों में शामिल नहीं किया जा रहा है; इसके बजाय उनके बाल उत्पाद दिखाई देते हैं। मेरा समाधान विन्यास योग्य उत्पादों को शामिल करना था, catalog_product_super_link पर बाईं ओर शामिल होना था तालिका, और ऐसी किसी भी चीज़ को फ़िल्टर करें जिसमें parent_id . हो . यहां वे परिवर्तन हैं जो आपको करने होंगे:
Collection.php:
public function addOrderedQty($from = '', $to = '', $getComplexProducts=false, $getComplexChildProducts = true, $getRemovedProducts = true)
{
$qtyOrderedTableName = $this->getTable('sales/order_item');
$qtyOrderedFieldName = 'qty_ordered';
$productIdFieldName = 'product_id';
if (!$getComplexProducts) {
$compositeTypeIds = Mage::getSingleton('catalog/product_type')->getCompositeTypes();
$productTypes = $this->getConnection()->quoteInto(' AND (e.type_id NOT IN (?))', $compositeTypeIds);
} else {
$productTypes = '';
}
if ($from != '' && $to != '') {
$dateFilter = " AND `order`.created_at BETWEEN '{$from}' AND '{$to}'";
} else {
$dateFilter = "";
}
$this->getSelect()->reset()->from(
array('order_items' => $qtyOrderedTableName),
array(
'ordered_qty' => "SUM(order_items.{$qtyOrderedFieldName})",
'order_items_name' => 'order_items.name'
)
);
$_joinCondition = $this->getConnection()->quoteInto(
'order.entity_id = order_items.order_id AND order.state<>?', Mage_Sales_Model_Order::STATE_CANCELED
);
$_joinCondition .= $dateFilter;
$this->getSelect()->joinInner(
array('order' => $this->getTable('sales/order')),
$_joinCondition,
array()
);
// Add join to get the parent id for configurables
$this->getSelect()->joinLeft(
array('cpsl' => $this->getTable('catalog/product_super_link')),
'cpsl.product_id = order_items.product_id',
'cpsl.parent_id'
);
if(!$getComplexChildProducts)
$this->getSelect()->having('parent_id IS NULL');
if($getRemovedProducts)
{
$this->getSelect()
->joinLeft(array('e' => $this->getProductEntityTableName()),
"e.entity_id = order_items.{$productIdFieldName} AND e.entity_type_id = {$this->getProductEntityTypeId()}{$productTypes}")
->group('order_items.product_id');
}
else
{
$this->getSelect()
->joinInner(array('e' => $this->getProductEntityTableName()),
"e.entity_id = order_items.{$productIdFieldName} AND e.entity_type_id = {$this->getProductEntityTypeId()}{$productTypes}")
->group('e.entity_id');
}
$this->getSelect()->having('ordered_qty > 0');
// This line is for debug purposes, in case you'd like to see what the SQL looks like
// $x = $this->getSelect()->__toString();
return $this;
}
List.php - निम्नलिखित दो पंक्तियों को खोजें...
$bestsellers->addOrderedQty($startDate, $todayDate, true);
$bestsellers->addOrderedQty('', '', true);
... और उन्हें इसमें बदलें:
$bestsellers->addOrderedQty($startDate, $todayDate, true, false, false);
$bestsellers->addOrderedQty('', '', true, false, false);
मेरे परिवर्तनों ने दो नए वैकल्पिक पैरामीटर जोड़े, जो दोनों डिफ़ॉल्ट रूप से true , मौजूदा कार्यक्षमता को भंग न करने के लिए।
- जब
$getComplexChildProductsfalseपर सेट है , कॉन्फ़िगर करने योग्य उत्पाद के सभी चाइल्ड आइटम परिणामों से हटा दिए जाएंगे। $getRemovedProductsनिर्धारित करता है कि पहले से ऑर्डर किए गए उत्पाद (जो तब से Magento से हटा दिए गए हैं) भी प्रदर्शित होने चाहिए या नहीं।
कृपया ध्यान दें कि सटीक परिणाम प्राप्त करने के लिए आपके रिपोर्ट आंकड़ों को अप-टू-डेट होना चाहिए।
उम्मीद है ये मदद करेगा! अगर आपके कोई प्रश्न हैं तो मुझे बताएं।