Same sku in different row in cart | Grouped product | Magento - magento

If we have same sku present in different grouped product, i would need to display that sku in different rows in cart.
For example,
I have a grouped product sku GP001 which has the child skus (SKU0001,SKU0002 and SKU0003).
I have another grouped product sku GP002 which has the child skus (SKU0001,SKU0004 and SKU0005).
Scenarios:
1) Add GP001 to cart
2) Add GP002 to cart
Expected :
SKU0001 shoule be present in cart as two separate rows.
1) Add GP001 to cart
2) Add SKU0001 to cart
Expected :
SKU0001 shoule be present in cart as single row with increased qty.

Related

Magento order products in cart by category

I would like to change the default order of the products in the cart. By default it sorts by the sequence the products are added to the cart.
But it would be way easier for me if I can sort them by category.
So let's say default way is this:
Product a (Snack)
Product b (Vegetables)
Product c (Snack)
Product d (Fruit)
I want it to be:
Product a (Snack)
Product c (Snack)
Product b (Vegetables)
Product d (Fruit)
Can someone guide me here in how to accomplish this?

Magento Bundle Product - Multiple Options with Same products. How to stop Magento from hiding the repetitive products?

I am trying to setup a bundle product within Magento. This product should allow the customer to select 4 free products to include with the bundle. These products can be all different or 4 of the same product.
For example
Free Product 1
Free Product 2
Free Product 3
A customer could select four of Free Product 1, or one of Free Product 1 & 2, with two of Free Product 3.
I am using 4 drop-down input types which each have all three Free products as options. So a customer can choose any of the three products for each Free Gift line item.
Magento is only displaying one of the drop-down select lists, I believe due to the fact that each drop-down contains the same product list.
Where would I need to look to stop Magento from checking if the product options are already listed in a previous selection?
Unless you're doing this programmatically (that is writing the code), there's no way to do this.
When Magento adds a product, it first looks into the quote / shopping cart to see if one already exists. If one does, it pulls that one and adds to the quantity. There is no way to turn this off.
Programmatically, you very manually add an item to a shopping cart. This is how...
$cart = Mage::getSingleton("checkout/cart");
foreach ($products_to_add as $product_id => $custom_options) {
$product = Mage::getModel("catalog/product")->load($product_id);
$options = new Varien_Object(array("options" => $custom_options,
"qty" => 1));
// some products may result in multiple products getting added to cart
// I beleive this pulls them all and sets the custom options accordingly
$add_all = $product->getTypeInstance(true)
->prepareForCartAdvanced($options, $product, Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL);
foreach ($add_all as $add_me) {
$item = Mage::getModel('sales/quote_item');
$item->setStoreId(Mage::app()->getStore()->getId());
$item->setOptions($add_me->getCustomOptions())
->setProduct($add_me);
$item->setQty(1);
$cart->getQuote()->addItem($item);
}
}
// when done adding all the items, finally call save on the cart
$cart->save();

How can i join 2 product collections (Magento)

I have configurable products that are placed in categories.
example:
configurable product: shirt in category with id 6.
this product has multiple simple products: green shirt with attribute 'size' = XL, L and M.
together this is one product in the shop.
no i want a collection so i can select all simple products with 'size' = XL and where the configurable product of the simple product is in category with id 6.
i think i need to join 2 collections (simple + configurable).
But i can't find info about it on the web.
somebody a solution?
You dont need to join 2 collections for this, you can simpy get the childproducts based on the parent.
//loop trough configurable products
$simpleProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
edit or simplified : $_product->getTypeInstance()->getUsedProducts(); this would be the best solution

Modify Magento Subtotal Calculation: Tier prices

I am using Tier Prices and have a set price for quantities that fall between 1 and 4 and a per item price for anything over 4.
I want to modify my cart to have a set price for items where Qty >= 1 && Qty <=4
How do I do that?
Here is the item i testing this with: http://stjamestutorials.com/ppptransportation/index.php/mayfield-falls-tours-negril-jamaica-tours.html
Try and create an observer for this event:
catalog_product_get_final_price
which is found in the class :
app\code\core\Mage\Catalog\Model\Product\Type\Price.php
The event comes with the product and the qty, so you can write your logic and then set your custom price in the final_price attribute of the product.

is it possible to get only the associated product count from shopping cart?

I am working on a Ajax cart for my website. I am trying to validate Configurable products for the stock availability. Please consider below case
Cotton shirt (Product ID : 421 - Configurable Product)
Size : L (Product ID : 425 - Simple product)
Size : M (Product ID : 436 - Simple product)
User should select at least one size to add product to the cart.
When i added this product with "Size L" twice and added this product with "Size M" once.
And when i print the item ids in shopping cart, it shows only the id of Configurable product (421).
How do i get ids of Simple product which are really being added to the cart?
You will need to check if the product in the cart is configurable, then if it is you can get the information stored in the product options to work out the simple product that was actually added. The below code should help a bit:
if($product['product_type']=='configurable'){
$options = unserialize($product['product_options']);
$simpleProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$options['simple_sku']);
}

Resources