public function addItem(Mage_Wishlist_Model_Item $item)
{
$superAttributes = Mage::app()->getRequest()->getParam('super_attribute');
if ($item instanceof Mage_Wishlist_Model_Item && isset($superAttributes)) {
$simpleItem = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($superAttributes, $item->getProduct());
}
return parent::addItem($simpleItem);
}
Now my problem is that i want to call the parent function which needs to receive an Mage_Wishlist_Model_Item
not a Mage_Catalog_Model_Product
MyCustom_Wishlist_Model_Wishlist extends Mage_Wishlist_Model_Wishlist
How can i get the wishlistitem for the Product $simpleItem
public function addItem(Mage_Wishlist_Model_Item $item)
{
$superAttributes = Mage::app()->getRequest()->getParam('super_attribute');
if ($item instanceof Mage_Wishlist_Model_Item && isset($superAttributes)) {
$product = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($superAttributes, $item->getProduct());
$item = Mage::getModel('wishlist/item');
$storeId = $product->hasWishlistStoreId() ? $product->getWishlistStoreId() : $this->getStore()->getId();
$qty = 1;
$item->setProductId($product->getId())
->setWishlistId($this->getId())
->setAddedAt(now())
->setStoreId($storeId)
->setOptions($product->getCustomOptions())
->setProduct($product)
->setQty($qty)
->save();
}
return parent::addItem($item);
}
This works for me now but i didn't figure out how to set the $qty
yet