Version Notes
v1.0.0 - This is the first release of upsell products.
v1.0.1 - improved performance when no remote results available
Download this release
Release Info
Developer | Michael |
Extension | AdvertiseUpsellProducts |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
app/code/community/Advertise/UpsellProducts/Block/Upsell.php
CHANGED
@@ -122,12 +122,27 @@ class Advertise_UpsellProducts_Block_Upsell extends Mage_Catalog_Block_Product_L
|
|
122 |
// Still haven't got the required number of upsell products so fill up with random products
|
123 |
$numRandomsToGet = $upsellCount - count($this->_itemCollection);
|
124 |
|
125 |
-
// Get random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
$randCollection = Mage::getResourceModel('catalog/product_collection');
|
127 |
Mage::getModel('catalog/layer')->prepareProductCollection($randCollection);
|
128 |
-
|
|
|
129 |
$randCollection->addStoreFilter();
|
130 |
-
$randCollection->
|
131 |
// Don't get items we already have
|
132 |
$exclude = $this->_itemCollection->getAllIds();
|
133 |
$toexclude = array();
|
@@ -145,6 +160,7 @@ class Advertise_UpsellProducts_Block_Upsell extends Mage_Catalog_Block_Product_L
|
|
145 |
$toexclude[] = $item->getProductId();
|
146 |
}
|
147 |
$randCollection->addIdFilter($toexclude, true);
|
|
|
148 |
foreach($randCollection as $randProduct)
|
149 |
{
|
150 |
$this->_itemCollection->addItem($randProduct);
|
122 |
// Still haven't got the required number of upsell products so fill up with random products
|
123 |
$numRandomsToGet = $upsellCount - count($this->_itemCollection);
|
124 |
|
125 |
+
// Get a list of 100 random product IDs
|
126 |
+
// (To execute SQL query directly: 1. Get the resource model, 2. Retrieve the read connection, 3. Execute the query)
|
127 |
+
$resource = Mage::getSingleton('core/resource');
|
128 |
+
$readConnection = $resource->getConnection('core_read');
|
129 |
+
$query = 'SELECT MAX(entity_id) AS maxid FROM ' . $resource->getTableName('catalog/product');
|
130 |
+
$maxid = $readConnection->fetchOne($query);
|
131 |
+
if (!$maxid) {
|
132 |
+
$maxid = $prodid;
|
133 |
+
}
|
134 |
+
$randids = array();
|
135 |
+
for ($i = 0; $i <= 100; $i++) {
|
136 |
+
array_push($randids , rand(1,$maxid));
|
137 |
+
}
|
138 |
+
|
139 |
+
// Select random products
|
140 |
$randCollection = Mage::getResourceModel('catalog/product_collection');
|
141 |
Mage::getModel('catalog/layer')->prepareProductCollection($randCollection);
|
142 |
+
// Select from the 100 random IDs
|
143 |
+
$randCollection->addIdFilter($randids, false);
|
144 |
$randCollection->addStoreFilter();
|
145 |
+
$randCollection->getSelect()->limit($numRandomsToGet);
|
146 |
// Don't get items we already have
|
147 |
$exclude = $this->_itemCollection->getAllIds();
|
148 |
$toexclude = array();
|
160 |
$toexclude[] = $item->getProductId();
|
161 |
}
|
162 |
$randCollection->addIdFilter($toexclude, true);
|
163 |
+
// Mage::log('RANDOM UPSELL ITEM SELECT QUERY:' . $randCollection->getSelect());
|
164 |
foreach($randCollection as $randProduct)
|
165 |
{
|
166 |
$this->_itemCollection->addItem($randProduct);
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>AdvertiseUpsellProducts</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Adverti.se Upsell Products for Magento - Dynamically Updated and Individually Personalised Upsell Products</summary>
|
10 |
<description>With Adverti.se Upsell Products you get automated Upell product relations.</description>
|
11 |
-
<notes>v1.0.0 - This is the first release of upsell products
|
|
|
|
|
12 |
<authors><author><name>Michael</name><user>Oxley</user><email>mike@adverti.se</email></author></authors>
|
13 |
-
<date>2012-
|
14 |
-
<time>13:
|
15 |
-
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Advertise_UpsellProducts.xml" hash="4f6e99ec106f66f039a17b1e831ddaf4"/></dir></dir><dir name="code"><dir name="community"><dir name="Advertise"><dir name="UpsellProducts"><dir name="Block"><dir name="Adminhtml"><file name="UpsellProducts.php" hash="c9ff33f8fd41206e64941f735edc9a74"/></dir><file name="Index.php" hash="2bf716a0737f38427248232c20ffc462"/><file name="Upsell.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>AdvertiseCommunity</name><channel>community</channel><min>1.2.0</min><max>1.2.9</max></package></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>AdvertiseUpsellProducts</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Adverti.se Upsell Products for Magento - Dynamically Updated and Individually Personalised Upsell Products</summary>
|
10 |
<description>With Adverti.se Upsell Products you get automated Upell product relations.</description>
|
11 |
+
<notes>v1.0.0 - This is the first release of upsell products.
|
12 |
+

|
13 |
+
v1.0.1 - improved performance when no remote results available</notes>
|
14 |
<authors><author><name>Michael</name><user>Oxley</user><email>mike@adverti.se</email></author></authors>
|
15 |
+
<date>2012-11-02</date>
|
16 |
+
<time>13:27:21</time>
|
17 |
+
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Advertise_UpsellProducts.xml" hash="4f6e99ec106f66f039a17b1e831ddaf4"/></dir></dir><dir name="code"><dir name="community"><dir name="Advertise"><dir name="UpsellProducts"><dir name="Block"><dir name="Adminhtml"><file name="UpsellProducts.php" hash="c9ff33f8fd41206e64941f735edc9a74"/></dir><file name="Index.php" hash="2bf716a0737f38427248232c20ffc462"/><file name="Upsell.php" hash="f3bdd6718bf49f8dc8fe75de666eb80b"/></dir><dir name="Helper"><file name="Data.php" hash="ca0dfcb6234afd34267bc25bcf3b2d2f"/></dir><dir name="Model"><file name="Config.php" hash="4bbb4dd3c7b16462e2e8569b26021046"/><dir name="Resource"><file name="Setup.php" hash="2ad4d65b99c5dc2974f09d8899839e45"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="UpsellProductsController.php" hash="0255e1d1a6237b3dfcb4efe9bea3aaf2"/></dir><file name="IndexController.php" hash="185cbe7a584c5ce5e7809c1896f7c763"/><file name="UpsellProductsController.php" hash="803c2f83aed7a2d7dc47f1cce5ab0a0a"/></dir><dir name="data"><dir name="upsellproducts_setup"><file name="data-install-1.0.0.php" hash="7c1d96df30727dd985ada4d2bd8f37e1"/></dir></dir><dir name="etc"><file name="config.xml" hash="58814a1f2ca679e88a16d615aadb4fe0"/><file name="system.xml" hash="5d2e06fdae604fa1b2bacc3cbaf06e26"/></dir><dir name="sql"><dir name="relatedproducts_setup"><file name="install-1.0.0.php" hash="13d5e308c0b9f639c757961191840c32"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="advertiseupsellproducts.xml" hash="c8c87a9ccc2ee6ed025161dae2f99c21"/></dir></dir></dir></dir></dir></dir><dir name="."><file name="README-Advertise-Up-Sell.txt" hash="d718d0caba17638f21fddc8140b7c1f0"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>AdvertiseCommunity</name><channel>community</channel><min>1.2.0</min><max>1.2.9</max></package></required></dependencies>
|
20 |
</package>
|