Version Notes
Please contact help@commercestack.com with any feature requests, bugs, issues, or questions.
Download this release
Release Info
Developer | CommerceStack |
Extension | CommerceStack_Recommender |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.9 to 2.1.0
app/code/community/CommerceStack/Recommender/Block/Cart/Crosssell.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell
|
4 |
{
|
5 |
protected $_linkSource = array('useLinkSourceManual', 'useLinkSourceCommerceStack'); // from most to least authoritative
|
6 |
-
|
7 |
protected function _getCollection($linkSource = null)
|
8 |
{
|
9 |
if(is_null($linkSource)) $linkSource = $this->_linkSource[0];
|
10 |
-
|
11 |
$collection = Mage::getModel('catalog/product_link')->useCrossSellLinks()
|
12 |
->{$linkSource}()
|
13 |
->getProductCollection()
|
@@ -21,7 +21,7 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
21 |
|
22 |
return $collection;
|
23 |
}
|
24 |
-
|
25 |
public function getItems()
|
26 |
{
|
27 |
$items = $this->getData('items');
|
@@ -30,7 +30,7 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
30 |
$ninProductIds = $this->_getCartProductIds();
|
31 |
if ($ninProductIds) {
|
32 |
$lastAdded = (int) $this->_getLastAddedProductId();
|
33 |
-
if ($lastAdded) {
|
34 |
$collection = $this->_getCollection()
|
35 |
->addProductFilter($lastAdded);
|
36 |
if (!empty($ninProductIds)) {
|
@@ -43,16 +43,18 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
43 |
$items[] = $item;
|
44 |
}
|
45 |
}
|
46 |
-
|
47 |
$limit = Mage::getStoreConfig('recommender/relatedproducts/numberofcrosssellproducts') - count($items);
|
48 |
-
|
49 |
// A bit of a hack, but return an empty collection if user selected 0 recommendations to show in config
|
50 |
if($limit < 1)
|
51 |
{
|
52 |
-
|
53 |
$this->_itemCollection->load();
|
54 |
$this->_itemCollection->clear();
|
55 |
-
return $this
|
|
|
|
|
56 |
}
|
57 |
|
58 |
if (count($items) > $limit)
|
@@ -60,7 +62,7 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
60 |
$this->setData('items', $items);
|
61 |
return $items;
|
62 |
}
|
63 |
-
|
64 |
$unionLinkedItemCollection = null;
|
65 |
foreach($this->_linkSource as $linkSource)
|
66 |
{
|
@@ -69,27 +71,27 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
69 |
{
|
70 |
$numRecsToGet = $limit - count($unionLinkedItemCollection);
|
71 |
}
|
72 |
-
|
73 |
if($numRecsToGet > 0)
|
74 |
{
|
75 |
-
if (count($items) < $numRecsToGet)
|
76 |
{
|
77 |
if(!is_null($unionLinkedItemCollection))
|
78 |
{
|
79 |
$ninProductIds = array_merge($ninProductIds, $unionLinkedItemCollection->getAllIds());
|
80 |
}
|
81 |
-
|
82 |
$filterProductIds = array_merge($this->_getCartProductIds(), $this->_getCartProductIdsRel());
|
83 |
$collection = $this->_getCollection($linkSource)
|
84 |
->addProductFilter($filterProductIds)
|
85 |
->addExcludeProductFilter($ninProductIds)
|
86 |
->setGroupBy()
|
87 |
->setPositionOrder();
|
88 |
-
|
89 |
$collection->getSelect()->limit($numRecsToGet);
|
90 |
$collection->load();
|
91 |
}
|
92 |
-
|
93 |
if(is_null($unionLinkedItemCollection))
|
94 |
{
|
95 |
$unionLinkedItemCollection = $collection;
|
@@ -105,8 +107,8 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
105 |
}
|
106 |
}
|
107 |
}
|
108 |
-
|
109 |
-
|
110 |
if(count($unionLinkedItemCollection) < $limit)
|
111 |
{
|
112 |
// Get categories for randoms
|
@@ -119,12 +121,12 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
119 |
$constrainCategory = Mage::getStoreConfig('recommender/relatedproducts/constraincategory');
|
120 |
$useCategoryFilter = !is_null($category) && $constrainCategory;
|
121 |
}
|
122 |
-
|
123 |
while(count($unionLinkedItemCollection) < $limit)
|
124 |
{
|
125 |
-
|
126 |
$numRecsToGet = $limit - count($unionLinkedItemCollection);
|
127 |
-
|
128 |
$randCollection = Mage::getResourceModel('catalog/product_collection');
|
129 |
Mage::getModel('catalog/layer')->prepareProductCollection($randCollection);
|
130 |
$randCollection->getSelect()->order('rand()');
|
@@ -138,24 +140,24 @@ class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block
|
|
138 |
{
|
139 |
$randCollection->addCategoryFilter($category);
|
140 |
}
|
141 |
-
|
142 |
foreach($randCollection as $linkedProduct)
|
143 |
{
|
144 |
$unionLinkedItemCollection->addItem($linkedProduct);
|
145 |
}
|
146 |
-
|
147 |
if(!$useCategoryFilter) break; // We tried everything
|
148 |
-
|
149 |
// Go up a category level for next iteration
|
150 |
$category = $category->getParentCategory();
|
151 |
if(is_null($category->getId())) $useCategoryFilter = false;
|
152 |
}
|
153 |
|
154 |
-
foreach ($unionLinkedItemCollection as $item)
|
155 |
{
|
156 |
$items[] = $item;
|
157 |
}
|
158 |
-
|
159 |
$this->setData('items', $items);
|
160 |
}
|
161 |
return $items;
|
3 |
class CommerceStack_Recommender_Block_Cart_Crosssell extends Mage_Checkout_Block_Cart_Crosssell
|
4 |
{
|
5 |
protected $_linkSource = array('useLinkSourceManual', 'useLinkSourceCommerceStack'); // from most to least authoritative
|
6 |
+
|
7 |
protected function _getCollection($linkSource = null)
|
8 |
{
|
9 |
if(is_null($linkSource)) $linkSource = $this->_linkSource[0];
|
10 |
+
|
11 |
$collection = Mage::getModel('catalog/product_link')->useCrossSellLinks()
|
12 |
->{$linkSource}()
|
13 |
->getProductCollection()
|
21 |
|
22 |
return $collection;
|
23 |
}
|
24 |
+
|
25 |
public function getItems()
|
26 |
{
|
27 |
$items = $this->getData('items');
|
30 |
$ninProductIds = $this->_getCartProductIds();
|
31 |
if ($ninProductIds) {
|
32 |
$lastAdded = (int) $this->_getLastAddedProductId();
|
33 |
+
if ($lastAdded) {
|
34 |
$collection = $this->_getCollection()
|
35 |
->addProductFilter($lastAdded);
|
36 |
if (!empty($ninProductIds)) {
|
43 |
$items[] = $item;
|
44 |
}
|
45 |
}
|
46 |
+
|
47 |
$limit = Mage::getStoreConfig('recommender/relatedproducts/numberofcrosssellproducts') - count($items);
|
48 |
+
|
49 |
// A bit of a hack, but return an empty collection if user selected 0 recommendations to show in config
|
50 |
if($limit < 1)
|
51 |
{
|
52 |
+
/*$this->_itemCollection = $this->_getCollection($this->_linkSource[0]);
|
53 |
$this->_itemCollection->load();
|
54 |
$this->_itemCollection->clear();
|
55 |
+
return $this;*/
|
56 |
+
$this->setData('items', $items);
|
57 |
+
return $items;
|
58 |
}
|
59 |
|
60 |
if (count($items) > $limit)
|
62 |
$this->setData('items', $items);
|
63 |
return $items;
|
64 |
}
|
65 |
+
|
66 |
$unionLinkedItemCollection = null;
|
67 |
foreach($this->_linkSource as $linkSource)
|
68 |
{
|
71 |
{
|
72 |
$numRecsToGet = $limit - count($unionLinkedItemCollection);
|
73 |
}
|
74 |
+
|
75 |
if($numRecsToGet > 0)
|
76 |
{
|
77 |
+
if (count($items) < $numRecsToGet)
|
78 |
{
|
79 |
if(!is_null($unionLinkedItemCollection))
|
80 |
{
|
81 |
$ninProductIds = array_merge($ninProductIds, $unionLinkedItemCollection->getAllIds());
|
82 |
}
|
83 |
+
|
84 |
$filterProductIds = array_merge($this->_getCartProductIds(), $this->_getCartProductIdsRel());
|
85 |
$collection = $this->_getCollection($linkSource)
|
86 |
->addProductFilter($filterProductIds)
|
87 |
->addExcludeProductFilter($ninProductIds)
|
88 |
->setGroupBy()
|
89 |
->setPositionOrder();
|
90 |
+
|
91 |
$collection->getSelect()->limit($numRecsToGet);
|
92 |
$collection->load();
|
93 |
}
|
94 |
+
|
95 |
if(is_null($unionLinkedItemCollection))
|
96 |
{
|
97 |
$unionLinkedItemCollection = $collection;
|
107 |
}
|
108 |
}
|
109 |
}
|
110 |
+
|
111 |
+
|
112 |
if(count($unionLinkedItemCollection) < $limit)
|
113 |
{
|
114 |
// Get categories for randoms
|
121 |
$constrainCategory = Mage::getStoreConfig('recommender/relatedproducts/constraincategory');
|
122 |
$useCategoryFilter = !is_null($category) && $constrainCategory;
|
123 |
}
|
124 |
+
|
125 |
while(count($unionLinkedItemCollection) < $limit)
|
126 |
{
|
127 |
+
// We still don't have enough recommendations. Fill out the remaining with randoms.
|
128 |
$numRecsToGet = $limit - count($unionLinkedItemCollection);
|
129 |
+
|
130 |
$randCollection = Mage::getResourceModel('catalog/product_collection');
|
131 |
Mage::getModel('catalog/layer')->prepareProductCollection($randCollection);
|
132 |
$randCollection->getSelect()->order('rand()');
|
140 |
{
|
141 |
$randCollection->addCategoryFilter($category);
|
142 |
}
|
143 |
+
|
144 |
foreach($randCollection as $linkedProduct)
|
145 |
{
|
146 |
$unionLinkedItemCollection->addItem($linkedProduct);
|
147 |
}
|
148 |
+
|
149 |
if(!$useCategoryFilter) break; // We tried everything
|
150 |
+
|
151 |
// Go up a category level for next iteration
|
152 |
$category = $category->getParentCategory();
|
153 |
if(is_null($category->getId())) $useCategoryFilter = false;
|
154 |
}
|
155 |
|
156 |
+
foreach ($unionLinkedItemCollection as $item)
|
157 |
{
|
158 |
$items[] = $item;
|
159 |
}
|
160 |
+
|
161 |
$this->setData('items', $items);
|
162 |
}
|
163 |
return $items;
|
app/code/community/CommerceStack/Recommender/Block/Product/List/Related.php
CHANGED
@@ -107,7 +107,7 @@ class CommerceStack_Recommender_Block_Product_List_Related extends Mage_Catalog_
|
|
107 |
}
|
108 |
|
109 |
// If we still don't have enough recommendations fill out the remaining with randoms.
|
110 |
-
$currentCategory = $productCategory;
|
111 |
while($numRecsToGet > 0)
|
112 |
{
|
113 |
$randCollection = Mage::getResourceModel('catalog/product_collection');
|
107 |
}
|
108 |
|
109 |
// If we still don't have enough recommendations fill out the remaining with randoms.
|
110 |
+
if($numRecsToGet > 0) $currentCategory = $productCategory;
|
111 |
while($numRecsToGet > 0)
|
112 |
{
|
113 |
$randCollection = Mage::getResourceModel('catalog/product_collection');
|
app/code/community/CommerceStack/Recommender/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<CommerceStack_Recommender>
|
5 |
-
<version>2.0
|
6 |
</CommerceStack_Recommender>
|
7 |
</modules>
|
8 |
|
2 |
<config>
|
3 |
<modules>
|
4 |
<CommerceStack_Recommender>
|
5 |
+
<version>2.1.0</version>
|
6 |
</CommerceStack_Recommender>
|
7 |
</modules>
|
8 |
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>CommerceStack_Recommender</name>
|
4 |
-
<version>2.0
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License v 3.0</license>
|
7 |
<channel>community</channel>
|
@@ -16,9 +16,9 @@ Please contact help@commercestack.com with any bugs, issues, or feature requests
|
|
16 |
After installing, navigate to System->Configuration->Related Products Manager to begin.</description>
|
17 |
<notes>Please contact help@commercestack.com with any feature requests, bugs, issues, or questions.</notes>
|
18 |
<authors><author><name>CommerceStack</name><user>dbright</user><email>dbright@commercestack.com</email></author></authors>
|
19 |
-
<date>2013-06-
|
20 |
-
<time>
|
21 |
-
<contents><target name="magecommunity"><dir name="CommerceStack"><dir name="Recommender"><dir name="Block"><dir name="Cart"><file name="Crosssell.php" hash="
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
24 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>CommerceStack_Recommender</name>
|
4 |
+
<version>2.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License v 3.0</license>
|
7 |
<channel>community</channel>
|
16 |
After installing, navigate to System->Configuration->Related Products Manager to begin.</description>
|
17 |
<notes>Please contact help@commercestack.com with any feature requests, bugs, issues, or questions.</notes>
|
18 |
<authors><author><name>CommerceStack</name><user>dbright</user><email>dbright@commercestack.com</email></author></authors>
|
19 |
+
<date>2013-06-18</date>
|
20 |
+
<time>23:58:00</time>
|
21 |
+
<contents><target name="magecommunity"><dir name="CommerceStack"><dir name="Recommender"><dir name="Block"><dir name="Cart"><file name="Crosssell.php" hash="f88461f17a9b136ebcabdc74329ced25"/></dir><dir name="Catalog"><dir name="Product"><dir name="Edit"><dir name="Tab"><file name="Crosssell.php" hash="6bf054a0c4cb02d5029e865c1f834d65"/><file name="Related.php" hash="0daa5a8c523d389eaea2d1d220d96be9"/></dir><file name="Tabs.php" hash="aa26d6e9e585117100e983616e6a0afa"/></dir></dir></dir><dir name="Product"><dir name="List"><file name="Related.php" hash="a3541fdac08ba290871eb0454b9eca4b"/><file name="Upsell.php" hash="3af4da1b2ede35e0cb34fd2c9603ef5f"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Apikey.php" hash="def235a2710cea0b01ace89bce9ffda4"/><file name="Apikeyurl.php" hash="5ce3031fd84f912b3552d7c37f2a04ac"/><file name="Apisecret.php" hash="9b9a92981a5ff80aa4ec3e4255844801"/><file name="Apiuser.php" hash="bba5a87192ab0821d999aa4ab8cddada"/><file name="Cancelbutton.php" hash="7a87871461a6d589a28ccbc18f9d1603"/><file name="Email.php" hash="0231900a317a75e1f72cfdd440df2e45"/><file name="Helpiframe.php" hash="cd049db20bfa53e6a57eaba796a0f5b6"/><file name="Paymentiframe.php" hash="aac32f6d47bf80aef61c1b4288363f7e"/><file name="Updatebutton.php" hash="997d957fab4ac828237b9b0ca92d51e6"/></dir><file name="Form.php" hash="de1c3b70b03ac09fe1d5c7cd7613feb1"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f522b3fa9caa77c3ab85e448382ff469"/></dir><dir name="Model"><dir name="Product"><file name="Link.php" hash="c2fb978783910af6472fbcf50070bb0f"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><dir name="Product"><dir name="Link"><dir name="Product"><file name="Collection.php" hash="3fb32d0da982297829938dc2427b35cb"/></dir></dir><file name="Link.php" hash="0910e13e6a3b3cac3573a4ea1df59e9f"/></dir></dir></dir><dir name="Mysql4"><file name="Setup.php" hash="1e93566c0f56cc52cdf4e4a73153d2f9"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Upsellsource.php" hash="34ed5e3c61bd288340b7de3809953ad3"/></dir></dir></dir></dir><dir name="controllers"><file name="AccountController.php" hash="2ba2f4ae67df9a140ed2b8b5bc4ec986"/><file name="IndexController.php" hash="fdefef57154a23f84a7910b93c2f6e94"/><file name="ProductController.php" hash="83ad4a8d6d22d53f4fb03744950500d9"/></dir><dir name="etc"><file name="config.xml" hash="a2c3e600bd4c1cb1d05c738c18aed2e4"/><file name="system.xml" hash="2ee1ffb7b78936caf27acc87bc34a4c9"/></dir><dir name="sql"><dir name="recommender_setup"><file name="mysql4-install-0.9.3.php" hash="cfe38102d96814f6b254cc38c07f2037"/><file name="mysql4-upgrade-0.9.3-0.9.4.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-0.9.4-0.9.5.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-0.9.5-1.0.0.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.0.2-1.1.0.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.1.0-1.2.0.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.0-1.2.1.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.1-1.2.2.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.2-1.2.3.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.3-1.2.4.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.4-1.2.5.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.5-1.2.6.php" hash="3beefb00777a6bd04265b7d33c23efa9"/><file name="mysql4-upgrade-1.2.6-2.0.0.php" hash="b2d2b463578d50b2a1a313c36d02ecdf"/></dir></dir></dir><dir name="CsApiClient"><dir name="Model"><file name="Account.php" hash="b463d405e9e6bc18c1ce27dc98992a61"/><file name="Server.php" hash="6dd11dab8794ab53cdb763d4820d36c9"/></dir><dir name="etc"><file name="config.xml" hash="5734d20ccb8807ea84041bf44620fa7c"/></dir></dir><dir name="CsNotification"><dir name="Model"><dir name="AdminNotification"><file name="Feed.php" hash="1f20e704fe895c4a2748612a028ee186"/></dir></dir><dir name="etc"><file name="config.xml" hash="9ede9a59b2e857828a341bbf53953abe"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="recommender.xml" hash="26d8deea180738fdd5e3f0a5bcbc8f07"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="commercestack"><dir name="adminhtml"><file name="recommender.js" hash="b9b1fb4afa53aeb99d3a180f9fafc155"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CommerceStack_Recommender.xml" hash="c0faaf57bb93c70fe6ba45e68c96fc11"/><file name="CommerceStack_CsApiClient.xml" hash="dd56312764a58b18b7e21738ebb8a6b0"/><file name="CommerceStack_CsNotification.xml" hash="94bb10db3af629c7e68bbf32fd18159c"/></dir></target></contents>
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
24 |
</package>
|