To add multiple products to the cart from the same request you need to use the related_product
url parameter. Simply add the extra products to the end of your add to cart url separated by a coman
/product/159/related_product/162,161,160
If you are calling the getUrl function to build your url you can do this as follows:
Mage::app()->getStore()->getUrl('checkout/cart/add/', array('product'=> 12, 'related_product' => implode(',', array(123,456))));
Product to catalog price rules data is stored in the table catalogrule_product
In that table you will find the product_id field that relates back to your product.
You should be able to build a query that checks the table for the product in question.
Not 100% what your intended functionality would involve, but doing a separate query for each product to check if they have an ACTIVE rule applying to them would slow your cart display down a fair bit. It would thus be better to make one query with all the products IDS you are interested in, and then use the resulting collection data to work your magic.
In case it helps you get a query built, I include below some code that I use in my Dynamic Category Products Extension which finds all products with an active rule. You should be able to adjust this and limit it to your products ids alone. It also takes the date range of the rule into consideration. Remember to consider that rules can be of two possible types: BY_PERCENT or FIXED
Some bits are out of context, but you should get the jest of it.
$category below is the current active category.
$value is simply the value of the discount I am interested in.
$operator is self explanatory ;)
$collection = $category->getProductCollection();
$value = $this->getValueParsed();
$operator = $this->_operatorMapToSql[$this->getOperator()];
$conditions = " (price_rule.product_id = e.entity_id) ";
if (strpos($value, '%') > 0) {
$value = str_replace('%', '', $value);
$conditions .= " AND action_operator = '" . Mage_SalesRule_Model_Rule::BY_PERCENT_ACTION . "' ";
} else {
$conditions .= " AND action_operator = '" . Mage_SalesRule_Model_Rule::BY_FIXED_ACTION . "' ";
}
$storeDate = Mage::app()->getLocale()->storeTimeStamp($this->getStoreId());
$conditions .= " AND (from_time = 0
OR from_time <= " . $storeDate . ")
AND (to_time = 0
OR to_time >= " . $storeDate . ") ";
$conditions .= " AND action_amount " . $operator . " " . $value;
$collection->getSelect()->joinInner(
array('price_rule' => $collection->getTable('catalogrule/rule_product')), $conditions
);
I hope this get you closer to your solution
Best Answer
This can be done with a little work on your individual product page theme. The functionality is already there in magento, you just have to make it look like it.
You can start by going into each product and setting up your upsell/cross-sell individually. This gives you the most control, but takes the longest amount of time. For more broad rules, look into the rule based product relations you mentioned in your question.
You can then create the discounts by setting up shopping cart price rules.
After that, all you need to do is edit your theme. You can do this in either related.phtml or upsell.phtml, (depending on how you setup your relations rules).
These themes are located in app/design/frontend/{package}/{theme}/catalog/product/list/