Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

Fix for issue #144 #145

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/code/community/Inchoo/PHP7/Model/Wishlist/Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

class Inchoo_PHP7_Model_Wishlist_Observer extends Mage_Wishlist_Model_Observer
{
/**
* Fixes: Warning: count(): Parameter must be an array or an object that implements Countable in app/code/core/Mage/Wishlist/Model/Observer.php on line 105
* Fixes: Warning: count(): Parameter must be an array or an object that implements Countable in app/code/core/Mage/Wishlist/Model/Observer.php on line 128
*
* Original algorithm will be not touched and the price is that we will always store array for two variables in the session if they are not set, when this algorithm runs.
* @param $observer
*/
public function processAddToCart($observer)
{
$session = Mage::getSingleton('checkout/session');

$urls = $session->getWishlistPendingUrls();
if (!is_array($urls) && !($urls instanceof Countable) && !$urls) $session->setWishlistPendingUrls([]);

$wishlistIds = $session->getWishlistIds();
if (!is_array($wishlistIds) && !($wishlistIds instanceof Countable) && !$wishlistIds) $session->setWishlistIds([]);

return parent::processAddToCart($observer);
}
}
8 changes: 8 additions & 0 deletions app/code/community/Inchoo/PHP7/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
</core>
</helpers>

<models>
<wishlist>
<rewrite>
<observer>Inchoo_PHP7_Model_Wishlist_Observer</observer>
</rewrite>
</wishlist>
</models>

<!-- Fix for incorrect sorting in the calculation of the discount -->
<sales>
<quote>
Expand Down