ReplenishProducts - Version 1.0.0

Version Notes

first release

Download this release

Release Info

Developer ramu
Extension ReplenishProducts
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (40) hide show
  1. app/code/local/Conversionbug/Core/Block/Info.php +58 -0
  2. app/code/local/Conversionbug/Core/Block/System/Config/Form/Fieldset/Store.php +15 -0
  3. app/code/local/Conversionbug/Core/Block/System/Config/Info.php +31 -0
  4. app/code/local/Conversionbug/Core/Helper/Data.php +20 -0
  5. app/code/local/Conversionbug/Core/Model/Feed.php +46 -0
  6. app/code/local/Conversionbug/Core/Model/System/Config/Source/Display.php +18 -0
  7. app/code/local/Conversionbug/Core/Model/System/Config/Source/Footer.php +22 -0
  8. app/code/local/Conversionbug/Core/Model/System/Config/Source/Options.php +18 -0
  9. app/code/local/Conversionbug/Core/etc/adminhtml.xml +24 -0
  10. app/code/local/Conversionbug/Core/etc/config.xml +45 -0
  11. app/code/local/Conversionbug/Core/etc/system.xml +42 -0
  12. app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder.php +16 -0
  13. app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit.php +48 -0
  14. app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit/Form.php +17 -0
  15. app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit/Tab/Form.php +97 -0
  16. app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit/Tabs.php +21 -0
  17. app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Grid.php +90 -0
  18. app/code/local/Conversionbug/Quickreorder/Block/Product.php +7 -0
  19. app/code/local/Conversionbug/Quickreorder/Helper/Data.php +76 -0
  20. app/code/local/Conversionbug/Quickreorder/Model/Mysql4/Quickreorder.php +8 -0
  21. app/code/local/Conversionbug/Quickreorder/Model/Mysql4/Quickreorder/Collection.php +12 -0
  22. app/code/local/Conversionbug/Quickreorder/Model/Observer.php +271 -0
  23. app/code/local/Conversionbug/Quickreorder/Model/Quickreorder.php +12 -0
  24. app/code/local/Conversionbug/Quickreorder/controllers/Adminhtml/QuickreorderController.php +161 -0
  25. app/code/local/Conversionbug/Quickreorder/etc/adminhtml.xml +23 -0
  26. app/code/local/Conversionbug/Quickreorder/etc/config.xml +168 -0
  27. app/code/local/Conversionbug/Quickreorder/etc/system.xml +36 -0
  28. app/code/local/Conversionbug/Quickreorder/sql/quickreorder_setup/mysql4-install-1.0.0.php +93 -0
  29. app/design/adminhtml/default/default/layout/conversionbugcore.xml +15 -0
  30. app/design/adminhtml/default/default/layout/quickreorder.xml +8 -0
  31. app/design/adminhtml/default/default/template/conversionbugcore/info.phtml +43 -0
  32. app/etc/modules/ConversionBug_Core.xml +32 -0
  33. app/etc/modules/Conversionbug_Quickreorder.xml +9 -0
  34. app/locale/en_US/template/email/replenishmail_notification.html +45 -0
  35. media/import/product.csv +6 -0
  36. package.xml +22 -0
  37. skin/adminhtml/default/default/conversionbug/core/core.css +12 -0
  38. skin/adminhtml/default/default/conversionbug/core/images/cb_pattern.png +0 -0
  39. skin/adminhtml/default/default/conversionbug/core/images/favicon.png +0 -0
  40. skin/adminhtml/default/default/conversionbug/core/images/logo.jpg +0 -0
app/code/local/Conversionbug/Core/Block/Info.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ConversionBug_Core_Block_Info extends Mage_Adminhtml_Block_Template {
4
+
5
+ /**
6
+ * Print init JS script into body
7
+ * @return string
8
+ */
9
+ protected function _toHtml() {
10
+ $section = $this->getAction()->getRequest()->getParam('section', false);
11
+ if ($section == 'cbstore') {
12
+ return parent::_toHtml();
13
+ } else {
14
+ return '';
15
+ }
16
+ }
17
+
18
+ function urlGetContents() {
19
+ $url = Mage::getUrl() . 'product.csv';
20
+ $cUrl = curl_init();
21
+ curl_setopt($cUrl, CURLOPT_URL, $url);
22
+ curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
23
+ curl_setopt($cUrl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)");
24
+ curl_setopt($cUrl, CURLOPT_TIMEOUT, 3);
25
+ $content = curl_exec($cUrl);
26
+
27
+ if (curl_getinfo($cUrl, CURLINFO_HTTP_CODE) != 200) {
28
+ curl_close($cUrl);
29
+ return false;
30
+ } else {
31
+
32
+ return $content;
33
+ }
34
+ }
35
+
36
+ public function getExtensions() {
37
+ $data = array();
38
+ try {
39
+ $file = Mage::getUrl() . 'product.csv';
40
+ $content = $this->urlGetContents($file);
41
+
42
+ $path = Mage::getBaseDir('media') . DS . 'import' . DS . 'product.csv';
43
+ if (!file_exists(Mage::getBaseDir('media') . DS . 'import')) {
44
+ mkdir(Mage::getBaseDir('media') . DS . 'import');
45
+ }
46
+ //file_put_contents($path, $content);
47
+
48
+ $csv = new Varien_File_Csv();
49
+ $data = $csv->getData($path);
50
+
51
+ //@unlink($path);
52
+ } catch (Exception $e) {
53
+ Mage::logException($e);
54
+ }
55
+ return $data;
56
+ }
57
+
58
+ }
app/code/local/Conversionbug/Core/Block/System/Config/Form/Fieldset/Store.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ConversionBug_Core_Block_System_Config_Form_Fieldset_Store extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
3
+ {
4
+
5
+ protected $_dummyElement;
6
+ protected $_fieldRenderer;
7
+ protected $_values;
8
+
9
+ public function render(Varien_Data_Form_Element_Abstract $element)
10
+ {
11
+ return '<div id="' . $element->getId() . '"></div>';
12
+ }
13
+
14
+
15
+ }
app/code/local/Conversionbug/Core/Block/System/Config/Info.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ConversionBug_Core_Block_System_Config_Info
4
+ extends Mage_Adminhtml_Block_Abstract
5
+ implements Varien_Data_Form_Element_Renderer_Interface
6
+ {
7
+
8
+ /**
9
+ * Render fieldset html
10
+ *
11
+ * @param Varien_Data_Form_Element_Abstract $element
12
+ * @return string
13
+ */
14
+ public function render(Varien_Data_Form_Element_Abstract $element)
15
+ {
16
+ $html = <<<HTML
17
+ <div class="cb-intro">
18
+ <div class="content">
19
+ <h1>CONVERSIONbug</h1>
20
+ <p>We want to change the way you look at your website</p>
21
+ <p><span>Visit Us: </span><a href="http://www.conversionbug.com/">www.conversionbug.com</a></p>
22
+ <p><span>Contact Us: </span><a href="mailto:support@conversionbug.com">support@conversionbug.com</a></p>
23
+ <p><span>Skype: </span><a href="#">convertsionbug</a></p>
24
+ </div>
25
+ <div class="cb-pattern"></div>
26
+ </div>
27
+ HTML;
28
+
29
+ return $html;
30
+ }
31
+ }
app/code/local/Conversionbug/Core/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ConversionBug_Core_Helper_Data extends Mage_Core_Helper_Abstract{
3
+
4
+ /**
5
+ * @return string
6
+ */
7
+ public function getInfoLink()
8
+ {
9
+ return 'http://www.conversionbug.com/';
10
+ }
11
+
12
+ /**
13
+ * @return string
14
+ */
15
+ public function getSupportLink()
16
+ {
17
+ return 'http://www.conversionbug.com/';
18
+ }
19
+ }
20
+ ?>
app/code/local/Conversionbug/Core/Model/Feed.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ConversionBug_Core_Model_Feed extends Mage_AdminNotification_Model_Feed {
4
+
5
+ const URL_NEWS = 'http://www.conversionbug.com/feed_news.xml';
6
+
7
+ public function _construct() {
8
+ parent::_construct();
9
+ $this->_init('cbcore/feed');
10
+ }
11
+
12
+ public function checkUpdate() {
13
+ if (!extension_loaded('curl')) {
14
+ return $this;
15
+ }
16
+ /*if (!Mage::getStoreConfig('info/notification/enable')) {
17
+ return $this;
18
+ }*/
19
+ $feedData = array();
20
+ $feedXml = $this->getFeedData();
21
+
22
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
23
+ foreach ($feedXml->channel->item as $item) {
24
+ $date = $this->getDate((string) $item->pubDate);
25
+ $feedData[] = array(
26
+ 'severity' => 3,
27
+ 'date_added' => $this->getDate($date),
28
+ 'title' => (string) $item->title,
29
+ 'description' => (string) $item->description,
30
+ 'url' => (string) $item->link,
31
+ );
32
+ }
33
+ if ($feedData) {
34
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
35
+ }
36
+ }
37
+ $this->setLastUpdate();
38
+ }
39
+
40
+ public function getFeedUrl() {
41
+ if (is_null($this->_feedUrl)) {
42
+ $this->_feedUrl = self::URL_NEWS;
43
+ }
44
+ return $this->_feedUrl;
45
+ }
46
+ }
app/code/local/Conversionbug/Core/Model/System/Config/Source/Display.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ConversionBug_Core_Model_System_Config_Source_Display
3
+ {
4
+
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Top')),
14
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Sidebar')),
15
+ );
16
+ }
17
+
18
+ }
app/code/local/Conversionbug/Core/Model/System/Config/Source/Footer.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ConversionBug_Core_Model_System_Config_Source_Footer
3
+ {
4
+
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+
14
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('1')),
15
+ array('value' => 2, 'label' => Mage::helper('adminhtml')->__('2')),
16
+ array('value' => 3, 'label' => Mage::helper('adminhtml')->__('3')),
17
+ array('value' => 4, 'label' => Mage::helper('adminhtml')->__('4')),
18
+ array('value' => 5, 'label' => Mage::helper('adminhtml')->__('5')),
19
+ array('value' => 6, 'label' => Mage::helper('adminhtml')->__('6')),
20
+ );
21
+ }
22
+ }
app/code/local/Conversionbug/Core/Model/System/Config/Source/Options.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class ConversionBug_Core_Model_System_Config_Source_Options
3
+ {
4
+
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
14
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
15
+ );
16
+ }
17
+
18
+ }
app/code/local/Conversionbug/Core/etc/adminhtml.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>Allow everything</all>
6
+ <admin>
7
+ <children>
8
+ <system>
9
+ <children>
10
+ <config>
11
+ <children>
12
+ <cbstore translate="title" module="cbcore">
13
+ <title>CB Extensions</title>
14
+ <sort_order>60</sort_order>
15
+ </cbstore>
16
+ </children>
17
+ </config>
18
+ </children>
19
+ </system>
20
+ </children>
21
+ </admin>
22
+ </resources>
23
+ </acl>
24
+ </config>
app/code/local/Conversionbug/Core/etc/config.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <ConversionBug_Core>
5
+ <version>0.1.0</version>
6
+ </ConversionBug_Core>
7
+ </modules>
8
+ <adminhtml>
9
+ <layout>
10
+ <updates>
11
+ <cbcore>
12
+ <file>conversionbugcore.xml</file>
13
+ </cbcore>
14
+ </updates>
15
+ </layout>
16
+ <events>
17
+ <controller_action_predispatch>
18
+ <observers>
19
+ <cbnotifications>
20
+ <type>singleton</type>
21
+ <class>cbcore/feed</class>
22
+ <method>checkUpdate</method>
23
+ </cbnotifications>
24
+ </observers>
25
+ </controller_action_predispatch>
26
+ </events>
27
+ </adminhtml>
28
+ <global>
29
+ <helpers>
30
+ <cbcore>
31
+ <class>ConversionBug_Core_Helper</class>
32
+ </cbcore>
33
+ </helpers>
34
+ <blocks>
35
+ <cbcore>
36
+ <class>ConversionBug_Core_Block</class>
37
+ </cbcore>
38
+ </blocks>
39
+ <models>
40
+ <cbcore>
41
+ <class>ConversionBug_Core_Model</class>
42
+ </cbcore>
43
+ </models>
44
+ </global>
45
+ </config>
app/code/local/Conversionbug/Core/etc/system.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <cbcore translate="label" module="cbcore">
5
+ <label>CB Extensions</label>
6
+ <sort_order>10</sort_order>
7
+ <class>cb-block</class>
8
+ </cbcore>
9
+ </tabs>
10
+ <sections>
11
+ <cbstore>
12
+ <class>separator-top</class>
13
+ <header_css>cb-header</header_css>
14
+ <label>CB Extensions</label>
15
+ <tab>cbcore</tab>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>1000</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>0</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ <groups>
22
+ <!-- <extensions translate="label">
23
+ <label>CB Extensions Store</label>
24
+ <frontend_model>cbcore/system_config_info</frontend_model>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </extensions>-->
30
+ <extension translate="label">
31
+ <label>CB Extensions Store</label>
32
+ <frontend_type>text</frontend_type>
33
+ <frontend_model>cbcore/system_config_form_fieldset_store</frontend_model>
34
+ <sort_order>11</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </extension>
39
+ </groups>
40
+ </cbstore>
41
+ </sections>
42
+ </config>
app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Block_Adminhtml_Quickreorder extends Mage_Adminhtml_Block_Widget_Grid_Container{
3
+
4
+ public function __construct()
5
+ {
6
+
7
+ $this->_controller = "adminhtml_quickreorder";
8
+ $this->_blockGroup = "quickreorder";
9
+ $this->_headerText = Mage::helper("quickreorder")->__("Manage Replenish Items");
10
+ $this->_addButtonLabel = Mage::helper("quickreorder")->__("Add New Item");
11
+ parent::__construct();
12
+ $this->_removeButton('add');
13
+
14
+ }
15
+
16
+ }
app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Conversionbug_Quickreorder_Block_Adminhtml_Quickreorder_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+
8
+ parent::__construct();
9
+ $this->_objectId = "id";
10
+ $this->_blockGroup = "quickreorder";
11
+ $this->_controller = "adminhtml_quickreorder";
12
+ $this->_updateButton("save", "label", Mage::helper("quickreorder")->__("Save Item"));
13
+ $this->_updateButton("delete", "label", Mage::helper("quickreorder")->__("Delete Item"));
14
+
15
+ $this->_addButton("saveandcontinue", array(
16
+ "label" => Mage::helper("quickreorder")->__("Save And Continue Edit"),
17
+ "onclick" => "saveAndContinueEdit()",
18
+ "class" => "save",
19
+ ), -100);
20
+
21
+
22
+
23
+ $this->_formScripts[] = "
24
+
25
+ function saveAndContinueEdit(){
26
+ editForm.submit($('edit_form').action+'back/edit/');
27
+ }
28
+ ";
29
+ $this->_removeButton('save');
30
+ $this->_removeButton('saveandcontinue');
31
+ $this->_removeButton('reset');
32
+
33
+ }
34
+
35
+ public function getHeaderText()
36
+ {
37
+ if( Mage::registry("quickreorder_data") && Mage::registry("quickreorder_data")->getId() ){
38
+
39
+ return Mage::helper("quickreorder")->__("View Item #%s", $this->htmlEscape(Mage::registry("quickreorder_data")->getId()));
40
+
41
+ }
42
+ else{
43
+
44
+ return Mage::helper("quickreorder")->__("Add Item");
45
+
46
+ }
47
+ }
48
+ }
app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Block_Adminhtml_Quickreorder_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form(array(
7
+ "id" => "edit_form",
8
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
9
+ "method" => "post",
10
+ "enctype" =>"multipart/form-data",
11
+ )
12
+ );
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+ }
app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit/Tab/Form.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Block_Adminhtml_Quickreorder_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset("quickreorder_form", array("legend"=>Mage::helper("quickreorder")->__("Item information")));
10
+
11
+ $fieldset->addField("order_increment_id", "label", array(
12
+ "label" => Mage::helper("quickreorder")->__("Order Id"),
13
+ "name" => "order_increment_id",
14
+ ));
15
+
16
+ $fieldset->addField("product_id", "label", array(
17
+ "label" => Mage::helper("quickreorder")->__("Product Id"),
18
+ "name" => "product_id",
19
+ ));
20
+
21
+ $fieldset->addField("sku", "label", array(
22
+ "label" => Mage::helper("quickreorder")->__("Product SKU"),
23
+ "name" => "sku",
24
+ ));
25
+
26
+ $fieldset->addField("customer_id", "label", array(
27
+ "label" => Mage::helper("quickreorder")->__("Customer Id"),
28
+ "name" => "customer_id",
29
+ ));
30
+
31
+ $fieldset->addField("customer_email", "label", array(
32
+ "label" => Mage::helper("quickreorder")->__("Customer Email"),
33
+ "name" => "customer_email",
34
+ ));
35
+
36
+ $fieldset->addField("period", "label", array(
37
+ "label" => Mage::helper("quickreorder")->__("Period"),
38
+ "name" => "period",
39
+ ));
40
+
41
+ $fieldset->addField("total_period", "label", array(
42
+ "label" => Mage::helper("quickreorder")->__("Total Period"),
43
+ "name" => "total_period",
44
+ ));
45
+
46
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
47
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
48
+ );
49
+
50
+ $fieldset->addField("replenish_status", "label", array(
51
+ "label" => Mage::helper("quickreorder")->__("Replenish Status"),
52
+ "name" => "replenish_status",
53
+ ));
54
+
55
+ $fieldset->addField('next_iteration_date', 'label', array(
56
+ 'label' => Mage::helper('quickreorder')->__('Next date'),
57
+ 'name' => 'next_iteration_date',
58
+ 'time' => true,
59
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
60
+ 'format' => $dateFormatIso
61
+
62
+ ));
63
+
64
+ $fieldset->addField('updated_on', 'label', array(
65
+ 'label' => Mage::helper('quickreorder')->__('Last updated date'),
66
+ 'name' => 'updated_on',
67
+ 'time' => true,
68
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
69
+ 'format' => $dateFormatIso
70
+
71
+ ));
72
+
73
+ $fieldset->addField('created_time', 'label', array(
74
+ 'label' => Mage::helper('quickreorder')->__('Created date'),
75
+ 'name' => 'created_time',
76
+ 'time' => true,
77
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
78
+ 'format' => $dateFormatIso
79
+ ));
80
+
81
+ $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(
82
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
83
+ );
84
+
85
+
86
+
87
+ if (Mage::getSingleton("adminhtml/session")->getQuickreorderData())
88
+ {
89
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getQuickreorderData());
90
+ Mage::getSingleton("adminhtml/session")->setQuickreorderData(null);
91
+ }
92
+ elseif(Mage::registry("quickreorder_data")) {
93
+ $form->setValues(Mage::registry("quickreorder_data")->getData());
94
+ }
95
+ return parent::_prepareForm();
96
+ }
97
+ }
app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Edit/Tabs.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Block_Adminhtml_Quickreorder_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId("quickreorder_tabs");
8
+ $this->setDestElementId("edit_form");
9
+ $this->setTitle(Mage::helper("quickreorder")->__("Item Information"));
10
+ }
11
+ protected function _beforeToHtml()
12
+ {
13
+ $this->addTab("form_section", array(
14
+ "label" => Mage::helper("quickreorder")->__("Item Information"),
15
+ "title" => Mage::helper("quickreorder")->__("Item Information"),
16
+ "content" => $this->getLayout()->createBlock("quickreorder/adminhtml_quickreorder_edit_tab_form")->toHtml(),
17
+ ));
18
+ return parent::_beforeToHtml();
19
+ }
20
+
21
+ }
app/code/local/Conversionbug/Quickreorder/Block/Adminhtml/Quickreorder/Grid.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Conversionbug_Quickreorder_Block_Adminhtml_Quickreorder_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId("quickreorderGrid");
10
+ $this->setDefaultSort("id");
11
+ $this->setDefaultDir("DESC");
12
+ $this->setSaveParametersInSession(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel("quickreorder/quickreorder")->getCollection();
18
+ $collection->getSelect()->join(Mage::getConfig()->getTablePrefix().'catalog_product_entity', 'main_table.product_id ='.Mage::getConfig()->getTablePrefix().'catalog_product_entity.entity_id',array('sku'));
19
+ $this->setCollection($collection);
20
+ return parent::_prepareCollection();
21
+ }
22
+ protected function _prepareColumns()
23
+ {
24
+ $this->addColumn("id", array(
25
+ "header" => Mage::helper("quickreorder")->__("ID"),
26
+ "align" =>"right",
27
+ "width" => "50px",
28
+ "type" => "number",
29
+ "index" => "id",
30
+ ));
31
+
32
+ $this->addColumn("order_increment_id", array(
33
+ "header" => Mage::helper("quickreorder")->__("Order Id"),
34
+ "index" => "order_increment_id",
35
+ ));
36
+ $this->addColumn("sku", array(
37
+ "header" => Mage::helper("quickreorder")->__("Product Sku"),
38
+ "index" => "sku",
39
+ ));
40
+
41
+ $this->addColumn("customer_email", array(
42
+ "header" => Mage::helper("quickreorder")->__("Customer Email"),
43
+ "index" => "customer_email",
44
+ ));
45
+ $this->addColumn("period", array(
46
+ "header" => Mage::helper("quickreorder")->__("Period"),
47
+ "index" => "period",
48
+ ));
49
+ $this->addColumn("total_period", array(
50
+ "header" => Mage::helper("quickreorder")->__("Total Period"),
51
+ "index" => "total_period",
52
+ ));
53
+ $this->addColumn('next_iteration_date', array(
54
+ 'header' => Mage::helper('quickreorder')->__('Next date'),
55
+ 'index' => 'next_iteration_date',
56
+ 'type' => 'datetime',
57
+ ));
58
+ $this->addColumn('created_time', array(
59
+ 'header' => Mage::helper('quickreorder')->__('Created at'),
60
+ 'index' => 'created_time',
61
+ 'type' => 'datetime',
62
+ ));
63
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
64
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
65
+
66
+ return parent::_prepareColumns();
67
+ }
68
+
69
+ public function getRowUrl($row)
70
+ {
71
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
72
+ }
73
+
74
+
75
+
76
+ protected function _prepareMassaction()
77
+ {
78
+ $this->setMassactionIdField('id');
79
+ $this->getMassactionBlock()->setFormFieldName('ids');
80
+ $this->getMassactionBlock()->setUseSelectAll(true);
81
+ $this->getMassactionBlock()->addItem('remove_quickreorder', array(
82
+ 'label'=> Mage::helper('quickreorder')->__('Remove'),
83
+ 'url' => $this->getUrl('*/adminhtml_quickreorder/massRemove'),
84
+ 'confirm' => Mage::helper('quickreorder')->__('Are you sure?')
85
+ ));
86
+ return $this;
87
+ }
88
+
89
+
90
+ }
app/code/local/Conversionbug/Quickreorder/Block/Product.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Block_Product extends Mage_Core_Block_Template{
3
+ public function _toHtml(){
4
+ return parent::_toHtml();
5
+ }
6
+ }
7
+ ?>
app/code/local/Conversionbug/Quickreorder/Helper/Data.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ const REORDER_ENABLED = 'quickreorder/general/status';
5
+
6
+ public function isEnabled()
7
+ {
8
+ return Mage::getStoreConfig(self::REORDER_ENABLED);
9
+ }
10
+
11
+ public function saveReplenishData($orderid){
12
+
13
+ $order = Mage::getModel('sales/order')->load($orderid);
14
+ if (!$order->getId()) {
15
+ return;
16
+ }
17
+ $orderData = $order->getData();
18
+ $replenishData = array();
19
+ //order info
20
+ $replenishData['order_id'] = $orderData['entity_id'];
21
+ $replenishData['order_increment_id'] = $orderData['increment_id'];
22
+ //customer data
23
+ $replenishData = $this->PreparedataCustomer($orderData,$replenishData);
24
+ //product data
25
+ $ordered_items = $order->getAllItems();
26
+
27
+ foreach($ordered_items as $ordered_item){
28
+ $product = Mage::getModel('catalog/product')->load($ordered_item->getProductId());
29
+ $recurringstatus = $product->getRecurringStatus();
30
+ $productid = $product->getId();
31
+ //echo $replenishData['customer_email']."--".$productid;
32
+
33
+ if($this->checkRecord($replenishData['customer_email'],$productid)){
34
+
35
+ if($recurringstatus == 1){
36
+ $replenishData['product_id'] = $product->getId();
37
+ $replenishData['period'] = $product->getRecurringTimespan();
38
+ $replenishData['total_period'] = $product->getRecurringTotalPeriod();
39
+ //$nextdate = time() + (86400 * $product->getRecurringTimespan());
40
+ $nextdate = time() + (60 * $product->getRecurringTimespan());
41
+ $nextdate = date("Y-m-d h:i:sa", $nextdate);
42
+ $replenishData['next_iteration_date'] = $nextdate;
43
+ $model = Mage::getModel("quickreorder/quickreorder")
44
+ ->addData($replenishData)
45
+ ->save();
46
+ }
47
+ }
48
+ unset($replenishData['product_id']);unset($replenishData['period']);unset($replenishData['total_period']);
49
+ }
50
+ return true;
51
+ }
52
+
53
+ public function PreparedataCustomer($orderData,$replenishData){
54
+ $replenishData['customer_id'] = $orderData['customer_id'];
55
+ $replenishData['customer_email'] = $orderData['customer_email'];
56
+ return $replenishData;
57
+ }
58
+
59
+ public function checkRecord($customer_email,$product_id){
60
+ $read = Mage::getSingleton('core/resource')->getConnection('core_read');
61
+ $qry = "select * FROM conversion_quickreorder WHERE customer_email = '{$customer_email}' and product_id = {$product_id}"; //query
62
+ $res = $read->fetchRow($qry);
63
+
64
+ if($res){
65
+ //$repleshProduct->setReplenishStatus(0);
66
+ $resource = Mage::getSingleton('core/resource');
67
+ $writeConnection = $resource->getConnection('core_write');
68
+
69
+ $query = "UPDATE conversion_quickreorder SET replenish_status = '1' WHERE customer_email = '{$customer_email}' and product_id = {$product_id}"; //query
70
+ $writeConnection->query($query);
71
+ return false;
72
+ }
73
+ return true;
74
+ }
75
+ }
76
+
app/code/local/Conversionbug/Quickreorder/Model/Mysql4/Quickreorder.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Model_Mysql4_Quickreorder extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("quickreorder/quickreorder", "id");
7
+ }
8
+ }
app/code/local/Conversionbug/Quickreorder/Model/Mysql4/Quickreorder/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Model_Mysql4_Quickreorder_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("quickreorder/quickreorder");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/local/Conversionbug/Quickreorder/Model/Observer.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Conversionbug_Quickreorder_Model_Observer
3
+ {
4
+ public function orderLog(Varien_Event_Observer $observer)
5
+ {
6
+ $moduleEnabled = Mage::Helper('quickreorder')->isEnabled();
7
+ if($moduleEnabled){
8
+ $orderIds = $observer->getEvent()->getOrderIds();
9
+ foreach($orderIds as $orderid){
10
+ $replenishData = Mage::Helper('quickreorder')->saveReplenishData($orderid);
11
+ }
12
+ return $this;
13
+ }
14
+ }
15
+
16
+ public function viewProduct(Varien_Event_Observer $observer) {
17
+ $moduleEnabled = Mage::Helper('quickreorder')->isEnabled();
18
+ if($moduleEnabled){
19
+ /*$orders = array(201);
20
+ foreach($orders as $orderid){
21
+ $replenishData = Mage::Helper('quickreorder')->saveReplenishData($orderid);
22
+ } */
23
+ }
24
+
25
+ return;
26
+ }
27
+ public function rePlenishTestEmail()
28
+ {
29
+
30
+ //return true;
31
+ //http://inchoo.net/magento/magento-custom-emails/
32
+ $todaydate = time();
33
+ $tomorrowdate = time()+86400;
34
+ /*$todaydate = time() + (86400 * 20);
35
+ $tomorrowdate = time() + (86400 * 31);*/
36
+ //echo date('Y-m-d 00:00:00', $todaydate)."--".date('Y-m-d 00:00:00', $tomorrowdate);die;
37
+ $repleshProducts = Mage::getModel("quickreorder/quickreorder")
38
+ ->getCollection()
39
+ ->addfieldtofilter('next_iteration_date',
40
+ array(
41
+ array('to' => date('Y-m-d 00:00:00', $tomorrowdate))
42
+ )
43
+ )
44
+ ->addfieldtofilter('next_iteration_date',
45
+ array(
46
+ array('gteq' => date('Y-m-d 00:00:00', $todaydate))
47
+ )
48
+ );
49
+ $sql = $repleshProducts->getSelect();
50
+ Mage::log($sql, null, 'reorder_test.log');
51
+ //echo $sql;die;
52
+ //echo "<pre>"; print_R($repleshProducts->getData());die;
53
+ foreach($repleshProducts as $repleshProduct){
54
+
55
+ $productData = Mage::getModel("catalog/product")->load($repleshProduct->getProductId());
56
+ $customerData = Mage::getModel('customer/customer')->load($repleshProduct->getCustomerId());
57
+ $store = Mage::app()->getStore();
58
+ if($customerData->getEmail()=="shivam.kumar@conversionbug.com"){
59
+ //echo "<pre>"; print_R($customerData->getData());die;
60
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('replenishmail_notification');
61
+
62
+ $producthtml = Mage::app()->getLayout()->createBlock('quickreorder/product')
63
+ ->setData('product', $productData)
64
+ ->setTemplate('reorder/product.phtml')->toHtml();
65
+
66
+ $relatedproducthtml = Mage::app()->getLayout()->createBlock('quickreorder/product')
67
+ ->setData('product', $productData)
68
+ ->setTemplate('reorder/related_products.phtml')->toHtml();
69
+
70
+ //echo $producthtml;die;
71
+ //echo $relatedproducthtml;die;
72
+ //Variables for Confirmation Mail.
73
+ $emailTemplateVariables = array();
74
+ $emailTemplateVariables['product'] = $producthtml;
75
+ Mage::log($producthtml,null,'reorder_test.log');
76
+ $emailTemplateVariables['customer'] = $customerData;
77
+
78
+ $cname = $customerData->getFirstname();
79
+ $cname = ucwords($cname); // HELLO WORLD!
80
+ $cname = ucwords(strtolower($cname));
81
+ $emailTemplateVariables['customer_name'] = $cname;
82
+ Mage::log($cname,null,'reorder_test.log');
83
+ $emailTemplateVariables['store'] = $store;
84
+ //$emailTemplateVariables['related_products'] = $relatedproducthtml;
85
+ Mage::log($relatedproducthtml,null,'reorder_test.log');
86
+ //die("test sent");
87
+ //Appending the Custom Variables to Template.
88
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
89
+
90
+ //Sender details
91
+ $senderName = Mage::getStoreConfig('trans_email/ident_support/name');
92
+ $senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
93
+ //recepient details
94
+ $recepientEmail = $customerData->getEmail();
95
+ $recepientName = $customerData->getFirstname();
96
+ Mage::log($recepientEmail,null,'reorder_test.log');
97
+ $mail = Mage::getModel('core/email')
98
+ ->setToName($recepientName)
99
+ ->setToEmail($recepientEmail)
100
+ ->setBody($processedTemplate)
101
+ ->setSubject('Now It\'s time to re-order - '.$productData->getName())
102
+ ->setFromEmail($senderEmail)
103
+ ->setFromName($senderName)
104
+ ->setType('html');
105
+ try{
106
+ //Confimation E-Mail Send
107
+ $mail->send();
108
+ //echo "<br><br>"; print_R($processedTemplate);die;
109
+ echo $processedTemplate;exit;
110
+ }catch(Exception $error){
111
+ //echo $error->getMessage();die;
112
+
113
+ }
114
+ //echo "<pre>"; print_R($emailTemplate->getData());die;
115
+ $nextmailsendtime = $this->getnextmailtime($repleshProduct);
116
+ $last_iteration_date = $this->getlastmailtime($repleshProduct);
117
+ $updated_date = date("Y-m-d h:i:sa", time());
118
+ if($nextmailsendtime < $last_iteration_date){
119
+ $repleshProduct->setNextIterationDate($nextmailsendtime);
120
+ $repleshProduct->setUpdatedOn($updated_date);
121
+ $repleshProduct->setReplenishStatus(0);
122
+ $repleshProduct->save();
123
+ }else{
124
+ $repleshProduct->delete();
125
+ }
126
+ }
127
+ }
128
+
129
+ //return $this;
130
+ }
131
+ public function rePlenishEmail()
132
+ {
133
+ Mage::unregister('_singleton/core/design_package' );
134
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
135
+ Mage::getSingleton('core/design_package' )->setStore(1);
136
+
137
+ //return true;
138
+ //http://inchoo.net/magento/magento-custom-emails/
139
+ $todaydate = time();
140
+ $tomorrowdate = time()+86400;
141
+ /*$todaydate = time() + (86400 * 20);
142
+ $tomorrowdate = time() + (86400 * 31);*/
143
+ //echo date('Y-m-d 00:00:00', $todaydate)."--".date('Y-m-d 00:00:00', $tomorrowdate);die;
144
+ $repleshProducts = Mage::getModel("quickreorder/quickreorder")
145
+ ->getCollection()
146
+ ->addfieldtofilter('next_iteration_date',
147
+ array(
148
+ array('to' => date('Y-m-d 00:00:00', $tomorrowdate))
149
+ )
150
+ )
151
+ ->addfieldtofilter('next_iteration_date',
152
+ array(
153
+ array('gteq' => date('Y-m-d 00:00:00', $todaydate))
154
+ )
155
+ );
156
+ $sql = $repleshProducts->getSelect();
157
+ Mage::log($sql, null, 'reorder.log');
158
+ //echo $sql;die;
159
+ //echo "<pre>"; print_R($repleshProducts->getData());die;
160
+ foreach($repleshProducts as $repleshProduct){
161
+
162
+ $productData = Mage::getModel("catalog/product")->load($repleshProduct->getProductId());
163
+ $customerData = Mage::getModel('customer/customer')->load($repleshProduct->getCustomerId());
164
+ $store = Mage::app()->getStore();
165
+ if($customerData->getEmail()!="kannan_jayaprakasam@yahoo.co.in"){
166
+ //echo "<pre>"; print_R($customerData->getData());die;
167
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('replenishmail_notification');
168
+
169
+ $producthtml = Mage::app()->getLayout()->createBlock('quickreorder/product')
170
+ ->setData('product', $productData)
171
+ ->setTemplate('reorder/product.phtml')->toHtml();
172
+
173
+ $relatedproducthtml = Mage::app()->getLayout()->createBlock('quickreorder/product')
174
+ ->setData('product', $productData)
175
+ ->setTemplate('reorder/related_products.phtml')->toHtml();
176
+
177
+ //echo $producthtml;die;
178
+ //echo $relatedproducthtml;die;
179
+ //Variables for Confirmation Mail.
180
+ $emailTemplateVariables = array();
181
+ $emailTemplateVariables['product'] = $producthtml;
182
+ $emailTemplateVariables['customer'] = $customerData;
183
+
184
+ $cname = $customerData->getFirstname();
185
+ $cname = ucwords($cname); // HELLO WORLD!
186
+ $cname = ucwords(strtolower($cname));
187
+ $emailTemplateVariables['customer_name'] = $cname;
188
+
189
+ $emailTemplateVariables['store'] = $store;
190
+ $emailTemplateVariables['related_products'] = $relatedproducthtml;
191
+ //die("test sent");
192
+ //Appending the Custom Variables to Template.
193
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
194
+ //echo $processedTemplate;exit;
195
+ //Sender details
196
+ $senderName = Mage::getStoreConfig('trans_email/ident_support/name');
197
+ $senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
198
+ //recepient details
199
+ $recepientEmail = $customerData->getEmail();
200
+ $recepientName = $customerData->getFirstname();
201
+
202
+ $mail = Mage::getModel('core/email')
203
+ ->setToName($recepientName)
204
+ ->setToEmail($recepientEmail)
205
+ ->setBody($processedTemplate)
206
+ ->setSubject('Now It\'s time to re-order - '.$productData->getName())
207
+ ->setFromEmail($senderEmail)
208
+ ->setFromName($senderName)
209
+ ->setType('html');
210
+ try{
211
+ //Confimation E-Mail Send
212
+ $mail->send();
213
+ //echo "<br><br>"; print_R($processedTemplate);die;
214
+
215
+ }catch(Exception $error){
216
+ //echo $error->getMessage();die;
217
+
218
+ }
219
+ //echo "<pre>"; print_R($emailTemplate->getData());die;
220
+ $nextmailsendtime = $this->getnextmailtime($repleshProduct);
221
+ $last_iteration_date = $this->getlastmailtime($repleshProduct);
222
+ $updated_date = date("Y-m-d h:i:sa", time());
223
+ if($nextmailsendtime < $last_iteration_date){
224
+ $repleshProduct->setNextIterationDate($nextmailsendtime);
225
+ $repleshProduct->setUpdatedOn($updated_date);
226
+ $repleshProduct->setReplenishStatus(0);
227
+ $repleshProduct->save();
228
+ }else{
229
+ $repleshProduct->delete();
230
+ }
231
+ }
232
+ }
233
+
234
+ //return $this;
235
+ }
236
+
237
+ public function getnextmailtime($repleshProduct){
238
+ $replenishdata = $repleshProduct->getData();
239
+ $currenttime = strtotime($replenishdata['next_iteration_date']);
240
+ $next_iteration_date = $currenttime + (86400 * $replenishdata['period']);
241
+ $next_iteration_date = date("Y-m-d h:i:sa", $next_iteration_date);
242
+ return $next_iteration_date;
243
+ }
244
+
245
+ public function getlastmailtime($repleshProduct){
246
+ $replenishdata = $repleshProduct->getData();
247
+ $currenttime = strtotime($replenishdata['created_time']);
248
+ $last_iteration_date = $currenttime + (86400 * $replenishdata['total_period']) * 30;
249
+ $last_iteration_date = date("Y-m-d h:i:sa", $last_iteration_date);
250
+ return $last_iteration_date;
251
+ }
252
+
253
+ public function deleteProduct(Varien_Event_Observer $observer){
254
+ $productId = $observer->getEvent()->getProduct()->getId();
255
+ $repleshProducts = Mage::getModel("quickreorder/quickreorder")->getCollection()->addfieldtofilter('product_id',$productId);
256
+ foreach($repleshProducts as $repleshProduct){
257
+ $repleshProduct->delete();
258
+ }
259
+ return true;
260
+ }
261
+
262
+ public function deleteCustomer(Varien_Event_Observer $observer){
263
+ $customerId = $observer->getEvent()->getCustomer()->getId();
264
+ $repleshProducts = Mage::getModel("quickreorder/quickreorder")->getCollection()->addfieldtofilter('customer_id',$customerId);
265
+ foreach($repleshProducts as $repleshProduct){
266
+ $repleshProduct->delete();
267
+ }
268
+ return true;
269
+ }
270
+
271
+ }
app/code/local/Conversionbug/Quickreorder/Model/Quickreorder.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Conversionbug_Quickreorder_Model_Quickreorder extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct(){
6
+
7
+ $this->_init("quickreorder/quickreorder");
8
+
9
+ }
10
+
11
+ }
12
+
app/code/local/Conversionbug/Quickreorder/controllers/Adminhtml/QuickreorderController.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Conversionbug_Quickreorder_Adminhtml_QuickreorderController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu("quickreorder/quickreorder")->_addBreadcrumb(Mage::helper("adminhtml")->__("Quickreorder Manager"),Mage::helper("adminhtml")->__("Manage Replenish Items"));
8
+ return $this;
9
+ }
10
+ public function indexAction()
11
+ {
12
+ $this->_title($this->__("Quickreorder"));
13
+ $this->_title($this->__("Manage Replenish Items"));
14
+
15
+ $this->_initAction();
16
+ $this->renderLayout();
17
+ }
18
+ public function editAction()
19
+ {
20
+ $this->_title($this->__("Quickreorder"));
21
+ $this->_title($this->__("Quickreorder"));
22
+ $this->_title($this->__("View Item"));
23
+
24
+ $id = $this->getRequest()->getParam("id");
25
+ $model = Mage::getModel("quickreorder/quickreorder")->load($id);
26
+ $sku = Mage::getResourceModel('catalog/product')->getAttributeRawValue($model->getProductId(), 'sku', 1);
27
+ $model->setSku($sku);
28
+ $statuschange = ($model->getReplenishStatus() == 0) ? "Not yet Purchased" : "Purchased";
29
+ $model->setReplenishStatus($statuschange);
30
+ if ($model->getId()) {
31
+ Mage::register("quickreorder_data", $model);
32
+ $this->loadLayout();
33
+ $this->_setActiveMenu("quickreorder/quickreorder");
34
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Manage Replenish Items"), Mage::helper("adminhtml")->__("Manage Replenish Items"));
35
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Quickreorder Description"), Mage::helper("adminhtml")->__("Quickreorder Description"));
36
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
37
+ $this->_addContent($this->getLayout()->createBlock("quickreorder/adminhtml_quickreorder_edit"))->_addLeft($this->getLayout()->createBlock("quickreorder/adminhtml_quickreorder_edit_tabs"));
38
+ $this->renderLayout();
39
+ }
40
+ else {
41
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("quickreorder")->__("Item does not exist."));
42
+ $this->_redirect("*/*/");
43
+ }
44
+ }
45
+
46
+ public function newAction()
47
+ {
48
+
49
+ $this->_title($this->__("Quickreorder"));
50
+ $this->_title($this->__("Quickreorder"));
51
+ $this->_title($this->__("New Item"));
52
+
53
+ $id = $this->getRequest()->getParam("id");
54
+ $model = Mage::getModel("quickreorder/quickreorder")->load($id);
55
+
56
+ $data = Mage::getSingleton("adminhtml/session")->getFormData(true);
57
+ if (!empty($data)) {
58
+ $model->setData($data);
59
+ }
60
+
61
+ Mage::register("quickreorder_data", $model);
62
+
63
+ $this->loadLayout();
64
+ $this->_setActiveMenu("quickreorder/quickreorder");
65
+
66
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
67
+
68
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Manage Replenish Items"), Mage::helper("adminhtml")->__("Manage Replenish Items"));
69
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Quickreorder Description"), Mage::helper("adminhtml")->__("Quickreorder Description"));
70
+
71
+
72
+ $this->_addContent($this->getLayout()->createBlock("quickreorder/adminhtml_quickreorder_edit"))->_addLeft($this->getLayout()->createBlock("quickreorder/adminhtml_quickreorder_edit_tabs"));
73
+
74
+ $this->renderLayout();
75
+
76
+ }
77
+ public function saveAction()
78
+ {
79
+ $post_data=$this->getRequest()->getPost();
80
+ if ($post_data) {
81
+
82
+ try {
83
+ $model = Mage::getModel("quickreorder/quickreorder")
84
+ ->addData($post_data)
85
+ ->setId($this->getRequest()->getParam("id"))
86
+ ->save();
87
+
88
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Quickreorder was successfully saved"));
89
+ Mage::getSingleton("adminhtml/session")->setQuickreorderData(false);
90
+
91
+ if ($this->getRequest()->getParam("back")) {
92
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
93
+ return;
94
+ }
95
+ $this->_redirect("*/*/");
96
+ return;
97
+ }
98
+ catch (Exception $e) {
99
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
100
+ Mage::getSingleton("adminhtml/session")->setQuickreorderData($this->getRequest()->getPost());
101
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
102
+ return;
103
+ }
104
+
105
+ }
106
+ $this->_redirect("*/*/");
107
+ }
108
+
109
+ public function deleteAction()
110
+ {
111
+ if( $this->getRequest()->getParam("id") > 0 ) {
112
+ try {
113
+ $model = Mage::getModel("quickreorder/quickreorder");
114
+ $model->setId($this->getRequest()->getParam("id"))->delete();
115
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
116
+ $this->_redirect("*/*/");
117
+ }
118
+ catch (Exception $e) {
119
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
120
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
121
+ }
122
+ }
123
+ $this->_redirect("*/*/");
124
+ }
125
+
126
+
127
+ public function massRemoveAction()
128
+ {
129
+ try {
130
+ $ids = $this->getRequest()->getPost('ids', array());
131
+ foreach ($ids as $id) {
132
+ $model = Mage::getModel("quickreorder/quickreorder");
133
+ $model->setId($id)->delete();
134
+ }
135
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
136
+ }
137
+ catch (Exception $e) {
138
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
139
+ }
140
+ $this->_redirect('*/*/');
141
+ }
142
+
143
+ /**
144
+ * Export order grid to CSV format
145
+ */
146
+ public function exportCsvAction()
147
+ {
148
+ $fileName = 'quickreorder.csv';
149
+ $grid = $this->getLayout()->createBlock('quickreorder/adminhtml_quickreorder_grid');
150
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
151
+ }
152
+ /**
153
+ * Export order grid to Excel XML format
154
+ */
155
+ public function exportExcelAction()
156
+ {
157
+ $fileName = 'quickreorder.xml';
158
+ $grid = $this->getLayout()->createBlock('quickreorder/adminhtml_quickreorder_grid');
159
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
160
+ }
161
+ }
app/code/local/Conversionbug/Quickreorder/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <quickreorder translate="title" module="quickreorder">
12
+ <title>Quickreorder Section</title>
13
+ <sort_order>100</sort_order>
14
+ </quickreorder>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/Conversionbug/Quickreorder/etc/config.xml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Conversionbug_Quickreorder>
5
+ <version>1.0.0</version>
6
+ </Conversionbug_Quickreorder>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <quickreorder>
11
+ <class>Conversionbug_Quickreorder_Helper</class>
12
+ </quickreorder>
13
+ </helpers>
14
+ <blocks>
15
+ <quickreorder>
16
+ <class>Conversionbug_Quickreorder_Block</class>
17
+ </quickreorder>
18
+ </blocks>
19
+ <models>
20
+ <quickreorder>
21
+ <class>Conversionbug_Quickreorder_Model</class>
22
+ <resourceModel>quickreorder_mysql4</resourceModel>
23
+ </quickreorder>
24
+ <quickreorder_mysql4>
25
+ <class>Conversionbug_Quickreorder_Model_Mysql4</class>
26
+ <entities>
27
+ <quickreorder>
28
+ <table>conversion_quickreorder</table>
29
+ </quickreorder>
30
+ </entities>
31
+ </quickreorder_mysql4>
32
+ </models>
33
+ <resources>
34
+ <quickreorder_setup>
35
+ <setup>
36
+ <module>Conversionbug_Quickreorder</module>
37
+ </setup>
38
+ <connection>
39
+ <use>core_setup</use>
40
+ </connection>
41
+ </quickreorder_setup>
42
+ <quickreorder_write>
43
+ <connection>
44
+ <use>core_write</use>
45
+ </connection>
46
+ </quickreorder_write>
47
+ <quickreorder_read>
48
+ <connection>
49
+ <use>core_read</use>
50
+ </connection>
51
+ </quickreorder_read>
52
+ </resources>
53
+ <events>
54
+ <checkout_onepage_controller_success_action> <!-- identifier of the event we want to catch -->
55
+ <observers>
56
+ <checkout_onepage_controller_success_action_handler> <!-- identifier of the event handler -->
57
+ <type>model</type> <!-- class method call type; valid are model, object and singleton -->
58
+ <class>quickreorder/observer</class> <!-- observers class alias -->
59
+ <method>orderLog</method> <!-- observer's method to be called -->
60
+ <args></args> <!-- additional arguments passed to observer -->
61
+ </checkout_onepage_controller_success_action_handler>
62
+ </observers>
63
+ </checkout_onepage_controller_success_action>
64
+ <catalog_controller_product_view>
65
+ <observers>
66
+ <quickreorder>
67
+ <type>model</type>
68
+ <class>quickreorder/observer</class>
69
+ <method>viewProduct</method>
70
+ </quickreorder>
71
+ </observers>
72
+ </catalog_controller_product_view>
73
+ <catalog_product_delete_before>
74
+ <observers>
75
+ <quickreorder>
76
+ <type>model</type>
77
+ <class>quickreorder/observer</class>
78
+ <method>deleteProduct</method>
79
+ </quickreorder>
80
+ </observers>
81
+ </catalog_product_delete_before>
82
+ <customer_delete_before>
83
+ <observers>
84
+ <quickreorder>
85
+ <type>model</type>
86
+ <class>quickreorder/observer</class>
87
+ <method>deleteCustomer</method>
88
+ </quickreorder>
89
+ </observers>
90
+ </customer_delete_before>
91
+ </events>
92
+ <template>
93
+ <email>
94
+ <replenishmail_notification module="quickreorder">
95
+ <label>Replenishmail Notification</label>
96
+ <file>replenishmail_notification.html</file>
97
+ <type>html</type>
98
+ </replenishmail_notification>
99
+ </email>
100
+ </template>
101
+ </global>
102
+ <admin>
103
+ <routers>
104
+ <quickreorder>
105
+ <use>admin</use>
106
+ <args>
107
+ <module>Conversionbug_Quickreorder</module>
108
+ <frontName>admin_quickreorder</frontName>
109
+ </args>
110
+ </quickreorder>
111
+ </routers>
112
+ </admin>
113
+ <adminhtml>
114
+ <menu>
115
+ <quickreorder module="quickreorder">
116
+ <title>Replenish Items</title>
117
+ <sort_order>100</sort_order>
118
+ <children>
119
+ <quickreorder module="quickreorder">
120
+ <title>Manage Replenish Items</title>
121
+ <sort_order>0</sort_order>
122
+ <action>admin_quickreorder/adminhtml_quickreorder</action>
123
+ </quickreorder>
124
+ </children>
125
+ </quickreorder>
126
+ </menu>
127
+ <acl>
128
+ <resources>
129
+ <all>
130
+ <title>Allow Everything</title>
131
+ </all>
132
+ <admin>
133
+ <children>
134
+ <quickreorder translate="title" module="quickreorder">
135
+ <title>Quickreorder</title>
136
+ <sort_order>1000</sort_order>
137
+ <children>
138
+ <quickreorder translate="title">
139
+ <title>Manage Replenish Items</title>
140
+ <sort_order>0</sort_order>
141
+ </quickreorder>
142
+ </children>
143
+ </quickreorder>
144
+ </children>
145
+ </admin>
146
+ </resources>
147
+ </acl>
148
+ <layout>
149
+ <updates>
150
+ <quickreorder>
151
+ <file>quickreorder.xml</file>
152
+ </quickreorder>
153
+ </updates>
154
+ </layout>
155
+ </adminhtml>
156
+ <crontab>
157
+ <jobs>
158
+ <quickreorder>
159
+ <schedule>
160
+ <cron_expr>*/20 * * * * </cron_expr>
161
+ </schedule>
162
+ <run>
163
+ <model>quickreorder/observer::rePlenishEmail</model>
164
+ </run>
165
+ </quickreorder>
166
+ </jobs>
167
+ </crontab>
168
+ </config>
app/code/local/Conversionbug/Quickreorder/etc/system.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <quickreorder translate="label" module="quickreorder">
5
+ <label>Quickreorder</label>
6
+ <tab>cbcore</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>100</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <general translate="label">
14
+ <label>General</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>100</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <fields>
21
+ <status translate="label">
22
+ <label>Enabled</label>
23
+ <frontend_type>select</frontend_type>
24
+ <source_model>adminhtml/system_config_source_yesno</source_model>
25
+ <sort_order>0</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <comment>Enabled/Disabled</comment>
30
+ </status>
31
+ </fields>
32
+ </general>
33
+ </groups>
34
+ </quickreorder>
35
+ </sections>
36
+ </config>
app/code/local/Conversionbug/Quickreorder/sql/quickreorder_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->run("
6
+ CREATE TABLE IF NOT EXISTS {$this->getTable('conversion_quickreorder')} (
7
+ `id` int(11) NOT NULL AUTO_INCREMENT,
8
+ `order_id` int(11) NOT NULL,
9
+ `order_increment_id` varchar(256) NOT NULL,
10
+ `product_id` int(11) NOT NULL,
11
+ `customer_id` int(11) NOT NULL,
12
+ `customer_email` varchar(256) DEFAULT NULL,
13
+ `period` int(11) NOT NULL,
14
+ `total_period` int(11) NOT NULL,
15
+ `replenish_status` tinyint(1) NOT NULL,
16
+ `next_iteration_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
17
+ `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ `updated_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
19
+ PRIMARY KEY (`id`)
20
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
21
+ ");
22
+
23
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
24
+
25
+ /**
26
+ * Adding Different Attributes
27
+ */
28
+
29
+ // adding attribute group
30
+ $setup->addAttributeGroup('catalog_product', 'Default', 'Replenish Attributes', 1000);
31
+
32
+ // the attribute added will be displayed under the group/tab Special Attributes in product edit page
33
+
34
+ $setup->addAttribute('catalog_product', "recurring_status", array(
35
+ 'group' => 'Replenish Attributes',
36
+ 'type' => 'int',//can be int, varchar, decimal, text, datetime
37
+ 'backend' => '',
38
+ 'frontend_input' => '',
39
+ 'frontend' => '',
40
+ 'label' => 'Status',
41
+ 'input' => 'select', //text, textarea, select, file, image, multilselect
42
+ 'default' => array(0),
43
+ 'class' => '',
44
+ 'source' => 'eav/entity_attribute_source_boolean',//this is necessary for select and multilelect, for the rest leave it blank
45
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,//scope can be SCOPE_STORE or SCOPE_GLOBAL or SCOPE_WEBSITE
46
+ 'visible' => true,
47
+ 'frontend_class' => '',
48
+ 'required' => false,//or true
49
+ 'user_defined' => true,
50
+ 'default' => '',
51
+ 'position' => 0,//any number will do
52
+ ));
53
+
54
+ $setup->addAttribute('catalog_product', 'recurring_timespan', array(
55
+ 'group' => 'Replenish Attributes',
56
+ 'input' => 'text',
57
+ 'type' => 'text',
58
+ 'label' => 'Replenish Timespan',
59
+ 'backend' => '',
60
+ 'visible' => 1,
61
+ 'required' => 0,
62
+ 'user_defined' => 1,
63
+ 'searchable' => 1,
64
+ 'filterable' => 0,
65
+ 'comparable' => 1,
66
+ 'visible_on_front' => 1,
67
+ 'visible_in_advanced_search' => 0,
68
+ 'is_html_allowed_on_front' => 0,
69
+ 'note' => 'In Days',
70
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
71
+ ));
72
+
73
+ $setup->addAttribute('catalog_product', 'recurring_total_period', array(
74
+ 'group' => 'Replenish Attributes',
75
+ 'input' => 'text',
76
+ 'type' => 'text',
77
+ 'label' => 'Replenish Total Period',
78
+ 'backend' => '',
79
+ 'visible' => 1,
80
+ 'required' => 0,
81
+ 'user_defined' => 1,
82
+ 'searchable' => 1,
83
+ 'filterable' => 0,
84
+ 'comparable' => 1,
85
+ 'visible_on_front' => 1,
86
+ 'visible_in_advanced_search' => 0,
87
+ 'is_html_allowed_on_front' => 0,
88
+ 'note' => 'In Months',
89
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
90
+ ));
91
+
92
+ $installer->endSetup();
93
+
app/design/adminhtml/default/default/layout/conversionbugcore.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss">
6
+ <name>conversionbug/core/core.css</name>
7
+ </action>
8
+ </reference>
9
+ </default>
10
+ <adminhtml_system_config_edit>
11
+ <reference name="content">
12
+ <block type="cbcore/info" name="cbcore.info" template="conversionbugcore/info.phtml"></block>
13
+ </reference>
14
+ </adminhtml_system_config_edit>
15
+ </layout>
app/design/adminhtml/default/default/layout/quickreorder.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <quickreorder_adminhtml_quickreorder_index>
4
+ <reference name="content">
5
+ <block type="quickreorder/adminhtml_quickreorder" name="quickreorder" />
6
+ </reference>
7
+ </quickreorder_adminhtml_quickreorder_index>
8
+ </layout>
app/design/adminhtml/default/default/template/conversionbugcore/info.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ jQuery(document).ready(function ($) {
4
+ $('.content-header').remove();
5
+ });
6
+ </script>
7
+ <div class="cbstore-block">
8
+ <!--<h3 class="store-extensions-header"><?php echo $this->__('Featured Extensions') ?></h3>-->
9
+ <div class="cb-intro">
10
+ <div class="content">
11
+ <h1>CONVERSIONbug</h1>
12
+ <p>We want to change the way you look at your website</p>
13
+ <p><span>Visit Us: </span><a href="http://www.conversionbug.com/">www.conversionbug.com</a></p>
14
+ <p><span>Contact Us: </span><a href="mailto:support@conversionbug.com">support@conversionbug.com</a></p>
15
+ <p><span>Skype: </span><a href="#">conversionbug</a></p>
16
+ </div>
17
+ <div class="cb-pattern"></div>
18
+ </div>
19
+ <?php
20
+ $collection = $this->getExtensions();
21
+ //echo "<pre>";print_r($collection);
22
+ ?>
23
+
24
+ <?php $i = 0;
25
+ foreach ($collection as $product): ?>
26
+ <?php if ($i == 0) {
27
+ $i++;
28
+ continue;
29
+ } ?>
30
+ <div class="item-extensions">
31
+ <div class="image">
32
+ <a href="<?php echo $product[0] ?>" target="_blank"><img src="<?php echo $product[1] ?>"/></a>
33
+ </div>
34
+ <div class="title">
35
+ <a href="<?php echo $product[0] ?>" target="_blank"><?php echo $product[2] ?></a>
36
+ </div>
37
+ <div class="price">$<?php echo $product[3] ?></div>
38
+ </div>
39
+ <?php ++$i; ?>
40
+ <?php endforeach; ?>
41
+ </div>
42
+
43
+
app/etc/modules/ConversionBug_Core.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ConversionBug
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the ConversionBug.com license that is
9
+ * available through the world-wide-web at this URL:
10
+ * http://www.ConversionBug.com/license-agreement.html
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade this extension to newer
15
+ * version in the future.
16
+ *
17
+ * @category ConversionBug
18
+ * @package ConversionBug_Core
19
+ * @copyright Copyright (c) 2015 ConversionBug (http://www.ConversionBug.com/)
20
+ * @license http://www.ConversionBug.com/license-agreement.html
21
+ * @author shiv kumar singh
22
+ * @email shivam.kumar@conversionbug.com
23
+ */
24
+ -->
25
+ <config>
26
+ <modules>
27
+ <ConversionBug_Core>
28
+ <active>true</active>
29
+ <codePool>local</codePool>
30
+ </ConversionBug_Core>
31
+ </modules>
32
+ </config>
app/etc/modules/Conversionbug_Quickreorder.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Conversionbug_Quickreorder>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Conversionbug_Quickreorder>
8
+ </modules>
9
+ </config>
app/locale/en_US/template/email/replenishmail_notification.html ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@It's almost time to re-order - "{{var product.name}}" @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "var logo_alt":"Email Logo Image Alt",
6
+ "var product.name":"Product Name",
7
+ "var product":"Product Html",
8
+ "var related_products":"Related Product html"}
9
+ @-->
10
+ <!--@styles
11
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
12
+ .product-img-box {width:40%;float:left;}
13
+ .related_products li{float: left;list-style: outside none none;width: 33%;margin-bottom: 15px;text-align: center;}
14
+ @-->
15
+ <body style="background:#F6F6F6; font-family: Arial, serif; font-size:12px; margin:0; padding:0;">
16
+ <div style="background:#F6F6F6; font-family: Arial, serif; font-size:12px; margin:0; padding:0;">
17
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
18
+ <tr>
19
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
20
+ <!-- [ header starts here] -->
21
+ <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="800" style="border:1px solid #E0E0E0;">
22
+ <tr>
23
+ <td valign="top" style="text-align: center;">
24
+ <a href="{{store url=""}}" style="color:#1E7EC8;"><img style="margin: 1% 0px;" src="{{var logo_url}}" alt="{{var logo_alt}}" border="0"/></a>
25
+ <p style="font-size:15px; line-height:16px; margin:16px 0 16px 0; text-align: center;"><span style=" font-size: 25px;">Hey {{var customer_name}},</span><br/></p>
26
+ </td>
27
+ </tr>
28
+ <!-- [ middle starts here] -->
29
+ <tr>
30
+ <td valign="top" style="text-align: center;background: #F6F6F6;border: 16px solid #fff;border-radius: 16px;padding: 35px 10px;">
31
+ {{var product}}
32
+ <br/>
33
+ </td>
34
+ </tr>
35
+ {{var related_products}}
36
+ <tr>
37
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you</p></center></td>
38
+ </tr>
39
+ </table>
40
+ </td>
41
+ </tr>
42
+ </table>
43
+ </div>
44
+
45
+ </body>
media/import/product.csv ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ URL,Prod_Image,Product_Name,Discount_Price
2
+ http://magestore.conversionbug.com/exit-intent-social-popup.html,http://magestore.conversionbug.com/media/catalog/product/b/a/banner_1.png,Social Login With Exit Intent,120
3
+ http://magestore.conversionbug.com/filter-products-by-zip-code.html,http://magestore.conversionbug.com/media/catalog/product/c/b/cb_zip_code_banner_1.png,Filter Products By ZIP code,80
4
+ http://magestore.conversionbug.com/sticky-product.html,http://magestore.conversionbug.com/media/catalog/product/s/t/stickproduct_banner_1.png,Sticky Product Bar,60
5
+ http://magestore.conversionbug.com/replenish-products.html,http://magestore.conversionbug.com/media/catalog/product/b/a/banner_1_1.png,Replenish Products Emailer,75
6
+ http://magestore.conversionbug.com/cookies-based-recently-viewed-products.html,http://magestore.conversionbug.com/media/catalog/product/b/a/banner_1_2.png,Cookies Based Recently Viewed Products,75
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Conversionbug_Quickreorder</name>
4
+ <version>1.0.0</version>
5
+ <stability>devel</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Replenish Products&#xD;
10
+ &#xD;
11
+ For the products which need to be replenished after a certain interval of time, this extension can prove to be really helpful for boosting their sales. The replenish products extension keeps a track of the products bought by the customer and after a certain interval (as decided and entered in advance by the admin), the extension sends the customers a reminder email for buying back the products before it gets over. The replenish products extension is beneficial in the following ways:</summary>
12
+ <description>Replenish Products&#xD;
13
+ &#xD;
14
+ For the products which need to be replenished after a certain interval of time, this extension can prove to be really helpful for boosting their sales. The replenish products extension keeps a track of the products bought by the customer and after a certain interval (as decided and entered in advance by the admin), the extension sends the customers a reminder email for buying back the products before it gets over. The replenish products extension is beneficial in the following ways:</description>
15
+ <notes>first release</notes>
16
+ <authors><author><name>ramu</name><user>ramu</user><email>shivam.kumar@conversionbug.com</email></author></authors>
17
+ <date>2016-05-14</date>
18
+ <time>09:20:38</time>
19
+ <contents><target name="magelocal"><dir name="Conversionbug"><dir name="Quickreorder"><dir name="Block"><dir name="Adminhtml"><dir name="Quickreorder"><dir name="Edit"><file name="Form.php" hash="594459d7f2f4c5fc7403ed027afef673"/><dir name="Tab"><file name="Form.php" hash="fb47f3e558f9fbc96b93156c8218d20c"/></dir><file name="Tabs.php" hash="376f30a5d6c62369cdc079af34f2c013"/></dir><file name="Edit.php" hash="1aaef323e40c0dc3a9da81e75a7bdb94"/><file name="Grid.php" hash="5ab3a1cb81276408d40663f3cceed2a7"/></dir><file name="Quickreorder.php" hash="ececcd88103d2f2307944dde602ce3f0"/></dir><file name="Product.php" hash="1f1e772d21224841b06095cb568e565d"/></dir><dir name="Helper"><file name="Data.php" hash="e933199d99fbf3bfcc1bea6764846205"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Quickreorder"><file name="Collection.php" hash="43c761be75f58369ebee90c4762801df"/></dir><file name="Quickreorder.php" hash="1a39e8610ee7de1759e601ae1710350a"/></dir><file name="Observer.php" hash="6d722ac7c03ce9ae4ab86364739b8316"/><file name="Quickreorder.php" hash="6df41da7da84ad23bf6726c90169563c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="QuickreorderController.php" hash="f49ff203cd92c67933706334172a3388"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0aab0542856704bcb8316d25f113d93e"/><file name="config.xml" hash="2a2dda3c923b8dc3c242b51e32266aaf"/><file name="system.xml" hash="022409bc148d5086511b763e574883b7"/></dir><dir name="sql"><dir name="quickreorder_setup"><file name="mysql4-install-1.0.0.php" hash="4c2cfab86ae07609355d189869623821"/></dir></dir></dir></dir><dir name="ConversionBug"><dir name="Core"><dir name="Block"><file name="Info.php" hash="90e4c31958204ac9e40b2293c6372296"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Fieldset"><file name="Store.php" hash="15df9afac0ea33498b03ad544e0bc8c5"/></dir></dir><file name="Info.php" hash="a0601dea3e6e7d3c3f7f4ac7544dd249"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="fd937326042c8165a1df0faca629db7f"/></dir><dir name="Model"><file name="Feed.php" hash="9266834784c19c05f6cf06a3acc69acc"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Display.php" hash="fd271787952e4f1b1ce98a0a68cb37cb"/><file name="Footer.php" hash="7c13df78247e0cc2fe1e11ddff2cdcdf"/><file name="Options.php" hash="a26a31999e38a540292ff24e5ed33428"/></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="7164e6536faa45bccbf4a09bc6fba886"/><file name="config.xml" hash="c7b1ac437420d8bb3160e561c18d10e6"/><file name="system.xml" hash="8371de258efa47ceff95e858c6c09603"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Conversionbug_Quickreorder.xml" hash="2559a4feba4027178964c2e851dbf5d4"/><file name="ConversionBug_Core.xml" hash="537de773791fc95a5a3e340de82162f7"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="quickreorder.xml" hash="4f233886e49965e9ace14456b88470ae"/><file name="conversionbugcore.xml" hash="12ae2f9f2a96093fcefd593fed15e7b3"/></dir><dir name="template"><dir name="conversionbugcore"><file name="info.phtml" hash="4099f81b6ea49b517ef4354fd8bcb0a2"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="replenishmail_notification.html" hash="a3344e7375ed2d73120076a7a816f92c"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="conversionbug"><dir name="core"><file name="core.css" hash="726ac65a6b5f5aa819cebef92f99c7d4"/><dir name="images"><file name="cb_pattern.png" hash="9c5044bebc10bc6a34aa6a1e8e41b54a"/><file name="favicon.png" hash="bab36888d2974803acc518fc6e80c0a8"/><file name="logo.jpg" hash="04b873540f127f3db2702ec81537a92c"/></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="import"><file name="product.csv" hash="fe4db0faa97e0181d36109d73e2a709d"/></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>
skin/adminhtml/default/default/conversionbug/core/core.css ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .cb-block dl > dt.label{background: #d1dedf url("images/logo.jpg") no-repeat scroll 0px -1px;padding-left: 50px;text-indent: -999em;}
2
+ .cb-intro{background:rgb(25,25,25);height:162px;}
3
+ .cb-pattern{background: url("images/cb_pattern.png") no-repeat;height: 162px;width:39%;float:right}
4
+ .cb-intro .content{float:left;width:56%;padding:10px 10px 10px 30px;color:white;}
5
+ h3.cb-header{background: transparent url("images/favicon.png") no-repeat scroll 0 0;height: 37px;overflow: hidden;padding: 0;text-indent: -9999px;width: 120px;display:none;}
6
+ .cbstore-block .item-extensions {float: left;margin: 0 0 0 70px;min-height: 400px;padding: 24px 0;width: 17%;}
7
+ .cbstore-block .item-extensions .image img {width: 175px;}
8
+ .cbstore-block .item-extensions .title {border-bottom: 1px solid #ededed;margin: 0 0 15px;padding: 31px 0 17px;text-align: center;}
9
+ .cbstore-block .item-extensions .title a {color: #545454;display: block;font-family: Arial;font-size: 16px;font-weight: bold;max-height: 57px;min-height: 57px;overflow: hidden;text-decoration: none;}
10
+ .cbstore-block .item-extensions .title a:hover {color: #d4022e;}
11
+ .cbstore-block .item-extensions .price {color: #000000;font-size: 20px;font-weight: bold;text-align: center;}
12
+ .cbstore-block .store-extensions-header {border-bottom: 1px dashed #dddddd;font-family: Arial;font-size: 1.6666em;line-height: 1.25em;margin-left: 70px;padding-bottom: 30px;padding-top: 7px;}
skin/adminhtml/default/default/conversionbug/core/images/cb_pattern.png ADDED
Binary file
skin/adminhtml/default/default/conversionbug/core/images/favicon.png ADDED
Binary file
skin/adminhtml/default/default/conversionbug/core/images/logo.jpg ADDED
Binary file