1

I'm looking now for a while but I can not find any solution. The Magento wishlist allways replacing the existing wishlist item with the newly added item.

SELECT * FROM wishlist_item WHERE wishlist_id LIKE 4578

shows allways only one Item.

the part in which the addurl is generated:

app\design\frontend\[mytheme]\default\template\catalog\product\view\addto.phtml
<?php 
    $_product = $this->getProduct(); 
    $_wishlistSubmitUrl = $this->helper('wishlist')->getAddUrl($_product); 
?>
<ul class="wishlist-recommend-links">
    <?php if ($this->helper('wishlist')->isAllow()) : ?>
    <li>
        <a href="<?php echo $_wishlistSubmitUrl ?>" onclick="productAddToCartForm.submitLight(this, this.href); return false;" class="add-to-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>
    </li>
    <?php endif; ?>
    <li>
        <a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>" class="recommend fancybox" data-type="iframe" data-fancybox-width="480" data-fancybox-height="90%"><?php echo $this->__('Recommend product') ?></a>
    </li>
</ul>

the part in which the wish list will be displayed:

\app\design\frontend\[mytheme]\default\template\wishlist\item\list.phtml
<?php
    $columns = $this->getColumns();
?>
<table class="data-table cart-table" id="wishlist-table">
    <thead>
        <tr>
            <?php foreach ($columns as $column): ?>
                <th><?php echo $column->getTitle();?></th>
            <?php endforeach; ?>
        </tr>
    </thead>
    <tbody>
        <?php if (count($this->getItems())): ?>
            <?php foreach ($this->getItems() as $item): ?>
                <tr id="item_<?php echo $item->getId();?>">
                    <?php foreach ($columns as $column): ?>
                        <td><?php $column->setItem($item); echo $column->toHtml($item);?></td>
                    <?php endforeach; ?>
                </tr>
            <?php endforeach ?>
        <?php else: ?>
                <td colspan="<?php echo count($columns);?>" class="wishlist-empty"><?php echo $this->__('This Wishlist has no Items');?></td>
        <?php endif; ?>
    </tbody>
</table>
<?php foreach ($columns as $column): ?>
    <?php echo $column->getAdditionalHtml();?>
<?php endforeach; ?>
<script type="text/javascript">
//<![CDATA[
    decorateTable('wishlist-table');

<?php foreach ($columns as $column): ?>
    <?php echo $column->getJs();?>
<?php endforeach; ?>
//]]>
</script>

Does anyone have the same problem and possibly a solution for this?

1 Answer 1

2

Try to override core classes Mage_Wishlist_Model_Resource_Item_Collection and Mage_Catalog_Model_Resource_Product_Collection according to diff:

Mage_Wishlist_Model_Resource_Item_Collection

@@ -184,9 +184,13 @@
         $this->_productIds = array_merge($this->_productIds, array_keys($productIds));
         $attributes = Mage::getSingleton('wishlist/config')->getProductAttributes();
-        $productCollection = Mage::getModel('catalog/product')->getCollection();
+
+        /** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
+        $productCollection = Mage::getModel('catalog/product')->getCollection()
+            ->setUseLeftJoinForPriceIndex(true);
+
         foreach ($storeIds as $id) {
-            $productCollection->addStoreFilter($id);
+            $productCollection->addWebsiteFilter(Mage::app()->getStore($id)->getWebsiteId());
         }

         if ($this->_productVisible) {

And Mage_Catalog_Model_Resource_Product_Collection:

@@ -132,13 +132,20 @@
     protected $_productCountSelect           = null;

     /**
-     * Enter description here ...
+     * Is website filter
      *
      * @var bool
      */
     protected $_isWebsiteFilter              = false;

     /**
+     * Type of joining price index table
+     *
+     * @var bool
+     */
+    protected $_useLeftJoinForPriceIndex     = false;
+
+    /**
      * Additional field filters, applied in _productLimitationJoinPrice()
      *
      * @var array
@@ -1759,11 +1766,15 @@
     /**
      * Join Product Price Table with left-join possibility
      *
+     * @param bool|null $joinLeft
+     *
      * @see Mage_Catalog_Model_Resource_Product_Collection::_productLimitationJoinPrice()
      * @return Mage_Catalog_Model_Resource_Product_Collection
      */
-    protected function _productLimitationPrice($joinLeft = false)
+    protected function _productLimitationPrice($joinLeft = null)
     {
+        $joinLeft = is_null($joinLeft) ? $this->_useLeftJoinForPriceIndex : $joinLeft;
+
         $filters = $this->_productLimitationFilters;
         if (empty($filters['use_price_index'])) {
             return $this;
@@ -2172,4 +2183,18 @@

         return $this->_pricesCount;
     }
+
+    /**
+     * Set type of joining price index table
+     *
+     * @param bool $value
+     *
+     * @return Mage_Catalog_Model_Resource_Product_Collection
+     */
+    public function setUseLeftJoinForPriceIndex($value)
+    {
+        $this->_useLeftJoinForPriceIndex = (bool)$value;
+
+        return $this;
+    }
 }
2
  • btw. You can also say why this is necessary?
    – rayphi
    Sep 4, 2014 at 14:57
  • 1
    Yes, because in query was used inner join for joining price index, and in case when price data are absent in index, your product will skipped.
    – user13804
    Sep 4, 2014 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.