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

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.

 
Magento Community Magento Community
Magento Community
Magento Community
 
YoavKutner
Guru
 
Avatar
Total Posts:  491
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 06: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 06: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.

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

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