4
4
* See COPYING.txt for license details.
5
5
*/
6
6
7
- /**
8
- * Wishlist item collection grouped by customer id
9
- */
10
7
namespace Magento \Wishlist \Model \ResourceModel \Item \Collection ;
11
8
12
9
use Magento \Customer \Controller \RegistryConstants as RegistryConstants ;
13
10
14
11
/**
12
+ * Wishlist item collection grouped by customer id
13
+ *
15
14
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
16
15
*/
17
16
class Grid extends \Magento \Wishlist \Model \ResourceModel \Item \Collection
@@ -98,7 +97,12 @@ protected function _initSelect()
98
97
parent ::_initSelect ();
99
98
$ this ->addCustomerIdFilter (
100
99
$ this ->_registryManager ->registry (RegistryConstants::CURRENT_CUSTOMER_ID )
101
- )->resetSortOrder ()->addDaysInWishlist ()->addStoreData ();
100
+ )
101
+ ->resetSortOrder ()
102
+ ->addDaysInWishlist ()
103
+ ->addStoreData ()
104
+ ->setVisibilityFilter ()
105
+ ->setInStockFilter ();
102
106
return $ this ;
103
107
}
104
108
@@ -122,6 +126,18 @@ public function setOrder($field, $direction = self::SORT_ORDER_DESC)
122
126
}
123
127
}
124
128
129
+ /**
130
+ * Add quantity to filter
131
+ *
132
+ * @param string $field
133
+ * @param array $condition
134
+ * @return \Magento\Wishlist\Model\ResourceModel\Item\Collection
135
+ */
136
+ private function addQtyFilter (string $ field , array $ condition )
137
+ {
138
+ return parent ::addFieldToFilter ('main_table. ' . $ field , $ condition );
139
+ }
140
+
125
141
/**
126
142
* Add field filter to collection
127
143
*
@@ -146,6 +162,11 @@ public function addFieldToFilter($field, $condition = null)
146
162
if (!isset ($ condition ['datetime ' ])) {
147
163
return $ this ->addDaysFilter ($ condition );
148
164
}
165
+ break ;
166
+ case 'qty ' :
167
+ if (isset ($ condition ['from ' ]) || isset ($ condition ['to ' ])) {
168
+ return $ this ->addQtyFilter ($ field , $ condition );
169
+ }
149
170
}
150
171
return parent ::addFieldToFilter ($ field , $ condition );
151
172
}
0 commit comments