I am almost done building an Amazon Affiliate extension. In my catalog, the amazon products use the attribute set named AmazonAffiliate, all of the other normal products in the catalog just use whatever set happens to be assigned to them. People can add both regular products to the cart as well as amazon products to the cart.
The separation of the regular products vs. amazon products comes in the cart screen. What I want on the cart page is 2 item tables. One with Amazon products and one with regular.
Through the use of an observer for the event core_collection_abstract_load_before
, I was able to filter out the Amazon products from the cart, the totals, everything. I love the way it pulls them out with just one function.
Here is the observer function:
public function excludeAmazonProductsFromMainCart($observer)
{
$collection = $observer->getEvent()->getCollection();
if($collection instanceof Mage_Sales_Model_Resource_Quote_Item_Collection) {
$attributeSetId = Mage::getModel('eav/entity_setup','core_setup')
->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY,CommerceExtensions_AmazonAffiliate_Model_Module::ATTRIBUTE_SET_NAME);
$productTable = Mage::getSingleton('core/resource')->getTableName('catalog/product');
$collection->getSelect()->joinLeft(array('product_table'=>$productTable),'`main_table`.`product_id`=`product_table`.`entity_id`',array('attribute_set_id'));
$collection->getSelect()->where('`product_table`.`attribute_set_id` != '.$attributeSetId);
}
return $collection;
}
Now, the problem is that I want another collection that grabs the items that were excluded in the observer function above. This way, the amazon cart table would have those products and the normal magento product cart table would have my normal catalog products. I just cant seem to split the collection into two.
And in case it can't be split into two, I have the amazon product collection I need created as CommerceExtensions_AmazonAffiliate_Model_Mysql4_Quote_Collection. I just cant seem to set it on my new block.
Here is a screenshot of what I am trying to do. I know it can be done because there are people selling extensions with the same type of functionality.
Thank you in advance for any help!