Advocado - Version 1.1.2

Version Notes

Allow Advocado to find out if store is managing inventory for stock checking before allowing customers to add to cart.

You can sign up for an account immediately after you register. Do let us know if you have any feedback or comments either through our website http://getadvocado.com, or via our email: dax@getadvocado.com

Download this release

Release Info

Developer SY Quek
Extension Advocado
Version 1.1.2
Comparing to
See all releases


Code changes from version 1.1.1 to 1.1.2

app/code/community/GozoLabs/Advocado/Block/Site.php CHANGED
@@ -51,7 +51,7 @@ class GozoLabs_Advocado_Block_Site extends
51
 
52
  $helper = Mage::helper('gozolabs_advocado');
53
  $wrappedProduct = $helper->getProducts($product->getId());
54
- $variants = $wrappedProduct->getVariants($product);
55
  $attribs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
56
 
57
  Mage::log('in product variants map');
51
 
52
  $helper = Mage::helper('gozolabs_advocado');
53
  $wrappedProduct = $helper->getProducts($product->getId());
54
+ $variants = $wrappedProduct->getVariants();
55
  $attribs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
56
 
57
  Mage::log('in product variants map');
app/code/community/GozoLabs/Advocado/Helper/Backend.php CHANGED
@@ -8,6 +8,7 @@ if ( isset( $_SERVER[ 'ADVOC_LOCAL_DEBUG' ] ) ) {
8
  define( 'ADVOCADO_BACKEND_HOST', 'http://api.advoca.do' );
9
  }
10
 
 
11
  /** Convenience function for setting multiple parameters
12
  * for a Varien_Http_Client
13
  * @param Varien_Http_Client $client
8
  define( 'ADVOCADO_BACKEND_HOST', 'http://api.advoca.do' );
9
  }
10
 
11
+
12
  /** Convenience function for setting multiple parameters
13
  * for a Varien_Http_Client
14
  * @param Varien_Http_Client $client
app/code/community/GozoLabs/Advocado/Helper/Data.php CHANGED
@@ -510,6 +510,34 @@ class AdvocPVariant extends AdvocModelInstance {
510
  return intval( $stock );
511
  }
512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  public function getData( $field = null ) {
514
 
515
  $o = $this->origObject;
@@ -520,6 +548,26 @@ class AdvocPVariant extends AdvocModelInstance {
520
  $currencyCode = Mage::app()->getStore()
521
  ->getCurrentCurrencyCode();
522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  return array_merge( $data,
524
  array(
525
  'id' => intval($o->getId()),
@@ -530,6 +578,7 @@ class AdvocPVariant extends AdvocModelInstance {
530
  //'currency_symbol' => $currencySymbol,
531
  //'currency_code' => $currencyCode,
532
  'sku' => $o->getSku(),
 
533
  'inventory_quantity' => $this->getStockQty( $o )
534
  ) );
535
  }
@@ -1264,6 +1313,7 @@ class GozoLabs_Advocado_Helper_Data extends Mage_Core_Helper_Data {
1264
  ->setStoreId($this->getWebsite()->getDefaultStore()->getStoreId());
1265
  // lazy collection, needs to load stuff, so we call count
1266
  // this is really weird.
 
1267
 
1268
  // version 1 of the join - doesn't work
1269
  //$_collect->getSelect()
@@ -1292,7 +1342,6 @@ class GozoLabs_Advocado_Helper_Data extends Mage_Core_Helper_Data {
1292
  //)
1293
  //)
1294
  //);
1295
- //Mage::log('Number of products = ' . $_collect->count());
1296
  $collect = new AdvocCustomProductCollection($_collect);
1297
 
1298
  if (is_array( $filters ) && count( $filters ) > 0 ) {
@@ -1562,12 +1611,3 @@ class GozoLabs_Advocado_Helper_Data extends Mage_Core_Helper_Data {
1562
  }
1563
 
1564
  ?>
1565
- <?php
1566
-
1567
- /*
1568
- * ==================================================
1569
- * Utilities
1570
- * ==================================================
1571
- */
1572
-
1573
-
510
  return intval( $stock );
511
  }
512
 
513
+ protected function getManageInventory( $product ) {
514
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
515
+ //$stockItem = $o->getStockItem();
516
+ $manageInventory = 'magento';
517
+ Mage::log('Getting inventory management details');
518
+ if ($stockItem && $stockItem->getId()) {
519
+ $useConfig = $stockItem->getData('use_config_manage_stock');
520
+ if ($useConfig) {
521
+ Mage::log('Uses config = ' . $useConfig);
522
+ $config = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
523
+ if ($config != '1') {
524
+ $manageInventory = null;
525
+ } else {
526
+ Mage::log('Config says manage stock');
527
+ }
528
+ } else {
529
+ Mage::log('Doesnt use config');
530
+ $stockItemManageInventory = $stockItem->getData('manage_stock');
531
+ if ($stockItemManageInventory == 0) {
532
+ $manageInventory = null;
533
+ }
534
+ }
535
+ //Mage::log('Stock item has id = ' . $stockItem->getId() . ', managing stock = ' . $stockItemManageInventory);
536
+ //Mage::log('v2 = ' . $stockItem->getData('use_config_notify_stock_qty'));
537
+ }
538
+ return $manageInventory;
539
+ }
540
+
541
  public function getData( $field = null ) {
542
 
543
  $o = $this->origObject;
548
  $currencyCode = Mage::app()->getStore()
549
  ->getCurrentCurrencyCode();
550
 
551
+ // config value
552
+ //$config = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
553
+ //Mage::log('config = ' . var_export($config, true));
554
+ //// return if manages inventory
555
+ //$stockData = $o->getStockData();
556
+ //Mage::log('Stock Data = ' . var_export($stockData, true));
557
+ //$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($o);
558
+ ////$stockItem = $o->getStockItem();
559
+ //$manageInventory = 'magento';
560
+ //Mage::log('Getting inventory management details');
561
+ //if (!$stockItem->getId()) {
562
+ //$stockItemManageInventory = $stockItem->getData('manage_stock');
563
+ //Mage::log('Manages stock = ' . $stockItemManageInventory);
564
+ //Mage::log('v2 = ' . $stockItem->getData('use_config_notify_stock_qty'));
565
+ //} else {
566
+ //$stockItemManageInventory = $stockItem->getData('manage_stock');
567
+ //Mage::log('Stock item has id = ' . $stockItem->getId() . ', managing stock = ' . $stockItemManageInventory);
568
+ //Mage::log('v2 = ' . $stockItem->getData('use_config_notify_stock_qty'));
569
+ //}
570
+
571
  return array_merge( $data,
572
  array(
573
  'id' => intval($o->getId()),
578
  //'currency_symbol' => $currencySymbol,
579
  //'currency_code' => $currencyCode,
580
  'sku' => $o->getSku(),
581
+ 'inventory_management' => $this->getManageInventory($o),
582
  'inventory_quantity' => $this->getStockQty( $o )
583
  ) );
584
  }
1313
  ->setStoreId($this->getWebsite()->getDefaultStore()->getStoreId());
1314
  // lazy collection, needs to load stuff, so we call count
1315
  // this is really weird.
1316
+ Mage::log('Number of products = ' . $_collect->count());
1317
 
1318
  // version 1 of the join - doesn't work
1319
  //$_collect->getSelect()
1342
  //)
1343
  //)
1344
  //);
 
1345
  $collect = new AdvocCustomProductCollection($_collect);
1346
 
1347
  if (is_array( $filters ) && count( $filters ) > 0 ) {
1611
  }
1612
 
1613
  ?>
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/gozolabs/advocado/login.phtml CHANGED
@@ -114,8 +114,7 @@
114
  </div>
115
  <div id="advoc-dashboard-container-dash" style="display:none">
116
  </div>
117
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
118
- <!-- <script src="//advocado-frontend-dev.s3.amazonaws.com/js/lib/easyXDM.debug.js"></script> -->
119
- <script src="//cdnjs.cloudflare.com/ajax/libs/easyXDM/2.4.17.1/easyXDM.min.js"></script>
120
-
121
 
114
  </div>
115
  <div id="advoc-dashboard-container-dash" style="display:none">
116
  </div>
117
+ <!--<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> -->
118
+ <script src="//advocado-frontend-dev.s3.amazonaws.com/js/lib/easyXDM.debug.js"></script>
119
+ <!-- <script src="//cdnjs.cloudflare.com/ajax/libs/easyXDM/2.4.17.1/easyXDM.min.js"></script> -->
 
120
 
app/design/frontend/base/default/layout/gozolabs_advocado.xml CHANGED
@@ -4,7 +4,7 @@
4
  <reference name="head">
5
  <block name="advocado.setup" type="core/text">
6
  <action method="setText">
7
- <text><![CDATA[<script type="text/javascript" src="https://cdnw.getadvocado.com/js/magento/loader.min.js"></script>]]></text>
8
  </action>
9
  </block>
10
  </reference>
@@ -16,7 +16,7 @@
16
  <reference name="head">
17
  <block name="advocado.setup" type="core/text">
18
  <action method="setText">
19
- <text><![CDATA[<script type="text/javascript" src="https://cdnw.getadvocado.com/js/magento/loader.min.js"></script>]]></text>
20
  </action>
21
  </block>
22
  </reference>
4
  <reference name="head">
5
  <block name="advocado.setup" type="core/text">
6
  <action method="setText">
7
+ <text><![CDATA[<script type="text/javascript" src="https://advocado-frontend-dev.s3.amazonaws.com/js/magento/loader.js"></script>]]></text>
8
  </action>
9
  </block>
10
  </reference>
16
  <reference name="head">
17
  <block name="advocado.setup" type="core/text">
18
  <action method="setText">
19
+ <text><![CDATA[<script type="text/javascript" src="https://advocado-frontend-dev.s3.amazonaws.com/js/magento/loader.js"></script>]]></text>
20
  </action>
21
  </block>
22
  </reference>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Advocado</name>
4
- <version>1.1.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/mit-license.php">MITL</license>
7
  <channel>community</channel>
@@ -24,13 +24,13 @@
24
  &lt;li&gt;Generate more referrals - Reward your customers for every successful referral they make and drive more sales for your business.&lt;/li&gt;&#xD;
25
  &lt;li&gt;Easy to set up - You can install our plugin or copy &amp; paste a snippet of codes to get Advocado up and running. Our set up wizard will guide you through this.&lt;/li&gt;&#xD;
26
  &lt;/ol&gt;</description>
27
- <notes>Some bugfixes.&#xD;
28
  &#xD;
29
  You can sign up for an account immediately after you register. Do let us know if you have any feedback or comments either through our website http://getadvocado.com, or via our email: dax@getadvocado.com</notes>
30
  <authors><author><name>SY Quek</name><user>syquek</user><email>quek@getadvocado.com</email></author></authors>
31
  <date>2013-08-15</date>
32
- <time>06:10:55</time>
33
- <contents><target name="magecommunity"><dir name="GozoLabs"><dir name="Advocado"><dir name="Block"><dir name="Adminhtml"><file name="Login.php" hash="39706986405f7348ef71192d1c86615d"/></dir><file name="Site.php" hash="3b62c41138ac5a90e1f9432a10e6d19e"/></dir><dir name="Helper"><file name="Admin.php" hash="bcda9a0a4e383c14b8c6f7372167a14d"/><file name="Analytics.php" hash="2bf2b9439ace050851ff54faf6734f31"/><file name="Backend.php" hash="125ee66f4aa5d43368679d960c165494"/><file name="Data.php" hash="0c7ea63433a87037af08372406b9ef73"/></dir><dir name="Model"><file name="Credentials.php" hash="f7d6c7c82369b4e71fa1ef605c7d5736"/><file name="Observer.php" hash="f39c3df5aa69c724f48e4e28afdb7b06"/><dir name="Resource"><dir name="Credentials"><file name="Collection.php" hash="d7061008f932a933bff5a934133f4f58"/></dir><file name="Credentials.php" hash="db06bec94d7eaf9e9511ef87296f791a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AdvocadoController.php" hash="b47e8a4eb15cb6fe497a04afa9e146e3"/></dir><file name="CampaignController.php" hash="95d945d30e11561c06c63a65744f0998"/><file name="CartController.php" hash="e42cb1757de7760862d905b64c1a21f0"/><file name="IndexController.php" hash="105efc19158e33b8dae67e23682d08d5"/><file name="V1Controller.php" hash="4c8cf4357c18224b317a172914de07d5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7c94738fe2d40efca729d81311afa529"/><file name="config.xml" hash="9dba171f358f27c5f9e51de2d533b040"/></dir><dir name="sql"><dir name="gozolabs_advocado_setup"><file name="install-0.1.0.php" hash="db8f967eb2a9af200305bde91abe423a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="gozolabs_advocado.xml" hash="8a3eee7e9e393ba02fea4d67a0ddcda1"/></dir><dir name="template"><dir name="gozolabs"><dir name="advocado"><file name="login.phtml" hash="8ade68e2f79c41c5b95d585a325cf883"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="gozolabs_advocado.xml" hash="5e560a16061cb5f792c0351b6c34bb69"/></dir><dir name="template"><dir name="gozolabs"><dir name="advocado"><file name="site.phtml" hash="a239ca877dd55c3c45943c428352df35"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GozoLabs_Advocado.xml" hash="5309e7603426b687ad46a42ab565c692"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="gozolabs_advocado.css" hash="4177c19b32d7aed880d1ce695dfc0ad7"/><file name="animate.min.css" hash="bbe717113fde11700cb83ec3d79d9de0"/></dir><dir name="js"><dir name="gozolabs_advocado"><file name="gozolabs_advocado.js" hash="8fe3afda0d605278e24b074efa2a940b"/><file name="jquery.min.js" hash="e1288116312e4728f98923c79b034b67"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Analytics"><dir name="Analytics"><file name="Client.php" hash="0648505a1ad5e4700b0a20855bb34fac"/><dir name="Consumer"><file name="File.php" hash="602b0430e01b131ef4a07f89bb548956"/><file name="ForkCurl.php" hash="83fa57b1b0f09f592e726545d58f12bc"/><file name="Socket.php" hash="b3c6aeacfb0f73ee842288cf2b6e2d56"/></dir><file name="Consumer.php" hash="8299490437cd905bd32f9294ac60b64e"/><file name="QueueConsumer.php" hash="cc20ab42b8013847f06355f32b46e94f"/></dir><file name="Analytics.php" hash="f5703a127a85f014335624016716260d"/></dir></target></contents>
34
  <compatible/>
35
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0.2</max></package></required></dependencies>
36
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Advocado</name>
4
+ <version>1.1.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/mit-license.php">MITL</license>
7
  <channel>community</channel>
24
  &lt;li&gt;Generate more referrals - Reward your customers for every successful referral they make and drive more sales for your business.&lt;/li&gt;&#xD;
25
  &lt;li&gt;Easy to set up - You can install our plugin or copy &amp; paste a snippet of codes to get Advocado up and running. Our set up wizard will guide you through this.&lt;/li&gt;&#xD;
26
  &lt;/ol&gt;</description>
27
+ <notes>Allow Advocado to find out if store is managing inventory for stock checking before allowing customers to add to cart.&#xD;
28
  &#xD;
29
  You can sign up for an account immediately after you register. Do let us know if you have any feedback or comments either through our website http://getadvocado.com, or via our email: dax@getadvocado.com</notes>
30
  <authors><author><name>SY Quek</name><user>syquek</user><email>quek@getadvocado.com</email></author></authors>
31
  <date>2013-08-15</date>
32
+ <time>09:07:21</time>
33
+ <contents><target name="magecommunity"><dir name="GozoLabs"><dir name="Advocado"><dir name="Block"><dir name="Adminhtml"><file name="Login.php" hash="39706986405f7348ef71192d1c86615d"/></dir><file name="Site.php" hash="08e784bc971fad25a2a4c020cd59e144"/></dir><dir name="Helper"><file name="Admin.php" hash="bcda9a0a4e383c14b8c6f7372167a14d"/><file name="Analytics.php" hash="2bf2b9439ace050851ff54faf6734f31"/><file name="Backend.php" hash="d5daef60657a7fbeedf1c9acb7e10e2c"/><file name="Data.php" hash="dfcacc99f98d2d13bc6dae559877ab9e"/></dir><dir name="Model"><file name="Credentials.php" hash="f7d6c7c82369b4e71fa1ef605c7d5736"/><file name="Observer.php" hash="f39c3df5aa69c724f48e4e28afdb7b06"/><dir name="Resource"><dir name="Credentials"><file name="Collection.php" hash="d7061008f932a933bff5a934133f4f58"/></dir><file name="Credentials.php" hash="db06bec94d7eaf9e9511ef87296f791a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="AdvocadoController.php" hash="b47e8a4eb15cb6fe497a04afa9e146e3"/></dir><file name="CampaignController.php" hash="95d945d30e11561c06c63a65744f0998"/><file name="CartController.php" hash="e42cb1757de7760862d905b64c1a21f0"/><file name="IndexController.php" hash="105efc19158e33b8dae67e23682d08d5"/><file name="V1Controller.php" hash="4c8cf4357c18224b317a172914de07d5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7c94738fe2d40efca729d81311afa529"/><file name="config.xml" hash="9dba171f358f27c5f9e51de2d533b040"/></dir><dir name="sql"><dir name="gozolabs_advocado_setup"><file name="install-0.1.0.php" hash="db8f967eb2a9af200305bde91abe423a"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="gozolabs_advocado.xml" hash="8a3eee7e9e393ba02fea4d67a0ddcda1"/></dir><dir name="template"><dir name="gozolabs"><dir name="advocado"><file name="login.phtml" hash="5c34c07722da9082829bec3e45245acb"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="gozolabs_advocado.xml" hash="eb4430e62e8582ba6c32e75a82d0b691"/></dir><dir name="template"><dir name="gozolabs"><dir name="advocado"><file name="site.phtml" hash="a239ca877dd55c3c45943c428352df35"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GozoLabs_Advocado.xml" hash="5309e7603426b687ad46a42ab565c692"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="css"><file name="gozolabs_advocado.css" hash="4177c19b32d7aed880d1ce695dfc0ad7"/><file name="animate.min.css" hash="bbe717113fde11700cb83ec3d79d9de0"/></dir><dir name="js"><dir name="gozolabs_advocado"><file name="gozolabs_advocado.js" hash="97040908742ab9c8c22ad511a9ab0a37"/><file name="jquery.min.js" hash="e1288116312e4728f98923c79b034b67"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Analytics"><dir name="Analytics"><file name="Client.php" hash="0648505a1ad5e4700b0a20855bb34fac"/><dir name="Consumer"><file name="File.php" hash="602b0430e01b131ef4a07f89bb548956"/><file name="ForkCurl.php" hash="83fa57b1b0f09f592e726545d58f12bc"/><file name="Socket.php" hash="b3c6aeacfb0f73ee842288cf2b6e2d56"/></dir><file name="Consumer.php" hash="8299490437cd905bd32f9294ac60b64e"/><file name="QueueConsumer.php" hash="cc20ab42b8013847f06355f32b46e94f"/></dir><file name="Analytics.php" hash="f5703a127a85f014335624016716260d"/></dir></target></contents>
34
  <compatible/>
35
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7.0.2</max></package></required></dependencies>
36
  </package>
skin/adminhtml/default/default/js/gozolabs_advocado/gozolabs_advocado.js CHANGED
@@ -1,7 +1,6 @@
1
-
2
- // give $ back
3
- var jQuery_A = jQuery.noConflict();
4
-
5
  var advocado = (function($, A) {
6
 
7
  var POPUP_TITLE = 'Create a new Advocado account',
@@ -299,9 +298,9 @@ var advocado = (function($, A) {
299
 
300
  return A;
301
 
302
- })(jQuery_A, advocado || {});
303
 
304
- jQuery_A(document).ready(function() {
305
  advocado.createAccountEvents();
306
  advocado.loginFormEvents();
307
  });
1
+ if(jQuery) {
2
+ jQuery.noConflict();
3
+ }
 
4
  var advocado = (function($, A) {
5
 
6
  var POPUP_TITLE = 'Create a new Advocado account',
298
 
299
  return A;
300
 
301
+ })(jQuery, advocado || {});
302
 
303
+ jQuery(document).ready(function() {
304
  advocado.createAccountEvents();
305
  advocado.loginFormEvents();
306
  });