Jewelerslink_Jewelryshare - Version 0.1.0

Version Notes

Share Jewelry Products to Jewelrslink.
Includes importing product from jewerlslink and Exporting products to Jewelerslink with attributes mapping functions.

Download this release

Release Info

Developer John Dorsey
Extension Jewelerslink_Jewelryshare
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (46) hide show
  1. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Edit/Codes.php +64 -0
  2. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Edit/Codes/Edit/Form.php +124 -0
  3. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare.php +12 -0
  4. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit.php +38 -0
  5. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Form.php +19 -0
  6. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Import.php +11 -0
  7. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Priceincrease.php +10 -0
  8. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Update.php +11 -0
  9. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Vendor.php +10 -0
  10. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tabs.php +42 -0
  11. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Codes.php +55 -0
  12. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Codes/Grid.php +131 -0
  13. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Items.php +51 -0
  14. app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Items/Grid.php +188 -0
  15. app/code/community/Jewelerslink/Jewelryshare/Block/Jewelryshare.php +17 -0
  16. app/code/community/Jewelerslink/Jewelryshare/Helper/Data.php +43 -0
  17. app/code/community/Jewelerslink/Jewelryshare/Model/Adminhtml/System/Source/Cron/Frequency.php +63 -0
  18. app/code/community/Jewelerslink/Jewelryshare/Model/Adminhtml/System/Source/Cron/Hours.php +50 -0
  19. app/code/community/Jewelerslink/Jewelryshare/Model/Codes.php +43 -0
  20. app/code/community/Jewelerslink/Jewelryshare/Model/Import.php +352 -0
  21. app/code/community/Jewelerslink/Jewelryshare/Model/Importcron.php +359 -0
  22. app/code/community/Jewelerslink/Jewelryshare/Model/Jewelryshare.php +10 -0
  23. app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Codes.php +35 -0
  24. app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Codes/Collection.php +36 -0
  25. app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Jewelryshare.php +10 -0
  26. app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Jewelryshare/Collection.php +10 -0
  27. app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Setup.php +36 -0
  28. app/code/community/Jewelerslink/Jewelryshare/Model/Observer.php +92 -0
  29. app/code/community/Jewelerslink/Jewelryshare/Model/Resource/Codes.php +42 -0
  30. app/code/community/Jewelerslink/Jewelryshare/Model/Resource/Codes/Collection.php +55 -0
  31. app/code/community/Jewelerslink/Jewelryshare/Model/Resource/Setup.php +36 -0
  32. app/code/community/Jewelerslink/Jewelryshare/Model/Status.php +15 -0
  33. app/code/community/Jewelerslink/Jewelryshare/controllers/Adminhtml/Jewelryshare/Codes/GridController.php +161 -0
  34. app/code/community/Jewelerslink/Jewelryshare/controllers/Adminhtml/Jewelryshare/Items/GridController.php +154 -0
  35. app/code/community/Jewelerslink/Jewelryshare/controllers/Adminhtml/JewelryshareController.php +1179 -0
  36. app/code/community/Jewelerslink/Jewelryshare/etc/config.xml +372 -0
  37. app/code/community/Jewelerslink/Jewelryshare/etc/system.xml +113 -0
  38. app/code/community/Jewelerslink/Jewelryshare/sql/jewelryshare_setup/mysql4-install-0.1.0.php +73 -0
  39. app/design/adminhtml/default/jewelerslink/layout/jewelryshare.xml +33 -0
  40. app/etc/modules/Jewelerslink_Jewelryshare.xml +9 -0
  41. js/jewelerslink/btn_bg.gif +0 -0
  42. js/jewelerslink/content_bg.gif +0 -0
  43. js/jewelerslink/jewelerslink.css +39 -0
  44. js/jewelerslink/top_bg.gif +0 -0
  45. js/jewelerslink/window_close.png +0 -0
  46. package.xml +20 -0
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Edit/Codes.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Attribute map edit codes form container block
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Edit_Codes extends Mage_Adminhtml_Block_Widget_Form_Container
36
+ {
37
+ /**
38
+ * Initialize form container
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ $this->_blockGroup = 'jewelryshare';
44
+ $this->_controller = 'adminhtml_edit_codes';
45
+
46
+ parent::__construct();
47
+
48
+ $this->_removeButton('back');
49
+ $url = $this->getUrl('*/adminhtml_jewelryshare_codes_grid/saveForm');
50
+ $this->_updateButton('save', 'onclick', 'saveNewImportItem(\''.$url.'\')');
51
+ $this->_updateButton('reset', 'label', 'Close');
52
+ $this->_updateButton('reset', 'onclick', 'closeNewImportItem()');
53
+ }
54
+
55
+ /**
56
+ * Return Form Header text
57
+ *
58
+ * @return string
59
+ */
60
+ public function getHeaderText()
61
+ {
62
+ return Mage::helper('jewelryshare')->__('Import attribute map');
63
+ }
64
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Edit/Codes/Edit/Form.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Attribute map edit form container block
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Edit_Codes_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36
+ {
37
+ /**
38
+ * Import codes list
39
+ *
40
+ * @return array
41
+ */
42
+ protected function _getImportCodeList()
43
+ {
44
+ $attributes = Mage::getConfig()->getNode(Jewelerslink_Jewelryshare_Model_Import::XML_NODE_FIND_FEED_ATTRIBUTES)->children();
45
+ $result = array();
46
+ foreach ($attributes as $node) {
47
+ $label = trim((string)$node->label);
48
+ if ($label) {
49
+ $result[$label] = $label;
50
+ }
51
+ }
52
+
53
+ return $result;
54
+ }
55
+
56
+ /**
57
+ * Magento entity type list for eav attributes
58
+ *
59
+ * @return array
60
+ */
61
+ protected function _getCatalogEntityType()
62
+ {
63
+ return Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getId();
64
+ }
65
+
66
+
67
+ /**
68
+ * Magento eav attributes list
69
+ *
70
+ * @return array
71
+ */
72
+ protected function _getEavAttributeList()
73
+ {
74
+ $result = array();
75
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection');
76
+ foreach ($collection as $model) {
77
+ $result[$model->getAttributeCode()] = $model->getAttributeCode();
78
+ }
79
+ return $result;
80
+ }
81
+
82
+ /**
83
+ * Prepare form
84
+ *
85
+ * @return Varien_Object
86
+ */
87
+ protected function _prepareForm()
88
+ {
89
+ $form = new Varien_Data_Form(array(
90
+ 'id' => 'import_item_form',
91
+ 'method' => 'post'
92
+ ));
93
+
94
+ $fieldset = $form->addFieldset('generate_fieldset', array(
95
+ 'legend' => Mage::helper('jewelryshare')->__('Item params')
96
+ ));
97
+ $fieldset->addField('import_code', 'select', array(
98
+ 'label' => Mage::helper('jewelryshare')->__('JewelersLink Code'),
99
+ 'name' => 'import_code',
100
+ 'required' => true,
101
+ 'options' => $this->_getImportCodeList()
102
+ ));
103
+ $fieldset->addField('eav_code', 'select', array(
104
+ 'label' => Mage::helper('jewelryshare')->__('Site attribute code'),
105
+ 'name' => 'eav_code',
106
+ 'required' => true,
107
+ 'options' => $this->_getEavAttributeList()
108
+ ));
109
+
110
+ $source = Mage::getModel('eav/entity_attribute_source_boolean');
111
+ $isImportedOptions = $source->getOptionArray();
112
+
113
+ $fieldset->addField('jewelry_imported', 'select', array(
114
+ 'label' => Mage::helper('jewelryshare')->__('Is imported'),
115
+ 'name' => 'jewelry_imported',
116
+ 'value' => 1,
117
+ 'options' => $isImportedOptions
118
+ ));
119
+ $form->setUseContainer(true);
120
+
121
+ $this->setForm($form);
122
+ return parent::_prepareForm();
123
+ }
124
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_jewelryshare';
7
+ $this->_blockGroup = 'jewelryshare';
8
+ $this->_headerText = Mage::helper('jewelryshare')->__('Jewelry Manager');
9
+ $this->_addButtonLabel = Mage::helper('jewelryshare')->__('Manage Jewelry');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'jewelryshare';
11
+ $this->_controller = 'adminhtml_jewelryshare';
12
+ $this->_removeButton('reset');
13
+ $this->_removeButton('back');
14
+ $this->_updateButton('save', 'label', Mage::helper('jewelryshare')->__('Save'));
15
+
16
+ /* $this->_addButton('disable_older', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Disable Old Products'),
18
+ 'onclick' => 'setLocation(\''.$this->getUrl('jewelryshare/adminhtml_jewelryshare/disableOlder', array('_current'=>true)).'\')',
19
+ 'class' => 'delete',
20
+ ), -100); */
21
+
22
+ $this->_addButton('restore_price_increase', array(
23
+ 'label' => Mage::helper('adminhtml')->__('Restore Price Increase'),
24
+ 'onclick' => 'setLocation(\''.$this->getUrl('jewelryshare/adminhtml_jewelryshare/restorePriceIncrease', array('_current'=>true)).'\')',
25
+ 'class' => 'delete',
26
+ ), -100);
27
+ }
28
+
29
+ protected function _prepareLayout()
30
+ {
31
+ return parent::_prepareLayout();
32
+ }
33
+
34
+ public function getHeaderText()
35
+ {
36
+ return Mage::helper('jewelryshare')->__('Manage Jewelry');
37
+ }
38
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Import.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit_Tab_Import extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('jewelryshare/tab/import.phtml');
9
+ }
10
+ }
11
+ ?>
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Priceincrease.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit_Tab_Priceincrease extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('jewelryshare/tab/priceincrease.phtml');
9
+ }
10
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Update.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit_Tab_Update extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('jewelryshare/tab/update.phtml');
9
+ }
10
+ }
11
+ ?>
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tab/Vendor.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit_Tab_Vendor extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('jewelryshare/tab/vendor.phtml');
9
+ }
10
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/Jewelryshare/Edit/Tabs.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_Jewelryshare_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('jewelryshare_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('jewelryshare')->__('Item Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('priceincrease', array(
17
+ 'label' => Mage::helper('jewelryshare')->__('Jewelry Price Increase'),
18
+ 'title' => Mage::helper('jewelryshare')->__('Jewelry Price Increase'),
19
+ 'content' => $this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit_tab_priceincrease')->toHtml(),
20
+ ));
21
+
22
+ $this->addTab('vendor', array(
23
+ 'label' => Mage::helper('jewelryshare')->__('Manage Vendors'),
24
+ 'title' => Mage::helper('jewelryshare')->__('Manage Vendors'),
25
+ 'content' => $this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit_tab_vendor')->toHtml(),
26
+ ));
27
+
28
+ $this->addTab('import', array(
29
+ 'label' => Mage::helper('jewelryshare')->__('Import Products'),
30
+ 'title' => Mage::helper('jewelryshare')->__('Import Products'),
31
+ 'content' => $this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit_tab_import')->toHtml(),
32
+ ));
33
+
34
+ $this->addTab('update', array(
35
+ 'label' => Mage::helper('jewelryshare')->__('Update Products'),
36
+ 'title' => Mage::helper('jewelryshare')->__('Update Products'),
37
+ 'content' => $this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit_tab_update')->toHtml(),
38
+ ));
39
+
40
+ return parent::_beforeToHtml();
41
+ }
42
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Codes.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * TheJewelerslink jewelryshare attribute map grid container
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_List_Codes extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+ /**
38
+ * Initialize grid container settings
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+
44
+ $this->_blockGroup = 'jewelryshare';
45
+ $this->_controller = 'adminhtml_list_codes';
46
+ $this->_headerText = Mage::helper('jewelryshare')->__('Attributes map');
47
+ $this->_addButtonLabel = Mage::helper('jewelryshare')->__('Add new');
48
+
49
+ parent::__construct();
50
+
51
+
52
+ $url = $this->getUrl('*/adminhtml_jewelryshare_codes_grid/editForm');
53
+ $this->_updateButton('add', 'onclick', 'openNewImportWindow(\''.$url.'\');');
54
+ }
55
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Codes/Grid.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * TheJewelerslink jewelryshare attribute map Grid
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_List_Codes_Grid extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ /**
38
+ * Initialize grid settings
39
+ *
40
+ */
41
+ protected function _construct()
42
+ {
43
+ parent::_construct();
44
+
45
+ $this->setId('jewelryshare_list_codes');
46
+ $this->setUseAjax(true);
47
+ }
48
+
49
+ /**
50
+ * Prepare codes collection
51
+ *
52
+ * @return Jewelerslink_Jewelryshare_Block_Adminhtml_List_Codes_Grid
53
+ */
54
+ protected function _prepareCollection()
55
+ {
56
+ $collection = Mage::getResourceModel('jewelerslink_jewelryshare/codes_collection');
57
+ $this->setCollection($collection);
58
+ return parent::_prepareCollection();
59
+ }
60
+
61
+ /**
62
+ * Configuration of grid
63
+ *
64
+ * @return $this
65
+ */
66
+ protected function _prepareColumns()
67
+ {
68
+ $this->addColumn('import_code', array(
69
+ 'header'=> Mage::helper('jewelryshare')->__('JewelersLink Code'),
70
+ 'width' => '80px',
71
+ 'type' => 'text',
72
+ 'index' => 'import_code'
73
+ ));
74
+
75
+ $this->addColumn('eav_code', array(
76
+ 'header'=> Mage::helper('jewelryshare')->__('Site attribute code'),
77
+ 'width' => '80px',
78
+ 'type' => 'text',
79
+ 'index' => 'eav_code'
80
+ ));
81
+
82
+ $source = Mage::getModel('eav/entity_attribute_source_boolean');
83
+ $isImportedOptions = $source->getOptionArray();
84
+
85
+ $this->addColumn('jewelry_imported', array(
86
+ 'header' => Mage::helper('jewelryshare')->__('Publish In Jewelerslink'),
87
+ 'width' => '100px',
88
+ 'index' => 'jewelry_imported',
89
+ 'type' => 'options',
90
+ 'options' => $isImportedOptions
91
+ ));
92
+ return parent::_prepareColumns();
93
+ }
94
+
95
+ /**
96
+ * Prepare massaction
97
+ *
98
+ * @return $this
99
+ */
100
+ protected function _prepareMassaction()
101
+ {
102
+ $this->setMassactionIdField('code_id');
103
+ $this->getMassactionBlock()->setFormFieldName('code_id');
104
+
105
+ //$this->getMassactionBlock()->addItem('enable', array(
106
+ // 'label' => Mage::helper('jewelryshare')->__('Import'),
107
+ // 'url' => $this->getUrl('*/codes_grid/massEnable'),
108
+ // 'selected' => true,
109
+ //));
110
+ //$this->getMassactionBlock()->addItem('disable', array(
111
+ // 'label' => Mage::helper('jewelryshare')->__('Not import'),
112
+ // 'url' => $this->getUrl('*/codes_grid/massDisable'),
113
+ //));
114
+ $this->getMassactionBlock()->addItem('delete', array(
115
+ 'label' => Mage::helper('jewelryshare')->__('Delete'),
116
+ 'url' => $this->getUrl('*/adminhtml_jewelryshare_codes_grid/delete'),
117
+ ));
118
+
119
+ return $this;
120
+ }
121
+
122
+ /**
123
+ * Return Grid URL for AJAX query
124
+ *
125
+ * @return string
126
+ */
127
+ public function getGridUrl()
128
+ {
129
+ return $this->getUrl('*/*/grid', array('_current'=>true));
130
+ }
131
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Items.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * TheJewelerslink jewelryshare product grid container
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_List_Items extends Mage_Adminhtml_Block_Widget_Grid_Container
36
+ {
37
+ /**
38
+ * Initialize grid container settings
39
+ *
40
+ */
41
+ public function __construct()
42
+ {
43
+ $this->_blockGroup = 'jewelryshare';
44
+ $this->_controller = 'adminhtml_list_items';
45
+ $this->_headerText = Mage::helper('jewelryshare')->__('Select products to be exported to jewelerslink');
46
+
47
+ parent::__construct();
48
+
49
+ $this->_removeButton('add');
50
+ }
51
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Adminhtml/List/Items/Grid.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * TheJewelerslink jewelryshare product grid container
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Jewelerslink_Jewelryshare_Block_Adminhtml_List_Items_Grid extends Mage_Adminhtml_Block_Widget_Grid
36
+ {
37
+ /**
38
+ * Initialize grid settings
39
+ *
40
+ */
41
+ protected function _construct()
42
+ {
43
+ parent::_construct();
44
+
45
+ $this->setId('jewelryshare_list_items');
46
+ $this->setDefaultSort('id');
47
+ $this->setUseAjax(true);
48
+ }
49
+
50
+ /**
51
+ * Return Current work store
52
+ *
53
+ * @return Mage_Core_Model_Store
54
+ */
55
+ protected function _getStore()
56
+ {
57
+ return Mage::app()->getStore();
58
+ }
59
+
60
+ /**
61
+ * Prepare product collection
62
+ *
63
+ * @return Jewelerslink_Jewelryshare_Block_Adminhtml_List_Items_Grid
64
+ */
65
+ protected function _prepareCollection()
66
+ {
67
+ $collection = Mage::getModel('catalog/product')->getCollection()
68
+ ->setStore($this->_getStore())
69
+ ->addAttributeToSelect('name')
70
+ ->addAttributeToSelect('sku')
71
+ ->addAttributeToSelect('price')
72
+ ->addAttributeToSelect('attribute_set_id')
73
+ ->addAttributeToSelect('jewelry_imported');
74
+ $this->setCollection($collection);
75
+
76
+ return parent::_prepareCollection();
77
+ }
78
+
79
+ /**
80
+ * Prepare grid columns
81
+ *
82
+ * @return Jewelerslink_Jewelryshare_Block_Adminhtml_List_Items_Grid
83
+ */
84
+ protected function _prepareColumns()
85
+ {
86
+ $this->addColumn('id', array(
87
+ 'header' => Mage::helper('jewelryshare')->__('ID'),
88
+ 'sortable' => true,
89
+ 'width' => '60px',
90
+ 'index' => 'entity_id'
91
+ ));
92
+
93
+ $this->addColumn('name', array(
94
+ 'header' => Mage::helper('jewelryshare')->__('Product Name'),
95
+ 'index' => 'name',
96
+ 'column_css_class' => 'name'
97
+ ));
98
+
99
+ $this->addColumn('type', array(
100
+ 'header' => Mage::helper('jewelryshare')->__('Type'),
101
+ 'width' => '60px',
102
+ 'index' => 'type_id',
103
+ 'type' => 'options',
104
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
105
+ ));
106
+
107
+ $entityTypeId = Mage::helper('jewelryshare')->getProductEntityType();
108
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
109
+ ->setEntityTypeFilter($entityTypeId)
110
+ ->load()
111
+ ->toOptionHash();
112
+
113
+ $this->addColumn('set_name', array(
114
+ 'header' => Mage::helper('jewelryshare')->__('Attrib. Set Name'),
115
+ 'width' => '100px',
116
+ 'index' => 'attribute_set_id',
117
+ 'type' => 'options',
118
+ 'options' => $sets,
119
+ ));
120
+
121
+ $this->addColumn('sku', array(
122
+ 'header' => Mage::helper('jewelryshare')->__('SKU'),
123
+ 'width' => '80px',
124
+ 'index' => 'sku',
125
+ 'column_css_class' => 'sku'
126
+ ));
127
+
128
+ $this->addColumn('price', array(
129
+ 'header' => Mage::helper('jewelryshare')->__('Price'),
130
+ 'align' => 'center',
131
+ 'type' => 'currency',
132
+ 'currency_code' => $this->_getStore()->getCurrentCurrencyCode(),
133
+ 'rate' => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getCurrentCurrencyCode()),
134
+ 'index' => 'price'
135
+ ));
136
+
137
+ $source = Mage::getModel('eav/entity_attribute_source_boolean');
138
+ $isImportedOptions = $source->getOptionArray();
139
+
140
+ $this->addColumn('jewelry_imported', array(
141
+ 'header' => Mage::helper('jewelryshare')->__('Publish In Jewelerslink'),
142
+ 'width' => '100px',
143
+ 'index' => 'jewelry_imported',
144
+ 'type' => 'options',
145
+ 'options' => $isImportedOptions
146
+ ));
147
+
148
+ return parent::_prepareColumns();
149
+ }
150
+
151
+ /**
152
+ * Prepare massaction
153
+ *
154
+ * @return Jewelerslink_Jewelryshare_Block_Adminhtml_List_Items_Grid
155
+ */
156
+ protected function _prepareMassaction()
157
+ {
158
+ $this->setMassactionIdField('entity_id');
159
+ $this->getMassactionBlock()->setFormFieldName('item_id');
160
+
161
+ $this->getMassactionBlock()->addItem('enable', array(
162
+ 'label' => Mage::helper('jewelryshare')->__('Publish to Jewelerslink'),
163
+ 'url' => $this->getUrl('*/adminhtml_jewelryshare_items_grid/massEnable'),
164
+ //'selected' => true,
165
+ ));
166
+ $this->getMassactionBlock()->addItem('disable', array(
167
+ 'label' => Mage::helper('jewelryshare')->__("Don't publish to Jewelerslink"),
168
+ 'url' => $this->getUrl('*/adminhtml_jewelryshare_items_grid/massDisable'),
169
+ ));
170
+
171
+ $this->getMassactionBlock()->addItem('jw_export', array(
172
+ 'label' => Mage::helper('jewelryshare')->__('Export published products to Jewelerslink'),
173
+ 'url' => $this->getUrl('*/adminhtml_jewelryshare_items_grid/massJwExport'),
174
+ ));
175
+
176
+ return $this;
177
+ }
178
+
179
+ /**
180
+ * Return Grid URL for AJAX query
181
+ *
182
+ * @return string
183
+ */
184
+ public function getGridUrl()
185
+ {
186
+ return $this->getUrl('*/*/grid', array('_current'=>true));
187
+ }
188
+ }
app/code/community/Jewelerslink/Jewelryshare/Block/Jewelryshare.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Jewelerslink_Jewelryshare_Block_Jewelryshare extends Mage_Core_Block_Template
3
+ {
4
+ public function _prepareLayout()
5
+ {
6
+ return parent::_prepareLayout();
7
+ }
8
+
9
+ public function getJewelryshare()
10
+ {
11
+ if (!$this->hasData('jewelryshare')) {
12
+ $this->setData('jewelryshare', Mage::registry('jewelryshare'));
13
+ }
14
+ return $this->getData('jewelryshare');
15
+
16
+ }
17
+ }
app/code/community/Jewelerslink/Jewelryshare/Helper/Data.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * Checking if some required attributes missed
7
+ *
8
+ * @param array $attributes
9
+ * @return bool
10
+ */
11
+ public function checkRequired($attributes)
12
+ {
13
+ return true;
14
+
15
+ $attributeConfig = Mage::getConfig()->getNode(Jewelerslink_Jewelryshare_Model_Import::XML_NODE_FIND_FEED_ATTRIBUTES);
16
+ $attributeRequired = array();
17
+ foreach ($attributeConfig->children() as $ac) {
18
+ if ((int)$ac->required) {
19
+ $attributeRequired[] = (string)$ac->label;
20
+ }
21
+ }
22
+
23
+ //echo "<pre>"; print_r($attributeRequired); exit;
24
+
25
+ foreach ($attributeRequired as $value) {
26
+ if (!isset($attributes[$value])) {
27
+ return false;
28
+ }
29
+ }
30
+ return true;
31
+ }
32
+
33
+ /**
34
+ * Product entity type
35
+ *
36
+ * @return int
37
+ */
38
+ public function getProductEntityType()
39
+ {
40
+ return Mage::getSingleton('eav/config')->getEntityType('catalog_product')->getId();
41
+ }
42
+
43
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Adminhtml/System/Source/Cron/Frequency.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Source for cron frequency
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ */
34
+ class Jewelerslink_Jewelryshare_Model_Adminhtml_System_Source_Cron_Frequency
35
+ {
36
+ const DAILY = 1;
37
+ const WEEKLY = 2;
38
+ const MONTHLY = 3;
39
+ const EVERY_MINUTE = 4;
40
+
41
+ /**
42
+ * Fetch options array
43
+ *
44
+ * @return array
45
+ */
46
+ public function toOptionArray()
47
+ {
48
+ return array(
49
+ array(
50
+ 'label' => 'Daily',
51
+ 'value' => self::DAILY),
52
+ array(
53
+ 'label' => 'Weekly',
54
+ 'value' => self::WEEKLY),
55
+ array(
56
+ 'label' => 'Monthly',
57
+ 'value' => self::MONTHLY),
58
+ array(
59
+ 'label' => 'Every minute',
60
+ 'value' => self::EVERY_MINUTE)
61
+ );
62
+ }
63
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Adminhtml/System/Source/Cron/Hours.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Source for cron hours
30
+ *
31
+ * @category Jewelerslink
32
+ * @package Jewelerslink_Jewelryshare
33
+ */
34
+ class Jewelerslink_Jewelryshare_Model_Adminhtml_System_Source_Cron_Hours
35
+ {
36
+
37
+ /**
38
+ * Fetch options array
39
+ *
40
+ * @return array
41
+ */
42
+ public function toOptionArray()
43
+ {
44
+ $hours = array();
45
+ for ($i = 1; $i <= 24; $i++) {
46
+ $hours[] = array('label' => $i, 'value' => $i);
47
+ }
48
+ return $hours;
49
+ }
50
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Codes.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jwshare attribute map grid container
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Codes extends Mage_Core_Model_Abstract
34
+ {
35
+ /**
36
+ * Local constructor
37
+ *
38
+ */
39
+ protected function _construct()
40
+ {
41
+ $this->_init('jewelerslink_jewelryshare/codes');
42
+ }
43
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Import.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jewelryshare import model
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Import extends Mage_Core_Model_Abstract
34
+ {
35
+ //const SEPARATOR = "\t";
36
+ const LINE_END = "\r\n";
37
+ const ENCLOSURE = '"';
38
+ const SEPARATOR = ',';
39
+ const COLLECTION_PAGE_SIZE = 5000;
40
+
41
+ const XML_PATH_SETTINGS_FTP_SERVER = 'jewelryshare/settings/ftp_server';
42
+ const XML_PATH_SETTINGS_FTP_USER = 'jewelryshare/settings/ftp_user';
43
+ const XML_PATH_SETTINGS_FTP_PASSWORD = 'jewelryshare/settings/ftp_password';
44
+ //const XML_PATH_SETTINGS_FTP_PATH = 'jewelryshare/settings/ftp_path';
45
+ //const XML_PATH_SETTINGS_FINDFEED_FILENAME = 'jewelryshare/settings/jewelerslinkjewelryshare_filename';
46
+ const XML_NODE_FIND_FEED_ATTRIBUTES = 'jewelerslink_jewelryshare_attributes';
47
+
48
+ /**
49
+ * Attribute sources
50
+ *
51
+ * @var array
52
+ */
53
+ protected $_attributeSources = array();
54
+
55
+ /**
56
+ * Cron action
57
+ */
58
+ public function dispatch()
59
+ {
60
+ $this->processImport();
61
+ }
62
+
63
+ /**
64
+ * TheJewelerslink jewelryshare process import
65
+ */
66
+ public function processImport()
67
+ {
68
+ $file = $this->_createFile();
69
+ if ($file) {
70
+ $this->_deleteFtpFiles();
71
+ $this->_sendFile($file);
72
+ if (!$this->_deleteFile($file)) {
73
+ Mage::throwException(Mage::helper('jewelryshare')->__("FTP: Can't delete files"));
74
+ }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Create temp csv file and write export
80
+ *
81
+ * @return mixed
82
+ */
83
+ protected function _createFile()
84
+ {
85
+
86
+
87
+ $dir = $this->_getTmpDir();
88
+ $customerId = $this->getJwCustomerId();
89
+
90
+ $fileName = $customerId.".csv";
91
+
92
+ if (!$dir || !$customerId) {
93
+ return false;
94
+ }
95
+ //echo count($this->_getImportAttributes());exit;
96
+
97
+ if (!($attributes = $this->_getImportAttributes()) || count($attributes) <= 0) {
98
+ return false;
99
+ }
100
+ $headers = array_keys($attributes);
101
+
102
+ $file = new Varien_Io_File;
103
+ $file->checkAndCreateFolder($dir);
104
+ $file->cd($dir);
105
+ $file->streamOpen($fileName, 'w+');
106
+ $file->streamLock();
107
+
108
+ //echo "<pre>"; print_r($headers); exit;
109
+ $file->streamWriteCsv($headers, self::SEPARATOR, self::ENCLOSURE);
110
+
111
+ $productCollectionPrototype = Mage::getResourceModel('catalog/product_collection');
112
+ $productCollectionPrototype->setPageSize(self::COLLECTION_PAGE_SIZE);
113
+ $pageNumbers = $productCollectionPrototype->getLastPageNumber();
114
+ unset($productCollectionPrototype);
115
+
116
+ for ($i = 1; $i <= $pageNumbers; $i++) {
117
+ $productCollection = Mage::getResourceModel('catalog/product_collection');
118
+ $productCollection->addAttributeToSelect($attributes);
119
+ $productCollection->addAttributeToFilter('is_imported', 1);
120
+ $productCollection->setPageSize(self::COLLECTION_PAGE_SIZE);
121
+ $productCollection->setCurPage($i)->load();
122
+ //echo "<pre>"; print_r($productCollection->getData()); exit;
123
+
124
+ foreach ($productCollection as $product) {
125
+ $attributesRow = array();
126
+ foreach ($attributes as $key => $value) {
127
+ if ($this->_checkAttributeSource($product, $value)) {
128
+ if (is_array($product->getAttributeText($value))) {
129
+ $attributesRow[$key] = implode(', ', $product->getAttributeText($value));
130
+ } else {
131
+ $attributesRow[$key] = $product->getAttributeText($value);
132
+ }
133
+ } else {
134
+ if($key == 'image' || $key == 'small_image' || $key == 'thumbnail') {
135
+ $siteUrl = str_replace("/index.php/","",Mage::getBaseUrl());
136
+ $imageUrl = $siteUrl."/media/catalog/product/";
137
+ $attributesRow[$key] = $imageUrl.$product->getData($value);
138
+ } else if($key == 'gallery') {
139
+ $_product = Mage::getModel('catalog/product')->load($product->getId());
140
+ $galleryArray = array();
141
+ $galleryString = "";
142
+ if($gallery = $_product->getMediaGalleryImages()) {
143
+ //echo "<pre>"; print_r($gallery);exit;
144
+ foreach ($gallery as $image) {
145
+ $exlode = explode("media/catalog/product",$image->getUrl());
146
+ $galleryPart = $exlode[1];
147
+ //echo $galleryPart."==".$_product->getImage(); exit;
148
+ if($galleryPart == $_product->getImage() || $galleryPart == $_product->getSmallImage() || $galleryPart == $_product->getThumbnail()) {
149
+ continue;
150
+ }
151
+ $galleryArray[] = $image->getUrl();
152
+ }
153
+ $galleryString = implode(";",$galleryArray);
154
+ }
155
+ $attributesRow[$key] = $galleryString;
156
+ } else {
157
+ $attributesRow[$key] = $product->getData($value);
158
+ }
159
+ }
160
+ }
161
+
162
+ //echo "<pre>"; print_r($attributesRow); //exit;
163
+
164
+ $file->streamWriteCsv($attributesRow, self::SEPARATOR, self::ENCLOSURE);
165
+ }
166
+ unset($productCollection);
167
+ }
168
+ //exit;
169
+ $file->streamUnlock();
170
+ $file->streamClose();
171
+
172
+ if ($file->fileExists($fileName)) {
173
+ return $fileName;
174
+ }
175
+ return false;
176
+ }
177
+
178
+ /**
179
+ * Check attribute source
180
+ *
181
+ * @param Mage_Catalog_Model_Product $product
182
+ * @param string $value
183
+ * @return bool
184
+ */
185
+ protected function _checkAttributeSource($product, $value)
186
+ {
187
+ if (!array_key_exists($value, $this->_attributeSources)) {
188
+ $this->_attributeSources[$value] = $product->getResource()->getAttribute($value)->usesSource();
189
+ }
190
+ return $this->_attributeSources[$value];
191
+ }
192
+
193
+ /**
194
+ * List import codes (attribute map) model
195
+ *
196
+ * @return mixed
197
+ */
198
+ protected function _getImportAttributes()
199
+ {
200
+ $attributes = Mage::getResourceModel('jewelerslink_jewelryshare/codes_collection')
201
+ ->getImportAttributes();
202
+
203
+ if (!Mage::helper('jewelryshare')->checkRequired($attributes)) {
204
+ return false;
205
+ }
206
+ return $attributes;
207
+ }
208
+
209
+ /**
210
+ * Send file to remote ftp server
211
+ *
212
+ * @param string $fileName
213
+ */
214
+ protected function _sendFile($fileName)
215
+ {
216
+ $dir = $this->_getTmpDir();
217
+ $ftpServer = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_SERVER);
218
+ $ftpUserName = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_USER);
219
+ $ftpPass = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_PASSWORD);
220
+
221
+ $ftpPath = '/';
222
+ // set up basic connection
223
+ $conn_id = ftp_connect($ftpServer);
224
+
225
+ // login with username and password
226
+ $login_result = ftp_login($conn_id, $ftpUserName, $ftpPass);
227
+ //echo $login_result."==".$conn_id."==".$ftpPath.$fileName."==".$dir.$fileName; exit;
228
+ ftp_pasv($conn_id, true);
229
+
230
+ if(ftp_put($conn_id, $ftpPath.$fileName, $dir.$fileName, FTP_BINARY)) {
231
+ Mage::getSingleton("adminhtml/session")->addSuccess("csv exported to jewelerslink successfully.");
232
+ //echo "csv exported to jewelerslink successfully.";
233
+ } else {
234
+ Mage::getSingleton("adminhtml/session")->addError("There was a problem exporting csv to jewelerslink.");
235
+ //echo "There was a problem exporting csv to jewelerslink.";
236
+ }
237
+ // close the connection
238
+ ftp_close($conn_id);
239
+ }
240
+
241
+ /**
242
+ * Delete all files in current jewelryshare ftp directory
243
+ *
244
+ * @return bool
245
+ */
246
+ protected function _deleteFtpFiles()
247
+ {
248
+ if (is_callable('ftp_connect')) {
249
+
250
+ $ftpServer = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_SERVER);
251
+ $ftpUserName = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_USER);
252
+ $ftpPass = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_PASSWORD);
253
+
254
+ $ftpPath = '/';
255
+
256
+ try {
257
+ $connId = ftp_connect($ftpServer);
258
+
259
+ $loginResult = ftp_login($connId, $ftpUserName, $ftpPass);
260
+ //echo $loginResult; exit;
261
+
262
+ if (!$loginResult) {
263
+ return false;
264
+ }
265
+ ftp_pasv($connId, true);
266
+
267
+ $ftpDir = $ftpPath?$ftpPath:'.';
268
+ $nlist = ftp_nlist($connId, $ftpDir);
269
+ if ($nlist === false) {
270
+ return false;
271
+ }
272
+ //echo "<pre>"; print_r($nlist); exit;
273
+
274
+ foreach ($nlist as $file) {
275
+ if (!preg_match('/\.[xX][mM][lL]$/', $file)) {
276
+
277
+ if($file != '/..' && $file != '/.') {
278
+ ftp_delete($connId, $file);
279
+ }
280
+
281
+ }
282
+ }
283
+
284
+ ftp_close($connId);
285
+ } catch (Exception $e) {
286
+ Mage::log($e->getMessage());
287
+ return false;
288
+ }
289
+ return true;
290
+ } else {
291
+ return false;
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Current tmp directory
297
+ *
298
+ * @return string
299
+ */
300
+ protected function _getTmpDir()
301
+ {
302
+ return Mage::getBaseDir('var') . DS . 'export' . DS . 'jewelryshare' . DS;
303
+ }
304
+
305
+ /**
306
+ * Delete tmp file
307
+ *
308
+ * @param string $fileName
309
+ * @return true
310
+ */
311
+ protected function _deleteFile($fileName)
312
+ {
313
+ $dir = $this->_getTmpDir();
314
+ $file = new Varien_Io_File;
315
+ if ($file->fileExists($dir . $fileName, true)) {
316
+ $file->cd($dir);
317
+ $file->rm($fileName);
318
+ }
319
+ return true;
320
+ }
321
+
322
+ public function getJwCustomerId()
323
+ {
324
+ try
325
+ {
326
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
327
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
328
+
329
+ $ch = curl_init();
330
+ $timeout = 5;
331
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getjwId");
332
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
333
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
334
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password));
335
+ $data = curl_exec($ch);
336
+ curl_close($ch);
337
+ //echo $data;
338
+ if($data == "Invalid Login") {
339
+ //echo "Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail";
340
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
341
+ return;
342
+ } else {
343
+ //echo $data; exit;
344
+ return $data;
345
+ }
346
+ }
347
+ catch (Exception $e) {
348
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
349
+ return;
350
+ }
351
+ }
352
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Importcron.php ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jewelryshare import model
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Importcron extends Mage_Core_Model_Abstract
34
+ {
35
+ //const SEPARATOR = "\t";
36
+ const LINE_END = "\r\n";
37
+ const ENCLOSURE = '"';
38
+ const SEPARATOR = ',';
39
+ const COLLECTION_PAGE_SIZE = 5000;
40
+
41
+ const XML_PATH_SETTINGS_FTP_SERVER = 'jewelryshare/settings/ftp_server';
42
+ const XML_PATH_SETTINGS_FTP_USER = 'jewelryshare/settings/ftp_user';
43
+ const XML_PATH_SETTINGS_FTP_PASSWORD = 'jewelryshare/settings/ftp_password';
44
+ //const XML_PATH_SETTINGS_FTP_PATH = 'jewelryshare/settings/ftp_path';
45
+ //const XML_PATH_SETTINGS_FINDFEED_FILENAME = 'jewelryshare/settings/jewelerslinkjewelryshare_filename';
46
+ const XML_NODE_FIND_FEED_ATTRIBUTES = 'jewelryshare_attributes';
47
+
48
+ /**
49
+ * Attribute sources
50
+ *
51
+ * @var array
52
+ */
53
+ protected $_attributeSources = array();
54
+
55
+ /**
56
+ * Cron action
57
+ */
58
+ public function dispatch()
59
+ {
60
+ $this->processImport();
61
+ }
62
+
63
+ /**
64
+ * TheJewelerslink jewelryshare process import
65
+ */
66
+ public function processImport()
67
+ {
68
+ $file = $this->_createFile();
69
+ if ($file) {
70
+ $this->_deleteFtpFiles();
71
+ $this->_sendFile($file);
72
+ if (!$this->_deleteFile($file)) {
73
+ Mage::throwException(Mage::helper('jewelryshare')->__("FTP: Can't delete files"));
74
+ }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Create temp csv file and write export
80
+ *
81
+ * @return mixed
82
+ */
83
+ protected function _createFile()
84
+ {
85
+ $dir = $this->_getTmpDir();
86
+ //$fileName = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FINDFEED_FILENAME);
87
+ $customerId = $this->getJwCustomerId();
88
+
89
+ $fileName = $customerId.".csv";
90
+
91
+ if (!$dir || !$customerId) {
92
+ return false;
93
+ }
94
+ //echo count($this->_getImportAttributes());exit;
95
+
96
+ if (!($attributes = $this->_getImportAttributes()) || count($attributes) <= 0) {
97
+ return false;
98
+ }
99
+ $headers = array_keys($attributes);
100
+
101
+ $file = new Varien_Io_File;
102
+ $file->checkAndCreateFolder($dir);
103
+ $file->cd($dir);
104
+ $file->streamOpen($fileName, 'w+');
105
+ $file->streamLock();
106
+
107
+ //echo "<pre>"; print_r($headers); exit;
108
+ $file->streamWriteCsv($headers, self::SEPARATOR, self::ENCLOSURE);
109
+
110
+ $productCollectionPrototype = Mage::getResourceModel('catalog/product_collection');
111
+ $productCollectionPrototype->setPageSize(self::COLLECTION_PAGE_SIZE);
112
+ $pageNumbers = $productCollectionPrototype->getLastPageNumber();
113
+ unset($productCollectionPrototype);
114
+
115
+ for ($i = 1; $i <= $pageNumbers; $i++) {
116
+ $productCollection = Mage::getResourceModel('catalog/product_collection');
117
+ $productCollection->addAttributeToSelect($attributes);
118
+ $productCollection->addAttributeToFilter('is_imported', 1);
119
+ $productCollection->setPageSize(self::COLLECTION_PAGE_SIZE);
120
+ $productCollection->setCurPage($i)->load();
121
+ //echo "<pre>"; print_r($productCollection->getData()); exit;
122
+
123
+ foreach ($productCollection as $product) {
124
+ $attributesRow = array();
125
+ foreach ($attributes as $key => $value) {
126
+ if ($this->_checkAttributeSource($product, $value)) {
127
+ if (is_array($product->getAttributeText($value))) {
128
+ $attributesRow[$key] = implode(', ', $product->getAttributeText($value));
129
+ } else {
130
+ $attributesRow[$key] = $product->getAttributeText($value);
131
+ }
132
+ } else {
133
+ if($key == 'image' || $key == 'small_image' || $key == 'thumbnail') {
134
+ $siteUrl = str_replace("/index.php/","",Mage::getBaseUrl());
135
+ $imageUrl = $siteUrl."/media/catalog/product/";
136
+ $attributesRow[$key] = $imageUrl.$product->getData($value);
137
+ } else if($key == 'gallery') {
138
+ $_product = Mage::getModel('catalog/product')->load($product->getId());
139
+ $galleryArray = array();
140
+ $galleryString = "";
141
+ if($gallery = $_product->getMediaGalleryImages()) {
142
+ //echo "<pre>"; print_r($gallery);exit;
143
+ foreach ($gallery as $image) {
144
+ $exlode = explode("media/catalog/product",$image->getUrl());
145
+ $galleryPart = $exlode[1];
146
+ //echo $galleryPart."==".$_product->getImage(); exit;
147
+ if($galleryPart == $_product->getImage() || $galleryPart == $_product->getSmallImage() || $galleryPart == $_product->getThumbnail()) {
148
+ continue;
149
+ }
150
+ $galleryArray[] = $image->getUrl();
151
+ }
152
+ $galleryString = implode(";",$galleryArray);
153
+ }
154
+ $attributesRow[$key] = $galleryString;
155
+ } else {
156
+ $attributesRow[$key] = $product->getData($value);
157
+ }
158
+ }
159
+ }
160
+
161
+ //echo "<pre>"; print_r($attributesRow); //exit;
162
+
163
+ $file->streamWriteCsv($attributesRow, self::SEPARATOR, self::ENCLOSURE);
164
+ }
165
+ unset($productCollection);
166
+ }
167
+ //exit;
168
+ $file->streamUnlock();
169
+ $file->streamClose();
170
+
171
+ if ($file->fileExists($fileName)) {
172
+ return $fileName;
173
+ }
174
+ return false;
175
+ }
176
+
177
+ /**
178
+ * Check attribute source
179
+ *
180
+ * @param Mage_Catalog_Model_Product $product
181
+ * @param string $value
182
+ * @return bool
183
+ */
184
+ protected function _checkAttributeSource($product, $value)
185
+ {
186
+ if (!array_key_exists($value, $this->_attributeSources)) {
187
+ $this->_attributeSources[$value] = $product->getResource()->getAttribute($value)->usesSource();
188
+ }
189
+ return $this->_attributeSources[$value];
190
+ }
191
+
192
+ /**
193
+ * List import codes (attribute map) model
194
+ *
195
+ * @return mixed
196
+ */
197
+ protected function _getImportAttributes()
198
+ {
199
+ $attributes = Mage::getResourceModel('jewelryshare/codes_collection')
200
+ ->getImportAttributes();
201
+
202
+ if (!Mage::helper('jewelryshare')->checkRequired($attributes)) {
203
+ return false;
204
+ }
205
+ return $attributes;
206
+ }
207
+
208
+ /**
209
+ * Send file to remote ftp server
210
+ *
211
+ * @param string $fileName
212
+ */
213
+ protected function _sendFile($fileName)
214
+ {
215
+ $dir = $this->_getTmpDir();
216
+ $ftpServer = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_SERVER);
217
+ $ftpUserName = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_USER);
218
+ $ftpPass = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_PASSWORD);
219
+
220
+ $ftpPath = '/';
221
+ // set up basic connection
222
+ $conn_id = ftp_connect($ftpServer);
223
+
224
+ // login with username and password
225
+ $login_result = ftp_login($conn_id, $ftpUserName, $ftpPass);
226
+ //echo $login_result."==".$conn_id."==".$ftpPath.$fileName."==".$dir.$fileName; exit;
227
+ ftp_pasv($conn_id, true);
228
+
229
+ if(ftp_put($conn_id, $ftpPath.$fileName, $dir.$fileName, FTP_BINARY)) {
230
+ Mage::getSingleton("adminhtml/session")->addSuccess("csv exported to jewelerslink successfully.");
231
+ //echo "csv exported to jewelerslink successfully.";
232
+ } else {
233
+ Mage::getSingleton("adminhtml/session")->addError("There was a problem exporting csv to jewelerslink.");
234
+ //echo "There was a problem exporting csv to jewelerslink.";
235
+ }
236
+ // close the connection
237
+ ftp_close($conn_id);
238
+
239
+ /* $ch = curl_init();
240
+ curl_setopt($ch, CURLOPT_URL, 'ftp://'.$ftpUserName.':'.$ftpPass.'@'.$ftpServer.'/'.$ftpPath.$fileName);
241
+ curl_setopt($ch, CURLOPT_UPLOAD, 1);
242
+ curl_setopt($ch, CURLOPT_INFILE, fopen($dir.$fileName, 'r'));
243
+ curl_setopt($ch, CURLOPT_INFILESIZE, filesize($dir.$fileName));
244
+ curl_exec($ch);
245
+ curl_close($ch); */
246
+ }
247
+
248
+ /**
249
+ * Delete all files in current jewelryshare ftp directory
250
+ *
251
+ * @return bool
252
+ */
253
+ protected function _deleteFtpFiles()
254
+ {
255
+ if (is_callable('ftp_connect')) {
256
+
257
+ $ftpServer = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_SERVER);
258
+ $ftpUserName = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_USER);
259
+ $ftpPass = Mage::getStoreConfig(self::XML_PATH_SETTINGS_FTP_PASSWORD);
260
+
261
+ $ftpPath = '/';
262
+
263
+ try {
264
+ $connId = ftp_connect($ftpServer);
265
+
266
+ $loginResult = ftp_login($connId, $ftpUserName, $ftpPass);
267
+ //echo $loginResult; exit;
268
+
269
+ if (!$loginResult) {
270
+ return false;
271
+ }
272
+ ftp_pasv($connId, true);
273
+
274
+ $ftpDir = $ftpPath?$ftpPath:'.';
275
+ $nlist = ftp_nlist($connId, $ftpDir);
276
+ if ($nlist === false) {
277
+ return false;
278
+ }
279
+ //echo "<pre>"; print_r($nlist); exit;
280
+
281
+ foreach ($nlist as $file) {
282
+ if (!preg_match('/\.[xX][mM][lL]$/', $file)) {
283
+
284
+ if($file != '/..' && $file != '/.') {
285
+ ftp_delete($connId, $file);
286
+ }
287
+
288
+ }
289
+ }
290
+
291
+ ftp_close($connId);
292
+ } catch (Exception $e) {
293
+ Mage::log($e->getMessage());
294
+ return false;
295
+ }
296
+ return true;
297
+ } else {
298
+ return false;
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Current tmp directory
304
+ *
305
+ * @return string
306
+ */
307
+ protected function _getTmpDir()
308
+ {
309
+ return Mage::getBaseDir('var') . DS . 'export' . DS . 'jewelryshare' . DS;
310
+ }
311
+
312
+ /**
313
+ * Delete tmp file
314
+ *
315
+ * @param string $fileName
316
+ * @return true
317
+ */
318
+ protected function _deleteFile($fileName)
319
+ {
320
+ $dir = $this->_getTmpDir();
321
+ $file = new Varien_Io_File;
322
+ if ($file->fileExists($dir . $fileName, true)) {
323
+ $file->cd($dir);
324
+ $file->rm($fileName);
325
+ }
326
+ return true;
327
+ }
328
+
329
+ public function getJwCustomerId()
330
+ {
331
+ try
332
+ {
333
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
334
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
335
+
336
+ $ch = curl_init();
337
+ $timeout = 5;
338
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getjwId");
339
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
340
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
341
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password));
342
+ $data = curl_exec($ch);
343
+ curl_close($ch);
344
+ //echo $data;
345
+ if($data == "Invalid Login") {
346
+ //echo "Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail";
347
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
348
+ return;
349
+ } else {
350
+ //echo $data; exit;
351
+ return $data;
352
+ }
353
+ }
354
+ catch (Exception $e) {
355
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
356
+ return;
357
+ }
358
+ }
359
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Jewelryshare.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Model_Jewelryshare extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('jewelryshare/jewelryshare');
9
+ }
10
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Codes.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Thejewelerslink jwshare codes (attribute map) model
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Mysql4_Codes extends Jewelerslink_Jewelryshare_Model_Resource_Codes
34
+ {
35
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Codes/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jwshare codes (attribute map) collection
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Mysql4_Codes_Collection extends Jewelerslink_Jewelryshare_Model_Resource_Codes_Collection
34
+ {
35
+
36
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Jewelryshare.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Model_Mysql4_Jewelryshare extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the jewelryshare_id refers to the key field in your database table.
8
+ $this->_init('jewelryshare/jewelryshare', 'code_id');
9
+ }
10
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Jewelryshare/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Model_Mysql4_Jewelryshare_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('jewelryshare/jewelryshare');
9
+ }
10
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Thejewelerslink jwshare module setup
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
34
+ {
35
+ }
36
+
app/code/community/Jewelerslink/Jewelryshare/Model/Observer.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jwshare main observer
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Observer
34
+ {
35
+ /**
36
+ * Save system config event
37
+ *
38
+ * @param Varien_Object $observer
39
+ */
40
+ public function saveSystemConfig($observer)
41
+ {
42
+ $store = $observer->getStore();
43
+ $website = $observer->getWebsite();
44
+ $groups['settings']['fields']['cron_schedule']['value'] = $this->_getSchedule();
45
+
46
+ Mage::getModel('adminhtml/config_data')
47
+ ->setSection('jwshare')
48
+ ->setWebsite($website)
49
+ ->setStore($store)
50
+ ->setGroups($groups)
51
+ ->save();
52
+ }
53
+
54
+ /**
55
+ * Transform system settings option to cron schedule string
56
+ *
57
+ * @return string
58
+ */
59
+ protected function _getSchedule()
60
+ {
61
+ $data = Mage::app()->getRequest()->getPost('groups');
62
+
63
+ $frequency = !empty($data['settings']['fields']['cron_frequency']['value'])?
64
+ $data['settings']['fields']['cron_frequency']['value']:
65
+ 0;
66
+ $hours = !empty($data['settings']['fields']['cron_hours']['value'])?
67
+ $data['settings']['fields']['cron_hours']['value']:
68
+ 0;
69
+
70
+ $schedule = "0 $hours ";
71
+
72
+ switch ($frequency) {
73
+ case Jewelerslink_Jewelryshare_Model_Adminhtml_System_Source_Cron_Frequency::DAILY:
74
+ $schedule .= "* * *";
75
+ break;
76
+ case Jewelerslink_Jewelryshare_Model_Adminhtml_System_Source_Cron_Frequency::WEEKLY:
77
+ $schedule .= "* * 1";
78
+ break;
79
+ case Jewelerslink_Jewelryshare_Model_Adminhtml_System_Source_Cron_Frequency::MONTHLY:
80
+ $schedule .= "1 * *";
81
+ break;
82
+ case Jewelerslink_Jewelryshare_Model_Adminhtml_System_Source_Cron_Frequency::EVERY_MINUTE:
83
+ $schedule = "0-59 * * * *";
84
+ break;
85
+ default:
86
+ $schedule .= "* */1 *";
87
+ break;
88
+ }
89
+
90
+ return $schedule;
91
+ }
92
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Resource/Codes.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Thejewelerslink jwshare codes (attribute map) model
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Resource_Codes extends Mage_Core_Model_Resource_Db_Abstract
34
+ {
35
+ /**
36
+ * Class local constructor
37
+ */
38
+ protected function _construct()
39
+ {
40
+ return $this->_init('jewelerslink_jewelryshare/jewelryshare_import_codes', 'code_id');
41
+ }
42
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Resource/Codes/Collection.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jewelryshare codes (attribute map) collection
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Resource_Codes_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
34
+ {
35
+ /**
36
+ * Local constructor
37
+ *
38
+ */
39
+ protected function _construct()
40
+ {
41
+ $this->_init('jewelerslink_jewelryshare/codes');
42
+ }
43
+
44
+ /**
45
+ * Fetch attributes to import
46
+ *
47
+ * @return array
48
+ */
49
+ public function getImportAttributes()
50
+ {
51
+ $this->addFieldToFilter('jewelry_imported', array('eq' => '1'));
52
+ return $this->_toOptionHash('import_code', 'eav_code');
53
+ }
54
+
55
+ }
app/code/community/Jewelerslink/Jewelryshare/Model/Resource/Setup.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Thejewelerslink jwshare module setup
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Model_Resource_Setup extends Mage_Catalog_Model_Resource_Setup
34
+ {
35
+ }
36
+
app/code/community/Jewelerslink/Jewelryshare/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('jewelryshare')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('jewelryshare')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/community/Jewelerslink/Jewelryshare/controllers/Adminhtml/Jewelryshare/Codes/GridController.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jewelryshare attribute map grid controller
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Adminhtml_Jewelryshare_Codes_GridController extends Mage_Adminhtml_Controller_Action
34
+ {
35
+ /**
36
+ * Main index action
37
+ *
38
+ */
39
+ public function indexAction()
40
+ {
41
+ $this->loadLayout();
42
+ $this->renderLayout();
43
+ }
44
+
45
+ /**
46
+ * Grid action
47
+ *
48
+ */
49
+ public function gridAction()
50
+ {
51
+ $this->loadLayout();
52
+ $this->getResponse()->setBody($this->getLayout()->createBlock('jewelryshare/adminhtml_list_codes_grid')->toHtml());
53
+ }
54
+
55
+ /**
56
+ * Grid edit form action
57
+ *
58
+ */
59
+ public function editFormAction()
60
+ {
61
+ $this->loadLayout();
62
+ $this->getResponse()->setBody($this->getLayout()->createBlock('jewelryshare/adminhtml_edit_codes')->toHtml());
63
+ }
64
+
65
+ /**
66
+ * Save grid edit form action
67
+ *
68
+ */
69
+ public function saveFormAction()
70
+ {
71
+ $codeId = $this->getRequest()->getParam('code_id');
72
+ $response = new Varien_Object();
73
+ try {
74
+ $model = Mage::getModel('jewelerslink_jewelryshare/codes');
75
+ if ($codeId) {
76
+ $model->load($codeId);
77
+ }
78
+ $model->setImportCode($this->getRequest()->getParam('import_code'));
79
+ $model->setEavCode($this->getRequest()->getParam('eav_code'));
80
+ $model->setJewelryImported(intval($this->getRequest()->getParam('jewelry_imported')));
81
+ $model->save();
82
+ $response->setError(0);
83
+ } catch(Exception $e) {
84
+ $response->setError(1);
85
+ $response->setMessage('Save error');
86
+ }
87
+ $this->getResponse()->setBody($response->toJson());
88
+ }
89
+
90
+ /**
91
+ * Codes (attribute map) list for mass action
92
+ *
93
+ * @return array
94
+ */
95
+ protected function _getMassActionCodes()
96
+ {
97
+ $idList = $this->getRequest()->getParam('code_id');
98
+ if (!empty($idList)) {
99
+ $codes = array();
100
+ foreach ($idList as $id) {
101
+ $model = Mage::getModel('jewelerslink_jewelryshare/codes');
102
+ if ($model->load($id)) {
103
+ array_push($codes, $model);
104
+ }
105
+ }
106
+ return $codes;
107
+ } else {
108
+ return array();
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Set imported codes (attribute map) mass action
114
+ */
115
+ public function massEnableAction()
116
+ {
117
+ $updatedCodes = 0;
118
+ foreach ($this->_getMassActionCodes() as $code) {
119
+ $code->setJewelryImported(1);
120
+ $code->save();
121
+ $updatedCodes++;
122
+ }
123
+ if ($updatedCodes > 0) {
124
+ $this->_getSession()->addSuccess(Mage::helper('jewelryshare')->__("%s codes imported", $updatedCodes));
125
+ }
126
+ $this->_redirect('*/*/index');
127
+ }
128
+
129
+ /**
130
+ * Set not imported codes (attribute map) mass action
131
+ */
132
+ public function massDisableAction()
133
+ {
134
+ $updatedCodes = 0;
135
+ foreach ($this->_getMassActionCodes() as $code) {
136
+ $code->setJewelryImported(0);
137
+ $code->save();
138
+ $updatedCodes++;
139
+ }
140
+ if ($updatedCodes > 0) {
141
+ $this->_getSession()->addSuccess(Mage::helper('jewelryshare')->__("%s codes not imported", $updatedCodes));
142
+ }
143
+ $this->_redirect('*/*/index');
144
+ }
145
+
146
+ /**
147
+ * Delete codes (attribute map) mass action
148
+ */
149
+ public function deleteAction()
150
+ {
151
+ $updatedCodes = 0;
152
+ foreach ($this->_getMassActionCodes() as $code) {
153
+ $code->delete();
154
+ $updatedCodes++;
155
+ }
156
+ if ($updatedCodes > 0) {
157
+ $this->_getSession()->addSuccess(Mage::helper('jewelryshare')->__("%s codes deleted", $updatedCodes));
158
+ }
159
+ $this->_redirect('*/*/index');
160
+ }
161
+ }
app/code/community/Jewelerslink/Jewelryshare/controllers/Adminhtml/Jewelryshare/Items/GridController.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category
22
+ * @package _storage
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * TheJewelerslink jewelryshare product grid controller
29
+ *
30
+ * @category Jewelerslink
31
+ * @package Jewelerslink_Jewelryshare
32
+ */
33
+ class Jewelerslink_Jewelryshare_Adminhtml_Jewelryshare_Items_GridController extends Mage_Adminhtml_Controller_Action
34
+ {
35
+ /**
36
+ * Main index action
37
+ */
38
+ public function indexAction()
39
+ {
40
+ $this->loadLayout();
41
+ $this->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * Grid action
46
+ */
47
+ public function gridAction()
48
+ {
49
+ $this->loadLayout();
50
+ $this->getResponse()->setBody($this->getLayout()->createBlock('jewelryshare/adminhtml_list_items_grid')->toHtml());
51
+ }
52
+
53
+ /**
54
+ * Product list for mass action
55
+ *
56
+ * @return array
57
+ */
58
+ protected function _getMassActionProducts()
59
+ {
60
+ $idList = $this->getRequest()->getParam('item_id');
61
+ if (!empty($idList)) {
62
+ $products = array();
63
+ foreach ($idList as $id) {
64
+ $model = Mage::getModel('catalog/product');
65
+ if ($model->load($id)) {
66
+ array_push($products, $model);
67
+ }
68
+ }
69
+ return $products;
70
+ } else {
71
+ return array();
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Add product to jewelryshare mass action
77
+ */
78
+ public function massEnableAction()
79
+ {
80
+ $idList = $this->getRequest()->getParam('item_id');
81
+ $updateAction = Mage::getModel('catalog/product_action');
82
+ $attrData = array(
83
+ 'jewelry_imported' => 1
84
+ );
85
+ $updatedProducts = count($idList);
86
+ if ($updatedProducts) {
87
+ try {
88
+ $updateAction->updateAttributes($idList, $attrData, Mage::app()->getStore()->getId());
89
+ //Mage::getModel('jewelerslink_jewelryshare/import')->processImport();
90
+ $this->_getSession()->addSuccess(Mage::helper('jewelryshare')->__("%s product will be exported in jewelerslink.", $updatedProducts));
91
+ } catch (Exception $e) {
92
+ $this->_getSession()->addError(Mage::helper('jewelryshare')->__("Unable to process an export. ") . $e->getMessage());
93
+ }
94
+ }
95
+ $this->_redirect('*/*/index');
96
+ }
97
+
98
+ /**
99
+ * Not add product to jewelryshare mass action
100
+ */
101
+ public function massDisableAction()
102
+ {
103
+ /*$updatedProducts = 0;
104
+ foreach ($this->_getMassActionProducts() as $product) {
105
+ $product->setIsImported(0);
106
+ $product->save();
107
+ $updatedProducts++;
108
+ }*/
109
+ $idList = $this->getRequest()->getParam('item_id');
110
+ $updateAction = Mage::getModel('catalog/product_action');
111
+ $attrData = array(
112
+ 'jewelry_imported' => 0
113
+ );
114
+ $updatedProducts = count($idList);
115
+
116
+ if ($updatedProducts) {
117
+
118
+ try {
119
+ $updateAction->updateAttributes($idList, $attrData, Mage::app()->getStore()->getId());
120
+ //Mage::getModel('jewelerslink_jewelryshare/import')->processImport();
121
+ $this->_getSession()->addSuccess(Mage::helper('jewelryshare')->__("%s product(s) will not be exported in jewelerslink.", $updatedProducts));
122
+ } catch (Exception $e) {
123
+ $this->_getSession()->addError(Mage::helper('jewelryshare')->__("Unable to process an export. ") . $e->getMessage());
124
+ }
125
+
126
+ }
127
+ $this->_redirect('*/*/index');
128
+ }
129
+
130
+ /**
131
+ * Export products to jewelerslink mass action
132
+ */
133
+ public function massJwExportAction()
134
+ {
135
+ $idList = $this->getRequest()->getParam('item_id');
136
+ $updateAction = Mage::getModel('catalog/product_action');
137
+ $attrData = array(
138
+ 'jewelry_imported' => 1
139
+ );
140
+ $updatedProducts = count($idList);
141
+
142
+ if ($updatedProducts) {
143
+ try {
144
+ $updateAction->updateAttributes($idList, $attrData, Mage::app()->getStore()->getId());
145
+ Mage::getModel('jewelerslink_jewelryshare/import')->processImport();
146
+ $this->_getSession()->addSuccess(Mage::helper('jewelryshare')->__("%s product in jewelerslink.", $updatedProducts));
147
+ } catch (Exception $e) {
148
+ $this->_getSession()->addError(Mage::helper('jewelryshare')->__("Unable to process an import. ") . $e->getMessage());
149
+ }
150
+ }
151
+ $this->_redirect('*/*/index');
152
+ }
153
+
154
+ }
app/code/community/Jewelerslink/Jewelryshare/controllers/Adminhtml/JewelryshareController.php ADDED
@@ -0,0 +1,1179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Jewelerslink_Jewelryshare_Adminhtml_JewelryshareController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('jewelryshare/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('jewelryshare/jewelryshare')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('jewelryshare_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('jewelryshare/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('jewelryshare')->__('Item does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+
50
+ public function importFormAction() {
51
+
52
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
53
+ if (!empty($data)) {
54
+ $model->setData($data);
55
+ }
56
+
57
+ Mage::register('jewelryshare_data', $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu('jewelryshare/items');
61
+
62
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
63
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
64
+
65
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
66
+
67
+ $this->_addContent($this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit'))
68
+ ->_addLeft($this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_edit_tabs'));
69
+
70
+ $this->renderLayout();
71
+
72
+ }
73
+
74
+ public function newAction() {
75
+ $this->_forward('edit');
76
+ }
77
+
78
+ public function saveAction() {
79
+ try
80
+ {
81
+ $resource = Mage::getConfig()->getNode('global/resources')->asArray();
82
+ $magento_db = $resource['default_setup']['connection']['host'];
83
+ $mdb_user = $resource['default_setup']['connection']['username'];
84
+ $mdb_passwd = $resource['default_setup']['connection']['password'];
85
+ $mdb_name = $resource['default_setup']['connection']['dbname'];
86
+ $magento_connection = @mysql_connect($magento_db, $mdb_user, $mdb_passwd);
87
+
88
+ if (!$magento_connection)
89
+ {
90
+ die('Unable to connect to the database');
91
+ }
92
+ @mysql_select_db($mdb_name, $magento_connection) or die ("Database not found.");
93
+
94
+ $priceTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_priceincrease');
95
+ mysql_query("TRUNCATE TABLE $priceTable");
96
+
97
+ for($i = 1; $i<1000; $i++)
98
+ {
99
+ if(isset($_REQUEST['multiline_0-'.$i]) && ($_REQUEST['multiline_0-'.$i] != '')) {
100
+ $price_from_0 = $_REQUEST['multiline_0-'.$i];
101
+ $price_to_1 = $_REQUEST['multiline_1-'.$i];
102
+ $price_increase_percent = $_REQUEST['multiline_2-'.$i];
103
+ $price_increase_2 = $_REQUEST['multiline_2-'.$i]/100;
104
+ $price_to_increase_3 = 1 + $price_increase_2;
105
+
106
+ $query_insert_1 = "INSERT INTO $priceTable SET price_from = ".$price_from_0.", price_to = ".$price_to_1.", price_increase = ".$price_increase_percent;
107
+ mysql_query($query_insert_1) or die(mysql_error());
108
+ }
109
+ }
110
+
111
+ $vendorTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_vendor');
112
+ mysql_query("TRUNCATE TABLE $vendorTable");
113
+
114
+ for($j = 0; $j<1000; $j++)
115
+ {
116
+ if(isset($_REQUEST['vendor_1-'.$j]) && ($_REQUEST['vendor_1-'.$j] != '')) {
117
+ $vendor_name = $_REQUEST['vendor_1-'.$j];
118
+ $vendor_id = $_REQUEST['vendor_2-'.$j];
119
+ $query_insert = "INSERT INTO $vendorTable SET vendor_name = '".$vendor_name."', vendor_id = '".$vendor_id."'";
120
+ mysql_query($query_insert) or die(mysql_error());
121
+ }
122
+ }
123
+
124
+ Mage::getSingleton("adminhtml/session")->addSuccess("Rules Saved.");
125
+ $this->_redirect("*/*/importForm");
126
+ return;
127
+ }
128
+ catch (Exception $e) {
129
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
130
+ $this->_redirect("*/*/importForm");
131
+ return;
132
+ }
133
+
134
+ }
135
+
136
+ public function deleteDir($dirPath) {
137
+
138
+ if (! is_dir($dirPath)) {
139
+ throw new InvalidArgumentException("$dirPath must be a directory");
140
+ }
141
+ if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
142
+ $dirPath .= '/';
143
+ }
144
+ $files = glob($dirPath . '*', GLOB_MARK);
145
+ foreach ($files as $file) {
146
+ if (is_dir($file)) {
147
+ self::deleteDir($file);
148
+ } else {
149
+ unlink($file);
150
+ }
151
+ }
152
+ rmdir($dirPath);
153
+ }
154
+
155
+ public function getJwCustomerId() {
156
+ try
157
+ {
158
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
159
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
160
+
161
+ $ch = curl_init();
162
+ $timeout = 5;
163
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getjwId");
164
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
165
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
166
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password));
167
+ $data = curl_exec($ch);
168
+ curl_close($ch);
169
+ //echo $data;
170
+
171
+ if($data == "Invalid Login") {
172
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
173
+ $this->_redirect("*/*/importForm");
174
+ return;
175
+
176
+ } else {
177
+ //echo $data; exit;
178
+ return $data;
179
+ }
180
+
181
+ }
182
+ catch (Exception $e) {
183
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
184
+ $this->_redirect("*/*/importForm");
185
+ return;
186
+ }
187
+ }
188
+
189
+ /**
190
+ * List import codes (attribute map) model
191
+ *
192
+ * @return mixed
193
+ */
194
+ protected function _getImportAttributes()
195
+ {
196
+ $attributes = Mage::getResourceModel('jewelerslink_jewelryshare/codes_collection')->getImportAttributes();
197
+ return $attributes;
198
+ }
199
+
200
+ public function getImportCSVAction() {
201
+ try
202
+ {
203
+ $resource = Mage::getConfig()->getNode('global/resources')->asArray();
204
+ $magento_db = $resource['default_setup']['connection']['host'];
205
+ $mdb_user = $resource['default_setup']['connection']['username'];
206
+ $mdb_passwd = $resource['default_setup']['connection']['password'];
207
+ $mdb_name = $resource['default_setup']['connection']['dbname'];
208
+ $magento_connection = @mysql_connect($magento_db, $mdb_user, $mdb_passwd);
209
+
210
+ if (!$magento_connection)
211
+ {
212
+ die('Unable to connect to the database');
213
+ }
214
+ @mysql_select_db($mdb_name, $magento_connection) or die ("Database not found.");
215
+
216
+ $vendorTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_vendor');
217
+ $select_vendor = 'select * from `'.$vendorTable.'`';
218
+ $result = mysql_query($select_vendor);
219
+ while($row = mysql_fetch_array($result))
220
+ {
221
+ $vendorArray[] = $row['vendor_name'];
222
+ }
223
+
224
+ $attributes = $this->_getImportAttributes();
225
+ $mapped_attributes = array_keys($attributes);
226
+ //echo "<pre>";print_r($mapped_attributes); exit;
227
+ $mapped_string = json_encode($mapped_attributes);
228
+
229
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
230
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
231
+
232
+ $data_string = json_encode($vendorArray);
233
+
234
+ $ch = curl_init();
235
+ $timeout = 5;
236
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getjson");
237
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
238
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
239
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password,"vendors"=>$data_string,"attributes"=>$mapped_string));
240
+ $data = curl_exec($ch);
241
+ curl_close($ch);
242
+ //echo $data; exit;
243
+
244
+ if($data == "Invalid Login") {
245
+
246
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
247
+ $this->_redirect("*/*/importForm");
248
+ return;
249
+
250
+ } else {
251
+ //echo $data;
252
+
253
+ $existingProducts = Mage::getModel('catalog/product')->getCollection();
254
+ $existingProducts->addAttributeToSelect('sku');
255
+
256
+ $existSkus = array();
257
+ foreach($existingProducts as $exists) {
258
+ $existSkus[] = $exists->getSku();
259
+ }
260
+ //echo "<pre>"; print_r($existSkus); exit;
261
+ $jsonData = json_decode($data, true);
262
+
263
+ $mappedHeader = array();
264
+ foreach($jsonData[0] as $key => $header){
265
+
266
+ if($header == 'sku') {
267
+ $skuKey = $key;
268
+ }
269
+ if(isset($attributes[$header]) && $attributes[$header] != "") {
270
+ $mappedHeader[] = $attributes[$header];
271
+ } else {
272
+ $mappedHeader[] = $header;
273
+ }
274
+ }
275
+ $jsonData[0] = $mappedHeader;
276
+ //echo "<pre>"; print_r($jsonData);exit;
277
+
278
+ $csvData = array();
279
+ foreach($jsonData as $csvRow) {
280
+ if(!in_array($csvRow[$skuKey], $existSkus)) {
281
+ $csvData[] = $csvRow;
282
+ }
283
+ }
284
+
285
+ //echo "<pre>"; print_r($csvData);exit;
286
+
287
+ $priceTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_priceincrease');
288
+ $query = "SELECT * FROM $priceTable";
289
+ $result= mysql_query($query);
290
+ while($row = mysql_fetch_array($result)) {
291
+ $price_from[] = $row['price_from'];
292
+ $price_to[] = $row['price_to'];
293
+ $price_increase_per = $row['price_increase']/100 ;
294
+ $price_increase_final[] = 1 + $price_increase_per ;
295
+ }
296
+
297
+
298
+ // Apply Price Increase before saving csv because we are not storing jewelry to database like diamonds.
299
+ $row=0;
300
+ $csvRowCnt = 1;
301
+ foreach($csvData as $column) {
302
+
303
+ if($row==0){
304
+
305
+ foreach($column as $key => $field) {
306
+ //$priceFields = array('price','special_price','tier_price','msrp','g14_price','g18_price','plat_price','pall_price');
307
+ if($field == 'price') {
308
+ $priceKey = $key;
309
+ }
310
+ if($field == 'special_price') {
311
+ $special_priceKey = $key;
312
+ }
313
+ if($field == 'tier_price') {
314
+ $tier_priceKey = $key;
315
+ }
316
+ if($field == 'msrp') {
317
+ $msrpKey = $key;
318
+ }
319
+ if($field == 'g14_price') {
320
+ $g14_priceKey = $key;
321
+ }
322
+ if($field == 'g18_price') {
323
+ $g18_priceKey = $key;
324
+ }
325
+ if($field == 'plat_price') {
326
+ $plat_priceKey = $key;
327
+ }
328
+ if($field == 'pall_price') {
329
+ $pall_priceKey = $key;
330
+ }
331
+ }
332
+
333
+ $row++;
334
+ continue;
335
+ }
336
+
337
+ if(isset($priceKey) && $priceKey != "") {
338
+ $price = $column[$priceKey];
339
+ if($price == 0) $price = "";
340
+ $csvData[$csvRowCnt][$priceKey] = $price;
341
+ }
342
+
343
+ if(isset($special_priceKey) && $special_priceKey != "") {
344
+ $special_price = $column[$special_priceKey];
345
+ if($special_price == 0) $special_price = "";
346
+ $csvData[$csvRowCnt][$special_priceKey] = $special_price;
347
+ }
348
+
349
+ if(isset($tier_priceKey) && $tier_priceKey != "") {
350
+ $tier_price = $column[$tier_priceKey];
351
+ if($tier_price == 0) $tier_price = "";
352
+ $csvData[$csvRowCnt][$tier_priceKey] = $tier_price;
353
+ }
354
+
355
+ if(isset($msrpKey) && $msrpKey != "") {
356
+ $msrp = $column[$msrpKey];
357
+ if($msrp == 0) $msrp = "";
358
+ $csvData[$csvRowCnt][$msrpKey] = $msrp;
359
+ }
360
+
361
+ if(isset($g14_priceKey) && $g14_priceKey != "") {
362
+ $g14_price = $column[$g14_priceKey];
363
+ if($g14_price == 0) $g14_price = "";
364
+ $csvData[$csvRowCnt][$g14_priceKey] = $g14_price;
365
+ }
366
+
367
+ if(isset($g18_priceKey) && $g18_priceKey != "") {
368
+ $g18_price = $column[$g18_priceKey];
369
+ if($g18_price == 0) $g18_price = "";
370
+ $csvData[$csvRowCnt][$g18_priceKey] = $g18_price;
371
+ }
372
+
373
+ if(isset($plat_priceKey) && $plat_priceKey != "") {
374
+ $plat_price = $column[$plat_priceKey];
375
+ if($plat_price == 0) $plat_price = "";
376
+ $csvData[$csvRowCnt][$plat_priceKey] = $plat_price;
377
+ }
378
+
379
+ if(isset($pall_priceKey) && $pall_priceKey != "") {
380
+ $pall_price = $column[$pall_priceKey];
381
+ if($pall_price == 0) $pall_price = "";
382
+ $csvData[$csvRowCnt][$pall_priceKey] = $pall_price;
383
+ }
384
+
385
+ for($i=0; $i < count($price_increase_final); $i++) {
386
+
387
+ if($price_increase_final[$i] != '') {
388
+
389
+ if(isset($priceKey) && $priceKey != "") {
390
+ if(($price >= $price_from[$i]) && ($price <= $price_to[$i]) && ($price != 0) && ($price != '')) {
391
+ $incPrice = $price*$price_increase_final[$i];
392
+ //echo $incPrice."==".$csvRowCnt."<br>";
393
+ $csvData[$csvRowCnt][$priceKey] = $incPrice;
394
+ }
395
+ }
396
+
397
+ if(isset($special_priceKey) && $special_priceKey != "") {
398
+ if(($special_price >= $price_from[$i]) && ($special_price <= $price_to[$i]) && ($special_price != 0) && ($special_price != '')) {
399
+
400
+ $incSpPrice = $special_price*$price_increase_final[$i];
401
+ //echo $incSpPrice."==".$csvRowCnt."<br>";
402
+ $csvData[$csvRowCnt][$special_priceKey] = $incSpPrice;
403
+ }
404
+ }
405
+
406
+ if(isset($tier_priceKey) && $tier_priceKey != "") {
407
+ if(($tier_price >= $price_from[$i]) && ($tier_price <= $price_to[$i]) && ($tier_price != 0) && ($tier_price != '')) {
408
+
409
+ $incTrPrice = $tier_price*$price_increase_final[$i];
410
+ //echo $incTrPrice."==".$csvRowCnt."<br>";
411
+ $csvData[$csvRowCnt][$tier_priceKey] = $incTrPrice;
412
+ }
413
+ }
414
+
415
+ if(isset($msrpKey) && $msrpKey != "") {
416
+ if(($msrp >= $price_from[$i]) && ($msrp <= $price_to[$i]) && ($msrp != 0) && ($msrp != '')) {
417
+
418
+ $incMSPrice = $msrp*$price_increase_final[$i];
419
+ //echo $incMSPrice."==".$csvRowCnt."<br>";
420
+ $csvData[$csvRowCnt][$msrpKey] = $incMSPrice;
421
+ }
422
+ }
423
+
424
+ if(isset($g14_priceKey) && $g14_priceKey != "") {
425
+ if(($g14_price >= $price_from[$i]) && ($g14_price <= $price_to[$i]) && ($g14_price != 0) && ($g14_price != '')) {
426
+
427
+ $incG14Price = $g14_price*$price_increase_final[$i];
428
+ //echo $incG14Price."==".$csvRowCnt."<br>";
429
+ $csvData[$csvRowCnt][$g14_priceKey] = $incG14Price;
430
+ }
431
+ }
432
+
433
+ if(isset($g18_priceKey) && $g18_priceKey != "") {
434
+ if(($g18_price >= $price_from[$i]) && ($g18_price <= $price_to[$i]) && ($g18_price != 0) && ($g18_price != '')) {
435
+
436
+ $incG18Price = $g18_price*$price_increase_final[$i];
437
+ //echo $incG18Price."==".$csvRowCnt."<br>";
438
+ $csvData[$csvRowCnt][$g18_priceKey] = $incG18Price;
439
+ }
440
+ }
441
+
442
+ if(isset($plat_priceKey) && $plat_priceKey != "") {
443
+ if(($plat_price >= $price_from[$i]) && ($plat_price <= $price_to[$i]) && ($plat_price != 0) && ($plat_price != '')) {
444
+
445
+ $incPtPrice = $plat_price*$price_increase_final[$i];
446
+ //echo $incPtPrice."==".$csvRowCnt."<br>";
447
+ $csvData[$csvRowCnt][$plat_priceKey] = $incPtPrice;
448
+ }
449
+ }
450
+
451
+ if(isset($pall_priceKey) && $pall_priceKey != "") {
452
+ if(($pall_price >= $price_from[$i]) && ($pall_price <= $price_to[$i]) && ($pall_price != 0) && ($pall_price != '')) {
453
+
454
+ $incPlPrice = $pall_price*$price_increase_final[$i];
455
+ //echo $incPlPrice."==".$csvRowCnt."<br>";
456
+ $csvData[$csvRowCnt][$pall_priceKey] = $incPlPrice;
457
+ }
458
+ }
459
+
460
+ }
461
+ }
462
+
463
+ $csvRowCnt++;
464
+ }
465
+ //echo "<pre>"; print_r($csvData);exit;
466
+
467
+ $path = Mage::getBaseDir("var") . DS ."import" . DS;
468
+ $fp = fopen($path."jewelerslink_import.csv", "w") or die("can't open file");
469
+ foreach ($csvData as $fields) {
470
+ fputcsv($fp, $fields);
471
+ }
472
+ fclose($fp);
473
+
474
+ //$this->getImagesAction();
475
+
476
+ Mage::getSingleton("adminhtml/session")->addSuccess(count($csvData)." New Products CSV Created from Jewelerslink Inventory.");
477
+ $this->_redirect("*/*/importForm");
478
+ }
479
+
480
+ }
481
+ catch (Exception $e) {
482
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
483
+ $this->_redirect("*/*/importForm");
484
+ return;
485
+ }
486
+ }
487
+
488
+ public function getUpdateCSVAction() {
489
+ try
490
+ {
491
+ $resource = Mage::getConfig()->getNode('global/resources')->asArray();
492
+ $magento_db = $resource['default_setup']['connection']['host'];
493
+ $mdb_user = $resource['default_setup']['connection']['username'];
494
+ $mdb_passwd = $resource['default_setup']['connection']['password'];
495
+ $mdb_name = $resource['default_setup']['connection']['dbname'];
496
+ $magento_connection = @mysql_connect($magento_db, $mdb_user, $mdb_passwd);
497
+
498
+ if (!$magento_connection)
499
+ {
500
+ die('Unable to connect to the database');
501
+ }
502
+ @mysql_select_db($mdb_name, $magento_connection) or die ("Database not found.");
503
+
504
+ $vendorTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_vendor');
505
+ $select_vendor = 'select * from `'.$vendorTable.'`';
506
+ $result = mysql_query($select_vendor);
507
+ while($row = mysql_fetch_array($result))
508
+ {
509
+ $vendorArray[] = $row['vendor_name'];
510
+ }
511
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
512
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
513
+
514
+ $data_string = json_encode($vendorArray);
515
+
516
+ $ch = curl_init();
517
+ $timeout = 5;
518
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getUpdateJson");
519
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
520
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
521
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password,"vendors"=>$data_string));
522
+ $data = curl_exec($ch);
523
+ curl_close($ch);
524
+ //echo $data; exit;
525
+
526
+ if($data == "Invalid Login") {
527
+
528
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
529
+ $this->_redirect("*/*/importForm");
530
+ return;
531
+
532
+ } else {
533
+ //echo $data;
534
+
535
+ $existingProducts = Mage::getModel('catalog/product')->getCollection();
536
+ $existingProducts->addAttributeToSelect('sku');
537
+
538
+ $existSkus = array();
539
+ foreach($existingProducts as $exists) {
540
+ $existSkus[] = $exists->getSku();
541
+ }
542
+ //echo "<pre>"; print_r($existSkus); exit;
543
+ $jsonData = json_decode($data, true);
544
+ //echo "<pre>"; print_r($jsonData);exit;
545
+
546
+ $csvData = array();
547
+ $rowCnt = 0;
548
+ foreach($jsonData as $csvRow) {
549
+ if($rowCnt==0) {
550
+ $csvData[] = $csvRow;
551
+ } else {
552
+ if(in_array($csvRow[2], $existSkus)) {
553
+ $csvData[] = $csvRow;
554
+ }
555
+ }
556
+ $rowCnt++;
557
+ }
558
+
559
+ //echo "<pre>"; print_r($csvData);exit;
560
+
561
+ $attributes = Mage::getResourceModel('jewelerslink_jewelryshare/codes_collection')->getImportAttributes();
562
+ $attributesKey = array_keys($attributes);
563
+ $attributesValue = array_values($attributes);
564
+ //echo "<pre>"; print_r($attributesKey); print_r($attributesValue);print_r($csvData[0]);
565
+
566
+ // Below Loop == to map header with attribute & update csv title $csvData[0] (header array)
567
+ for($i=0; $i<count($csvData[0]); $i++) {
568
+
569
+ for($j=0; $j<count($attributesKey); $j++) {
570
+
571
+ if(trim($attributesKey[$j]) == trim($csvData[0][$i])) {
572
+ //echo $attributesKey[$j]." ".$attributesValue[$j]."<br>";
573
+ $csvData[0][$i] = $attributesValue[$j];
574
+ break;
575
+ }
576
+ }
577
+
578
+ }
579
+ //echo "<pre>"; print_r($csvData);exit;
580
+ $priceTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_priceincrease');
581
+ $query = "SELECT * FROM $priceTable";
582
+ $result= mysql_query($query);
583
+ while($row = mysql_fetch_array($result)) {
584
+ $price_from[] = $row['price_from'];
585
+ $price_to[] = $row['price_to'];
586
+ $price_increase_per = $row['price_increase']/100 ;
587
+ $price_increase_final[] = 1 + $price_increase_per ;
588
+ }
589
+
590
+
591
+ // Apply Price Increase before saving csv because we are not storing jewelry to database like diamonds.
592
+ $row=0;
593
+ $csvRowCnt = 1;
594
+ foreach($csvData as $column) {
595
+
596
+ if($row==0){
597
+ $row++;
598
+ continue;
599
+ }
600
+
601
+ $price = $column[4];
602
+ if($price == 0) $price = "";
603
+ $csvData[$csvRowCnt][4] = $price;
604
+
605
+ $special_price = $column[5];
606
+ if($special_price == 0) $special_price = "";
607
+ $csvData[$csvRowCnt][5] = $special_price;
608
+
609
+ $tier_price = $column[6];
610
+ if($tier_price == 0) $tier_price = "";
611
+ $csvData[$csvRowCnt][6] = $tier_price;
612
+
613
+ $msrp = $column[7];
614
+ if($msrp == 0) $msrp = "";
615
+ $csvData[$csvRowCnt][7] = $msrp;
616
+
617
+ $g14_price = $column[8];
618
+ if($g14_price == 0) $g14_price = "";
619
+ $csvData[$csvRowCnt][8] = $g14_price;
620
+
621
+ $g18_price = $column[9];
622
+ if($g18_price == 0) $g18_price = "";
623
+ $csvData[$csvRowCnt][9] = $g18_price;
624
+
625
+ $plat_price = $column[10];
626
+ if($plat_price == 0) $plat_price = "";
627
+ $csvData[$csvRowCnt][10] = $plat_price;
628
+
629
+ $pall_price = $column[11];
630
+ if($pall_price == 0) $pall_price = "";
631
+ $csvData[$csvRowCnt][11] = $pall_price;
632
+
633
+ for($i=0; $i < count($price_increase_final); $i++) {
634
+ if($price_increase_final[$i] != '') {
635
+ //$query_update = "UPDATE diamonds_inventory SET totalprice = totalprice*".$price_increase_final[$i]." where cost between ".$price_from[$i]." AND ".$price_to[$i];
636
+ if(($price >= $price_from[$i]) && ($price <= $price_to[$i]) && ($price != 0) && ($price != '')) {
637
+
638
+ $incPrice = $price*$price_increase_final[$i];
639
+ //echo $incPrice."==".$csvRowCnt."<br>";
640
+ $csvData[$csvRowCnt][4] = $incPrice;
641
+ }
642
+
643
+ if(($special_price >= $price_from[$i]) && ($special_price <= $price_to[$i]) && ($special_price != 0) && ($special_price != '')) {
644
+
645
+ $incSpPrice = $special_price*$price_increase_final[$i];
646
+ //echo $incSpPrice."==".$csvRowCnt."<br>";
647
+ $csvData[$csvRowCnt][5] = $incSpPrice;
648
+ }
649
+
650
+ if(($tier_price >= $price_from[$i]) && ($tier_price <= $price_to[$i]) && ($tier_price != 0) && ($tier_price != '')) {
651
+
652
+ $incTrPrice = $tier_price*$price_increase_final[$i];
653
+ //echo $incTrPrice."==".$csvRowCnt."<br>";
654
+ $csvData[$csvRowCnt][6] = $incTrPrice;
655
+ }
656
+
657
+ if(($msrp >= $price_from[$i]) && ($msrp <= $price_to[$i]) && ($msrp != 0) && ($msrp != '')) {
658
+
659
+ $incMSPrice = $msrp*$price_increase_final[$i];
660
+ //echo $incMSPrice."==".$csvRowCnt."<br>";
661
+ $csvData[$csvRowCnt][7] = $incMSPrice;
662
+ }
663
+
664
+ if(($g14_price >= $price_from[$i]) && ($g14_price <= $price_to[$i]) && ($g14_price != 0) && ($g14_price != '')) {
665
+
666
+ $incG14Price = $g14_price*$price_increase_final[$i];
667
+ //echo $incG14Price."==".$csvRowCnt."<br>";
668
+ $csvData[$csvRowCnt][8] = $incG14Price;
669
+ }
670
+
671
+ if(($g18_price >= $price_from[$i]) && ($g18_price <= $price_to[$i]) && ($g18_price != 0) && ($g18_price != '')) {
672
+
673
+ $incG18Price = $g18_price*$price_increase_final[$i];
674
+ //echo $incG18Price."==".$csvRowCnt."<br>";
675
+ $csvData[$csvRowCnt][9] = $incG18Price;
676
+ }
677
+
678
+ if(($plat_price >= $price_from[$i]) && ($plat_price <= $price_to[$i]) && ($plat_price != 0) && ($plat_price != '')) {
679
+
680
+ $incPtPrice = $plat_price*$price_increase_final[$i];
681
+ //echo $incPtPrice."==".$csvRowCnt."<br>";
682
+ $csvData[$csvRowCnt][10] = $incPtPrice;
683
+ }
684
+
685
+ if(($pall_price >= $price_from[$i]) && ($pall_price <= $price_to[$i]) && ($pall_price != 0) && ($pall_price != '')) {
686
+
687
+ $incPlPrice = $pall_price*$price_increase_final[$i];
688
+ //echo $incPlPrice."==".$csvRowCnt."<br>";
689
+ $csvData[$csvRowCnt][11] = $incPlPrice;
690
+ }
691
+
692
+ }
693
+ }
694
+
695
+ $csvRowCnt++;
696
+ }
697
+ //echo "<pre>"; print_r($csvData);exit;
698
+
699
+ $path = Mage::getBaseDir("var") . DS ."import" . DS;
700
+ $fp = fopen($path."jewelerslink_update.csv", "w") or die("can't open file");
701
+ foreach ($csvData as $fields) {
702
+ fputcsv($fp, $fields);
703
+ }
704
+ fclose($fp);
705
+
706
+ //$this->getImagesAction();
707
+
708
+ Mage::getSingleton("adminhtml/session")->addSuccess(count($csvData)." Update Products CSV Created from Jewelerslink Inventory.");
709
+ $this->_redirect("*/*/importForm");
710
+ }
711
+
712
+ }
713
+ catch (Exception $e) {
714
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
715
+ $this->_redirect("*/*/importForm");
716
+ return;
717
+ }
718
+ }
719
+
720
+ public function getImagesAction() {
721
+
722
+ try {
723
+ $path = Mage::getBaseDir("var") . DS ."import" . DS;
724
+ $fp = fopen($path."jewelerslink_import.csv",'r') or die("can't open file");
725
+ $row=0;
726
+ $count = 1;
727
+ while($csv_line = fgetcsv($fp,1024))
728
+ {
729
+ //echo "<pre>";print_r($csv_line);
730
+ if($row==0){
731
+
732
+ foreach($csv_line as $key => $field) {
733
+
734
+ if($field == 'image') {
735
+ $imageKey = $key;
736
+ }
737
+ if($field == 'small_image') {
738
+ $small_imageKey = $key;
739
+ }
740
+ if($field == 'thumbnail') {
741
+ $thumbnailKey = $key;
742
+ }
743
+ if($field == 'gallery') {
744
+ $galleryKey = $key;
745
+ }
746
+
747
+ }
748
+
749
+ $row++;
750
+ continue;
751
+ }
752
+
753
+ if(isset($imageKey) && $imageKey != "") {
754
+ // Main Image Save
755
+ $imagePath = str_replace("/jewelerslink","",$csv_line[$imageKey]);
756
+ $httpUrl = "http://images.jewelerslink.com/jewelry/".$imagePath;
757
+ $imageName = basename($imagePath);
758
+ $localpath = getcwd()."/media/import/jewelerslink/".str_replace($imageName,"",$imagePath)."/";
759
+ if(!is_dir($localpath)) mkdir($localpath,0777,true);
760
+ if(!file_exists($localpath.$imageName))
761
+ copy($httpUrl, $localpath.$imageName);
762
+ }
763
+
764
+ if(isset($small_imageKey) && $small_imageKey != "") {
765
+ // Small Image Save
766
+ $simagePath = str_replace("/jewelerslink","",$csv_line[$small_imageKey]);
767
+ $shttpUrl = "http://images.jewelerslink.com/jewelry/".$simagePath;
768
+ $simageName = basename($simagePath);
769
+ $slocalpath = getcwd()."/media/import/jewelerslink/".str_replace($simageName,"",$simagePath)."/";
770
+ if(!is_dir($slocalpath)) mkdir($slocalpath,0777,true);
771
+ if(!file_exists($slocalpath.$simageName))
772
+ copy($shttpUrl, $slocalpath.$simageName);
773
+ }
774
+
775
+ if(isset($thumbnailKey) && $thumbnailKey != "") {
776
+ // Thumbnail Image Save
777
+ $timagePath = str_replace("/jewelerslink","",$csv_line[$thumbnailKey]);
778
+ $thttpUrl = "http://images.jewelerslink.com/jewelry/".$timagePath;
779
+ $timageName = basename($timagePath);
780
+ $tlocalpath = getcwd()."/media/import/jewelerslink/".str_replace($timageName,"",$timagePath)."/";
781
+ if(!is_dir($tlocalpath)) mkdir($tlocalpath,0777,true);
782
+ if(!file_exists($tlocalpath.$timageName))
783
+ copy($thttpUrl, $tlocalpath.$timageName);
784
+ }
785
+
786
+ if(isset($galleryKey) && $galleryKey != "") {
787
+ // Galley Images Save
788
+ $galleryArray = explode(";",$csv_line[$galleryKey]);
789
+
790
+ foreach($galleryArray as $galleryImg) {
791
+ $gimagePath = str_replace("/jewelerslink","",$galleryImg);
792
+ $ghttpUrl = "http://images.jewelerslink.com/jewelry/".$gimagePath;
793
+ $gimageName = basename($gimagePath);
794
+ $glocalpath = getcwd()."/media/import/jewelerslink/".str_replace($gimageName,"",$gimagePath)."/";
795
+ if(!is_dir($glocalpath)) mkdir($glocalpath,0777,true);
796
+ if(!file_exists($glocalpath.$gimageName))
797
+ copy($ghttpUrl, $glocalpath.$gimageName);
798
+ }
799
+ }
800
+
801
+ }
802
+
803
+ Mage::getSingleton("adminhtml/session")->addSuccess("Images written successfully.");
804
+ $this->_redirect("*/*/importForm");
805
+ return;
806
+
807
+ }
808
+ catch (Exception $e) {
809
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
810
+ $this->_redirect("*/*/importForm");
811
+ return;
812
+ }
813
+ }
814
+
815
+ public function importJewelryAction() {
816
+
817
+ $url = $this->getUrl("*idealAdmin/system_convert_gui/run/", array("id" => 3, "files" => "jewelerslink_import.csv"));
818
+ $url = str_replace("*idealAdmin","idealAdmin", $url);
819
+ ?>
820
+ <script type="text/javascript">
821
+ window.location = "<?php echo $url ?>";
822
+ </script>
823
+ <?php
824
+ }
825
+
826
+ public function updateJewelryAction() {
827
+
828
+ $url = $this->getUrl("*idealAdmin/system_convert_gui/run/", array("id" => 3, "files" => "jewelerslink_update.csv"));
829
+ $url = str_replace("*idealAdmin","idealAdmin", $url);
830
+ ?>
831
+ <script type="text/javascript">
832
+ window.location = "<?php echo $url ?>";
833
+ </script>
834
+ <?php
835
+ }
836
+
837
+ public function disableOlderAction() {
838
+ try
839
+ {
840
+ $resource = Mage::getConfig()->getNode('global/resources')->asArray();
841
+ $magento_db = $resource['default_setup']['connection']['host'];
842
+ $mdb_user = $resource['default_setup']['connection']['username'];
843
+ $mdb_passwd = $resource['default_setup']['connection']['password'];
844
+ $mdb_name = $resource['default_setup']['connection']['dbname'];
845
+ $magento_connection = @mysql_connect($magento_db, $mdb_user, $mdb_passwd);
846
+
847
+ if (!$magento_connection)
848
+ {
849
+ die('Unable to connect to the database');
850
+ }
851
+ @mysql_select_db($mdb_name, $magento_connection) or die ("Database not found.");
852
+
853
+ $vendorTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_vendor');
854
+ $select_vendor = 'select * from `'.$vendorTable.'`';
855
+ $result = mysql_query($select_vendor);
856
+ while($row = mysql_fetch_array($result))
857
+ {
858
+ $vendorArray[] = $row['vendor_name'];
859
+ }
860
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
861
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
862
+
863
+ $data_string = json_encode($vendorArray);
864
+
865
+ $ch = curl_init();
866
+ $timeout = 5;
867
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getUpdateJson");
868
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
869
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
870
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password,"vendors"=>$data_string));
871
+ $data = curl_exec($ch);
872
+ curl_close($ch);
873
+ //echo $data; exit;
874
+
875
+ if($data == "Invalid Login") {
876
+
877
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
878
+ $this->_redirect("*/*/importForm");
879
+ return;
880
+
881
+ } else {
882
+ //echo $data;
883
+ $jsonData = json_decode($data, true);
884
+ $jwlProducts = array();
885
+ foreach($jsonData as $data) {
886
+ if($data[2] != 'sku')
887
+ $jwlProducts[] = $data[2];
888
+ }
889
+ //echo "<pre>"; print_r($jwlProducts);exit;
890
+
891
+ $existingProducts = Mage::getModel('catalog/product')->getCollection();
892
+ //$existingProducts->addAttributeToSelect('sku');
893
+
894
+ $disable = 0;
895
+ foreach($existingProducts as $exists) {
896
+
897
+ $sku = $exists->getSku();
898
+ if(!in_array($sku, $jwlProducts)) {
899
+
900
+ $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);
901
+ if($product) {
902
+ $status = $product->getStatus();
903
+ if($status != 2) {
904
+ $product->setStatus(2);
905
+ $product->save();
906
+ }
907
+ }
908
+ $disable++;
909
+ }
910
+ }
911
+ //echo $disable; exit;
912
+
913
+ Mage::getSingleton("adminhtml/session")->addSuccess($disable." Products not in jewelrslink has been disabled.");
914
+ $this->_redirect("*/*/importForm");
915
+ }
916
+
917
+ }
918
+ catch (Exception $e) {
919
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
920
+ $this->_redirect("*/*/importForm");
921
+ return;
922
+ }
923
+ }
924
+
925
+ public function restorePriceIncreaseAction() {
926
+
927
+ try
928
+ {
929
+ $resource = Mage::getConfig()->getNode('global/resources')->asArray();
930
+ $magento_db = $resource['default_setup']['connection']['host'];
931
+ $mdb_user = $resource['default_setup']['connection']['username'];
932
+ $mdb_passwd = $resource['default_setup']['connection']['password'];
933
+ $mdb_name = $resource['default_setup']['connection']['dbname'];
934
+ $magento_connection = @mysql_connect($magento_db, $mdb_user, $mdb_passwd);
935
+
936
+ if (!$magento_connection)
937
+ {
938
+ die('Unable to connect to the database');
939
+ }
940
+ @mysql_select_db($mdb_name, $magento_connection) or die ("Database not found.");
941
+
942
+ $priceTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_priceincrease');
943
+ mysql_query("TRUNCATE TABLE $priceTable");
944
+
945
+ mysql_query("INSERT INTO $priceTable SET price_from = 100000.01, price_to = 10000000, price_increase = 0")or die(mysql_error());
946
+ mysql_query("INSERT INTO $priceTable SET price_from = 50000.01, price_to = 100000, price_increase = 0")or die(mysql_error());
947
+ mysql_query("INSERT INTO $priceTable SET price_from = 30000.01, price_to = 50000, price_increase = 0")or die(mysql_error());
948
+ mysql_query("INSERT INTO $priceTable SET price_from = 25000.01, price_to = 30000, price_increase = 0")or die(mysql_error());
949
+ mysql_query("INSERT INTO $priceTable SET price_from = 20000.01, price_to = 25000, price_increase = 0")or die(mysql_error());
950
+ mysql_query("INSERT INTO $priceTable SET price_from = 15000.01, price_to = 20000, price_increase = 0")or die(mysql_error());
951
+ mysql_query("INSERT INTO $priceTable SET price_from = 10000.01, price_to = 15000, price_increase = 0")or die(mysql_error());
952
+ mysql_query("INSERT INTO $priceTable SET price_from = 5000.01, price_to = 10000, price_increase = 0")or die(mysql_error());
953
+ mysql_query("INSERT INTO $priceTable SET price_from = 3500.01, price_to = 5000, price_increase = 0")or die(mysql_error());
954
+ mysql_query("INSERT INTO $priceTable SET price_from = 2000.01, price_to = 3500, price_increase = 0")or die(mysql_error());
955
+ mysql_query("INSERT INTO $priceTable SET price_from = 1000.01, price_to = 2000, price_increase = 0")or die(mysql_error());
956
+ mysql_query("INSERT INTO $priceTable SET price_from = 500.01, price_to = 1000, price_increase = 0")or die(mysql_error());
957
+ mysql_query("INSERT INTO $priceTable SET price_from = 1, price_to = 500, price_increase = 0")or die(mysql_error());
958
+
959
+ Mage::getSingleton("adminhtml/session")->addSuccess("Price Increase Restored to default values.");
960
+ $this->_redirect("*/*/importForm");
961
+
962
+ }
963
+ catch (Exception $e) {
964
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
965
+ $this->_redirect("*/*/importForm");
966
+ return;
967
+ }
968
+ }
969
+
970
+ public function getImagesActionOld() { // Not Using this
971
+
972
+ $vendors = $this->getvendorIdsAction();
973
+
974
+ if(count($vendors)>0) {
975
+
976
+ foreach($vendors as $vendorId) {
977
+
978
+ //echo $vendorId; exit;
979
+
980
+ $ftp_host = "images.jewelerslink.com";
981
+ $ftp_username = "images@jewelerslink.com";
982
+ $ftp_password = "jewelerslink123";
983
+
984
+ // path to remote file
985
+ $server_file = "/jewelry/".$vendorId."/".$vendorId.".zip";
986
+
987
+ $localDir = getcwd()."/media/import/jewelerslink/".$vendorId."/";
988
+ $local_file = $localDir.$vendorId.".zip";
989
+
990
+ if (is_dir($localDir)) $this->deleteDir($localDir);
991
+ if (!is_dir($localDir)) mkdir($localDir);
992
+
993
+ // set up basic connection
994
+ $conn_id = ftp_connect($ftp_host);
995
+ // login with username and password
996
+ $login_result = ftp_login($conn_id, $ftp_username, $ftp_password);
997
+
998
+ // try to download $server_file and save to $local_file
999
+ if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
1000
+
1001
+ $zip = new ZipArchive();
1002
+ $x = $zip->open($local_file);
1003
+ if ($x === true) {
1004
+ $zip->extractTo($localDir); // change this to the correct site path
1005
+ $zip->close();
1006
+ unlink($local_file);
1007
+ }
1008
+ Mage::getSingleton("adminhtml/session")->addSuccess("Images written successfully.");
1009
+ } else {
1010
+ Mage::getSingleton("adminhtml/session")->addError("There was a problem getting images.");
1011
+ }
1012
+ // close the connection
1013
+ ftp_close($conn_id);
1014
+ }
1015
+
1016
+ } else {
1017
+ Mage::getSingleton("adminhtml/session")->addError("No Vendors found.");
1018
+ }
1019
+
1020
+ }
1021
+
1022
+ public function getvendorIdsAction() { // Not Using this
1023
+
1024
+ try
1025
+ {
1026
+ $resource = Mage::getConfig()->getNode('global/resources')->asArray();
1027
+ $magento_db = $resource['default_setup']['connection']['host'];
1028
+ $mdb_user = $resource['default_setup']['connection']['username'];
1029
+ $mdb_passwd = $resource['default_setup']['connection']['password'];
1030
+ $mdb_name = $resource['default_setup']['connection']['dbname'];
1031
+ $magento_connection = @mysql_connect($magento_db, $mdb_user, $mdb_passwd);
1032
+
1033
+ if (!$magento_connection)
1034
+ {
1035
+ die('Unable to connect to the database');
1036
+ }
1037
+ @mysql_select_db($mdb_name, $magento_connection) or die ("Database not found.");
1038
+
1039
+ $vendorTable = Mage::getSingleton('core/resource')->getTableName('jewelryshare_vendor');
1040
+ $select_vendor = 'select * from `'.$vendorTable.'`';
1041
+ $result = mysql_query($select_vendor);
1042
+ while($row = mysql_fetch_array($result))
1043
+ {
1044
+ $vendorArray[] = $row['vendor_name'];
1045
+ }
1046
+ $username = Mage::getStoreConfig('jewelryshare/user_detail/ideal_username');
1047
+ $password = Mage::getStoreConfig('jewelryshare/user_detail/ideal_password');
1048
+
1049
+ $data_string = json_encode($vendorArray);
1050
+
1051
+ $ch = curl_init();
1052
+ $timeout = 5;
1053
+ curl_setopt($ch,CURLOPT_URL,"http://www.jewelerslink.com/jewelry/index/getvendorIdsjson");
1054
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
1055
+ curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
1056
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("username"=>$username,"password"=>$password,"vendors"=>$data_string));
1057
+ $data = curl_exec($ch);
1058
+ curl_close($ch);
1059
+ //echo $data;
1060
+
1061
+ if($data == "Invalid Login") {
1062
+
1063
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("adminhtml")->__("Unauthenticate Login, Go to ( System > Configuration > Jewelry Config ) and enter Jewelerslink Login Detail"));
1064
+ $this->_redirect("*/*/importForm");
1065
+ return;
1066
+
1067
+ } else {
1068
+
1069
+ $vendorData = json_decode($data, true);
1070
+ //echo "<pre>"; print_r($vendorData);exit;
1071
+ return $vendorData;
1072
+ }
1073
+
1074
+ }
1075
+ catch (Exception $e) {
1076
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
1077
+ $this->_redirect("*/*/importForm");
1078
+ return;
1079
+ }
1080
+ }
1081
+
1082
+ public function deleteAction() {
1083
+ if( $this->getRequest()->getParam('id') > 0 ) {
1084
+ try {
1085
+ $model = Mage::getModel('jewelryshare/jewelryshare');
1086
+
1087
+ $model->setId($this->getRequest()->getParam('id'))
1088
+ ->delete();
1089
+
1090
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
1091
+ $this->_redirect('*/*/');
1092
+ } catch (Exception $e) {
1093
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
1094
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
1095
+ }
1096
+ }
1097
+ $this->_redirect('*/*/');
1098
+ }
1099
+
1100
+ public function massDeleteAction() {
1101
+ $jewelryshareIds = $this->getRequest()->getParam('jewelryshare');
1102
+ if(!is_array($jewelryshareIds)) {
1103
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
1104
+ } else {
1105
+ try {
1106
+ foreach ($jewelryshareIds as $jewelryshareId) {
1107
+ $jewelryshare = Mage::getModel('jewelryshare/jewelryshare')->load($jewelryshareId);
1108
+ $jewelryshare->delete();
1109
+ }
1110
+ Mage::getSingleton('adminhtml/session')->addSuccess(
1111
+ Mage::helper('adminhtml')->__(
1112
+ 'Total of %d record(s) were successfully deleted', count($jewelryshareIds)
1113
+ )
1114
+ );
1115
+ } catch (Exception $e) {
1116
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
1117
+ }
1118
+ }
1119
+ $this->_redirect('*/*/index');
1120
+ }
1121
+
1122
+ public function massStatusAction()
1123
+ {
1124
+ $jewelryshareIds = $this->getRequest()->getParam('jewelryshare');
1125
+ if(!is_array($jewelryshareIds)) {
1126
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
1127
+ } else {
1128
+ try {
1129
+ foreach ($jewelryshareIds as $jewelryshareId) {
1130
+ $jewelryshare = Mage::getSingleton('jewelryshare/jewelryshare')
1131
+ ->load($jewelryshareId)
1132
+ ->setStatus($this->getRequest()->getParam('status'))
1133
+ ->setIsMassupdate(true)
1134
+ ->save();
1135
+ }
1136
+ $this->_getSession()->addSuccess(
1137
+ $this->__('Total of %d record(s) were successfully updated', count($jewelryshareIds))
1138
+ );
1139
+ } catch (Exception $e) {
1140
+ $this->_getSession()->addError($e->getMessage());
1141
+ }
1142
+ }
1143
+ $this->_redirect('*/*/index');
1144
+ }
1145
+
1146
+ public function exportCsvAction()
1147
+ {
1148
+ $fileName = 'jewelryshare.csv';
1149
+ $content = $this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_grid')
1150
+ ->getCsv();
1151
+
1152
+ $this->_sendUploadResponse($fileName, $content);
1153
+ }
1154
+
1155
+ public function exportXmlAction()
1156
+ {
1157
+ $fileName = 'jewelryshare.xml';
1158
+ $content = $this->getLayout()->createBlock('jewelryshare/adminhtml_jewelryshare_grid')
1159
+ ->getXml();
1160
+
1161
+ $this->_sendUploadResponse($fileName, $content);
1162
+ }
1163
+
1164
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
1165
+ {
1166
+ $response = $this->getResponse();
1167
+ $response->setHeader('HTTP/1.1 200 OK','');
1168
+ $response->setHeader('Pragma', 'public', true);
1169
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
1170
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
1171
+ $response->setHeader('Last-Modified', date('r'));
1172
+ $response->setHeader('Accept-Ranges', 'bytes');
1173
+ $response->setHeader('Content-Length', strlen($content));
1174
+ $response->setHeader('Content-type', $contentType);
1175
+ $response->setBody($content);
1176
+ $response->sendResponse();
1177
+ die;
1178
+ }
1179
+ }
app/code/community/Jewelerslink/Jewelryshare/etc/config.xml ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Jewelerslink_Jewelryshare>
5
+ <version>0.1.0</version>
6
+ </Jewelerslink_Jewelryshare>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <jewelryshare>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Jewelerslink_Jewelryshare</module>
14
+ <frontName>jewelryshare</frontName>
15
+ </args>
16
+ </jewelryshare>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <jewelryshare>
21
+ <file>jewelryshare.xml</file>
22
+ </jewelryshare>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <jewelryshare>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Jewelerslink_Jewelryshare</module>
32
+ <frontName>jewelryshare</frontName>
33
+ </args>
34
+ </jewelryshare>
35
+ </routers>
36
+ </admin>
37
+ <stores>
38
+ <admin>
39
+ <design>
40
+ <theme>
41
+ <default>jewelerslink</default>
42
+ </theme>
43
+ </design>
44
+ </admin>
45
+ </stores>
46
+ <adminhtml>
47
+ <menu>
48
+ <jewelryshare module="jewelryshare">
49
+ <title>Jewelerslink</title>
50
+ <sort_order>200</sort_order>
51
+ <children>
52
+ <jewelery module="jewelryshare">
53
+ <title>Jewelery</title>
54
+ <sort_order>1</sort_order>
55
+ <children>
56
+ <jewelryshare_attributes module="jewelryshare">
57
+ <title>Jewelery Attributes</title>
58
+ <sort_order>0</sort_order>
59
+ <action>jewelryshare/adminhtml_jewelryshare_codes_grid/index</action>
60
+ </jewelryshare_attributes>
61
+ <jewelryshare_export module="jewelryshare">
62
+ <title>Export Jewelery</title>
63
+ <sort_order>1</sort_order>
64
+ <action>jewelryshare/adminhtml_jewelryshare_items_grid/index</action>
65
+ </jewelryshare_export>
66
+ <jewelryshare_import module="jewelryshare">
67
+ <title>Import Jewelery</title>
68
+ <sort_order>2</sort_order>
69
+ <action>jewelryshare/adminhtml_jewelryshare/importForm/</action>
70
+ </jewelryshare_import>
71
+ <jewelryshare_settings module="jewelryshare">
72
+ <title>Settings</title>
73
+ <sort_order>3</sort_order>
74
+ <action>adminhtml/system_config/edit/section/jewelryshare/</action>
75
+ </jewelryshare_settings>
76
+ </children>
77
+ </jewelery>
78
+ </children>
79
+ </jewelryshare>
80
+ </menu>
81
+ <acl>
82
+ <resources>
83
+ <all>
84
+ <title>Allow Everything</title>
85
+ </all>
86
+ <admin>
87
+ <children>
88
+ <Jewelerslink_Jewelryshare>
89
+ <title>Jewelryshare Module</title>
90
+ <sort_order>10</sort_order>
91
+ </Jewelerslink_Jewelryshare>
92
+ <system>
93
+ <children>
94
+ <config>
95
+ <children>
96
+ <jewelryshare translate="title" module="jewelryshare">
97
+ <title>Jewelryshare Section</title>
98
+ </jewelryshare>
99
+ </children>
100
+ </config>
101
+ </children>
102
+ </system>
103
+ </children>
104
+
105
+ </admin>
106
+ </resources>
107
+ </acl>
108
+ <layout>
109
+ <updates>
110
+ <jewelryshare>
111
+ <file>jewelryshare.xml</file>
112
+ </jewelryshare>
113
+ </updates>
114
+ </layout>
115
+ </adminhtml>
116
+ <global>
117
+ <models>
118
+
119
+ <jewelerslink_jewelryshare>
120
+ <class>Jewelerslink_Jewelryshare_Model</class>
121
+ <resourceModel>jewelerslink_jewelryshare_resource</resourceModel>
122
+ </jewelerslink_jewelryshare>
123
+ <jewelerslink_jewelryshare_resource>
124
+ <class>Jewelerslink_Jewelryshare_Model_Resource</class>
125
+ <deprecatedNode>jewelerslink_jewelryshare_mysql4</deprecatedNode>
126
+ <entities>
127
+ <jewelryshare_import_codes>
128
+ <table>jewelryshare_import_codes</table>
129
+ </jewelryshare_import_codes>
130
+ </entities>
131
+ </jewelerslink_jewelryshare_resource>
132
+ </models>
133
+ <resources>
134
+ <jewelryshare_setup>
135
+ <setup>
136
+ <module>Jewelerslink_Jewelryshare</module>
137
+ <class>Jewelerslink_Jewelryshare_Model_Resource_Setup</class>
138
+ </setup>
139
+ <connection>
140
+ <use>core_setup</use>
141
+ </connection>
142
+ </jewelryshare_setup>
143
+ <jewelryshare_write>
144
+ <connection>
145
+ <use>core_write</use>
146
+ </connection>
147
+ </jewelryshare_write>
148
+ <jewelryshare_read>
149
+ <connection>
150
+ <use>core_read</use>
151
+ </connection>
152
+ </jewelryshare_read>
153
+ </resources>
154
+ <blocks>
155
+ <jewelryshare>
156
+ <class>Jewelerslink_Jewelryshare_Block</class>
157
+ </jewelryshare>
158
+ </blocks>
159
+ <helpers>
160
+ <jewelryshare>
161
+ <class>Jewelerslink_Jewelryshare_Helper</class>
162
+ </jewelryshare>
163
+ </helpers>
164
+ </global>
165
+
166
+ <jewelerslink_jewelryshare_attributes>
167
+ <sku>
168
+ <required>1</required>
169
+ <label>sku</label>
170
+ </sku>
171
+ <name>
172
+ <required>1</required>
173
+ <label>name</label>
174
+ </name>
175
+ <description>
176
+ <required>1</required>
177
+ <label>description</label>
178
+ </description>
179
+ <short_description>
180
+ <required>1</required>
181
+ <label>short_description</label>
182
+ </short_description>
183
+ <price>
184
+ <required>0</required>
185
+ <label>price</label>
186
+ </price>
187
+ <special_price>
188
+ <required>0</required>
189
+ <label>special_price</label>
190
+ </special_price>
191
+ <tier_price>
192
+ <required>0</required>
193
+ <label>tier_price</label>
194
+ </tier_price>
195
+ <msrp>
196
+ <required>0</required>
197
+ <label>msrp</label>
198
+ </msrp>
199
+ <g14_price>
200
+ <required>0</required>
201
+ <label>g14_price</label>
202
+ </g14_price>
203
+ <g18_price>
204
+ <required>0</required>
205
+ <label>g18_price</label>
206
+ </g18_price>
207
+ <plat_price>
208
+ <required>0</required>
209
+ <label>plat_price</label>
210
+ </plat_price>
211
+ <pall_price>
212
+ <required>0</required>
213
+ <label>pall_price</label>
214
+ </pall_price>
215
+ <notes>
216
+ <required>0</required>
217
+ <label>notes</label>
218
+ </notes>
219
+ <image>
220
+ <required>0</required>
221
+ <label>image</label>
222
+ </image>
223
+ <small_image>
224
+ <required>0</required>
225
+ <label>small_image</label>
226
+ </small_image>
227
+ <thumbnail>
228
+ <required>0</required>
229
+ <label>thumbnail</label>
230
+ </thumbnail>
231
+ <gallery>
232
+ <required>0</required>
233
+ <label>gallery</label>
234
+ </gallery>
235
+ <video>
236
+ <required>0</required>
237
+ <label>video</label>
238
+ </video>
239
+ <meta_keyword>
240
+ <required>0</required>
241
+ <label>meta_keyword</label>
242
+ </meta_keyword>
243
+ <meta_title>
244
+ <required>0</required>
245
+ <label>meta_title</label>
246
+ </meta_title>
247
+ <meta_description>
248
+ <required>0</required>
249
+ <label>meta_description</label>
250
+ </meta_description>
251
+ <country_of_manufacture>
252
+ <required>0</required>
253
+ <label>country_of_manufacture</label>
254
+ </country_of_manufacture>
255
+ <bandwidth>
256
+ <required>0</required>
257
+ <label>bandwidth</label>
258
+ </bandwidth>
259
+ <ring_height>
260
+ <required>0</required>
261
+ <label>ring_height</label>
262
+ </ring_height>
263
+ <dimension>
264
+ <required>0</required>
265
+ <label>dimension</label>
266
+ </dimension>
267
+ <dimension_height>
268
+ <required>0</required>
269
+ <label>dimension_height</label>
270
+ </dimension_height>
271
+ <dimension_length>
272
+ <required>0</required>
273
+ <label>dimension_length</label>
274
+ </dimension_length>
275
+ <dimension_width>
276
+ <required>0</required>
277
+ <label>dimension_width</label>
278
+ </dimension_width>
279
+ <total_diam_weight>
280
+ <required>0</required>
281
+ <label>total_diam_weight</label>
282
+ </total_diam_weight>
283
+ <total_diam_pcs>
284
+ <required>0</required>
285
+ <label>total_diam_pcs</label>
286
+ </total_diam_pcs>
287
+ <center_stone_sizes>
288
+ <required>0</required>
289
+ <label>center_stone_sizes</label>
290
+ </center_stone_sizes>
291
+ <center_size_availability>
292
+ <required>0</required>
293
+ <label>center_size_availability</label>
294
+ </center_size_availability>
295
+ <center_shape_availability>
296
+ <required>0</required>
297
+ <label>center_shape_availability</label>
298
+ </center_shape_availability>
299
+ <style>
300
+ <required>0</required>
301
+ <label>style</label>
302
+ </style>
303
+ <setting>
304
+ <required>0</required>
305
+ <label>setting</label>
306
+ </setting>
307
+ <manufacturer>
308
+ <required>0</required>
309
+ <label>manufacturer</label>
310
+ </manufacturer>
311
+ <collections>
312
+ <required>0</required>
313
+ <label>collections</label>
314
+ </collections>
315
+ <gender>
316
+ <required>0</required>
317
+ <label>gender</label>
318
+ </gender>
319
+ <center_stone_shapes>
320
+ <required>0</required>
321
+ <label>center_stone_shapes</label>
322
+ </center_stone_shapes>
323
+ <type>
324
+ <required>0</required>
325
+ <label>type</label>
326
+ </type>
327
+ <metal_type>
328
+ <reuired>0</reuired>
329
+ <label>metal_type</label>
330
+ </metal_type>
331
+ <jewelry_type>
332
+ <reuired>0</reuired>
333
+ <label>jewelry_type</label>
334
+ </jewelry_type>
335
+ <primary_stone>
336
+ <reuired>0</reuired>
337
+ <label>primary_stone</label>
338
+ </primary_stone>
339
+ <gemstone>
340
+ <required>0</required>
341
+ <label>gemstone</label>
342
+ </gemstone>
343
+ <average_color>
344
+ <required>0</required>
345
+ <label>average_color</label>
346
+ </average_color>
347
+ <average_clarity>
348
+ <required>0</required>
349
+ <label>average_clarity</label>
350
+ </average_clarity>
351
+ <diamond_carat>
352
+ <required>0</required>
353
+ <label>diamond_carat</label>
354
+ </diamond_carat>
355
+ <weight>
356
+ <required>0</required>
357
+ <label>weight</label>
358
+ </weight>
359
+ </jewelerslink_jewelryshare_attributes>
360
+
361
+ <default>
362
+ <jewelryshare>
363
+ <settings>
364
+ <ftp_server>jewelerslink.com</ftp_server>
365
+ <ftp_user>csv@jewelerslink.com</ftp_user>
366
+ <ftp_password>jewelerslink123</ftp_password>
367
+ <jewelerslinkjwshare_update>1</jewelerslinkjwshare_update>
368
+ </settings>
369
+ </jewelryshare>
370
+ </default>
371
+
372
+ </config>
app/code/community/Jewelerslink/Jewelryshare/etc/system.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category
23
+ * @package _storage
24
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <tabs>
30
+ <jewelerslink translate="label" module="jewelryshare">
31
+ <label>The Jewelerslink</label>
32
+ <sort_order>100</sort_order>
33
+ </jewelerslink>
34
+ </tabs>
35
+ <sections>
36
+
37
+ <jewelryshare translate="label" module="jewelryshare">
38
+ <label>Jewelryshare Configuration</label>
39
+ <tab>jewelerslink</tab>
40
+ <sort_order>100</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <groups>
45
+ <user_detail translate="label">
46
+ <label>Jewelerslink Login Detail</label>
47
+ <sort_order>2</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <fields>
51
+ <ideal_username translate="label">
52
+ <label>Jewelerslink Username(Email)</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>1</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </ideal_username>
59
+ <ideal_password translate="label">
60
+ <label>Jewelerslink Password</label>
61
+ <frontend_type>password</frontend_type>
62
+ <sort_order>2</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </ideal_password>
67
+ </fields>
68
+ </user_detail>
69
+
70
+ <settings translate="label">
71
+ <label>Export Settings</label>
72
+ <frontend_type>text</frontend_type>
73
+ <sort_order>200</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <fields>
78
+ <name translate="label">
79
+ <label>FTP Settings</label>
80
+ </name>
81
+ <ftp_server translate="label">
82
+ <label>FTP Server</label>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>10</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </ftp_server>
89
+
90
+ <ftp_user translate="label comment">
91
+ <label>FTP User</label>
92
+ <frontend_type>text</frontend_type>
93
+ <sort_order>20</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ <!-- <comment><![CDATA[In order to access your FTP account information, you must first register and verify your store in TheJewelerslink Merchant Center. Click <a href="https://merchant.thefind.com/mc/claim.fhtml">here</a> to get started.]]></comment> -->
98
+ </ftp_user>
99
+ <ftp_password translate="label">
100
+ <label>FTP Password</label>
101
+ <frontend_type>password</frontend_type>
102
+ <sort_order>30</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </ftp_password>
107
+
108
+ </fields>
109
+ </settings>
110
+ </groups>
111
+ </jewelryshare>
112
+ </sections>
113
+ </config>
app/code/community/Jewelerslink/Jewelryshare/sql/jewelryshare_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ /**
8
+ * Create table 'jewelryshare_import_codes'
9
+ */
10
+ $table = $installer->getConnection()
11
+ ->newTable($installer->getTable('jewelryshare_import_codes'))
12
+ ->addColumn('code_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
13
+ 'identity' => true,
14
+ 'unsigned' => true,
15
+ 'nullable' => false,
16
+ 'primary' => true,
17
+ ), 'Code id')
18
+ ->addColumn('import_code', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
19
+ 'nullable' => false,
20
+ ), 'Import type')
21
+ ->addColumn('eav_code', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
22
+ 'nullable' => false,
23
+ ), 'EAV code')
24
+ ->addColumn('jewelry_imported', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
25
+ 'nullable' => false,
26
+ ), 'Is imported')
27
+ ->setComment('Jewelerslink jewelryshare import codes');
28
+ $installer->getConnection()->createTable($table);
29
+
30
+ $this->addAttribute('catalog_product', 'jewelry_imported', array(
31
+ 'group' => 'General',
32
+ 'type' => 'int',
33
+ 'input' => 'select',
34
+ 'label' => 'Publish Jewelery In Jewelerslink',
35
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
36
+ 'visible' => 1,
37
+ 'required' => 0,
38
+ 'visible_on_front' => 0,
39
+ 'is_html_allowed_on_front' => 0,
40
+ 'is_configurable' => 0,
41
+ 'source' => 'eav/entity_attribute_source_boolean',
42
+ 'searchable' => 0,
43
+ 'filterable' => 0,
44
+ 'comparable' => 0,
45
+ 'unique' => false,
46
+ 'user_defined' => false,
47
+ 'is_user_defined' => false,
48
+ 'used_in_product_listing' => true
49
+ ));
50
+
51
+ $installer->run("
52
+ -- DROP TABLE IF EXISTS {$this->getTable('jewelryshare_priceincrease')};
53
+ CREATE TABLE {$this->getTable('jewelryshare_priceincrease')} (
54
+ `id` int(11) NOT NULL AUTO_INCREMENT,
55
+ `price_from` varchar(255) NOT NULL,
56
+ `price_to` varchar(255) NOT NULL,
57
+ `price_increase` varchar(255) NOT NULL,
58
+ PRIMARY KEY (`id`)
59
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
60
+ ");
61
+
62
+ $installer->run("
63
+ -- DROP TABLE IF EXISTS {$this->getTable('jewelryshare_vendor')};
64
+ CREATE TABLE {$this->getTable('jewelryshare_vendor')} (
65
+ `id` int(11) NOT NULL AUTO_INCREMENT,
66
+ `vendor_name` varchar(255) NOT NULL,
67
+ `vendor_id` int(11) NOT NULL,
68
+ PRIMARY KEY (`id`),
69
+ UNIQUE KEY `id` (`id`)
70
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
71
+ ");
72
+
73
+ $installer->endSetup();
app/design/adminhtml/default/jewelerslink/layout/jewelryshare.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <jewelryshare_adminhtml_jewelryshare_index>
4
+ <reference name="content">
5
+ <block type="jewelryshare/adminhtml_jewelryshare" name="jewelryshare" />
6
+ </reference>
7
+ </jewelryshare_adminhtml_jewelryshare_index>
8
+
9
+ <jewelryshare_adminhtml_jewelryshare_codes_grid_index>
10
+ <reference name="head">
11
+ <action method="addItem"><type>js</type><name>prototype/window.js</name></action>
12
+ <action method="addItem"><type>js_css</type><name>prototype/windows/themes/default.css</name></action>
13
+ <action method="addItem"><type>js_css</type><name>jewelerslink/jewelerslink.css</name></action>
14
+ </reference>
15
+ <reference name="content">
16
+ <block type="core/template" template="jewelryshare/head/window.phtml" name="head.window" />
17
+ <block type="jewelryshare/adminhtml_list_codes" name="adminhtml_list_codes" />
18
+ </reference>
19
+ </jewelryshare_adminhtml_jewelryshare_codes_grid_index>
20
+
21
+ <jewelryshare_adminhtml_jewelryshare_items_grid_index>
22
+ <reference name="content">
23
+ <block type="jewelryshare/adminhtml_list_items" name="adminhtml_list_items_grid" />
24
+ </reference>
25
+ </jewelryshare_adminhtml_jewelryshare_items_grid_index>
26
+
27
+ <jewelryshare_adminhtml_jewelryshare_importForm>
28
+ <reference name="content">
29
+ <block type="jewelryshare/adminhtml_jewelryshare" name="jewelryshare" />
30
+ </reference>
31
+ </jewelryshare_adminhtml_jewelryshare_importForm>
32
+
33
+ </layout>
app/etc/modules/Jewelerslink_Jewelryshare.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Jewelerslink_Jewelryshare>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Jewelerslink_Jewelryshare>
8
+ </modules>
9
+ </config>
js/jewelerslink/btn_bg.gif ADDED
Binary file
js/jewelerslink/content_bg.gif ADDED
Binary file
js/jewelerslink/jewelerslink.css ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .dialog { border:1px solid #555; }
2
+ .dialog .bot { display:none !important; }
3
+ .overlay_magento { background-color:#000; filter:alpha(opacity=60); -moz-opacity:.6; opacity:.6; -webkit-opacity:.6; }
4
+ .top.table_window { border-bottom:1px solid #e6e6e6; background:#6a838b url(top_bg.gif) 0 100% repeat-x; }
5
+
6
+ .magento_nw { width:6px; height:28px; }
7
+ .magento_n { height:28px; }
8
+ .magento_ne { width:6px; height:28px; }
9
+
10
+ .magento_w { width:6px; }
11
+ .magento_e { width:6px; }
12
+ .magento_w,
13
+ .magento_e,
14
+ .magento_content { background: #fafafa url(content_bg.gif) 0 0 repeat-x; }
15
+
16
+ .magento_sw { background:#deebf0; width:5px; height:3px; }
17
+ .magento_s { background:#deebf0; height:3px; }
18
+ .magento_se,
19
+
20
+ .magento_sizer { background:#deebf0; width:5px; height:3px; }
21
+ .magento_sizer { cursor:se-resize; }
22
+
23
+ .magento_close { width:16px; height:16px; background:url(window_close.png) no-repeat 0 0; position:absolute; top:5px; right:7px; cursor:pointer; z-index:1000; }
24
+ .magento_minimize { width:16px; height:16px; background:url(window_minimize.png) 0 0 no-repeat; position:absolute; top:5px; right:28px; cursor:pointer; z-index:1000; }
25
+ .magento_maximize { width:16px; height:16px; background:url(window_maximize.png)0 0 no-repeat; position:absolute; top:5px; right:49px; cursor:pointer; z-index:1000; }
26
+
27
+ .magento_title { float:left; width:100%; font:bold 12px/28px Arial, Helvetica, sans-serif; color:#fff; text-align:left; }
28
+
29
+ .magento_content { overflow:auto; font-size:12px; }
30
+ .magento_content,
31
+ .magento_content label { color:#333; font-family:Arial, sans-serif; }
32
+
33
+ .magento_buttons { padding:10px; text-align:right; }
34
+ .magento_buttons input.button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; background:#ffac47 url(btn_bg.gif) 0 100% repeat-x; padding:0 7px 1px 7px; font:bold 12px/18px Arial, Helvetica, sans-serif; color:#fff; cursor:pointer; text-align:center; white-space:nowrap; }
35
+
36
+ /* FOR IE */
37
+ * html .magento_close { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_maximize.png", sizingMethod="crop"); }
38
+ * html .magento_minimize { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_close.png", sizingMethod="crop");}
39
+ * html .magento_maximize { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_minimize.png", sizingMethod="crop"); }
js/jewelerslink/top_bg.gif ADDED
Binary file
js/jewelerslink/window_close.png ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Jewelerslink_Jewelryshare</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Share Jewelry Products to Jewelrslink.</summary>
10
+ <description>Share Jewelry Products to Jewelrslink.&#xD;
11
+ Includes importing product from jewerlslink and Exporting products to Jewelerslink with attributes mapping functions.</description>
12
+ <notes>Share Jewelry Products to Jewelrslink.&#xD;
13
+ Includes importing product from jewerlslink and Exporting products to Jewelerslink with attributes mapping functions.</notes>
14
+ <authors><author><name>John Dorsey</name><user>jewelerslink</user><email>support@idealbrandmarketing.com</email></author></authors>
15
+ <date>2014-01-30</date>
16
+ <time>11:36:05</time>
17
+ <contents><target name="magecommunity"><dir name="Jewelerslink"><dir name="Jewelryshare"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><dir name="Codes"><dir name="Edit"><file name="Form.php" hash="862f0625803dda26595c8dffea1c00db"/></dir></dir><file name="Codes.php" hash="7622b2901f4fa12ef746d23f5b0f52ef"/></dir><dir name="Jewelryshare"><dir name="Edit"><file name="Form.php" hash="2c1802fc7f6660a99d8fd73ef0bc0c7b"/><dir name="Tab"><file name="Import.php" hash="8846742c307b767b976af6135a71c72a"/><file name="Priceincrease.php" hash="6cd5181396c0bbb62df79cde4ebf1599"/><file name="Update.php" hash="72c7e63d769217d1fd8a86b37970e45b"/><file name="Vendor.php" hash="355e7536bbb62a609e8472ebfebb991e"/></dir><file name="Tabs.php" hash="05912b81eea239ad16b5528104fde50a"/></dir><file name="Edit.php" hash="3878e1bb83b25c789a74e41d35cbab37"/></dir><file name="Jewelryshare.php" hash="ac4e61454f5446c9f71c448e55344b7d"/><dir name="List"><dir name="Codes"><file name="Grid.php" hash="91745a1b7af27c8429ca64d92b9e9a6c"/></dir><file name="Codes.php" hash="b0559a0add7c44382f0c8f0718f5c7d5"/><dir name="Items"><file name="Grid.php" hash="14fac42fe4cfeb73d5d12cd5b5100e95"/></dir><file name="Items.php" hash="01e37c7ee401aa6b80d1ece47bb5c0a8"/></dir></dir><file name="Jewelryshare.php" hash="bbedf7e6b9af83cf30a06ff98847f7f4"/></dir><dir name="Helper"><file name="Data.php" hash="583953d868a0f9e820f642e9316f54a3"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Source"><dir name="Cron"><file name="Frequency.php" hash="157982f145c28e528d9a1baa1474aa9a"/><file name="Hours.php" hash="af3a105daaa3f1b9d12779270e7f7389"/></dir></dir></dir></dir><file name="Codes.php" hash="d3364c4fb3efc5b8c0a9b20e36b19577"/><file name="Import.php" hash="43baefae0ce560c3e86deab89970a066"/><file name="Importcron.php" hash="3e25435df67efa4739943a1ac49b2f4e"/><file name="Jewelryshare.php" hash="1a81cc9320f2862938f3de32b8aef228"/><dir name="Mysql4"><dir name="Codes"><file name="Collection.php" hash="108ffaa4a81851cef0523ad4e69b6a4a"/></dir><file name="Codes.php" hash="369c47bfb299953de7bb589e7c53dfcf"/><dir name="Jewelryshare"><file name="Collection.php" hash="995827e4401121ac018640a0116235c5"/></dir><file name="Jewelryshare.php" hash="c1949083da201ed4c3beb448f6f4a0a1"/><file name="Setup.php" hash="a5e601f2f9bdd74ee4d071f7b44b91d8"/></dir><file name="Observer.php" hash="5aa1d35df5f842dea67ba4f8b5c82913"/><dir name="Resource"><dir name="Codes"><file name="Collection.php" hash="9ae5ee4977f839eae5529430cea149d2"/></dir><file name="Codes.php" hash="d5c4c6d0ea0c53d5c9483e373c46c35d"/><file name="Setup.php" hash="d671e546f292d41e109a0dd05c38f2bb"/></dir><file name="Status.php" hash="0e4ad2aa81885846bea70a33f2742530"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Jewelryshare"><dir name="Codes"><file name="GridController.php" hash="f89b68945ac1593bae82702becb9fe3d"/></dir><dir name="Items"><file name="GridController.php" hash="3b1158d0e36ed1d0a01324bc8b32c1a0"/></dir></dir><file name="JewelryshareController.php" hash="9fa99287f44f697a575b7f2c1bfeb6d1"/></dir></dir><dir name="etc"><file name="config.xml" hash="4f4698ac474ffb0e0ea2e57dabadc4b7"/><file name="system.xml" hash="3fe851581dc7bc721b2a65a1e9de03d7"/></dir><dir name="sql"><dir name="jewelryshare_setup"><file name="mysql4-install-0.1.0.php" hash="cf2b169dc15ab3aacfaef4e6fef5e0f6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="jewelerslink"><dir name="layout"><file name="jewelryshare.xml" hash="2c882425e9e4d2a1a8b5aea0f7e72aa7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jewelerslink_Jewelryshare.xml" hash="90d667cb2838d75a228701dc33f2ec69"/></dir></target><target name="mageweb"><dir><dir name="js"><dir name="jewelerslink"><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="content_bg.gif" hash="21278ea0da2d4256f4ced96b6080ba2e"/><file name="jewelerslink.css" hash="41a7b0279ce58c53afda35b3c02a0a64"/><file name="top_bg.gif" hash="26f28090de87d64f9b01bf624f89bfe2"/><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>