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

Add products to cart at once
 
santos_m
Jr. Member
 
Total Posts:  6
Joined:  2008-10-13
 

Hello folks!

I have a doubt about how to ‘add more than one’ product to the ‘cart’ at once.
This action is for one ‘particular product’ in my store that has to be added ‘many times’ (at once) according to the values of its attributes.

I’m editing ‘CartController.php’ to turn my store capable to do like I said like the following:

<?
    
// .....
    // A lot of code

    // Get an array of something. For example: blue, green and black for T-shirt colors
    
$a_options = array();
    
$a_options explode"|" $options_list );

    
// Add a product for each option that came from product's page
    
for( $i 0$i count$a_options ); $i++ )
    
{
        
// Set the value (blue, green, black) for '$params[ "options" ][ 71 ]' to add one product with a distinct charateristic.
        
$params[ "options" ][ $attr_id ] $a_options[ $i ];
        
$cart->addProduct($product$params);
    
}
    
    
if (!empty($related)) {
        $cart
->addProductsByIds(explode(','$related));
    
}

    $cart
->save();
    
    
// A lot of code
    // .....
?>

But I want that the ‘Shopping Cart’ page something like this (DESIRED):

Product Name         Qty
-------------------------------
t-shirt
color
blue                1
------------------------------
t-shirt
color
green             1
------------------------------
t-shirt
color
black                1
 
-------------------------------

But it is like this (NOT DESIRED):

Product Name         Qty
------------------------------
t-shirt
color
black                3
------------------------------

What I have to do to get the first (DESIRED) way?
I’m not understanding how ‘$cart->addProduct’ or ‘$params’ works. If I know, I could to code these to get that I want?
Can anyone help me? There are any tutorial that explain how Magento are layered?

I’m getting crazy!

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top