Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Page 2 of 2
Calculate Extra Parameters for a given product (which affect the product price)
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 

I found out some more info.

When the cart is getting ready to turn the quote into an order, something funny happens with the quote items

class Mage_Sales_Model_Entity_Quote_Item_Collection extends Mage_Eav_Model_Entity_Collection_Abstract

protected function _afterLoad()
    
{

        $productCollection 
$this->_getProductCollection();
        foreach (
$this as $item{
            $product 
$productCollection->getItemById($item->getProductId());

            if (!
$product{
                
continue;
            
}

            
if ($item->getSuperProductId()) {
                $superProduct 
$productCollection->getItemById($item->getSuperProductId());
            
}
            
else {
                $superProduct 
null;
            
}


            $itemProduct 
= clone $product;
            if (
$superProduct{
                $itemProduct
->setSuperProduct($superProduct);
                
$item->setSuperProduct($superProduct);
            
}

            $item
->importCatalogProduct($itemProduct);
            
$item->checkData();

        
}
        
return $this;
    
}

in the _afterLoad function of the quote item collection entity, the quote item’s values are being overridden with default settings from the product.  This seems backwards.  If you’ve quoted someone something, and you are loading it up from the DB to turn it into an order, why should default products settings force themselves over what you’ve quoted.

This is going to be a huge stumbling block for anyone who wants to change the default behavior.

 Signature 

There’s info on lots of custom modules in my Magento Group
http://www.magentocommerce.com/group/view/174
Need Upgrade help from 0.6, 0.7, and 0.8 available?  P.M. me for details on CMS integration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Magento Team
 
Avatar
Total Posts:  479
Joined:  2007-08-08
 

Mark_Kimsal - This is a bit misleading. The quote is an internal quote. So the shopping cart and order are updated with the updated values for the product. We have on our to-do list implementation of a quote system with more complex functionality in the future. I guess the choice of naming is a bit confusing.

Thanks for your great input.

yoav

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mark_Kimsal
Sr. Member
 
Total Posts:  186
Joined:  2007-09-12
Michigan, USA
 
YoavKutner - 17 December 2007 07:58 PM

Mark_Kimsal - This is a bit misleading. The quote is an internal quote. So the shopping cart and order are updated with the updated values for the product.

Both dsgnfred and I need some sort of functionality to flag extra parameters with an order.  Would you recommend attaching values directly to the quote instead of the product?  I’m not sure how to find the entity ID of the product if I attach directly to the quote and not to a sales_quote_item.

I *can* work around the problem now by changing my “$item->setConfigid( $product->getConfigid() ) “ line to check if there is a value for getConfigid().  If there is not, then the system is trying to set an empty value from the default product.

I’m wondering if this behavior is desirable under any circumstances.  Why should the quote be repeatedly initialized with fresh values from the product ID from the database (especially when it’s only being loaded just to convert to a sales_order and be saved right away)?  Can this whole thing be solved (changed) by throwing in an “if isLoaded()” into the collection’s _afterLoad() method?  If it’s loaded from the DB, then the attributes can be assumed to be correct, no?

YoavKutner - 17 December 2007 07:58 PM

We have on our to-do list implementation of a quote system with more complex functionality in the future.

Cool, I’m keeping track of all these changes in a Magento group wiki page, so I’m ready for changes to the sales quote system.  I’m trying to get a feel for the *best* solution and keep updating that solution as magento gets closer to 1.0.

 Signature 

There’s info on lots of custom modules in my Magento Group
http://www.magentocommerce.com/group/view/174
Need Upgrade help from 0.6, 0.7, and 0.8 available?  P.M. me for details on CMS integration.

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2007-09-06
Easthampton, MA
 

Hi Moshe,

I need to let customers specify how many full time employees they have when they buy a membership and multiply that number by 4, then add that to the total.  You and I worked on this sort of thing in the past.  I did all the code changes you called for but I need this to let me use a text field and parse that number entered

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52302 users|480 users currently online|105622 forum posts