Version Notes
Channable Connect
Download this release
Release Info
Developer | Magmodules |
Extension | Magmodules_Channable |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.8 to 1.5.0
- app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Extra.php +48 -30
- app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Filter.php +54 -28
- app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Shipping.php +53 -30
- app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Renderer/Select.php +128 -78
- app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Feeds.php +35 -25
- app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Heading.php +12 -5
- app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Note.php +13 -4
- app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Token.php +10 -24
- app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Version.php +8 -2
- app/code/community/Magmodules/Channable/Block/Adminhtml/Widget/Info/Info.php +35 -29
- app/code/community/Magmodules/Channable/Helper/Data.php +1165 -789
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Extra.php +39 -27
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Filter.php +48 -30
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Shipping.php +53 -31
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Action.php +16 -11
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute.php +51 -27
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Category.php +45 -32
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Categorytype.php +15 -10
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Conditions.php +26 -20
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Configurable.php +21 -16
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Countries.php +17 -12
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Images.php +16 -11
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Mainimage.php +28 -16
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Name.php +60 -47
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Pricemodel.php +17 -11
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Selectattribute.php +37 -26
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Shipping.php +16 -10
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Tax.php +17 -12
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Textattribute.php +58 -47
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Type.php +17 -12
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Visibility.php +17 -12
- app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Weight.php +18 -13
- app/code/community/Magmodules/Channable/Model/Channable.php +629 -417
- app/code/community/Magmodules/Channable/Model/Common.php +258 -207
- app/code/community/Magmodules/Channable/controllers/Adminhtml/ChannableController.php +27 -17
- app/code/community/Magmodules/Channable/controllers/FeedController.php +43 -31
- app/code/community/Magmodules/Channable/data/magmodules_channable_setup/data-upgrade-1.4.8-1.4.9.php +33 -0
- app/code/community/Magmodules/Channable/etc/adminhtml.xml +11 -11
- app/code/community/Magmodules/Channable/etc/config.xml +87 -77
- app/code/community/Magmodules/Channable/etc/system.xml +55 -64
- app/code/community/Magmodules/Channable/sql/magmodules_channable_setup/upgrade-1.4.8-1.4.9.php +36 -0
- package.xml +4 -4
app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Extra.php
CHANGED
@@ -11,42 +11,60 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Extra
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
)
|
38 |
-
|
39 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$this->_addAfter = false;
|
41 |
$this->_addButtonLabel = Mage::helper('channable')->__('Add Attribute');
|
42 |
parent::__construct();
|
43 |
}
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
51 |
|
52 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Extra
|
19 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
20 |
+
{
|
21 |
+
|
22 |
+
protected $_renders = array();
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Extra constructor.
|
26 |
+
*/
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
$layout = Mage::app()->getFrontController()->getAction()->getLayout();
|
30 |
+
$rendererAttributes = $layout->createBlock(
|
31 |
+
'channable/adminhtml_config_form_renderer_select',
|
32 |
+
'',
|
33 |
+
array('is_render_to_js_template' => true)
|
34 |
+
);
|
35 |
+
$rendererAttributes->setOptions(
|
36 |
+
Mage::getModel('channable/adminhtml_system_config_source_attribute')->toOptionArray()
|
37 |
+
);
|
38 |
+
|
39 |
+
$this->addColumn(
|
40 |
+
'attribute', array(
|
41 |
+
'label' => Mage::helper('channable')->__('Magento Attribute'),
|
42 |
+
'style' => 'width:120px',
|
43 |
+
'renderer' => $rendererAttributes
|
44 |
+
)
|
45 |
+
);
|
46 |
+
|
47 |
+
$this->addColumn(
|
48 |
+
'label', array(
|
49 |
+
'label' => Mage::helper('channable')->__('Title'),
|
50 |
+
'style' => 'width:120px',
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
$this->_renders['attribute'] = $rendererAttributes;
|
55 |
$this->_addAfter = false;
|
56 |
$this->_addButtonLabel = Mage::helper('channable')->__('Add Attribute');
|
57 |
parent::__construct();
|
58 |
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param Varien_Object $row
|
62 |
+
*/
|
63 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
64 |
+
{
|
65 |
+
foreach ($this->_renders as $key => $render) {
|
66 |
+
$row->setData('option_extra_attr_' . $render->calcOptionHash($row->getData($key)), 'selected="selected"');
|
67 |
+
}
|
68 |
+
}
|
69 |
|
70 |
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Filter.php
CHANGED
@@ -15,38 +15,62 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Filter
|
|
|
|
|
19 |
|
20 |
-
|
21 |
|
22 |
-
|
|
|
|
|
|
|
23 |
{
|
24 |
$layout = Mage::app()->getFrontController()->getAction()->getLayout();
|
25 |
-
$
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
$
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
$this->addColumn(
|
|
|
32 |
'label' => Mage::helper('channable')->__('Attribute'),
|
33 |
'style' => 'width:100px',
|
34 |
-
|
35 |
-
|
|
|
36 |
|
37 |
-
$this->addColumn(
|
|
|
38 |
'label' => Mage::helper('channable')->__('Condition'),
|
39 |
'style' => 'width:100px',
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
$this->addColumn(
|
|
|
44 |
'label' => Mage::helper('channable')->__('Value'),
|
45 |
'style' => 'width:100px',
|
46 |
-
|
|
|
47 |
|
48 |
-
$this->_renders['attribute'] = $
|
49 |
-
$this->_renders['condition'] = $
|
50 |
|
51 |
$this->_addAfter = false;
|
52 |
$this->_addButtonLabel = Mage::helper('channable')->__('Add Filter');
|
@@ -54,14 +78,16 @@ class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Filter extends Mage
|
|
54 |
}
|
55 |
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
}
|
|
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Filter
|
19 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
20 |
+
{
|
21 |
|
22 |
+
protected $_renders = array();
|
23 |
|
24 |
+
/**
|
25 |
+
* Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Filter constructor.
|
26 |
+
*/
|
27 |
+
public function __construct()
|
28 |
{
|
29 |
$layout = Mage::app()->getFrontController()->getAction()->getLayout();
|
30 |
+
$rendererAttributes = $layout->createBlock(
|
31 |
+
'channable/adminhtml_config_form_renderer_select',
|
32 |
+
'',
|
33 |
+
array('is_render_to_js_template' => true)
|
34 |
+
);
|
35 |
+
$rendererAttributes->setOptions(
|
36 |
+
Mage::getModel('channable/adminhtml_system_config_source_attribute')->toOptionArray()
|
37 |
+
);
|
38 |
|
39 |
+
$rendererConditions = $layout->createBlock(
|
40 |
+
'channable/adminhtml_config_form_renderer_select',
|
41 |
+
'',
|
42 |
+
array('is_render_to_js_template' => true)
|
43 |
+
);
|
44 |
+
|
45 |
+
$rendererConditions->setOptions(
|
46 |
+
Mage::getModel('channable/adminhtml_system_config_source_conditions')->toOptionArray()
|
47 |
+
);
|
48 |
|
49 |
+
$this->addColumn(
|
50 |
+
'attribute', array(
|
51 |
'label' => Mage::helper('channable')->__('Attribute'),
|
52 |
'style' => 'width:100px',
|
53 |
+
'renderer' => $rendererAttributes
|
54 |
+
)
|
55 |
+
);
|
56 |
|
57 |
+
$this->addColumn(
|
58 |
+
'condition', array(
|
59 |
'label' => Mage::helper('channable')->__('Condition'),
|
60 |
'style' => 'width:100px',
|
61 |
+
'renderer' => $rendererConditions
|
62 |
+
)
|
63 |
+
);
|
64 |
|
65 |
+
$this->addColumn(
|
66 |
+
'value', array(
|
67 |
'label' => Mage::helper('channable')->__('Value'),
|
68 |
'style' => 'width:100px',
|
69 |
+
)
|
70 |
+
);
|
71 |
|
72 |
+
$this->_renders['attribute'] = $rendererAttributes;
|
73 |
+
$this->_renders['condition'] = $rendererConditions;
|
74 |
|
75 |
$this->_addAfter = false;
|
76 |
$this->_addButtonLabel = Mage::helper('channable')->__('Add Filter');
|
78 |
}
|
79 |
|
80 |
|
81 |
+
/**
|
82 |
+
* @param Varien_Object $row
|
83 |
+
*/
|
84 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
85 |
+
{
|
86 |
+
foreach ($this->_renders as $key => $render) {
|
87 |
+
$row->setData(
|
88 |
+
'option_extra_attr_' . $render->calcOptionHash($row->getData($key)),
|
89 |
+
'selected="selected"'
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Shipping.php
CHANGED
@@ -15,47 +15,70 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Shipping
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
23 |
{
|
24 |
$layout = Mage::app()->getFrontController()->getAction()->getLayout();
|
25 |
-
$
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
$this->addColumn(
|
|
|
29 |
'label' => Mage::helper('channable')->__('Country'),
|
30 |
'style' => 'width:120px',
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
'label'
|
44 |
-
'style'
|
45 |
-
|
46 |
-
|
47 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
$this->_addAfter = false;
|
50 |
$this->_addButtonLabel = Mage::helper('channable')->__('Add Option');
|
51 |
parent::__construct();
|
52 |
}
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
}
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Shipping
|
19 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
20 |
+
{
|
21 |
|
22 |
+
protected $_renders = array();
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Magmodules_Channable_Block_Adminhtml_Config_Form_Field_Shipping constructor.
|
26 |
+
*/
|
27 |
+
public function __construct()
|
28 |
{
|
29 |
$layout = Mage::app()->getFrontController()->getAction()->getLayout();
|
30 |
+
$rendererCoutries = $layout->createBlock(
|
31 |
+
'channable/adminhtml_config_form_renderer_select',
|
32 |
+
'',
|
33 |
+
array('is_render_to_js_template' => true)
|
34 |
+
);
|
35 |
+
|
36 |
+
$rendererCoutries->setOptions(
|
37 |
+
Mage::getModel('channable/adminhtml_system_config_source_countries')->toOptionArray()
|
38 |
+
);
|
39 |
|
40 |
+
$this->addColumn(
|
41 |
+
'country', array(
|
42 |
'label' => Mage::helper('channable')->__('Country'),
|
43 |
'style' => 'width:120px',
|
44 |
+
'renderer' => $rendererCoutries
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$this->addColumn(
|
49 |
+
'price_from', array(
|
50 |
+
'label' => Mage::helper('channable')->__('Price From'),
|
51 |
+
'style' => 'width:40px',
|
52 |
+
)
|
53 |
+
);
|
54 |
+
$this->addColumn(
|
55 |
+
'price_to', array(
|
56 |
+
'label' => Mage::helper('channable')->__('Price To'),
|
57 |
+
'style' => 'width:40px',
|
58 |
+
)
|
59 |
+
);
|
60 |
+
$this->addColumn(
|
61 |
+
'cost', array(
|
62 |
+
'label' => Mage::helper('channable')->__('Cost'),
|
63 |
+
'style' => 'width:40px',
|
64 |
+
)
|
65 |
+
);
|
66 |
+
|
67 |
+
$this->_renders['country'] = $rendererCoutries;
|
68 |
|
69 |
$this->_addAfter = false;
|
70 |
$this->_addButtonLabel = Mage::helper('channable')->__('Add Option');
|
71 |
parent::__construct();
|
72 |
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @param Varien_Object $row
|
76 |
+
*/
|
77 |
+
protected function _prepareArrayRow(Varien_Object $row)
|
78 |
+
{
|
79 |
+
foreach ($this->_renders as $key => $render) {
|
80 |
+
$row->setData('option_extra_attr_' . $render->calcOptionHash($row->getData($key)), 'selected="selected"');
|
81 |
+
}
|
82 |
}
|
83 |
|
84 |
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Renderer/Select.php
CHANGED
@@ -11,67 +11,74 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_Config_Form_Renderer_Select extends Mage_Core_Block_Html_Select
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
return $this;
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
return $this;
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
return $this;
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
protected function _toHtml()
|
64 |
{
|
65 |
-
if(!$this->_beforeToHtml()) {
|
66 |
return '';
|
67 |
}
|
68 |
|
69 |
-
$html =
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
71 |
$values = $this->getValue();
|
72 |
|
73 |
-
if (!is_array($values)){
|
74 |
-
if (!
|
75 |
$values = array($values);
|
76 |
} else {
|
77 |
$values = array();
|
@@ -79,11 +86,11 @@ class Magmodules_Channable_Block_Adminhtml_Config_Form_Renderer_Select extends M
|
|
79 |
}
|
80 |
|
81 |
$isArrayOption = true;
|
82 |
-
|
83 |
-
|
84 |
-
if($isArrayOption && is_array($option)) {
|
85 |
-
$value
|
86 |
-
$label
|
87 |
$params = (!empty($option['params'])) ? $option['params'] : array();
|
88 |
} else {
|
89 |
$value = $key;
|
@@ -92,36 +99,71 @@ class Magmodules_Channable_Block_Adminhtml_Config_Form_Renderer_Select extends M
|
|
92 |
$params = array();
|
93 |
}
|
94 |
|
95 |
-
if(is_array($value)) {
|
96 |
-
$html.= '<optgroup label="'
|
97 |
-
foreach($value as $keyGroup => $optionGroup) {
|
98 |
-
if(!is_array($optionGroup)) {
|
99 |
$optionGroup = array(
|
100 |
'value' => $keyGroup,
|
101 |
'label' => $optionGroup
|
102 |
);
|
103 |
}
|
104 |
-
|
105 |
-
|
106 |
-
in_array($optionGroup['value'], $values)
|
107 |
-
);
|
108 |
}
|
109 |
-
|
|
|
110 |
} else {
|
111 |
-
$html.= $this->_optionToHtml(
|
|
|
112 |
'value' => $value,
|
113 |
'label' => $label,
|
114 |
'params' => $params
|
115 |
-
|
116 |
-
in_array($value, $values)
|
117 |
);
|
118 |
}
|
119 |
}
|
120 |
-
|
|
|
|
|
121 |
return $html;
|
122 |
}
|
123 |
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
{
|
126 |
$selectedHtml = $selected ? ' selected="selected"' : '';
|
127 |
if ($this->getIsRenderToJsTemplate() === true) {
|
@@ -141,21 +183,29 @@ class Magmodules_Channable_Block_Adminhtml_Config_Form_Renderer_Select extends M
|
|
141 |
}
|
142 |
}
|
143 |
|
144 |
-
return sprintf(
|
|
|
145 |
$this->htmlEscape($option['value']),
|
146 |
$selectedHtml,
|
147 |
-
$params,
|
148 |
-
|
149 |
}
|
150 |
|
151 |
-
|
|
|
|
|
|
|
|
|
152 |
{
|
153 |
-
return $this->toHtml();
|
154 |
-
}
|
155 |
-
|
156 |
-
public function calcOptionHash($optionValue)
|
157 |
-
{
|
158 |
return sprintf('%u', crc32($this->getColumnName() . $this->getInputName() . $optionValue));
|
159 |
}
|
160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_Config_Form_Renderer_Select extends Mage_Core_Block_Html_Select
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param $inputName
|
23 |
+
* @return $this
|
24 |
+
*/
|
25 |
+
public function setInputName($inputName)
|
26 |
+
{
|
27 |
+
$this->setData('inputname', $inputName);
|
28 |
+
|
29 |
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param $columnName
|
34 |
+
* @return $this
|
35 |
+
*/
|
36 |
+
public function setColumnName($columnName)
|
37 |
+
{
|
38 |
+
$this->setData('columnname', $columnName);
|
39 |
+
|
40 |
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param $column
|
45 |
+
* @return $this
|
46 |
+
*/
|
47 |
+
public function setColumn($column)
|
48 |
+
{
|
49 |
+
$this->setData('column', $column);
|
50 |
+
|
51 |
return $this;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return mixed
|
56 |
+
*/
|
57 |
+
public function getHtml()
|
58 |
+
{
|
59 |
+
return $this->toHtml();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
protected function _toHtml()
|
|
|
|
|
|
|
|
|
66 |
{
|
67 |
+
if (!$this->_beforeToHtml()) {
|
68 |
return '';
|
69 |
}
|
70 |
|
71 |
+
$html = sprintf(
|
72 |
+
'<select name="%s" class="%s" %s>',
|
73 |
+
$this->getInputName(),
|
74 |
+
$this->getClass(),
|
75 |
+
$this->getExtraParams()
|
76 |
+
);
|
77 |
+
|
78 |
$values = $this->getValue();
|
79 |
|
80 |
+
if (!is_array($values)) {
|
81 |
+
if (!empty($values)) {
|
82 |
$values = array($values);
|
83 |
} else {
|
84 |
$values = array();
|
86 |
}
|
87 |
|
88 |
$isArrayOption = true;
|
89 |
+
|
90 |
+
foreach ($this->getOptions() as $key => $option) {
|
91 |
+
if ($isArrayOption && is_array($option)) {
|
92 |
+
$value = $option['value'];
|
93 |
+
$label = $option['label'];
|
94 |
$params = (!empty($option['params'])) ? $option['params'] : array();
|
95 |
} else {
|
96 |
$value = $key;
|
99 |
$params = array();
|
100 |
}
|
101 |
|
102 |
+
if (is_array($value)) {
|
103 |
+
$html .= '<optgroup label="' . $label . '">';
|
104 |
+
foreach ($value as $keyGroup => $optionGroup) {
|
105 |
+
if (!is_array($optionGroup)) {
|
106 |
$optionGroup = array(
|
107 |
'value' => $keyGroup,
|
108 |
'label' => $optionGroup
|
109 |
);
|
110 |
}
|
111 |
+
|
112 |
+
$html .= $this->_optionToHtml($optionGroup, in_array($optionGroup['value'], $values));
|
|
|
|
|
113 |
}
|
114 |
+
|
115 |
+
$html .= '</optgroup>';
|
116 |
} else {
|
117 |
+
$html .= $this->_optionToHtml(
|
118 |
+
array(
|
119 |
'value' => $value,
|
120 |
'label' => $label,
|
121 |
'params' => $params
|
122 |
+
), in_array($value, $values)
|
|
|
123 |
);
|
124 |
}
|
125 |
}
|
126 |
+
|
127 |
+
$html .= '</select>';
|
128 |
+
|
129 |
return $html;
|
130 |
}
|
131 |
|
132 |
+
/**
|
133 |
+
* @return mixed
|
134 |
+
*/
|
135 |
+
public function getInputName()
|
136 |
+
{
|
137 |
+
return $this->getData('inputname');
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @return string
|
142 |
+
*/
|
143 |
+
public function getExtraParams()
|
144 |
+
{
|
145 |
+
$column = $this->getColumn();
|
146 |
+
if ($column && isset($column['style'])) {
|
147 |
+
return ' style="' . $column['style'] . '" ';
|
148 |
+
} else {
|
149 |
+
return '';
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @return mixed
|
155 |
+
*/
|
156 |
+
public function getColumn()
|
157 |
+
{
|
158 |
+
return $this->getData('column');
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @param $option
|
163 |
+
* @param bool $selected
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
protected function _optionToHtml($option, $selected = false)
|
167 |
{
|
168 |
$selectedHtml = $selected ? ' selected="selected"' : '';
|
169 |
if ($this->getIsRenderToJsTemplate() === true) {
|
183 |
}
|
184 |
}
|
185 |
|
186 |
+
return sprintf(
|
187 |
+
'<option value="%s"%s %s>%s</option>',
|
188 |
$this->htmlEscape($option['value']),
|
189 |
$selectedHtml,
|
190 |
+
$params, $this->htmlEscape($option['label'])
|
191 |
+
);
|
192 |
}
|
193 |
|
194 |
+
/**
|
195 |
+
* @param $optionValue
|
196 |
+
* @return string
|
197 |
+
*/
|
198 |
+
public function calcOptionHash($optionValue)
|
199 |
{
|
|
|
|
|
|
|
|
|
|
|
200 |
return sprintf('%u', crc32($this->getColumnName() . $this->getInputName() . $optionValue));
|
201 |
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* @return mixed
|
205 |
+
*/
|
206 |
+
public function getColumnName()
|
207 |
+
{
|
208 |
+
return $this->getData('columnname');
|
209 |
+
}
|
210 |
+
|
211 |
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Feeds.php
CHANGED
@@ -6,40 +6,50 @@
|
|
6 |
* This source file is subject to the EULA that is
|
7 |
* available through the world-wide-web at:
|
8 |
* http://www.magmodules.eu/license-agreement/
|
9 |
-
*
|
10 |
* @category Magmodules
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Feeds
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
foreach($storeIds as $storeId) {
|
27 |
-
$base_url = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
28 |
-
$channable_feed = $base_url . 'channable/feed/get/code/' . $token .'/store/' . $storeId . '/array/1';
|
29 |
-
$store_title = Mage::app()->getStore($storeId)->getName();
|
30 |
-
$html_feedlinks .= '<tr><td>' . $store_title . '</td><td><a href="' . $channable_feed . '">Preview</a></td><td><a href="https://app.channable.com/connect/magento.html?store_id=' . $storeId . '&url=' . $base_url . '&token=' . $token . '" target="_blank">Click to auto connect with Channable</a></td></tr>';
|
31 |
-
}
|
32 |
-
|
33 |
-
if(!$html_feedlinks) {
|
34 |
-
$html_feedlinks = Mage::helper('channable')->__('No enabled feed(s) found');
|
35 |
-
} else {
|
36 |
-
$html_header = '<div class="grid"><table cellpadding="0" cellspacing="0" class="border" style="width:425px;"><tbody><tr class="headings"><th>Store</th><th>Preview</th><th>Connect</th></tr>';
|
37 |
-
$html_footer = '</tbody></table></div>';
|
38 |
-
$html_feedlinks = $html_header . $html_feedlinks . $html_footer;
|
39 |
-
}
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
-
|
45 |
}
|
6 |
* This source file is subject to the EULA that is
|
7 |
* available through the world-wide-web at:
|
8 |
* http://www.magmodules.eu/license-agreement/
|
9 |
+
*
|
10 |
* @category Magmodules
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Feeds
|
19 |
+
extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
27 |
{
|
28 |
+
$helper = Mage::helper('channable');
|
29 |
+
$storeIds = $helper->getStoreIds('channable/connect/enabled');
|
30 |
+
$token = Mage::getStoreConfig('channable/connect/token');
|
31 |
+
$htmlFeedlinks = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
foreach ($storeIds as $storeId) {
|
34 |
+
$baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
35 |
+
$channableFeed = $baseUrl . 'channable/feed/get/code/' . $token . '/store/' . $storeId . '/array/1';
|
36 |
+
$storeTitle = Mage::app()->getStore($storeId)->getName();
|
37 |
+
$htmlFeedlinks .= '<tr><td>' . $storeTitle . '</td><td><a href="' . $channableFeed . '">Preview</a></td><td><a href="https://app.channable.com/connect/magento.html?store_id=' . $storeId . '&url=' . $baseUrl . '&token=' . $token . '" target="_blank">Click to auto connect with Channable</a></td></tr>';
|
38 |
+
}
|
39 |
+
|
40 |
+
if (!$htmlFeedlinks) {
|
41 |
+
$htmlFeedlinks = $helper->__('No enabled feed(s) found');
|
42 |
+
} else {
|
43 |
+
$htmlHeader = '<div class="grid"><table cellpadding="0" cellspacing="0" class="border" style="width:425px;"><tbody><tr class="headings"><th>Store</th><th>Preview</th><th>Connect</th></tr>';
|
44 |
+
$htmlFooter = '</tbody></table></div>';
|
45 |
+
$htmlFeedlinks = $htmlHeader . $htmlFeedlinks . $htmlFooter;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
return sprintf(
|
50 |
+
'<tr id="row_%s"><td colspan="6" class="label" style="margin-bottom: 10px;">%s</td></tr>',
|
51 |
+
$element->getHtmlId(), $htmlFeedlinks
|
52 |
+
);
|
53 |
}
|
54 |
+
|
55 |
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Heading.php
CHANGED
@@ -15,13 +15,20 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Heading
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
-
|
23 |
-
|
24 |
-
$element->getHtmlId(),
|
|
|
25 |
);
|
26 |
}
|
27 |
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Heading
|
19 |
+
extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
27 |
{
|
28 |
+
return sprintf(
|
29 |
+
'<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4>%s</h4></td></tr>',
|
30 |
+
$element->getHtmlId(),
|
31 |
+
$element->getLabel()
|
32 |
);
|
33 |
}
|
34 |
|
app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Note.php
CHANGED
@@ -15,12 +15,21 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Note
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
}
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Note
|
19 |
+
extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
27 |
{
|
28 |
+
return sprintf(
|
29 |
+
'<tr id="row_%s"><td colspan="5" class="label" style="margin-bottom: 10px;">%s</td></tr>',
|
30 |
+
$element->getHtmlId(),
|
31 |
+
$element->getLabel()
|
32 |
+
);
|
33 |
}
|
34 |
|
35 |
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Token.php
CHANGED
@@ -15,31 +15,17 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Token
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
$config = new Mage_Core_Model_Config();
|
28 |
-
$config->saveConfig('channable/connect/token', $token, 'default', 0);
|
29 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
30 |
-
return $token;
|
31 |
-
} else {
|
32 |
-
$token = '';
|
33 |
-
$chars = str_split("abcdefghijklmnopqrstuvwxyz0123456789");
|
34 |
-
for($i = 0; $i < 16; $i++) {
|
35 |
-
$token .= $chars[array_rand($chars)];
|
36 |
-
}
|
37 |
-
$config = new Mage_Core_Model_Config();
|
38 |
-
$config->saveConfig('channable/connect/token', $token, 'default', 0);
|
39 |
-
Mage::app()->getCacheInstance()->cleanType('config');
|
40 |
-
return $token;
|
41 |
-
}
|
42 |
-
}
|
43 |
}
|
44 |
|
45 |
}
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Token
|
19 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return mixed
|
25 |
+
*/
|
26 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
27 |
+
{
|
28 |
+
return Mage::getStoreConfig('channable/connect/token');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
}
|
app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Version.php
CHANGED
@@ -15,9 +15,15 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Version
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
$modules = Mage::getConfig()->getNode('modules')->children();
|
23 |
$modulesArray = (array)$modules;
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Version
|
19 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return mixed
|
25 |
+
*/
|
26 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
27 |
{
|
28 |
$modules = Mage::getConfig()->getNode('modules')->children();
|
29 |
$modulesArray = (array)$modules;
|
app/code/community/Magmodules/Channable/Block/Adminhtml/Widget/Info/Info.php
CHANGED
@@ -15,16 +15,22 @@
|
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Block_Adminhtml_Widget_Info_Info
|
|
|
|
|
19 |
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
-
$
|
23 |
-
$
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
<h4>About Magmodules.eu</h4>
|
29 |
<p>We are a Magento only E-commerce Agency located in the Netherlands.<br>
|
30 |
<br />
|
@@ -48,30 +54,30 @@ class Magmodules_Channable_Block_Adminhtml_Widget_Info_Info extends Mage_Adminht
|
|
48 |
</table>
|
49 |
</div>';
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
return $html;
|
76 |
}
|
77 |
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Block_Adminhtml_Widget_Info_Info
|
19 |
+
extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
27 |
{
|
28 |
+
$magentoVersion = Mage::getVersion();
|
29 |
+
$moduleVersion = Mage::getConfig()->getNode()->modules->Magmodules_Channable->version;
|
30 |
|
31 |
+
$logoLink = '//www.magmodules.eu/logo/channable/' . $moduleVersion . '/' . $magentoVersion . '/logo.png';
|
32 |
|
33 |
+
$html = '<div style="background:url(\'' . $logoLink . '\') no-repeat scroll 15px center #EAF0EE;border:1px solid #CCCCCC;margin-bottom:10px;padding:10px 5px 5px 200px;">
|
34 |
<h4>About Magmodules.eu</h4>
|
35 |
<p>We are a Magento only E-commerce Agency located in the Netherlands.<br>
|
36 |
<br />
|
54 |
</table>
|
55 |
</div>';
|
56 |
|
57 |
+
if (Mage::helper('channable')->checkOldVersion('Channable')) {
|
58 |
+
$msg = '<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>' . Mage::helper('channable')->__('Old version detected on the server, please remove the directory <u>app/code/local/Magmodules/Channable</u> and flush cache!') . '</span></li></ul></li></ul></div>';
|
59 |
+
$html = $msg . $html;
|
60 |
+
}
|
61 |
|
62 |
+
$flatProduct = Mage::getStoreConfig('catalog/frontend/flat_catalog_product');
|
63 |
+
$flatCategoy = Mage::getStoreConfig('catalog/frontend/flat_catalog_category');
|
64 |
+
if ((!$flatProduct) || (!$flatCategoy)) {
|
65 |
+
$msg = '<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>' . Mage::helper('channable')->__('Please enable "Flat Catalog Category" and "Flat Catalog Product" for the extension to work properly. <a href="https://www.magmodules.eu/help/enable-flat-catalog/" target="_blank">More information.</a>') . '</span></li></ul></li></ul></div>';
|
66 |
+
$html = $html . $msg;
|
67 |
+
}
|
68 |
+
|
69 |
+
if (empty($oldversion)) {
|
70 |
+
if (Mage::getStoreConfig('catalog/frontend/flat_catalog_product')) {
|
71 |
+
$storeId = Mage::helper('channable')->getStoreIdConfig();
|
72 |
+
$nonFlatAttributes = Mage::helper('channable')->checkFlatCatalog(Mage::getModel("channable/channable")->getFeedAttributes('', $storeId));
|
73 |
+
if (!empty($nonFlatAttributes)) {
|
74 |
+
$html .= '<div id="messages"><ul class="messages"><li class="error-msg"><ul><li><span>';
|
75 |
+
$html .= $this->__('Warning: The following used attribute(s) were not found in the flat catalog: %s. This can result in empty data or higher resource usage. Click <a href="%s">here</a> to add these to the flat catalog. ', implode($nonFlatAttributes, ', '), $this->getUrl('adminhtml/channable/addToFlat'));
|
76 |
+
$html .= '</span></ul></li></ul></div>';
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
return $html;
|
82 |
}
|
83 |
|
app/code/community/Magmodules/Channable/Helper/Data.php
CHANGED
@@ -11,796 +11,1172 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
-
* @version
|
16 |
* =============================================================
|
17 |
*/
|
18 |
-
|
19 |
-
class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract {
|
20 |
-
|
21 |
-
public function getStoreIds($path)
|
22 |
-
{
|
23 |
-
$store_ids = array();
|
24 |
-
foreach(Mage::app()->getStores() as $store) {
|
25 |
-
$store_id = Mage::app()->getStore($store)->getId();
|
26 |
-
if(Mage::getStoreConfig($path, $store_id)) {
|
27 |
-
$store_ids[] = $store_id;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
return $store_ids;
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getProductDataRow($product, $config, $parent)
|
34 |
-
{
|
35 |
-
$fields = $config['field'];
|
36 |
-
$data = array();
|
37 |
-
|
38 |
-
if(!$this->validateParent($parent, $config, $product)) { $parent = ''; }
|
39 |
-
if(!$this->validateProduct($product, $config, $parent)) { return false; }
|
40 |
-
|
41 |
-
foreach($fields as $key => $field) {
|
42 |
-
$rows = $this->getAttributeValue($key, $product, $config, $field['action'], $parent);
|
43 |
-
if(is_array($rows)) {
|
44 |
-
$data = array_merge($data, $rows);
|
45 |
-
}
|
46 |
-
}
|
47 |
-
if(empty($config['skip_validation'])) {
|
48 |
-
if(!empty($data[$fields['price']['label']])) {
|
49 |
-
return $data;
|
50 |
-
}
|
51 |
-
} else {
|
52 |
-
return $data;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
public function getAttributeValue($field, $product, $config, $actions = '', $parent)
|
57 |
-
{
|
58 |
-
$data = $config['field'][$field];
|
59 |
-
$product_data = $product;
|
60 |
-
|
61 |
-
if(!empty($parent)) {
|
62 |
-
if(!empty($data['parent'])) {
|
63 |
-
$product_data = $parent;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
switch($field) {
|
68 |
-
case 'product_url':
|
69 |
-
$value = $this->getProductUrl($product, $config, $parent);
|
70 |
-
break;
|
71 |
-
case 'image_link':
|
72 |
-
$value = $this->getProductImage($product_data, $config);
|
73 |
-
break;
|
74 |
-
case 'condition':
|
75 |
-
$value = $this->getProductCondition($product_data, $config);
|
76 |
-
break;
|
77 |
-
case 'availability':
|
78 |
-
$value = $this->getProductAvailability($product_data, $config);
|
79 |
-
break;
|
80 |
-
case 'weight':
|
81 |
-
$value = $this->getProductWeight($product_data, $config);
|
82 |
-
break;
|
83 |
-
case 'price':
|
84 |
-
$value = $this->getProductPrice($product_data, $config, $parent);
|
85 |
-
break;
|
86 |
-
case 'bundle':
|
87 |
-
$value = $this->getProductBundle($product_data, $config);
|
88 |
-
break;
|
89 |
-
case 'parent_id':
|
90 |
-
$value = $this->getProductData($parent, $data);
|
91 |
-
break;
|
92 |
-
case 'attribute_set_id':
|
93 |
-
$value = $this->getAttributeSetName($product_data, $data);
|
94 |
-
break;
|
95 |
-
case 'categories':
|
96 |
-
$value = $this->getProductCategories($product_data, $config);
|
97 |
-
break;
|
98 |
-
default:
|
99 |
-
if(!empty($data['source'])) {
|
100 |
-
$value = $this->getProductData($product_data, $data, $config);
|
101 |
-
} else {
|
102 |
-
$value = '';
|
103 |
-
}
|
104 |
-
break;
|
105 |
-
}
|
106 |
-
|
107 |
-
if($config['field'][$field]['type'] == 'media_image') {
|
108 |
-
if($field != 'image_link') {
|
109 |
-
if(!empty($value)) {
|
110 |
-
if($value != 'no_selection') {
|
111 |
-
$value = $config['media_url'] . 'catalog/product' . $value;
|
112 |
-
} else {
|
113 |
-
$value = '';
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
if((isset($actions)) && (!empty($value))) {
|
120 |
-
$value = $this->cleanData($value, $actions);
|
121 |
-
}
|
122 |
-
|
123 |
-
if((is_array($value) && ($field == 'image_link'))) {
|
124 |
-
$i = 1;
|
125 |
-
foreach($value as $key => $val) {
|
126 |
-
$data_row[$key] = $val;
|
127 |
-
$i++;
|
128 |
-
}
|
129 |
-
return $data_row;
|
130 |
-
}
|
131 |
-
|
132 |
-
if(!empty($value) || is_numeric($value)) {
|
133 |
-
$data_row[$data['label']] = $value;
|
134 |
-
return $data_row;
|
135 |
-
}
|
136 |
-
}
|
137 |
-
|
138 |
-
public function cleanData($st, $action = '')
|
139 |
-
{
|
140 |
-
if($action) {
|
141 |
-
$actions = explode('_', $action);
|
142 |
-
if(in_array('striptags', $actions)) {
|
143 |
-
$st = $this->stripTags($st);
|
144 |
-
$st = trim($st);
|
145 |
-
}
|
146 |
-
if(in_array('replacetags', $actions)) {
|
147 |
-
$st = str_replace(array("\r", "\n"), "", $st);
|
148 |
-
$st = str_replace(array("<br>","<br/>", "<br />"), '\n', $st);
|
149 |
-
$st = $this->stripTags($st);
|
150 |
-
$st = rtrim($st);
|
151 |
-
}
|
152 |
-
if(in_array('replacetagsn', $actions)) {
|
153 |
-
$st = str_replace(array("\r", "\n"), "", $st);
|
154 |
-
$st = str_replace(array("<br>","<br/>", "<br />"), '\\' . '\n', $st);
|
155 |
-
$st = $this->stripTags($st);
|
156 |
-
$st = rtrim($st);
|
157 |
-
}
|
158 |
-
if(in_array('rn', $actions)) {
|
159 |
-
$st = str_replace(array("\r", "\n"), "", $st);
|
160 |
-
}
|
161 |
-
if(in_array('truncate', $actions)) {
|
162 |
-
$st = Mage::helper('core/string')->truncate($st, '5000');
|
163 |
-
}
|
164 |
-
if(in_array('truncate150', $actions)) {
|
165 |
-
$st = Mage::helper('core/string')->truncate($st, '150');
|
166 |
-
}
|
167 |
-
if(in_array('uppercheck', $actions)) {
|
168 |
-
if(strtoupper($st) == $st) {
|
169 |
-
$st = ucfirst(strtolower($st));
|
170 |
-
}
|
171 |
-
}
|
172 |
-
if(in_array('cdata', $actions)) {
|
173 |
-
$st = '<![CDATA[' . $st . ']]>';
|
174 |
-
}
|
175 |
-
if(in_array('round', $actions)) {
|
176 |
-
if(!empty($actions[1])) {
|
177 |
-
if($st > $actions[1]) {
|
178 |
-
$st = $actions[1];
|
179 |
-
}
|
180 |
-
}
|
181 |
-
$st = round($st);
|
182 |
-
}
|
183 |
-
if(in_array('boolean', $actions)) {
|
184 |
-
($st > 0 ? $st = 1 : $st = 0);
|
185 |
-
}
|
186 |
-
}
|
187 |
-
return $st;
|
188 |
-
}
|
189 |
-
|
190 |
-
public function getProductUrl($product, $config, $parent)
|
191 |
-
{
|
192 |
-
$url = '';
|
193 |
-
if(!empty($parent)) {
|
194 |
-
if($parent->getRequestPath()) {
|
195 |
-
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $parent->getRequestPath()));
|
196 |
-
}
|
197 |
-
if(empty($url)) {
|
198 |
-
if($parent->getUrlKey()) {
|
199 |
-
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $parent->getUrlKey()));
|
200 |
-
}
|
201 |
-
}
|
202 |
-
} else {
|
203 |
-
if($product->getRequestPath()) {
|
204 |
-
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $product->getRequestPath()));
|
205 |
-
}
|
206 |
-
if(empty($url)) {
|
207 |
-
if($product->getUrlKey()) {
|
208 |
-
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $product->getUrlKey()));
|
209 |
-
}
|
210 |
-
}
|
211 |
-
}
|
212 |
-
if(!empty($config['product_url_suffix'])) {
|
213 |
-
if(strpos($url, $config['product_url_suffix']) === false) {
|
214 |
-
$url = $url . $config['product_url_suffix'];
|
215 |
-
}
|
216 |
-
}
|
217 |
-
if(!empty($parent) && !empty($config['conf_switch_urls']) && !empty($url)) {
|
218 |
-
if($parent->getTypeId() == 'configurable') {
|
219 |
-
$productAttributeOptions = $parent->getTypeInstance(true)->getConfigurableAttributesAsArray($parent);
|
220 |
-
$url_extra = '';
|
221 |
-
foreach ($productAttributeOptions as $productAttribute) {
|
222 |
-
if($id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), $productAttribute['attribute_code'], $config['store_id'])) {
|
223 |
-
$url_extra .= $productAttribute['attribute_id'] . '=' . $id . '&';
|
224 |
-
}
|
225 |
-
}
|
226 |
-
if(!empty($url_extra)) {
|
227 |
-
$url = $url . '#' . rtrim($url_extra, '&');
|
228 |
-
}
|
229 |
-
}
|
230 |
-
}
|
231 |
-
return $url;
|
232 |
-
}
|
233 |
-
|
234 |
-
public function getProductImage($product, $config)
|
235 |
-
{
|
236 |
-
$image_data = array();
|
237 |
-
if(!empty($config['image_resize']) && !empty($config['image_size'])) {
|
238 |
-
$image_file = $product->getData($config['image_source']);
|
239 |
-
$imageModel = Mage::getModel('catalog/product_image')->setSize($config['image_size'])->setDestinationSubdir($config['image_source'])->setBaseFile($image_file);
|
240 |
-
if(!$imageModel->isCached()) {
|
241 |
-
$imageModel->resize()->saveFile();
|
242 |
-
}
|
243 |
-
$productImage = $imageModel->getUrl();
|
244 |
-
return (string)$productImage;
|
245 |
-
} else {
|
246 |
-
$image = '';
|
247 |
-
if(!empty($config['media_attributes'])) {
|
248 |
-
foreach($config['media_attributes'] as $media_att) {
|
249 |
-
if($media_att == 'base') { $media_att = 'image'; }
|
250 |
-
$media_data = $product->getData($media_att);
|
251 |
-
if(!empty($media_data)) {
|
252 |
-
if($media_data != 'no_selection') {
|
253 |
-
$image = $config['media_image_url'] . $media_data;
|
254 |
-
$image_data['image'][$media_att] = $image;
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
} else {
|
259 |
-
if($product->getThumbnail()) {
|
260 |
-
if($product->getThumbnail() != 'no_selection') {
|
261 |
-
$image = $config['media_image_url'] . $product->getThumbnail();
|
262 |
-
$image_data['image']['thumbnail'] = $image;
|
263 |
-
}
|
264 |
-
}
|
265 |
-
if($product->getSmallImage()) {
|
266 |
-
if($product->getSmallImage() != 'no_selection') {
|
267 |
-
$image = $config['media_image_url'] . $product->getSmallImage();
|
268 |
-
$image_data['image']['small_image'] = $image;
|
269 |
-
}
|
270 |
-
}
|
271 |
-
if($product->getImage()) {
|
272 |
-
if($product->getImage() != 'no_selection') {
|
273 |
-
$image = $config['media_image_url'] . $product->getImage();
|
274 |
-
$image_data['image']['image'] = $image;
|
275 |
-
}
|
276 |
-
}
|
277 |
-
}
|
278 |
-
if(!empty($config['images'])) {
|
279 |
-
$image_data['image_link'] = $image;
|
280 |
-
$container = new Varien_Object(array('attribute' => new Varien_Object(array('id' => $config['media_gallery_id']))));
|
281 |
-
$img_product = new Varien_Object(array('id' => $product->getId(),'store_id' => $config['store_id']));
|
282 |
-
$gallery = Mage::getResourceModel('catalog/product_attribute_backend_media')->loadGallery($img_product, $container);
|
283 |
-
$images = array(); $i = 1;
|
284 |
-
usort($gallery, function($a, $b) { return $a['position_default'] > $b['position_default']; });
|
285 |
-
foreach($gallery as $gal_image) {
|
286 |
-
if($gal_image['disabled'] == 0) {
|
287 |
-
$image_data['image']['all']['image_' . $i] = $config['media_image_url'] . $gal_image['file'];
|
288 |
-
$image_data['image']['last'] = $config['media_image_url'] . $gal_image['file'];
|
289 |
-
if($i == 1) { $image_data['image']['first'] = $config['media_image_url'] . $gal_image['file']; }
|
290 |
-
$i++;
|
291 |
-
}
|
292 |
-
}
|
293 |
-
return $image_data;
|
294 |
-
} else {
|
295 |
-
if(!empty($image_data['image']['image'])) {
|
296 |
-
return $image_data['image']['image'];
|
297 |
-
} else {
|
298 |
-
return $image;
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
302 |
-
}
|
303 |
-
|
304 |
-
public function getProductCondition($product, $config)
|
305 |
-
{
|
306 |
-
if(isset($config['condition_attribute'])) {
|
307 |
-
if($condition = $product->getAttributeText($config['condition_attribute'])) {
|
308 |
-
return $condition;
|
309 |
-
} else{
|
310 |
-
return false;
|
311 |
-
}
|
312 |
-
}
|
313 |
-
if(!empty($config['condition_default'])) {
|
314 |
-
return $config['condition_default'];
|
315 |
-
}
|
316 |
-
}
|
317 |
-
|
318 |
-
public function getProductBundle($product, $config)
|
319 |
-
{
|
320 |
-
if($product->getTypeId() == 'bundle') {
|
321 |
-
return 'true';
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
public function getProductAvailability($product, $config)
|
326 |
-
{
|
327 |
-
if(!empty($config['stock_instock'])) {
|
328 |
-
if($product->getUseConfigManageStock()) {
|
329 |
-
$manage_stock = $config['stock_manage'];
|
330 |
-
} else {
|
331 |
-
$manage_stock = $product->getManageStock();
|
332 |
-
}
|
333 |
-
if($manage_stock) {
|
334 |
-
if($product['stock_status']) {
|
335 |
-
$availability = $config['stock_instock'];
|
336 |
-
} else {
|
337 |
-
$availability = $config['stock_outofstock'];
|
338 |
-
}
|
339 |
-
} else {
|
340 |
-
$availability = $config['stock_instock'];
|
341 |
-
}
|
342 |
-
return $availability;
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
public function getProductWeight($product, $config)
|
347 |
-
{
|
348 |
-
if(!empty($config['weight'])) {
|
349 |
-
$weight = number_format($product->getWeight(), 2, '.', '');
|
350 |
-
if(isset($config['weight_units'])) {
|
351 |
-
$weight = $weight . ' ' . $config['weight_units'];
|
352 |
-
}
|
353 |
-
return $weight;
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
public function getAttributeSetName($product, $data)
|
358 |
-
{
|
359 |
-
return Mage::getModel('eav/entity_attribute_set')->load($product->getAttributeSetId())->getAttributeSetName();
|
360 |
-
}
|
361 |
-
|
362 |
-
public function getProductCategories($product, $config)
|
363 |
-
{
|
364 |
-
if(isset($config['category_data'])) {
|
365 |
-
$category_data = $config['category_data'];
|
366 |
-
$products_cat = array();
|
367 |
-
$category_ids = $product->getCategoryIds();
|
368 |
-
$level = 0;
|
369 |
-
if(!empty($config['category_full'])) {
|
370 |
-
$path = array();
|
371 |
-
foreach($category_ids as $category_id) {
|
372 |
-
if(isset($category_data[$category_id])) {
|
373 |
-
$path[] = $category_data[$category_id]['name'];
|
374 |
-
}
|
375 |
-
}
|
376 |
-
$products_cat = array('path' => $path);
|
377 |
-
} else {
|
378 |
-
foreach($category_ids as $category_id) {
|
379 |
-
if(isset($category_data[$category_id])) {
|
380 |
-
$products_cat[] = $category_data[$category_id];
|
381 |
-
$level = $category_data[$category_id]['level'];
|
382 |
-
}
|
383 |
-
}
|
384 |
-
}
|
385 |
-
return $this->getSortedArray($products_cat, 'level');
|
386 |
-
}
|
387 |
-
}
|
388 |
-
|
389 |
-
function getSortedArray($data, $sort)
|
390 |
-
{
|
391 |
-
$code = "return strnatcmp(\$a['$sort'], \$b['$sort']);";
|
392 |
-
usort($data, create_function('$a,$b', $code));
|
393 |
-
return array_reverse($data);
|
394 |
-
}
|
395 |
-
|
396 |
-
public function getProductData($product, $data, $config = '')
|
397 |
-
{
|
398 |
-
$type = $data['type'];
|
399 |
-
$source = $data['source'];
|
400 |
-
$value = '';
|
401 |
-
switch($type) {
|
402 |
-
case 'price':
|
403 |
-
if(!empty($product[$source])) {
|
404 |
-
$value = number_format($product[$source], 2, '.', '');
|
405 |
-
if(!empty($config['currency'])) {
|
406 |
-
$value .= ' ' . $config['currency'];
|
407 |
-
}
|
408 |
-
}
|
409 |
-
break;
|
410 |
-
case 'select':
|
411 |
-
$value = $product->getAttributeText($source);
|
412 |
-
break;
|
413 |
-
case 'multiselect':
|
414 |
-
if(count($product->getAttributeText($source))) {
|
415 |
-
if(count($product->getAttributeText($source)) > 1) {
|
416 |
-
$value = implode(',', $product->getAttributeText($source));
|
417 |
-
} else {
|
418 |
-
$value = $product->getAttributeText($source);
|
419 |
-
}
|
420 |
-
}
|
421 |
-
break;
|
422 |
-
default:
|
423 |
-
if(isset($product[$source])) {
|
424 |
-
$value = $product[$source];
|
425 |
-
}
|
426 |
-
break;
|
427 |
-
}
|
428 |
-
return $value;
|
429 |
-
}
|
430 |
-
|
431 |
-
public function getProductPrice($product, $config, $parent)
|
432 |
-
{
|
433 |
-
$price_data = array();
|
434 |
-
$price_markup = $this->getPriceMarkup($config);
|
435 |
-
$tax_param = $config['use_tax'];
|
436 |
-
|
437 |
-
if(!empty($config['hide_currency'])) {
|
438 |
-
$currency = '';
|
439 |
-
} else {
|
440 |
-
$currency = ' ' . $config['currency'];
|
441 |
-
}
|
442 |
-
|
443 |
-
if(!empty($config['price_scope'])) {
|
444 |
-
$price = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'price', $config['store_id']);
|
445 |
-
} else {
|
446 |
-
$price = $product->getPrice();
|
447 |
-
}
|
448 |
-
|
449 |
-
$price = Mage::helper('tax')->getPrice($product, $price, $tax_param);
|
450 |
-
$price_data['regular_price'] = number_format(($price * $price_markup), 2, '.', '') . $currency;
|
451 |
-
$pricerule_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), $tax_param);
|
452 |
-
|
453 |
-
$special_price = ''; $special_date = '';
|
454 |
-
if(($pricerule_price > 0) && ($pricerule_price < $price)) {
|
455 |
-
$sales_price = $pricerule_price;
|
456 |
-
$specialPriceFromDate = $product->getSpecialFromDate();
|
457 |
-
$specialPriceToDate = $product->getSpecialToDate();
|
458 |
-
$today = time();
|
459 |
-
if($today >= strtotime($specialPriceFromDate)) {
|
460 |
-
if($today <= strtotime($specialPriceToDate) || is_null($specialPriceToDate)) {
|
461 |
-
$price_data['sales_date_start'] = $specialPriceFromDate;
|
462 |
-
$price_data['sales_date_end'] = $specialPriceToDate;
|
463 |
-
}
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
if(($product->getTypeId() == 'bundle') && ($price < 0.01)) {
|
468 |
-
$price = $this->getPriceBundle($product, $config['store_id']);
|
469 |
-
}
|
470 |
-
|
471 |
-
if($product->getTypeId() == 'grouped') {
|
472 |
-
if(!empty($config['price_grouped'])) {
|
473 |
-
$price = $this->getPriceGrouped($product, $config['price_grouped']);
|
474 |
-
} else {
|
475 |
-
if($price < 0.01) {
|
476 |
-
$price = $this->getPriceGrouped($product);
|
477 |
-
}
|
478 |
-
}
|
479 |
-
}
|
480 |
-
|
481 |
-
$price_data['final_price_clean'] = $price;
|
482 |
-
$price_data['price'] = number_format(($price * $price_markup), 2, '.', '') . $currency;
|
483 |
-
|
484 |
-
if(isset($sales_price)) {
|
485 |
-
$price_data['sales_price'] = number_format(($sales_price * $price_markup), 2, '.', '') . $currency;
|
486 |
-
}
|
487 |
-
|
488 |
-
return $price_data;
|
489 |
-
}
|
490 |
-
|
491 |
-
public function getPriceMarkup($config)
|
492 |
-
{
|
493 |
-
$markup = 1;
|
494 |
-
if(!empty($config['price_add_tax']) && !empty($config['price_add_tax_perc'])) {
|
495 |
-
$markup = 1 + ($config['price_add_tax_perc'] / 100);
|
496 |
-
}
|
497 |
-
if($config['base_currency_code'] != $config['currency']) {
|
498 |
-
$exchange_rate = Mage::helper('directory')->currencyConvert(1, $config['base_currency_code'], $config['currency']);
|
499 |
-
$markup = ($markup * $exchange_rate);
|
500 |
-
}
|
501 |
-
return $markup;
|
502 |
-
}
|
503 |
-
|
504 |
-
public function getTaxUsage($config)
|
505 |
-
{
|
506 |
-
if(!empty($config['force_tax'])) {
|
507 |
-
if($config['force_tax'] == 'incl') {
|
508 |
-
return 'true';
|
509 |
-
} else {
|
510 |
-
return '';
|
511 |
-
}
|
512 |
-
} else {
|
513 |
-
return 'true';
|
514 |
-
}
|
515 |
-
}
|
516 |
-
|
517 |
-
public function addAttributeData($attributes, $config = '')
|
518 |
-
{
|
519 |
-
foreach($attributes as $key => $attribute) {
|
520 |
-
$type = (!empty($attribute['type']) ? $attribute['type'] : '');
|
521 |
-
$action = (!empty($attribute['action']) ? $attribute['action'] : '');
|
522 |
-
$parent = (!empty($attribute['parent']) ? $attribute['parent'] : '');
|
523 |
-
if(isset($attribute['source'])) {
|
524 |
-
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $attribute['source']);
|
525 |
-
$type = $attributeModel->getFrontendInput();
|
526 |
-
}
|
527 |
-
if(!empty($config['conf_fields'])) {
|
528 |
-
$conf_attributes = explode(',', $config['conf_fields']);
|
529 |
-
if(in_array($key, $conf_attributes)) {
|
530 |
-
$parent = '1';
|
531 |
-
}
|
532 |
-
}
|
533 |
-
$attributes[$key] = array('label' => $attribute['label'], 'source' => $attribute['source'], 'type' => $type, 'action' => $action, 'parent' => $parent);
|
534 |
-
}
|
535 |
-
return $attributes;
|
536 |
-
}
|
537 |
-
|
538 |
-
public function getCategoryData($config, $storeId)
|
539 |
-
{
|
540 |
-
$eavAttribute = new Mage_Eav_Model_Mysql4_Entity_Attribute();
|
541 |
-
$attributes = array('entity_id','path','name','level');
|
542 |
-
|
543 |
-
if(!empty($config['category_custom'])) {
|
544 |
-
$attributes[] = $config['category_custom'];
|
545 |
-
}
|
546 |
-
if(!empty($config['category_replace'])) {
|
547 |
-
$attributes[] = $config['category_replace'];
|
548 |
-
}
|
549 |
-
|
550 |
-
if(!empty($config['filter_enabled'])) {
|
551 |
-
$type = $config['filter_type'];
|
552 |
-
$f_categories = explode(',', $config['filter_cat']);
|
553 |
-
if($type && $f_categories) {
|
554 |
-
if($type == 'include') {
|
555 |
-
$categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect($attributes)->addFieldToFilter('is_active', array('eq' => 1))->addAttributeToFilter('entity_id', array('in' => $f_categories));
|
556 |
-
} else {
|
557 |
-
$categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect($attributes)->addFieldToFilter('is_active', array('eq' => 1))->addAttributeToFilter('entity_id', array('nin' => $f_categories));
|
558 |
-
}
|
559 |
-
}
|
560 |
-
} else {
|
561 |
-
$categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect($attributes)->addFieldToFilter('is_active', array('eq' => 1));
|
562 |
-
}
|
563 |
-
$_categories = array();
|
564 |
-
|
565 |
-
foreach($categories as $cat) {
|
566 |
-
$custom = ''; $name = '';
|
567 |
-
if(!empty($config['category_replace'])) {
|
568 |
-
if(!empty($cat[$config['category_replace']])) {
|
569 |
-
$name = $cat[$config['category_replace']];
|
570 |
-
}
|
571 |
-
}
|
572 |
-
if(isset($config['category_custom'])) {
|
573 |
-
if(!empty($cat[$config['category_custom']])) {
|
574 |
-
$custom = $cat[$config['category_custom']];
|
575 |
-
}
|
576 |
-
}
|
577 |
-
if(empty($name)) { $name = $cat['name']; }
|
578 |
-
$_categories[$cat->getId()] = array('path' => $cat['path'], 'custom' => $custom, 'name' => $name, 'level' => $cat['level']);
|
579 |
-
}
|
580 |
-
|
581 |
-
foreach($_categories as $key => $cat) {
|
582 |
-
$path = array();
|
583 |
-
$custom_path = array();
|
584 |
-
$paths = explode('/', $cat['path']);
|
585 |
-
foreach($paths as $p) {
|
586 |
-
if(!empty($_categories[$p]['name'])) {
|
587 |
-
if($_categories[$p]['level'] > 1) {
|
588 |
-
$path[] = $_categories[$p]['name'];
|
589 |
-
if(!empty($_categories[$p]['custom'])) {
|
590 |
-
$custom_path[] = $_categories[$p]['custom'];
|
591 |
-
}
|
592 |
-
}
|
593 |
-
}
|
594 |
-
}
|
595 |
-
$_categories[$key] = array('path' => $this->cleanData($path, 'stiptags'), 'custom_path' => $this->cleanData($custom_path, 'stiptags'), 'custom' => $this->cleanData(end($custom_path), 'striptags'), 'name' => $this->cleanData($cat['name'], 'striptags'), 'level' => $cat['level']);
|
596 |
-
}
|
597 |
-
return $_categories;
|
598 |
-
}
|
599 |
-
|
600 |
-
public function getParentData($product, $config)
|
601 |
-
{
|
602 |
-
if(!empty($config['conf_enabled'])) {
|
603 |
-
if(($product['type_id'] == 'simple')) {
|
604 |
-
$config_ids = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
605 |
-
$group_ids = Mage::getResourceSingleton('catalog/product_link')->getParentIdsByChild($product->getId(), Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED);
|
606 |
-
if($config_ids) {
|
607 |
-
return $config_ids[0];
|
608 |
-
}
|
609 |
-
if($group_ids) {
|
610 |
-
return $group_ids[0];
|
611 |
-
}
|
612 |
-
}
|
613 |
-
}
|
614 |
-
}
|
615 |
-
|
616 |
-
public function validateProduct($product, $config, $parent)
|
617 |
-
{
|
618 |
-
if(empty($config['skip_validation'])) {
|
619 |
-
if($product['visibility'] == 1) {
|
620 |
-
if(empty($parent)) {
|
621 |
-
return false;
|
622 |
-
}
|
623 |
-
if($parent['status'] != 1) {
|
624 |
-
return false;
|
625 |
-
}
|
626 |
-
}
|
627 |
-
if(!empty($config['filter_exclude'])) {
|
628 |
-
if($product[$config['filter_exclude']] == 1) {
|
629 |
-
return false;
|
630 |
-
}
|
631 |
-
}
|
632 |
-
if(!empty($config['hide_no_stock'])) {
|
633 |
-
if($product->getUseConfigManageStock()) {
|
634 |
-
$manage_stock = $config['stock_manage'];
|
635 |
-
} else {
|
636 |
-
$manage_stock = $product->getManageStock();
|
637 |
-
}
|
638 |
-
if($manage_stock) {
|
639 |
-
if(!$product['stock_status']) {
|
640 |
-
return false;
|
641 |
-
}
|
642 |
-
}
|
643 |
-
}
|
644 |
-
if(!empty($config['conf_exclude_parent'])) {
|
645 |
-
if($product->getTypeId() == 'configurable') {
|
646 |
-
return false;
|
647 |
-
}
|
648 |
-
}
|
649 |
-
}
|
650 |
-
return true;
|
651 |
-
}
|
652 |
-
|
653 |
-
public function validateParent($parent, $config, $product)
|
654 |
-
{
|
655 |
-
return $this->validateProduct($product, $config, $parent);
|
656 |
-
}
|
657 |
-
|
658 |
-
public function getPriceBundle($product, $storeId)
|
659 |
-
{
|
660 |
-
if(($product->getPriceType() == '1') && ($product->getFinalPrice() > 0)) {
|
661 |
-
$price = $product->getFinalPrice();
|
662 |
-
} else {
|
663 |
-
$priceModel = $product->getPriceModel();
|
664 |
-
$block = Mage::getSingleton('core/layout')->createBlock('bundle/catalog_product_view_type_bundle');
|
665 |
-
$options = $block->setProduct($product)->getOptions();
|
666 |
-
$price = 0;
|
667 |
-
|
668 |
-
foreach ($options as $option) {
|
669 |
-
$selection = $option->getDefaultSelection();
|
670 |
-
if($selection === null) { continue; }
|
671 |
-
$selection_product_id = $selection->getProductId();
|
672 |
-
$_resource = Mage::getSingleton('catalog/product')->getResource();
|
673 |
-
$final_price = $_resource->getAttributeRawValue($selection_product_id, 'final_price', $storeId);
|
674 |
-
$selection_qty = $_resource->getAttributeRawValue($selection_product_id, 'selection_qty', $storeId);
|
675 |
-
$price += ($final_price * $selection_qty);
|
676 |
-
}
|
677 |
-
}
|
678 |
-
if($price < 0.01) {
|
679 |
-
$price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
|
680 |
-
}
|
681 |
-
return $price;
|
682 |
-
}
|
683 |
-
|
684 |
-
public function getPriceGrouped($product, $pricemodel = '')
|
685 |
-
{
|
686 |
-
if(!$pricemodel) { $pricemodel = 'min'; }
|
687 |
-
$prices = array();
|
688 |
-
$_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
689 |
-
foreach($_associatedProducts as $_item) {
|
690 |
-
$price_associated = Mage::helper('tax')->getPrice($_item, $_item->getFinalPrice(), true);
|
691 |
-
if($price_associated > 0) {
|
692 |
-
$prices[] = $price_associated;
|
693 |
-
}
|
694 |
-
}
|
695 |
-
if(!empty($prices)) {
|
696 |
-
if($pricemodel == 'min') { return min($prices); }
|
697 |
-
if($pricemodel == 'max') { return max($prices); }
|
698 |
-
if($pricemodel == 'total') { return array_sum($prices); }
|
699 |
-
}
|
700 |
-
}
|
701 |
-
|
702 |
-
public function getTypePrices($config, $products)
|
703 |
-
{
|
704 |
-
$type_prices = array();
|
705 |
-
if(!empty($config['conf_enabled'])) {
|
706 |
-
if(!empty($config['hide_currency'])) {
|
707 |
-
$currency = '';
|
708 |
-
} else {
|
709 |
-
$currency = ' ' . $config['currency'];
|
710 |
-
}
|
711 |
-
foreach($products as $product) {
|
712 |
-
if($product->getTypeId() == 'configurable') {
|
713 |
-
$attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
|
714 |
-
$att_prices = array();
|
715 |
-
$base_price = $product->getFinalPrice();
|
716 |
-
$base_price_reg = $product->getPrice();
|
717 |
-
foreach ($attributes as $attribute){
|
718 |
-
$prices = $attribute->getPrices();
|
719 |
-
foreach ($prices as $price){
|
720 |
-
if ($price['is_percent']) {
|
721 |
-
$att_prices[$price['value_index']] = (float)(($price['pricing_value'] * $base_price / 100) * $config['markup']);
|
722 |
-
$att_prices[$price['value_index'] . '_reg'] = (float)(($price['pricing_value'] * $base_price_reg / 100) * $config['markup']);
|
723 |
-
} else {
|
724 |
-
$att_prices[$price['value_index']] = (float)($price['pricing_value'] * $config['markup']);
|
725 |
-
$att_prices[$price['value_index'] . '_reg'] = (float)($price['pricing_value'] * $config['markup']);
|
726 |
-
}
|
727 |
-
}
|
728 |
-
}
|
729 |
-
$simple = $product->getTypeInstance()->getUsedProducts();
|
730 |
-
$simple_prices = array();
|
731 |
-
foreach($simple as $sProduct) {
|
732 |
-
$total_price = $base_price;
|
733 |
-
$total_price_reg = $base_price_reg;
|
734 |
-
foreach($attributes as $attribute) {
|
735 |
-
$value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
|
736 |
-
if(isset($att_prices[$value])) {
|
737 |
-
$total_price += $att_prices[$value];
|
738 |
-
$total_price_reg += $att_prices[$value . '_reg'];
|
739 |
-
}
|
740 |
-
}
|
741 |
-
$type_prices[$sProduct->getEntityId()] = number_format(($total_price * $config['markup']), 2, '.', '');
|
742 |
-
$type_prices[$sProduct->getEntityId() . '_reg'] = number_format(($total_price_reg * $config['markup']), 2, '.', '');
|
743 |
-
}
|
744 |
-
}
|
745 |
-
}
|
746 |
-
}
|
747 |
-
return $type_prices;
|
748 |
-
}
|
749 |
-
|
750 |
-
public function checkOldVersion($dir)
|
751 |
-
{
|
752 |
-
if($dir) {
|
753 |
-
$dir = Mage::getBaseDir('app') . DS . 'code' . DS . 'local' . DS . 'Magmodules' . DS . $dir;
|
754 |
-
return file_exists($dir);
|
755 |
-
}
|
756 |
-
}
|
757 |
-
|
758 |
-
public function checkFlatCatalog($attributes)
|
759 |
-
{
|
760 |
-
$non_flat_attributes = array();
|
761 |
-
foreach($attributes as $key => $attribute) {
|
762 |
-
if(!empty($attribute['source'])) {
|
763 |
-
if(($attribute['source'] != 'entity_id') && ($attribute['source'] != 'sku')) {
|
764 |
-
$_attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $attribute['source']);
|
765 |
-
if($_attribute->getUsedInProductListing() == 0) {
|
766 |
-
if($_attribute->getId()) {
|
767 |
-
$non_flat_attributes[$_attribute->getId()] = $_attribute->getFrontendLabel();
|
768 |
-
}
|
769 |
-
}
|
770 |
-
}
|
771 |
-
}
|
772 |
-
}
|
773 |
-
return $non_flat_attributes;
|
774 |
-
}
|
775 |
-
|
776 |
-
public function getMediaAttributes()
|
777 |
-
{
|
778 |
-
$media_types = array();
|
779 |
-
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addFieldToFilter('frontend_input', 'media_image');
|
780 |
-
foreach($attributes as $attribute) {
|
781 |
-
$media_types[] = $attribute->getData('attribute_code');
|
782 |
-
}
|
783 |
-
return $media_types;
|
784 |
-
}
|
785 |
-
|
786 |
-
public function getStoreIdConfig()
|
787 |
-
{
|
788 |
-
$store_id = 0;
|
789 |
-
if(strlen($code = Mage::getSingleton('adminhtml/config_data')->getStore())) {
|
790 |
-
$store_id = Mage::getModel('core/store')->load($code)->getId();
|
791 |
-
}
|
792 |
-
return $store_id;
|
793 |
-
}
|
794 |
-
|
795 |
-
public function getProductUrlSuffix($storeId)
|
796 |
-
{
|
797 |
-
$suffix = Mage::getStoreConfig('catalog/seo/product_url_suffix', $storeId);
|
798 |
-
if(!empty($suffix)) {
|
799 |
-
if(($suffix[0] != '.') && ($suffix != '/')) {
|
800 |
-
$suffix = '.' . $suffix;
|
801 |
-
}
|
802 |
-
}
|
803 |
-
return $suffix;
|
804 |
-
}
|
805 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
806 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
+
* @version 16-09-2016
|
16 |
* =============================================================
|
17 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
20 |
+
{
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param $path
|
24 |
+
* @return array
|
25 |
+
*/
|
26 |
+
public function getStoreIds($path)
|
27 |
+
{
|
28 |
+
$storeIds = array();
|
29 |
+
foreach (Mage::app()->getStores() as $store) {
|
30 |
+
$storeId = Mage::app()->getStore($store)->getId();
|
31 |
+
if (Mage::getStoreConfig($path, $storeId)) {
|
32 |
+
$storeIds[] = $storeId;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
return $storeIds;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @param $product
|
41 |
+
* @param $config
|
42 |
+
* @param $parent
|
43 |
+
* @return array|bool
|
44 |
+
*/
|
45 |
+
public function getProductDataRow($product, $config, $parent)
|
46 |
+
{
|
47 |
+
$fields = $config['field'];
|
48 |
+
$data = array();
|
49 |
+
|
50 |
+
if (!$this->validateParent($parent, $config, $product)) {
|
51 |
+
$parent = '';
|
52 |
+
}
|
53 |
+
|
54 |
+
if (!$this->validateProduct($product, $config, $parent)) {
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
foreach ($fields as $key => $field) {
|
59 |
+
$rows = $this->getAttributeValue($key, $product, $config, $field['action'], $parent);
|
60 |
+
if (is_array($rows)) {
|
61 |
+
$data = array_merge($data, $rows);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
if (empty($config['skip_validation'])) {
|
66 |
+
if (!empty($data[$fields['price']['label']])) {
|
67 |
+
return $data;
|
68 |
+
}
|
69 |
+
} else {
|
70 |
+
return $data;
|
71 |
+
}
|
72 |
+
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @param $parent
|
78 |
+
* @param $config
|
79 |
+
* @param $product
|
80 |
+
* @return bool
|
81 |
+
*/
|
82 |
+
public function validateParent($parent, $config, $product)
|
83 |
+
{
|
84 |
+
return $this->validateProduct($product, $config, $parent);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param $product
|
89 |
+
* @param $config
|
90 |
+
* @param $parent
|
91 |
+
* @return bool
|
92 |
+
*/
|
93 |
+
public function validateProduct($product, $config, $parent)
|
94 |
+
{
|
95 |
+
if (empty($config['skip_validation'])) {
|
96 |
+
if ($product['visibility'] == 1) {
|
97 |
+
if (empty($parent)) {
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
|
101 |
+
if ($parent['status'] != 1) {
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
if (!empty($config['filter_exclude'])) {
|
107 |
+
if ($product[$config['filter_exclude']] == 1) {
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
if (!empty($config['hide_no_stock'])) {
|
113 |
+
if ($product->getUseConfigManageStock()) {
|
114 |
+
$manageStock = $config['stock_manage'];
|
115 |
+
} else {
|
116 |
+
$manageStock = $product->getManageStock();
|
117 |
+
}
|
118 |
+
|
119 |
+
if ($manageStock) {
|
120 |
+
if (!$product['stock_status']) {
|
121 |
+
return false;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
if (!empty($config['conf_exclude_parent'])) {
|
127 |
+
if ($product->getTypeId() == 'configurable') {
|
128 |
+
return false;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
return true;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @param $field
|
138 |
+
* @param $product
|
139 |
+
* @param $config
|
140 |
+
* @param string $actions
|
141 |
+
* @param $parent
|
142 |
+
* @return bool
|
143 |
+
*/
|
144 |
+
public function getAttributeValue($field, $product, $config, $actions = '', $parent)
|
145 |
+
{
|
146 |
+
$data = $config['field'][$field];
|
147 |
+
$productData = $product;
|
148 |
+
|
149 |
+
if (!empty($parent)) {
|
150 |
+
if (!empty($data['parent'])) {
|
151 |
+
$productData = $parent;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
switch ($field) {
|
156 |
+
case 'product_url':
|
157 |
+
$value = $this->getProductUrl($product, $config, $parent);
|
158 |
+
break;
|
159 |
+
case 'image_link':
|
160 |
+
$value = $this->getProductImage($productData, $config);
|
161 |
+
break;
|
162 |
+
case 'condition':
|
163 |
+
$value = $this->getProductCondition($productData, $config);
|
164 |
+
break;
|
165 |
+
case 'availability':
|
166 |
+
$value = $this->getProductAvailability($productData, $config);
|
167 |
+
break;
|
168 |
+
case 'weight':
|
169 |
+
$value = $this->getProductWeight($productData, $config);
|
170 |
+
break;
|
171 |
+
case 'price':
|
172 |
+
$value = $this->getProductPrice($productData, $config);
|
173 |
+
break;
|
174 |
+
case 'bundle':
|
175 |
+
$value = $this->getProductBundle($productData);
|
176 |
+
break;
|
177 |
+
case 'parent_id':
|
178 |
+
$value = $this->getProductData($parent, $data);
|
179 |
+
break;
|
180 |
+
case 'attribute_set_id':
|
181 |
+
$value = $this->getAttributeSetName($productData);
|
182 |
+
break;
|
183 |
+
case 'categories':
|
184 |
+
$value = $this->getProductCategories($productData, $config);
|
185 |
+
break;
|
186 |
+
default:
|
187 |
+
if (!empty($data['source'])) {
|
188 |
+
$value = $this->getProductData($productData, $data, $config);
|
189 |
+
} else {
|
190 |
+
$value = '';
|
191 |
+
}
|
192 |
+
break;
|
193 |
+
}
|
194 |
+
|
195 |
+
if ($config['field'][$field]['type'] == 'media_image') {
|
196 |
+
if ($field != 'image_link') {
|
197 |
+
if (!empty($value)) {
|
198 |
+
if ($value != 'no_selection') {
|
199 |
+
$value = $config['media_url'] . 'catalog/product' . $value;
|
200 |
+
} else {
|
201 |
+
$value = '';
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
if ((isset($actions)) && (!empty($value))) {
|
208 |
+
$value = $this->cleanData($value, $actions);
|
209 |
+
}
|
210 |
+
|
211 |
+
if ((is_array($value) && ($field == 'image_link'))) {
|
212 |
+
$i = 1;
|
213 |
+
foreach ($value as $key => $val) {
|
214 |
+
$dataRow[$key] = $val;
|
215 |
+
$i++;
|
216 |
+
}
|
217 |
+
|
218 |
+
return $dataRow;
|
219 |
+
}
|
220 |
+
|
221 |
+
if (!empty($value) || is_numeric($value)) {
|
222 |
+
$dataRow[$data['label']] = $value;
|
223 |
+
|
224 |
+
return $dataRow;
|
225 |
+
}
|
226 |
+
|
227 |
+
return false;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* @param $product
|
232 |
+
* @param $config
|
233 |
+
* @param $parent
|
234 |
+
* @return string
|
235 |
+
*/
|
236 |
+
public function getProductUrl($product, $config, $parent)
|
237 |
+
{
|
238 |
+
$url = '';
|
239 |
+
if (!empty($parent)) {
|
240 |
+
if ($parent->getRequestPath()) {
|
241 |
+
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $parent->getRequestPath()));
|
242 |
+
}
|
243 |
+
|
244 |
+
if (empty($url)) {
|
245 |
+
if ($parent->getUrlKey()) {
|
246 |
+
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $parent->getUrlKey()));
|
247 |
+
}
|
248 |
+
}
|
249 |
+
} else {
|
250 |
+
if ($product->getRequestPath()) {
|
251 |
+
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $product->getRequestPath()));
|
252 |
+
}
|
253 |
+
|
254 |
+
if (empty($url)) {
|
255 |
+
if ($product->getUrlKey()) {
|
256 |
+
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $product->getUrlKey()));
|
257 |
+
}
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
if (!empty($config['product_url_suffix'])) {
|
262 |
+
if (strpos($url, $config['product_url_suffix']) === false) {
|
263 |
+
$url = $url . $config['product_url_suffix'];
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
if (!empty($parent) && !empty($config['conf_switch_urls']) && !empty($url)) {
|
268 |
+
if ($parent->getTypeId() == 'configurable') {
|
269 |
+
$productAttributeOptions = $parent->getTypeInstance(true)->getConfigurableAttributesAsArray($parent);
|
270 |
+
$urlExtra = '';
|
271 |
+
foreach ($productAttributeOptions as $productAttribute) {
|
272 |
+
if ($id = Mage::getResourceModel('catalog/product')->getAttributeRawValue(
|
273 |
+
$product->getId(),
|
274 |
+
$productAttribute['attribute_code'], $config['store_id']
|
275 |
+
)
|
276 |
+
) {
|
277 |
+
$urlExtra .= $productAttribute['attribute_id'] . '=' . $id . '&';
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
if (!empty($urlExtra)) {
|
282 |
+
$url = $url . '#' . rtrim($urlExtra, '&');
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
return $url;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* @param $product
|
292 |
+
* @param $config
|
293 |
+
* @return array|string
|
294 |
+
*/
|
295 |
+
public function getProductImage($product, $config)
|
296 |
+
{
|
297 |
+
$imageData = array();
|
298 |
+
if (!empty($config['image_resize']) && !empty($config['image_size'])) {
|
299 |
+
$imageFile = $product->getData($config['image_source']);
|
300 |
+
$imageModel = Mage::getModel('catalog/product_image')->setSize($config['image_size'])->setDestinationSubdir($config['image_source'])->setBaseFile($imageFile);
|
301 |
+
if (!$imageModel->isCached()) {
|
302 |
+
$imageModel->resize()->saveFile();
|
303 |
+
}
|
304 |
+
|
305 |
+
$productImage = $imageModel->getUrl();
|
306 |
+
|
307 |
+
return (string)$productImage;
|
308 |
+
} else {
|
309 |
+
$image = '';
|
310 |
+
if (!empty($config['media_attributes'])) {
|
311 |
+
foreach ($config['media_attributes'] as $mediaAtt) {
|
312 |
+
if ($mediaAtt == 'base') {
|
313 |
+
$mediaAtt = 'image';
|
314 |
+
}
|
315 |
+
|
316 |
+
$mediaData = $product->getData($mediaAtt);
|
317 |
+
if (!empty($mediaData)) {
|
318 |
+
if ($mediaData != 'no_selection') {
|
319 |
+
$image = $config['media_image_url'] . $mediaData;
|
320 |
+
$imageData['image'][$mediaAtt] = $image;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
} else {
|
325 |
+
if ($product->getThumbnail()) {
|
326 |
+
if ($product->getThumbnail() != 'no_selection') {
|
327 |
+
$image = $config['media_image_url'] . $product->getThumbnail();
|
328 |
+
$imageData['image']['thumbnail'] = $image;
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
if ($product->getSmallImage()) {
|
333 |
+
if ($product->getSmallImage() != 'no_selection') {
|
334 |
+
$image = $config['media_image_url'] . $product->getSmallImage();
|
335 |
+
$imageData['image']['small_image'] = $image;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
if ($product->getImage()) {
|
340 |
+
if ($product->getImage() != 'no_selection') {
|
341 |
+
$image = $config['media_image_url'] . $product->getImage();
|
342 |
+
$imageData['image']['image'] = $image;
|
343 |
+
}
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
if (!empty($config['images'])) {
|
348 |
+
$imageData['image_link'] = $image;
|
349 |
+
$container = new Varien_Object(array('attribute' => new Varien_Object(array('id' => $config['media_gallery_id']))));
|
350 |
+
$imgProduct = new Varien_Object(array('id' => $product->getId(), 'store_id' => $config['store_id']));
|
351 |
+
$gallery = Mage::getResourceModel('catalog/product_attribute_backend_media')->loadGallery(
|
352 |
+
$imgProduct,
|
353 |
+
$container
|
354 |
+
);
|
355 |
+
|
356 |
+
$i = 1;
|
357 |
+
usort(
|
358 |
+
$gallery, function ($a, $b) {
|
359 |
+
return $a['position_default'] > $b['position_default'];
|
360 |
+
}
|
361 |
+
);
|
362 |
+
foreach ($gallery as $galleryImage) {
|
363 |
+
if ($galleryImage['disabled'] == 0) {
|
364 |
+
$imageData['image']['all']['image_' . $i] = $config['media_image_url'] . $galleryImage['file'];
|
365 |
+
$imageData['image']['last'] = $config['media_image_url'] . $galleryImage['file'];
|
366 |
+
if ($i == 1) {
|
367 |
+
$imageData['image']['first'] = $config['media_image_url'] . $galleryImage['file'];
|
368 |
+
}
|
369 |
+
|
370 |
+
$i++;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
return $imageData;
|
375 |
+
} else {
|
376 |
+
if (!empty($imageData['image']['image'])) {
|
377 |
+
return $imageData['image']['image'];
|
378 |
+
} else {
|
379 |
+
return $image;
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
/**
|
386 |
+
* @param $product
|
387 |
+
* @param $config
|
388 |
+
* @return bool
|
389 |
+
*/
|
390 |
+
public function getProductCondition($product, $config)
|
391 |
+
{
|
392 |
+
if (isset($config['condition_attribute'])) {
|
393 |
+
if ($condition = $product->getAttributeText($config['condition_attribute'])) {
|
394 |
+
return $condition;
|
395 |
+
} else {
|
396 |
+
return false;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
if (!empty($config['condition_default'])) {
|
401 |
+
return $config['condition_default'];
|
402 |
+
}
|
403 |
+
|
404 |
+
return false;
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* @param $product
|
409 |
+
* @param $config
|
410 |
+
* @return bool
|
411 |
+
*/
|
412 |
+
public function getProductAvailability($product, $config)
|
413 |
+
{
|
414 |
+
if (!empty($config['stock_instock'])) {
|
415 |
+
if ($product->getUseConfigManageStock()) {
|
416 |
+
$manageStock = $config['stock_manage'];
|
417 |
+
} else {
|
418 |
+
$manageStock = $product->getManageStock();
|
419 |
+
}
|
420 |
+
|
421 |
+
if ($manageStock) {
|
422 |
+
if ($product['stock_status']) {
|
423 |
+
$availability = $config['stock_instock'];
|
424 |
+
} else {
|
425 |
+
$availability = $config['stock_outofstock'];
|
426 |
+
}
|
427 |
+
} else {
|
428 |
+
$availability = $config['stock_instock'];
|
429 |
+
}
|
430 |
+
|
431 |
+
echo $availability; exit;
|
432 |
+
|
433 |
+
return $availability;
|
434 |
+
}
|
435 |
+
|
436 |
+
return false;
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* @param $product
|
441 |
+
* @param $config
|
442 |
+
* @return bool|string
|
443 |
+
*/
|
444 |
+
public function getProductWeight($product, $config)
|
445 |
+
{
|
446 |
+
if (!empty($config['weight'])) {
|
447 |
+
$weight = number_format($product->getWeight(), 2, '.', '');
|
448 |
+
if (isset($config['weight_units'])) {
|
449 |
+
$weight = $weight . ' ' . $config['weight_units'];
|
450 |
+
}
|
451 |
+
|
452 |
+
return $weight;
|
453 |
+
}
|
454 |
+
|
455 |
+
return false;
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* @param $product
|
460 |
+
* @param $config
|
461 |
+
* @return array
|
462 |
+
*/
|
463 |
+
public function getProductPrice($product, $config)
|
464 |
+
{
|
465 |
+
$priceData = array();
|
466 |
+
$priceMarkup = $this->getPriceMarkup($config);
|
467 |
+
$taxParam = $config['use_tax'];
|
468 |
+
|
469 |
+
if (!empty($config['hide_currency'])) {
|
470 |
+
$currency = '';
|
471 |
+
} else {
|
472 |
+
$currency = ' ' . $config['currency'];
|
473 |
+
}
|
474 |
+
|
475 |
+
if (!empty($config['price_scope'])) {
|
476 |
+
$price = Mage::getResourceModel('catalog/product')->getAttributeRawValue(
|
477 |
+
$product->getId(), 'price',
|
478 |
+
$config['store_id']
|
479 |
+
);
|
480 |
+
} else {
|
481 |
+
$price = $product->getPrice();
|
482 |
+
}
|
483 |
+
|
484 |
+
$price = Mage::helper('tax')->getPrice($product, $price, $taxParam);
|
485 |
+
$priceData['regular_price'] = number_format(($price * $priceMarkup), 2, '.', '') . $currency;
|
486 |
+
$pricerulePrice = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), $taxParam);
|
487 |
+
|
488 |
+
if (($pricerulePrice > 0) && ($pricerulePrice < $price)) {
|
489 |
+
$salesPrice = $pricerulePrice;
|
490 |
+
$specialPriceFromDate = $product->getSpecialFromDate();
|
491 |
+
$specialPriceToDate = $product->getSpecialToDate();
|
492 |
+
$today = time();
|
493 |
+
if ($today >= strtotime($specialPriceFromDate)) {
|
494 |
+
if ($today <= strtotime($specialPriceToDate) || is_null($specialPriceToDate)) {
|
495 |
+
$priceData['sales_date_start'] = $specialPriceFromDate;
|
496 |
+
$priceData['sales_date_end'] = $specialPriceToDate;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
if (($product->getTypeId() == 'bundle') && ($price < 0.01)) {
|
502 |
+
$price = $this->getPriceBundle($product, $config['store_id']);
|
503 |
+
}
|
504 |
+
|
505 |
+
if ($product->getTypeId() == 'grouped') {
|
506 |
+
if (!empty($config['price_grouped'])) {
|
507 |
+
$price = $this->getPriceGrouped($product, $config['price_grouped']);
|
508 |
+
} else {
|
509 |
+
if ($price < 0.01) {
|
510 |
+
$price = $this->getPriceGrouped($product);
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
$priceData['final_price_clean'] = $price;
|
516 |
+
$priceData['price'] = number_format(($price * $priceMarkup), 2, '.', '') . $currency;
|
517 |
+
|
518 |
+
if (isset($salesPrice)) {
|
519 |
+
$priceData['sales_price'] = number_format(($salesPrice * $priceMarkup), 2, '.', '') . $currency;
|
520 |
+
}
|
521 |
+
|
522 |
+
return $priceData;
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* @param $config
|
527 |
+
* @return int
|
528 |
+
*/
|
529 |
+
public function getPriceMarkup($config)
|
530 |
+
{
|
531 |
+
$markup = 1;
|
532 |
+
if (!empty($config['price_add_tax']) && !empty($config['price_add_tax_perc'])) {
|
533 |
+
$markup = 1 + ($config['price_add_tax_perc'] / 100);
|
534 |
+
}
|
535 |
+
|
536 |
+
if ($config['base_currency_code'] != $config['currency']) {
|
537 |
+
$exchangeRate = Mage::helper('directory')->currencyConvert(
|
538 |
+
1, $config['base_currency_code'],
|
539 |
+
$config['currency']
|
540 |
+
);
|
541 |
+
$markup = ($markup * $exchangeRate);
|
542 |
+
}
|
543 |
+
|
544 |
+
return $markup;
|
545 |
+
}
|
546 |
+
|
547 |
+
/**
|
548 |
+
* @param $product
|
549 |
+
* @param $storeId
|
550 |
+
* @return int
|
551 |
+
*/
|
552 |
+
public function getPriceBundle($product, $storeId)
|
553 |
+
{
|
554 |
+
if (($product->getPriceType() == '1') && ($product->getFinalPrice() > 0)) {
|
555 |
+
$price = $product->getFinalPrice();
|
556 |
+
} else {
|
557 |
+
$block = Mage::getSingleton('core/layout')->createBlock('bundle/catalog_product_view_type_bundle');
|
558 |
+
$options = $block->setProduct($product)->getOptions();
|
559 |
+
$price = 0;
|
560 |
+
|
561 |
+
foreach ($options as $option) {
|
562 |
+
$selection = $option->getDefaultSelection();
|
563 |
+
if ($selection === null) {
|
564 |
+
continue;
|
565 |
+
}
|
566 |
+
|
567 |
+
$selectionProductId = $selection->getProductId();
|
568 |
+
$_resource = Mage::getSingleton('catalog/product')->getResource();
|
569 |
+
$finalPrice = $_resource->getAttributeRawValue($selectionProductId, 'final_price', $storeId);
|
570 |
+
$selectionQty = $_resource->getAttributeRawValue($selectionProductId, 'selection_qty', $storeId);
|
571 |
+
$price += ($finalPrice * $selectionQty);
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
if ($price < 0.01) {
|
576 |
+
$price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true);
|
577 |
+
}
|
578 |
+
|
579 |
+
return $price;
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* @param $product
|
584 |
+
* @param string $pricemodel
|
585 |
+
* @return bool|mixed|number
|
586 |
+
*/
|
587 |
+
public function getPriceGrouped($product, $pricemodel = '')
|
588 |
+
{
|
589 |
+
if (!$pricemodel) {
|
590 |
+
$pricemodel = 'min';
|
591 |
+
}
|
592 |
+
|
593 |
+
$prices = array();
|
594 |
+
$_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
595 |
+
foreach ($_associatedProducts as $_item) {
|
596 |
+
$priceAssociated = Mage::helper('tax')->getPrice($_item, $_item->getFinalPrice(), true);
|
597 |
+
if ($priceAssociated > 0) {
|
598 |
+
$prices[] = $priceAssociated;
|
599 |
+
}
|
600 |
+
}
|
601 |
+
|
602 |
+
if (!empty($prices)) {
|
603 |
+
if ($pricemodel == 'min') {
|
604 |
+
return min($prices);
|
605 |
+
}
|
606 |
+
|
607 |
+
if ($pricemodel == 'max') {
|
608 |
+
return max($prices);
|
609 |
+
}
|
610 |
+
|
611 |
+
if ($pricemodel == 'total') {
|
612 |
+
return array_sum($prices);
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
return false;
|
617 |
+
}
|
618 |
+
|
619 |
+
/**
|
620 |
+
* @param $product
|
621 |
+
* @return bool|string
|
622 |
+
*/
|
623 |
+
public function getProductBundle($product)
|
624 |
+
{
|
625 |
+
if ($product->getTypeId() == 'bundle') {
|
626 |
+
return 'true';
|
627 |
+
}
|
628 |
+
|
629 |
+
return false;
|
630 |
+
}
|
631 |
+
|
632 |
+
/**
|
633 |
+
* @param $product
|
634 |
+
* @param $data
|
635 |
+
* @param string $config
|
636 |
+
* @return string
|
637 |
+
*/
|
638 |
+
public function getProductData($product, $data, $config = '')
|
639 |
+
{
|
640 |
+
$type = $data['type'];
|
641 |
+
$source = $data['source'];
|
642 |
+
$value = '';
|
643 |
+
switch ($type) {
|
644 |
+
case 'price':
|
645 |
+
if (!empty($product[$source])) {
|
646 |
+
$value = number_format($product[$source], 2, '.', '');
|
647 |
+
if (!empty($config['currency'])) {
|
648 |
+
$value .= ' ' . $config['currency'];
|
649 |
+
}
|
650 |
+
}
|
651 |
+
break;
|
652 |
+
case 'select':
|
653 |
+
$value = $product->getAttributeText($source);
|
654 |
+
break;
|
655 |
+
case 'multiselect':
|
656 |
+
if (count($product->getAttributeText($source))) {
|
657 |
+
if (count($product->getAttributeText($source)) > 1) {
|
658 |
+
$value = implode(',', $product->getAttributeText($source));
|
659 |
+
} else {
|
660 |
+
$value = $product->getAttributeText($source);
|
661 |
+
}
|
662 |
+
}
|
663 |
+
break;
|
664 |
+
default:
|
665 |
+
if (isset($product[$source])) {
|
666 |
+
$value = $product[$source];
|
667 |
+
}
|
668 |
+
break;
|
669 |
+
}
|
670 |
+
|
671 |
+
return $value;
|
672 |
+
}
|
673 |
+
|
674 |
+
/**
|
675 |
+
* @param $product
|
676 |
+
* @return mixed
|
677 |
+
*/
|
678 |
+
public function getAttributeSetName($product)
|
679 |
+
{
|
680 |
+
return Mage::getModel('eav/entity_attribute_set')->load($product->getAttributeSetId())->getAttributeSetName();
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* @param $product
|
685 |
+
* @param $config
|
686 |
+
* @return array
|
687 |
+
*/
|
688 |
+
public function getProductCategories($product, $config)
|
689 |
+
{
|
690 |
+
if (isset($config['category_data'])) {
|
691 |
+
$categoryData = $config['category_data'];
|
692 |
+
$productsCat = array();
|
693 |
+
$categoryIds = $product->getCategoryIds();
|
694 |
+
if (!empty($config['category_full'])) {
|
695 |
+
$path = array();
|
696 |
+
foreach ($categoryIds as $categoryId) {
|
697 |
+
if (isset($categoryData[$categoryId])) {
|
698 |
+
$path[] = $categoryData[$categoryId]['name'];
|
699 |
+
}
|
700 |
+
}
|
701 |
+
|
702 |
+
$productsCat = array('path' => $path);
|
703 |
+
} else {
|
704 |
+
foreach ($categoryIds as $categoryId) {
|
705 |
+
if (isset($categoryData[$categoryId])) {
|
706 |
+
$productsCat[] = $categoryData[$categoryId];
|
707 |
+
}
|
708 |
+
}
|
709 |
+
}
|
710 |
+
|
711 |
+
return $this->getSortedArray($productsCat, 'level');
|
712 |
+
}
|
713 |
+
}
|
714 |
+
|
715 |
+
/**
|
716 |
+
* @param $data
|
717 |
+
* @param $sort
|
718 |
+
* @return array
|
719 |
+
*/
|
720 |
+
function getSortedArray($data, $sort)
|
721 |
+
{
|
722 |
+
$code = "return strnatcmp(\$a['$sort'], \$b['$sort']);";
|
723 |
+
usort($data, create_function('$a,$b', $code));
|
724 |
+
|
725 |
+
return array_reverse($data);
|
726 |
+
}
|
727 |
+
|
728 |
+
/**
|
729 |
+
* @param $st
|
730 |
+
* @param string $action
|
731 |
+
* @return mixed|string
|
732 |
+
*/
|
733 |
+
public function cleanData($st, $action = '')
|
734 |
+
{
|
735 |
+
if ($action) {
|
736 |
+
$actions = explode('_', $action);
|
737 |
+
if (in_array('striptags', $actions)) {
|
738 |
+
$st = $this->stripTags($st);
|
739 |
+
$st = trim($st);
|
740 |
+
}
|
741 |
+
|
742 |
+
if (in_array('replacetags', $actions)) {
|
743 |
+
$st = str_replace(array("\r", "\n"), "", $st);
|
744 |
+
$st = str_replace(array("<br>", "<br/>", "<br />"), '\n', $st);
|
745 |
+
$st = $this->stripTags($st);
|
746 |
+
$st = rtrim($st);
|
747 |
+
}
|
748 |
+
|
749 |
+
if (in_array('replacetagsn', $actions)) {
|
750 |
+
$st = str_replace(array("\r", "\n"), "", $st);
|
751 |
+
$st = str_replace(array("<br>", "<br/>", "<br />"), '\\' . '\n', $st);
|
752 |
+
$st = $this->stripTags($st);
|
753 |
+
$st = rtrim($st);
|
754 |
+
}
|
755 |
+
|
756 |
+
if (in_array('rn', $actions)) {
|
757 |
+
$st = str_replace(array("\r", "\n"), "", $st);
|
758 |
+
}
|
759 |
+
|
760 |
+
if (in_array('truncate', $actions)) {
|
761 |
+
$st = Mage::helper('core/string')->truncate($st, '5000');
|
762 |
+
}
|
763 |
+
|
764 |
+
if (in_array('truncate150', $actions)) {
|
765 |
+
$st = Mage::helper('core/string')->truncate($st, '150');
|
766 |
+
}
|
767 |
+
|
768 |
+
if (in_array('uppercheck', $actions)) {
|
769 |
+
if (strtoupper($st) == $st) {
|
770 |
+
$st = ucfirst(strtolower($st));
|
771 |
+
}
|
772 |
+
}
|
773 |
+
|
774 |
+
if (in_array('cdata', $actions)) {
|
775 |
+
$st = '<![CDATA[' . $st . ']]>';
|
776 |
+
}
|
777 |
+
|
778 |
+
if (in_array('round', $actions)) {
|
779 |
+
if (!empty($actions[1])) {
|
780 |
+
if ($st > $actions[1]) {
|
781 |
+
$st = $actions[1];
|
782 |
+
}
|
783 |
+
}
|
784 |
+
|
785 |
+
$st = round($st);
|
786 |
+
}
|
787 |
+
|
788 |
+
if (in_array('boolean', $actions)) {
|
789 |
+
($st > 0 ? $st = 1 : $st = 0);
|
790 |
+
}
|
791 |
+
}
|
792 |
+
|
793 |
+
return $st;
|
794 |
+
}
|
795 |
+
|
796 |
+
/**
|
797 |
+
* @param $config
|
798 |
+
* @return string
|
799 |
+
*/
|
800 |
+
public function getTaxUsage($config)
|
801 |
+
{
|
802 |
+
if (!empty($config['force_tax'])) {
|
803 |
+
if ($config['force_tax'] == 'incl') {
|
804 |
+
return 'true';
|
805 |
+
} else {
|
806 |
+
return '';
|
807 |
+
}
|
808 |
+
} else {
|
809 |
+
return 'true';
|
810 |
+
}
|
811 |
+
}
|
812 |
+
|
813 |
+
/**
|
814 |
+
* @param $attributes
|
815 |
+
* @param string $config
|
816 |
+
* @return mixed
|
817 |
+
*/
|
818 |
+
public function addAttributeData($attributes, $config = '')
|
819 |
+
{
|
820 |
+
foreach ($attributes as $key => $attribute) {
|
821 |
+
$type = (!empty($attribute['type']) ? $attribute['type'] : '');
|
822 |
+
$action = (!empty($attribute['action']) ? $attribute['action'] : '');
|
823 |
+
$parent = (!empty($attribute['parent']) ? $attribute['parent'] : '');
|
824 |
+
if (isset($attribute['source'])) {
|
825 |
+
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode(
|
826 |
+
'catalog_product',
|
827 |
+
$attribute['source']
|
828 |
+
);
|
829 |
+
$type = $attributeModel->getFrontendInput();
|
830 |
+
}
|
831 |
+
|
832 |
+
if (!empty($config['conf_fields'])) {
|
833 |
+
$confAttributes = explode(',', $config['conf_fields']);
|
834 |
+
if (in_array($key, $confAttributes)) {
|
835 |
+
$parent = '1';
|
836 |
+
}
|
837 |
+
}
|
838 |
+
|
839 |
+
$attributes[$key] = array(
|
840 |
+
'label' => $attribute['label'],
|
841 |
+
'source' => $attribute['source'],
|
842 |
+
'type' => $type,
|
843 |
+
'action' => $action,
|
844 |
+
'parent' => $parent
|
845 |
+
);
|
846 |
+
}
|
847 |
+
|
848 |
+
return $attributes;
|
849 |
+
}
|
850 |
+
|
851 |
+
/**
|
852 |
+
* @param $config
|
853 |
+
* @param $storeId
|
854 |
+
* @return array
|
855 |
+
*/
|
856 |
+
public function getCategoryData($config, $storeId)
|
857 |
+
{
|
858 |
+
$defaultAttributes = array('entity_id', 'path', 'name', 'level');
|
859 |
+
|
860 |
+
$attributes = $defaultAttributes;
|
861 |
+
|
862 |
+
if (!empty($config['category_custom'])) {
|
863 |
+
$attributes[] = $config['category_custom'];
|
864 |
+
}
|
865 |
+
|
866 |
+
if (!empty($config['category_replace'])) {
|
867 |
+
$attributes[] = $config['category_replace'];
|
868 |
+
}
|
869 |
+
|
870 |
+
if (!empty($config['category_exclude'])) {
|
871 |
+
$attributes[] = $config['category_exclude'];
|
872 |
+
}
|
873 |
+
|
874 |
+
// CHECK IF NEW ATTRIBUTES ARE AVAILABLE
|
875 |
+
try {
|
876 |
+
Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect($attributes)->getFirstItem();
|
877 |
+
} catch (Exception $e) {
|
878 |
+
}
|
879 |
+
|
880 |
+
if (empty($e)) {
|
881 |
+
$categories = Mage::getModel('catalog/category')
|
882 |
+
->setStoreId($storeId)
|
883 |
+
->getCollection()
|
884 |
+
->addAttributeToSelect($attributes)
|
885 |
+
->addFieldToFilter('is_active', array('eq' => 1));
|
886 |
+
} else {
|
887 |
+
$categories = Mage::getModel('catalog/category')
|
888 |
+
->setStoreId($storeId)
|
889 |
+
->getCollection()
|
890 |
+
->addAttributeToSelect($defaultAttributes)
|
891 |
+
->addFieldToFilter('is_active', array('eq' => 1));
|
892 |
+
}
|
893 |
+
|
894 |
+
if (!empty($config['filter_enabled'])) {
|
895 |
+
$type = $config['filter_type'];
|
896 |
+
$fCategories = explode(',', $config['filter_cat']);
|
897 |
+
if ($type && $fCategories) {
|
898 |
+
if ($type == 'include') {
|
899 |
+
$categories->addAttributeToFilter('entity_id', array('in' => $fCategories));
|
900 |
+
} else {
|
901 |
+
$categories->addAttributeToFilter('entity_id', array('nin' => $fCategories));
|
902 |
+
}
|
903 |
+
}
|
904 |
+
}
|
905 |
+
|
906 |
+
$_categories = array();
|
907 |
+
|
908 |
+
foreach ($categories as $cat) {
|
909 |
+
$custom = '';
|
910 |
+
$name = '';
|
911 |
+
$exclude = 0;
|
912 |
+
if (!empty($config['category_replace'])) {
|
913 |
+
if (!empty($cat[$config['category_replace']])) {
|
914 |
+
$name = $cat[$config['category_replace']];
|
915 |
+
}
|
916 |
+
}
|
917 |
+
|
918 |
+
if (isset($config['category_custom'])) {
|
919 |
+
if (!empty($cat[$config['category_custom']])) {
|
920 |
+
$custom = $cat[$config['category_custom']];
|
921 |
+
}
|
922 |
+
}
|
923 |
+
|
924 |
+
if (isset($config['category_exclude'])) {
|
925 |
+
if (!empty($cat[$config['category_exclude']])) {
|
926 |
+
$exclude = $cat[$config['category_exclude']];
|
927 |
+
}
|
928 |
+
}
|
929 |
+
|
930 |
+
if (empty($name)) {
|
931 |
+
$name = $cat['name'];
|
932 |
+
}
|
933 |
+
|
934 |
+
if ($exclude != 1) {
|
935 |
+
$_categories[$cat->getId()] = array(
|
936 |
+
'path' => $cat['path'],
|
937 |
+
'custom' => $custom,
|
938 |
+
'name' => $name,
|
939 |
+
'level' => $cat['level'],
|
940 |
+
'exclude' => $exclude
|
941 |
+
);
|
942 |
+
}
|
943 |
+
}
|
944 |
+
|
945 |
+
foreach ($_categories as $key => $cat) {
|
946 |
+
$path = array();
|
947 |
+
$customPath = array();
|
948 |
+
$paths = explode('/', $cat['path']);
|
949 |
+
foreach ($paths as $p) {
|
950 |
+
if (!empty($_categories[$p]['name'])) {
|
951 |
+
if ($_categories[$p]['level'] > 1) {
|
952 |
+
$path[] = $_categories[$p]['name'];
|
953 |
+
if (!empty($_categories[$p]['custom'])) {
|
954 |
+
$customPath[] = $_categories[$p]['custom'];
|
955 |
+
}
|
956 |
+
}
|
957 |
+
}
|
958 |
+
}
|
959 |
+
|
960 |
+
$_categories[$key] = array(
|
961 |
+
'path' => $this->cleanData($path, 'stiptags'),
|
962 |
+
'custom_path' => $this->cleanData($customPath, 'stiptags'),
|
963 |
+
'custom' => $this->cleanData(end($customPath), 'striptags'),
|
964 |
+
'name' => $this->cleanData($cat['name'], 'striptags'),
|
965 |
+
'level' => $cat['level']
|
966 |
+
);
|
967 |
+
}
|
968 |
+
|
969 |
+
return $_categories;
|
970 |
+
}
|
971 |
+
|
972 |
+
/**
|
973 |
+
* @param $product
|
974 |
+
* @param $config
|
975 |
+
* @return bool
|
976 |
+
*/
|
977 |
+
public function getParentData($product, $config)
|
978 |
+
{
|
979 |
+
if (!empty($config['conf_enabled'])) {
|
980 |
+
if (($product['type_id'] == 'simple')) {
|
981 |
+
$configIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
982 |
+
$groupIds = Mage::getResourceSingleton('catalog/product_link')->getParentIdsByChild(
|
983 |
+
$product->getId(),
|
984 |
+
Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED
|
985 |
+
);
|
986 |
+
if ($configIds) {
|
987 |
+
return $configIds[0];
|
988 |
+
}
|
989 |
+
|
990 |
+
if ($groupIds) {
|
991 |
+
return $groupIds[0];
|
992 |
+
}
|
993 |
+
}
|
994 |
+
}
|
995 |
+
|
996 |
+
return false;
|
997 |
+
}
|
998 |
+
|
999 |
+
/**
|
1000 |
+
* @param $config
|
1001 |
+
* @param $products
|
1002 |
+
* @return array
|
1003 |
+
*/
|
1004 |
+
public function getTypePrices($config, $products)
|
1005 |
+
{
|
1006 |
+
$typePrices = array();
|
1007 |
+
if (!empty($config['conf_enabled'])) {
|
1008 |
+
foreach ($products as $product) {
|
1009 |
+
if ($product->getTypeId() == 'configurable') {
|
1010 |
+
$parentId = $product->getEntityId();
|
1011 |
+
$attributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
|
1012 |
+
$basePrice = $product->getFinalPrice();
|
1013 |
+
$basePriceReg = $product->getPrice();
|
1014 |
+
foreach ($attributes as $attribute) {
|
1015 |
+
$optionPrices = array();
|
1016 |
+
$prices = $attribute->getPrices();
|
1017 |
+
foreach ($prices as $value) {
|
1018 |
+
$product->setConfigurablePrice(
|
1019 |
+
$this->_preparePrice(
|
1020 |
+
$value['pricing_value'],
|
1021 |
+
$value['is_percent'], $product
|
1022 |
+
)
|
1023 |
+
);
|
1024 |
+
$product->setParentId(true);
|
1025 |
+
Mage::dispatchEvent(
|
1026 |
+
'catalog_product_type_configurable_price',
|
1027 |
+
array('product' => $product)
|
1028 |
+
);
|
1029 |
+
$configurablePrice = $product->getConfigurablePrice();
|
1030 |
+
$optionPrices[$value['value_index']] = $configurablePrice;
|
1031 |
+
$optionPrices[$value['value_index'] . '_reg'] = $this->_prepareOldPrice(
|
1032 |
+
$value['pricing_value'],
|
1033 |
+
$value['is_percent'], $product
|
1034 |
+
);
|
1035 |
+
}
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
$simple = $product->getTypeInstance()->getUsedProducts();
|
1039 |
+
foreach ($simple as $sProduct) {
|
1040 |
+
$totalPrice = $basePrice;
|
1041 |
+
$totalPriceReg = $basePriceReg;
|
1042 |
+
foreach ($attributes as $attribute) {
|
1043 |
+
$value = $sProduct->getData($attribute->getProductAttribute()->getAttributeCode());
|
1044 |
+
if (isset($optionPrices[$value])) {
|
1045 |
+
$totalPrice += $optionPrices[$value];
|
1046 |
+
$totalPriceReg += $optionPrices[$value . '_reg'];
|
1047 |
+
}
|
1048 |
+
}
|
1049 |
+
|
1050 |
+
$typePrices[$parentId . '_' . $sProduct->getEntityId()] = number_format(
|
1051 |
+
($totalPrice * $config['markup']), 2,
|
1052 |
+
'.', ''
|
1053 |
+
);
|
1054 |
+
$typePrices[$parentId . '_' . $sProduct->getEntityId() . '_reg'] = number_format(
|
1055 |
+
($totalPriceReg * $config['markup']),
|
1056 |
+
2, '.', ''
|
1057 |
+
);
|
1058 |
+
}
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
return $typePrices;
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
/**
|
1067 |
+
* @param $price
|
1068 |
+
* @param bool $isPercent
|
1069 |
+
* @param $product
|
1070 |
+
* @return float|int
|
1071 |
+
*/
|
1072 |
+
protected function _preparePrice($price, $isPercent = false, $product)
|
1073 |
+
{
|
1074 |
+
if ($isPercent && !empty($price)) {
|
1075 |
+
$price = $product->getFinalPrice() * $price / 100;
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
return $price;
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
/**
|
1082 |
+
* @param $price
|
1083 |
+
* @param bool $isPercent
|
1084 |
+
* @param $product
|
1085 |
+
* @return float|int
|
1086 |
+
*/
|
1087 |
+
protected function _prepareOldPrice($price, $isPercent = false, $product)
|
1088 |
+
{
|
1089 |
+
if ($isPercent && !empty($price)) {
|
1090 |
+
$price = $product->getPrice() * $price / 100;
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
return $price;
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
/**
|
1097 |
+
* @param $dir
|
1098 |
+
* @return bool
|
1099 |
+
*/
|
1100 |
+
public function checkOldVersion($dir)
|
1101 |
+
{
|
1102 |
+
if ($dir) {
|
1103 |
+
$dir = Mage::getBaseDir('app') . DS . 'code' . DS . 'local' . DS . 'Magmodules' . DS . $dir;
|
1104 |
+
|
1105 |
+
return file_exists($dir);
|
1106 |
+
}
|
1107 |
+
|
1108 |
+
return false;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
* @param $attributes
|
1113 |
+
* @return array
|
1114 |
+
*/
|
1115 |
+
public function checkFlatCatalog($attributes)
|
1116 |
+
{
|
1117 |
+
$nonFlatAttributes = array();
|
1118 |
+
foreach ($attributes as $key => $attribute) {
|
1119 |
+
if (!empty($attribute['source'])) {
|
1120 |
+
if (($attribute['source'] != 'entity_id') && ($attribute['source'] != 'sku')) {
|
1121 |
+
$_attribute = Mage::getModel('eav/entity_attribute')->loadByCode(
|
1122 |
+
'catalog_product',
|
1123 |
+
$attribute['source']
|
1124 |
+
);
|
1125 |
+
if ($_attribute->getUsedInProductListing() == 0) {
|
1126 |
+
if ($_attribute->getId()) {
|
1127 |
+
$nonFlatAttributes[$_attribute->getId()] = $_attribute->getFrontendLabel();
|
1128 |
+
}
|
1129 |
+
}
|
1130 |
+
}
|
1131 |
+
}
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
return $nonFlatAttributes;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
/**
|
1138 |
+
* @return array
|
1139 |
+
*/
|
1140 |
+
public function getMediaAttributes()
|
1141 |
+
{
|
1142 |
+
$mediaTypes = array();
|
1143 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addFieldToFilter(
|
1144 |
+
'frontend_input',
|
1145 |
+
'media_image'
|
1146 |
+
);
|
1147 |
+
foreach ($attributes as $attribute) {
|
1148 |
+
$mediaTypes[] = $attribute->getData('attribute_code');
|
1149 |
+
}
|
1150 |
+
|
1151 |
+
return $mediaTypes;
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
/**
|
1155 |
+
* @return int
|
1156 |
+
*/
|
1157 |
+
public function getStoreIdConfig()
|
1158 |
+
{
|
1159 |
+
$storeId = 0;
|
1160 |
+
if (strlen($code = Mage::getSingleton('adminhtml/config_data')->getStore())) {
|
1161 |
+
$storeId = Mage::getModel('core/store')->load($code)->getId();
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
return $storeId;
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
/**
|
1168 |
+
* @param $storeId
|
1169 |
+
* @return string
|
1170 |
+
*/
|
1171 |
+
public function getProductUrlSuffix($storeId)
|
1172 |
+
{
|
1173 |
+
$suffix = Mage::getStoreConfig('catalog/seo/product_url_suffix', $storeId);
|
1174 |
+
if (!empty($suffix)) {
|
1175 |
+
if (($suffix[0] != '.') && ($suffix != '/')) {
|
1176 |
+
$suffix = '.' . $suffix;
|
1177 |
+
}
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
return $suffix;
|
1181 |
+
}
|
1182 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Extra.php
CHANGED
@@ -11,42 +11,54 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Backend_Design_Extra extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array {
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
$value = $this->getValue();
|
23 |
-
if(is_array($value)) {
|
24 |
unset($value['__empty']);
|
25 |
-
if(
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
}
|
39 |
}
|
40 |
-
|
41 |
$this->setValue($value);
|
42 |
parent::_beforeSave();
|
43 |
}
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Backend_Design_Extra
|
19 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
20 |
+
{
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
protected function _beforeSave()
|
26 |
+
{
|
27 |
$value = $this->getValue();
|
28 |
+
if (is_array($value)) {
|
29 |
unset($value['__empty']);
|
30 |
+
if (!empty($value)) {
|
31 |
+
$value = $this->orderData($value, 'label');
|
32 |
+
$keys = array();
|
33 |
+
for ($i = 0; $i < count($value); $i++) {
|
34 |
+
$keys[] = 'fields_' . uniqid();
|
35 |
+
}
|
36 |
+
|
37 |
+
foreach ($value as $key => $field) {
|
38 |
+
$label = str_replace(" ", "_", trim($field['label']));
|
39 |
+
$value[$key]['label'] = strtolower($label);
|
40 |
+
$value[$key]['attribute'] = $field['attribute'];
|
41 |
+
}
|
42 |
+
|
43 |
+
$value = array_combine($keys, array_values($value));
|
44 |
}
|
45 |
}
|
46 |
+
|
47 |
$this->setValue($value);
|
48 |
parent::_beforeSave();
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* @param $data
|
53 |
+
* @param $sort
|
54 |
+
* @return mixed
|
55 |
+
*/
|
56 |
+
function orderData($data, $sort)
|
57 |
+
{
|
58 |
+
$code = "return strnatcmp(\$a['$sort'], \$b['$sort']);";
|
59 |
+
usort($data, create_function('$a,$b', $code));
|
60 |
+
|
61 |
+
return $data;
|
62 |
+
}
|
63 |
+
|
64 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Filter.php
CHANGED
@@ -11,46 +11,64 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Backend_Design_Filter
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
$value = $this->getValue();
|
23 |
-
if(is_array($value)) {
|
24 |
unset($value['__empty']);
|
25 |
-
if(count($value)) {
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
}
|
|
|
45 |
$this->setValue($value);
|
46 |
parent::_beforeSave();
|
47 |
}
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Backend_Design_Filter
|
19 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
20 |
+
{
|
21 |
|
22 |
+
|
23 |
+
/**
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
protected function _beforeSave()
|
27 |
+
{
|
28 |
$value = $this->getValue();
|
29 |
+
if (is_array($value)) {
|
30 |
unset($value['__empty']);
|
31 |
+
if (count($value)) {
|
32 |
+
$value = $this->orderData($value, 'attribute');
|
33 |
+
foreach ($value as $key => $field) {
|
34 |
+
if (!empty($field['attribute']) && !empty($field['condition'])) {
|
35 |
+
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode(
|
36 |
+
'catalog_product',
|
37 |
+
$field['attribute']
|
38 |
+
);
|
39 |
+
$value[$key]['attribute'] = $field['attribute'];
|
40 |
+
$value[$key]['condition'] = $field['condition'];
|
41 |
+
$value[$key]['value'] = $field['value'];
|
42 |
+
$value[$key]['type'] = $attribute->getFrontendInput();
|
43 |
+
} else {
|
44 |
+
unset($value[$key]);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$keys = array();
|
49 |
+
for ($i = 0; $i < count($value); $i++) {
|
50 |
+
$keys[] = 'filter_' . uniqid();
|
51 |
+
}
|
52 |
+
|
53 |
+
$value = array_combine($keys, array_values($value));
|
54 |
}
|
55 |
}
|
56 |
+
|
57 |
$this->setValue($value);
|
58 |
parent::_beforeSave();
|
59 |
}
|
60 |
|
61 |
+
/**
|
62 |
+
* @param $data
|
63 |
+
* @param $sort
|
64 |
+
* @return mixed
|
65 |
+
*/
|
66 |
+
function orderData($data, $sort)
|
67 |
+
{
|
68 |
+
$code = "return strnatcmp(\$a['$sort'], \$b['$sort']);";
|
69 |
+
usort($data, create_function('$a,$b', $code));
|
70 |
+
|
71 |
+
return $data;
|
72 |
+
}
|
73 |
+
|
74 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Shipping.php
CHANGED
@@ -11,48 +11,70 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Backend_Design_Shipping
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
22 |
$value = $this->getValue();
|
23 |
-
if(is_array($value)) {
|
24 |
unset($value['__empty']);
|
25 |
-
if(count($value)){
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
}
|
|
|
46 |
$this->setValue($value);
|
47 |
|
48 |
parent::_beforeSave();
|
49 |
}
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Backend_Design_Shipping
|
19 |
+
extends Mage_Adminhtml_Model_System_Config_Backend_Serialized_Array
|
20 |
+
{
|
21 |
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
protected function _beforeSave()
|
26 |
+
{
|
27 |
$value = $this->getValue();
|
28 |
+
if (is_array($value)) {
|
29 |
unset($value['__empty']);
|
30 |
+
if (count($value)) {
|
31 |
+
$value = $this->orderData($value, 'price_from');
|
32 |
+
$keys = array();
|
33 |
+
for ($i = 0; $i < count($value); $i++) {
|
34 |
+
$keys[] = 'shipping_' . uniqid();
|
35 |
+
}
|
36 |
+
|
37 |
+
foreach ($value as $key => $field) {
|
38 |
+
$priceFrom = str_replace(',', '.', $field['price_from']);
|
39 |
+
$priceTo = str_replace(',', '.', $field['price_to']);
|
40 |
+
$cost = str_replace(',', '.', $field['cost']);
|
41 |
+
if (empty($priceFrom)) {
|
42 |
+
$priceFrom = '0.00';
|
43 |
+
}
|
44 |
+
|
45 |
+
if (empty($priceTo)) {
|
46 |
+
$priceTo = '100000.00';
|
47 |
+
}
|
48 |
+
|
49 |
+
if (empty($cost)) {
|
50 |
+
$cost = '0.00';
|
51 |
+
}
|
52 |
+
|
53 |
+
$value[$key]['price_from'] = number_format($priceFrom, 2, '.', '');
|
54 |
+
$value[$key]['price_to'] = number_format($priceTo, 2, '.', '');
|
55 |
+
$value[$key]['cost'] = number_format($cost, 2, '.', '');
|
56 |
+
}
|
57 |
+
|
58 |
+
$value = array_combine($keys, array_values($value));
|
59 |
}
|
60 |
}
|
61 |
+
|
62 |
$this->setValue($value);
|
63 |
|
64 |
parent::_beforeSave();
|
65 |
}
|
66 |
|
67 |
+
/**
|
68 |
+
* @param $data
|
69 |
+
* @param $sort
|
70 |
+
* @return mixed
|
71 |
+
*/
|
72 |
+
function orderData($data, $sort)
|
73 |
+
{
|
74 |
+
$code = "return strnatcmp(\$a['$sort'], \$b['$sort']);";
|
75 |
+
usort($data, create_function('$a,$b', $code));
|
76 |
+
|
77 |
+
return $data;
|
78 |
+
}
|
79 |
+
|
80 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Action.php
CHANGED
@@ -11,18 +11,23 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Action {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Action
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$position = array();
|
27 |
+
$position[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- None'));
|
28 |
+
$position[] = array('value' => 'strip_tags', 'label' => Mage::helper('channable')->__('Strip Tags'));
|
29 |
+
|
30 |
+
return $position;
|
31 |
+
}
|
32 |
+
|
33 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute.php
CHANGED
@@ -11,36 +11,60 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Attribute {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
$
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
|
|
43 |
return $optionArray;
|
44 |
-
|
45 |
-
|
46 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Attribute
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$optionArray = array();
|
27 |
+
$optionArray[] = array(
|
28 |
+
'value' => '',
|
29 |
+
'label' => Mage::helper('channable')->__('-- none')
|
30 |
+
);
|
31 |
+
$optionArray[] = array(
|
32 |
+
'label' => Mage::helper('channable')->__('- Product ID'),
|
33 |
+
'value' => 'entity_id'
|
34 |
+
);
|
35 |
+
$optionArray[] = array(
|
36 |
+
'label' => Mage::helper('channable')->__('- Final Price'),
|
37 |
+
'value' => 'final_price'
|
38 |
+
);
|
39 |
+
$optionArray[] = array(
|
40 |
+
'label' => Mage::helper('channable')->__('- Product Type'),
|
41 |
+
'value' => 'type_id'
|
42 |
+
);
|
43 |
+
$optionArray[] = array(
|
44 |
+
'label' => Mage::helper('channable')->__('- Attribute Set'),
|
45 |
+
'value' => 'attribute_set_id'
|
46 |
+
);
|
47 |
+
|
48 |
+
$backendTypes = array('text', 'select', 'textarea', 'date', 'int', 'boolean', 'static', 'varchar', 'decimal');
|
49 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
50 |
+
->setOrder('frontend_label', 'ASC')
|
51 |
+
->addFieldToFilter('backend_type', $backendTypes);
|
52 |
+
foreach ($attributes as $attribute) {
|
53 |
+
if ($attribute->getData('attribute_code') != 'price') {
|
54 |
+
if ($attribute->getData('frontend_label')) {
|
55 |
+
$label = str_replace("'", "", $attribute->getData('frontend_label'));
|
56 |
+
} else {
|
57 |
+
$label = str_replace("'", "", $attribute->getData('attribute_code'));
|
58 |
+
}
|
59 |
+
|
60 |
+
$optionArray[] = array(
|
61 |
+
'value' => $attribute->getData('attribute_code'),
|
62 |
+
'label' => $label,
|
63 |
+
);
|
64 |
+
}
|
65 |
}
|
66 |
+
|
67 |
return $optionArray;
|
68 |
+
}
|
69 |
+
|
70 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Category.php
CHANGED
@@ -11,51 +11,64 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Category {
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
$options = array();
|
23 |
$collection = Mage::getResourceModel('catalog/category_collection');
|
24 |
$collection->addAttributeToSelect('name')->addPathFilter('^1/[0-9/]+')->load();
|
25 |
$cats = array();
|
26 |
foreach ($collection as $category) {
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
$cats[$cat->value] = $cat;
|
33 |
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
41 |
}
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
}
|
|
|
57 |
unset($cats);
|
|
|
58 |
return $options;
|
59 |
}
|
60 |
-
|
61 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Category
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param bool $addEmpty
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
public function toOptionArray($addEmpty = true)
|
26 |
+
{
|
27 |
$options = array();
|
28 |
$collection = Mage::getResourceModel('catalog/category_collection');
|
29 |
$collection->addAttributeToSelect('name')->addPathFilter('^1/[0-9/]+')->load();
|
30 |
$cats = array();
|
31 |
foreach ($collection as $category) {
|
32 |
+
$cat = new stdClass();
|
33 |
+
$cat->label = $category->getName();
|
34 |
+
$cat->value = $category->getId();
|
35 |
+
$cat->level = $category->getLevel();
|
36 |
+
$cat->parentid = $category->getParentId();
|
37 |
$cats[$cat->value] = $cat;
|
38 |
}
|
39 |
+
|
40 |
+
foreach ($cats as $id => $cat) {
|
41 |
+
if (isset($cats[$cat->parentid])) {
|
42 |
+
if (!isset($cats[$cat->parentid]->child)) {
|
43 |
+
$cats[$cat->parentid]->child = array();
|
44 |
+
}
|
45 |
+
|
46 |
+
$cats[$cat->parentid]->child[] =& $cats[$id];
|
47 |
+
}
|
48 |
}
|
49 |
+
|
50 |
+
foreach ($cats as $id => $cat) {
|
51 |
+
if (!isset($cats[$cat->parentid])) {
|
52 |
+
$stack = array($cats[$id]);
|
53 |
+
while (count($stack) > 0) {
|
54 |
+
$opt = array_pop($stack);
|
55 |
+
$option = array(
|
56 |
+
'label' => ($opt->level > 1 ? str_repeat('- ', $opt->level - 1) : '') . $opt->label,
|
57 |
+
'value' => $opt->value
|
58 |
+
);
|
59 |
+
array_push($options, $option);
|
60 |
+
if (isset($opt->child) && count($opt->child)) {
|
61 |
+
foreach (array_reverse($opt->child) as $child) {
|
62 |
+
array_push($stack, $child);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
}
|
68 |
+
|
69 |
unset($cats);
|
70 |
+
|
71 |
return $options;
|
72 |
}
|
73 |
+
|
74 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Categorytype.php
CHANGED
@@ -11,18 +11,23 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Categorytype {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Categorytype
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => 'include', 'label' => Mage::helper('channable')->__('Include by Category'));
|
28 |
+
$type[] = array('value' => 'exclude', 'label' => Mage::helper('channable')->__('Exclude by Category'));
|
29 |
+
|
30 |
+
return $type;
|
31 |
+
}
|
32 |
|
33 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Conditions.php
CHANGED
@@ -11,27 +11,33 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Conditions {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Conditions
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => '', 'label' => Mage::helper('channable')->__(''));
|
28 |
+
$type[] = array('value' => 'eq', 'label' => Mage::helper('channable')->__('Equal'));
|
29 |
+
$type[] = array('value' => 'neq', 'label' => Mage::helper('channable')->__('Not equal'));
|
30 |
+
$type[] = array('value' => 'gt', 'label' => Mage::helper('channable')->__('Greater than'));
|
31 |
+
$type[] = array('value' => 'gteq', 'label' => Mage::helper('channable')->__('Greater than or equal to'));
|
32 |
+
$type[] = array('value' => 'lt', 'label' => Mage::helper('channable')->__('Less than'));
|
33 |
+
$type[] = array('value' => 'lteg', 'label' => Mage::helper('channable')->__('Less than or equal to'));
|
34 |
+
$type[] = array('value' => 'in', 'label' => Mage::helper('channable')->__('In'));
|
35 |
+
$type[] = array('value' => 'nin', 'label' => Mage::helper('channable')->__('Not in'));
|
36 |
+
$type[] = array('value' => 'like', 'label' => Mage::helper('channable')->__('Like'));
|
37 |
+
$type[] = array('value' => 'empty', 'label' => Mage::helper('channable')->__('Empty'));
|
38 |
+
$type[] = array('value' => 'not-empty', 'label' => Mage::helper('channable')->__('Not Empty'));
|
39 |
+
|
40 |
+
return $type;
|
41 |
+
}
|
42 |
+
|
43 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Configurable.php
CHANGED
@@ -11,23 +11,28 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Configurable {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Configurable
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$attributes = Mage::getModel("channable/channable")->getFeedAttributes();
|
27 |
+
$attributesSkip = array('id', 'parent_id', 'price', 'stock', 'stock_status', 'visibility', 'status', 'type');
|
28 |
+
$att = array();
|
29 |
+
foreach ($attributes as $key => $attribute) {
|
30 |
+
if (!in_array($key, $attributesSkip)) {
|
31 |
+
$att[] = array('value' => $key, 'label' => $key);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
return $att;
|
36 |
+
}
|
37 |
+
|
38 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Countries.php
CHANGED
@@ -11,19 +11,24 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Countries {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Countries
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$countries = array();
|
27 |
+
$countries[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- All Countries'));
|
28 |
+
$source = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray();
|
29 |
+
unset($source[0]);
|
30 |
+
|
31 |
+
return array_merge($countries, $source);
|
32 |
+
}
|
33 |
+
|
34 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Images.php
CHANGED
@@ -11,18 +11,23 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Images {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Images
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => '', 'label' => Mage::helper('channable')->__('Only Base Image'));
|
28 |
+
$type[] = array('value' => 'all', 'label' => Mage::helper('channable')->__('All Images'));
|
29 |
+
|
30 |
+
return $type;
|
31 |
+
}
|
32 |
+
|
33 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Mainimage.php
CHANGED
@@ -11,23 +11,35 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Mainimage {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Mainimage
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addFieldToFilter(
|
27 |
+
'frontend_input',
|
28 |
+
'media_image'
|
29 |
+
);
|
30 |
+
$type = array();
|
31 |
+
$type[] = array('value' => '', 'label' => Mage::helper('channable')->__('Use default'));
|
32 |
+
foreach ($attributes as $attribute) {
|
33 |
+
$type[] = array(
|
34 |
+
'value' => $attribute->getData('attribute_code'),
|
35 |
+
'label' => str_replace("'", "", $attribute->getData('frontend_label'))
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
$type[] = array('value' => 'first', 'label' => Mage::helper('channable')->__('First Image'));
|
40 |
+
$type[] = array('value' => 'last', 'label' => Mage::helper('channable')->__('Last Image'));
|
41 |
+
|
42 |
+
return $type;
|
43 |
+
}
|
44 |
+
|
45 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Name.php
CHANGED
@@ -11,60 +11,73 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Name {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
'gallery',
|
23 |
-
'installation',
|
24 |
-
'language_support',
|
25 |
-
'country_of_manufacture',
|
26 |
-
'links_title',
|
27 |
-
'current_version',
|
28 |
-
'custom_design',
|
29 |
-
'custom_layout_update',
|
30 |
-
'gift_message_available',
|
31 |
-
'image',
|
32 |
-
'image_label',
|
33 |
-
'media_gallery',
|
34 |
-
'msrp_display_actual_price_type',
|
35 |
-
'msrp_enabled',
|
36 |
-
'options_container',
|
37 |
-
'price_view',
|
38 |
-
'page_layout',
|
39 |
-
'samples_title',
|
40 |
-
'sku_type',
|
41 |
-
'tier_price',
|
42 |
-
'url_key',
|
43 |
-
'small_image',
|
44 |
-
'small_image_label',
|
45 |
-
'thumbnail',
|
46 |
-
'thumbnail_label',
|
47 |
-
'recurring_profile',
|
48 |
-
'version_info',
|
49 |
-
'meta_title',
|
50 |
-
'meta_keyword',
|
51 |
-
);
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
$options = array();
|
55 |
-
|
56 |
$entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId();
|
57 |
-
$attributes = Mage::getModel('eav/entity_attribute')->getCollection()->addFilter(
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
67 |
-
|
|
|
|
|
68 |
return $options;
|
69 |
}
|
70 |
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Name
|
19 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
protected $_ignore = array(
|
22 |
+
'compatibility',
|
23 |
+
'gallery',
|
24 |
+
'installation',
|
25 |
+
'language_support',
|
26 |
+
'country_of_manufacture',
|
27 |
+
'links_title',
|
28 |
+
'current_version',
|
29 |
+
'custom_design',
|
30 |
+
'custom_layout_update',
|
31 |
+
'gift_message_available',
|
32 |
+
'image',
|
33 |
+
'image_label',
|
34 |
+
'media_gallery',
|
35 |
+
'msrp_display_actual_price_type',
|
36 |
+
'msrp_enabled',
|
37 |
+
'options_container',
|
38 |
+
'price_view',
|
39 |
+
'page_layout',
|
40 |
+
'samples_title',
|
41 |
+
'sku_type',
|
42 |
+
'tier_price',
|
43 |
+
'url_key',
|
44 |
+
'small_image',
|
45 |
+
'small_image_label',
|
46 |
+
'thumbnail',
|
47 |
+
'thumbnail_label',
|
48 |
+
'recurring_profile',
|
49 |
+
'version_info',
|
50 |
+
'meta_title',
|
51 |
+
'meta_keyword',
|
52 |
+
);
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return array
|
56 |
+
*/
|
57 |
+
public function toOptionArray()
|
58 |
+
{
|
59 |
$options = array();
|
60 |
+
$options[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- none'));
|
61 |
$entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId();
|
62 |
+
$attributes = Mage::getModel('eav/entity_attribute')->getCollection()->addFilter(
|
63 |
+
'entity_type_id',
|
64 |
+
$entityTypeId
|
65 |
+
)->setOrder('attribute_code', 'ASC');
|
66 |
+
foreach ($attributes as $attribute) {
|
67 |
+
if (($attribute->getBackendType() == 'text') || ($attribute->getBackendType() == 'varchar') || ($attribute->getBackendType() == 'static')) {
|
68 |
+
if ($attribute->getFrontendLabel()) {
|
69 |
+
if (!in_array($attribute->getAttributeCode(), $this->_ignore)) {
|
70 |
+
$options[] = array(
|
71 |
+
'value' => $attribute->getAttributeCode(),
|
72 |
+
'label' => $attribute->getFrontendLabel()
|
73 |
+
);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
}
|
78 |
+
|
79 |
+
$options[] = array('value' => 'use_custom', 'label' => Mage::helper('channable')->__('-- Custom:'));
|
80 |
+
|
81 |
return $options;
|
82 |
}
|
83 |
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Pricemodel.php
CHANGED
@@ -11,19 +11,25 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Pricemodel {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Pricemodel
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => '', 'label' => Mage::helper('adminhtml')->__('Use default price'));
|
28 |
+
$type[] = array('value' => 'min', 'label' => Mage::helper('adminhtml')->__('Use minimum price'));
|
29 |
+
$type[] = array('value' => 'max', 'label' => Mage::helper('adminhtml')->__('Use maximum price'));
|
30 |
+
$type[] = array('value' => 'total', 'label' => Mage::helper('adminhtml')->__('Use total price'));
|
31 |
+
|
32 |
+
return $type;
|
33 |
+
}
|
34 |
|
35 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Selectattribute.php
CHANGED
@@ -11,38 +11,49 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Selectattribute {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
{
|
33 |
$options = array();
|
34 |
-
|
35 |
$entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId();
|
36 |
-
$attributes = Mage::getModel('eav/entity_attribute')->getCollection()->addFilter(
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
return $options;
|
47 |
}
|
48 |
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Selectattribute
|
19 |
+
{
|
20 |
+
|
21 |
+
protected $_ignore = array(
|
22 |
+
'ebizmarts_mark_visited',
|
23 |
+
'is_recurring',
|
24 |
+
'links_purchased_separately',
|
25 |
+
'price_view',
|
26 |
+
'status',
|
27 |
+
'tax_class_id',
|
28 |
+
'visibility',
|
29 |
+
'shipment_type',
|
30 |
+
);
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function toOptionArray()
|
36 |
{
|
37 |
$options = array();
|
38 |
+
$options[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- none'));
|
39 |
$entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId();
|
40 |
+
$attributes = Mage::getModel('eav/entity_attribute')->getCollection()->addFilter(
|
41 |
+
'entity_type_id',
|
42 |
+
$entityTypeId
|
43 |
+
)->setOrder('attribute_code', 'ASC');
|
44 |
+
foreach ($attributes as $attribute) {
|
45 |
+
if ($attribute->getBackendType() == 'int') {
|
46 |
+
if ($attribute->getFrontendLabel()) {
|
47 |
+
if (!in_array($attribute->getAttributeCode(), $this->_ignore)) {
|
48 |
+
$options[] = array(
|
49 |
+
'value' => $attribute->getAttributeCode(),
|
50 |
+
'label' => $attribute->getFrontendLabel()
|
51 |
+
);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
return $options;
|
58 |
}
|
59 |
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Shipping.php
CHANGED
@@ -11,17 +11,23 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Shipping {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Shipping
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => 'price', 'label' => Mage::helper('channable')->__('Price'));
|
28 |
+
$type[] = array('value' => 'weight', 'label' => Mage::helper('channable')->__('Weight'));
|
29 |
+
|
30 |
+
return $type;
|
31 |
+
}
|
32 |
+
|
33 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Tax.php
CHANGED
@@ -11,19 +11,24 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Tax {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Tax
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$position = array();
|
27 |
+
$position[] = array('value' => '', 'label' => Mage::helper('channable')->__('No'));
|
28 |
+
$position[] = array('value' => 'incl', 'label' => Mage::helper('channable')->__('Force including Tax'));
|
29 |
+
$position[] = array('value' => 'excl', 'label' => Mage::helper('channable')->__('Force excluding Tax'));
|
30 |
+
|
31 |
+
return $position;
|
32 |
+
}
|
33 |
+
|
34 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Textattribute.php
CHANGED
@@ -11,60 +11,71 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Textattribute {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
'gallery',
|
23 |
-
'installation',
|
24 |
-
'language_support',
|
25 |
-
'country_of_manufacture',
|
26 |
-
'links_title',
|
27 |
-
'current_version',
|
28 |
-
'custom_design',
|
29 |
-
'custom_layout_update',
|
30 |
-
'gift_message_available',
|
31 |
-
'image',
|
32 |
-
'image_label',
|
33 |
-
'media_gallery',
|
34 |
-
'msrp_display_actual_price_type',
|
35 |
-
'msrp_enabled',
|
36 |
-
'options_container',
|
37 |
-
'price_view',
|
38 |
-
'page_layout',
|
39 |
-
'samples_title',
|
40 |
-
'sku_type',
|
41 |
-
'tier_price',
|
42 |
-
'url_key',
|
43 |
-
'small_image',
|
44 |
-
'small_image_label',
|
45 |
-
'thumbnail',
|
46 |
-
'thumbnail_label',
|
47 |
-
'recurring_profile',
|
48 |
-
'version_info',
|
49 |
-
'meta_title',
|
50 |
-
'meta_keyword',
|
51 |
-
);
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
{
|
55 |
$options = array();
|
56 |
-
|
57 |
$entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId();
|
58 |
-
$attributes = Mage::getModel('eav/entity_attribute')->getCollection()->addFilter(
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
return $options;
|
69 |
}
|
70 |
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Textattribute
|
19 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
protected $_ignore = array(
|
22 |
+
'compatibility',
|
23 |
+
'gallery',
|
24 |
+
'installation',
|
25 |
+
'language_support',
|
26 |
+
'country_of_manufacture',
|
27 |
+
'links_title',
|
28 |
+
'current_version',
|
29 |
+
'custom_design',
|
30 |
+
'custom_layout_update',
|
31 |
+
'gift_message_available',
|
32 |
+
'image',
|
33 |
+
'image_label',
|
34 |
+
'media_gallery',
|
35 |
+
'msrp_display_actual_price_type',
|
36 |
+
'msrp_enabled',
|
37 |
+
'options_container',
|
38 |
+
'price_view',
|
39 |
+
'page_layout',
|
40 |
+
'samples_title',
|
41 |
+
'sku_type',
|
42 |
+
'tier_price',
|
43 |
+
'url_key',
|
44 |
+
'small_image',
|
45 |
+
'small_image_label',
|
46 |
+
'thumbnail',
|
47 |
+
'thumbnail_label',
|
48 |
+
'recurring_profile',
|
49 |
+
'version_info',
|
50 |
+
'meta_title',
|
51 |
+
'meta_keyword',
|
52 |
+
);
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return array
|
56 |
+
*/
|
57 |
+
public function toOptionArray()
|
58 |
{
|
59 |
$options = array();
|
60 |
+
$options[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- none'));
|
61 |
$entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId();
|
62 |
+
$attributes = Mage::getModel('eav/entity_attribute')->getCollection()->addFilter(
|
63 |
+
'entity_type_id',
|
64 |
+
$entityTypeId
|
65 |
+
)->setOrder('attribute_code', 'ASC');
|
66 |
+
foreach ($attributes as $attribute) {
|
67 |
+
if (($attribute->getBackendType() == 'text') || ($attribute->getBackendType() == 'varchar') || ($attribute->getBackendType() == 'static')) {
|
68 |
+
if ($attribute->getFrontendLabel()) {
|
69 |
+
if (!in_array($attribute->getAttributeCode(), $this->_ignore)) {
|
70 |
+
$options[] = array(
|
71 |
+
'value' => $attribute->getAttributeCode(),
|
72 |
+
'label' => $attribute->getFrontendLabel()
|
73 |
+
);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
return $options;
|
80 |
}
|
81 |
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Type.php
CHANGED
@@ -11,19 +11,24 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Type {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Type
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => '', 'label' => Mage::helper('channable')->__('Disabled'));
|
28 |
+
$type[] = array('value' => 'fixed', 'label' => Mage::helper('channable')->__('Static'));
|
29 |
+
$type[] = array('value' => 'attribute', 'label' => Mage::helper('channable')->__('Use Attribute'));
|
30 |
+
|
31 |
+
return $type;
|
32 |
+
}
|
33 |
+
|
34 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Visibility.php
CHANGED
@@ -11,20 +11,25 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Visibility {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Visibility
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => '1', 'label' => Mage::helper('adminhtml')->__('Not Visible Individually'));
|
28 |
+
$type[] = array('value' => '2', 'label' => Mage::helper('adminhtml')->__('Catalog'));
|
29 |
+
$type[] = array('value' => '3', 'label' => Mage::helper('adminhtml')->__('Search'));
|
30 |
+
$type[] = array('value' => '4', 'label' => Mage::helper('adminhtml')->__('Catalog, Search'));
|
31 |
+
|
32 |
+
return $type;
|
33 |
+
}
|
34 |
|
35 |
}
|
app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Weight.php
CHANGED
@@ -11,20 +11,25 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Weight {
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2015 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
|
|
17 |
|
18 |
+
class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Weight
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return array
|
23 |
+
*/
|
24 |
+
public function toOptionArray()
|
25 |
+
{
|
26 |
+
$type = array();
|
27 |
+
$type[] = array('value' => 'lb', 'label' => Mage::helper('adminhtml')->__('Pounds (lb)'));
|
28 |
+
$type[] = array('value' => 'oz', 'label' => Mage::helper('adminhtml')->__('Ounces (oz)'));
|
29 |
+
$type[] = array('value' => 'g', 'label' => Mage::helper('adminhtml')->__('Grams (g)'));
|
30 |
+
$type[] = array('value' => 'kg', 'label' => Mage::helper('adminhtml')->__('Kilograms (kg)'));
|
31 |
+
|
32 |
+
return $type;
|
33 |
+
}
|
34 |
+
|
35 |
}
|
app/code/community/Magmodules/Channable/Model/Channable.php
CHANGED
@@ -11,424 +11,636 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Common
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
$config = $this->getFeedConfig($storeId);
|
24 |
-
$
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
+
|
18 |
+
class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Common
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param $storeId
|
23 |
+
* @param string $limit
|
24 |
+
* @param int $page
|
25 |
+
* @param $timeStart
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
public function generateFeed($storeId, $limit = '', $page = 1, $timeStart)
|
29 |
+
{
|
30 |
+
$this->setMemoryLimit($storeId);
|
31 |
$config = $this->getFeedConfig($storeId);
|
32 |
+
$this->cleanItemUpdates($storeId, $page);
|
33 |
+
$products = $this->getProducts($config, $limit, $page);
|
34 |
+
$prices = Mage::helper('channable')->getTypePrices($config, $products);
|
35 |
+
if ($feed = $this->getFeedData($products, $config, $timeStart, $prices, $page)) {
|
36 |
+
return $feed;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param $storeId
|
42 |
+
*/
|
43 |
+
protected function setMemoryLimit($storeId)
|
44 |
+
{
|
45 |
+
if (Mage::getStoreConfig('channable/server/overwrite', $storeId)) {
|
46 |
+
if ($memory_limit = Mage::getStoreConfig('channable/server/memory_limit', $storeId)) {
|
47 |
+
ini_set('memory_limit', $memory_limit);
|
48 |
+
}
|
49 |
+
|
50 |
+
if ($max_execution_time = Mage::getStoreConfig('channable/server/max_execution_time', $storeId)) {
|
51 |
+
ini_set('max_execution_time', $max_execution_time);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param $storeId
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function getFeedConfig($storeId)
|
61 |
+
{
|
62 |
+
|
63 |
+
$config = array();
|
64 |
+
$feed = Mage::helper('channable');
|
65 |
+
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
|
66 |
+
|
67 |
+
// DEFAULTS
|
68 |
+
$config['store_id'] = $storeId;
|
69 |
+
$config['website_name'] = $feed->cleanData(
|
70 |
+
Mage::getModel('core/website')->load($websiteId)->getName(),
|
71 |
+
'striptags'
|
72 |
+
);
|
73 |
+
$config['website_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
74 |
+
$config['media_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
75 |
+
$config['media_image_url'] = $config['media_url'] . 'catalog' . DS . 'product';
|
76 |
+
$config['media_attributes'] = $feed->getMediaAttributes();
|
77 |
+
$config['limit'] = Mage::getStoreConfig('channable/connect/max_products', $storeId);
|
78 |
+
$config['version'] = (string)Mage::getConfig()->getNode()->modules->Magmodules_Channable->version;
|
79 |
+
$config['media_gallery_id'] = Mage::getResourceModel('eav/entity_attribute')->getIdByCode(
|
80 |
+
'catalog_product',
|
81 |
+
'media_gallery'
|
82 |
+
);
|
83 |
+
$config['filters'] = @unserialize(Mage::getStoreConfig('channable/filter/advanced', $storeId));
|
84 |
+
$config['product_url_suffix'] = $feed->getProductUrlSuffix($storeId);
|
85 |
+
$config['filter_enabled'] = Mage::getStoreConfig('channable/filter/category_enabled', $storeId);
|
86 |
+
$config['filter_cat'] = Mage::getStoreConfig('channable/filter/categories', $storeId);
|
87 |
+
$config['filter_type'] = Mage::getStoreConfig('channable/filter/category_type', $storeId);
|
88 |
+
$config['filter_status'] = Mage::getStoreConfig('channable/filter/visibility_inc', $storeId);
|
89 |
+
$config['hide_no_stock'] = Mage::getStoreConfig('channable/filter/stock', $storeId);
|
90 |
+
$config['conf_enabled'] = Mage::getStoreConfig('channable/data/conf_enabled', $storeId);
|
91 |
+
$config['conf_fields'] = Mage::getStoreConfig('channable/data/conf_fields', $storeId);
|
92 |
+
$config['parent_att'] = $this->getParentAttributeSelection($config['conf_fields']);
|
93 |
+
$config['conf_switch_urls'] = Mage::getStoreConfig('channable/data/conf_switch_urls', $storeId);
|
94 |
+
$config['stock_manage'] = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
|
95 |
+
$config['use_qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/enable_qty_increments');
|
96 |
+
$config['qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/qty_increments');
|
97 |
+
$config['delivery'] = Mage::getStoreConfig('channable/data/delivery', $storeId);
|
98 |
+
$config['delivery_be'] = Mage::getStoreConfig('channable/data/delivery_be', $storeId);
|
99 |
+
$config['delivery_att'] = Mage::getStoreConfig('channable/data/delivery_att', $storeId);
|
100 |
+
$config['delivery_att_be'] = Mage::getStoreConfig('channable/data/delivery_att_be', $storeId);
|
101 |
+
$config['delivery_in'] = Mage::getStoreConfig('channable/data/delivery_in', $storeId);
|
102 |
+
$config['delivery_in_be'] = Mage::getStoreConfig('channable/data/delivery_in_be', $storeId);
|
103 |
+
$config['delivery_out'] = Mage::getStoreConfig('channable/data/delivery_out', $storeId);
|
104 |
+
$config['delivery_out_be'] = Mage::getStoreConfig('channable/data/delivery_out_be', $storeId);
|
105 |
+
$config['images'] = Mage::getStoreConfig('channable/data/images', $storeId);
|
106 |
+
$config['default_image'] = Mage::getStoreConfig('channable/data/default_image', $storeId);
|
107 |
+
$config['skip_validation'] = false;
|
108 |
+
$config['weight'] = Mage::getStoreConfig('channable/data/weight', $storeId);
|
109 |
+
$config['weight_units'] = Mage::getStoreConfig('channable/data/weight_units', $storeId);
|
110 |
+
$config['price_scope'] = Mage::getStoreConfig('catalog/price/scope');
|
111 |
+
$config['price_add_tax'] = Mage::getStoreConfig('channable/data/add_tax', $storeId);
|
112 |
+
$config['price_add_tax_perc'] = Mage::getStoreConfig('channable/data/tax_percentage', $storeId);
|
113 |
+
$config['force_tax'] = Mage::getStoreConfig('channable/data/force_tax', $storeId);
|
114 |
+
$config['currency'] = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
|
115 |
+
$config['base_currency_code'] = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
|
116 |
+
$config['markup'] = Mage::helper('channable')->getPriceMarkup($config);
|
117 |
+
$config['use_tax'] = Mage::helper('channable')->getTaxUsage($config);
|
118 |
+
|
119 |
+
if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) {
|
120 |
+
$config['item_updates'] = Mage::getStoreConfig('channable_api/item/enabled', $storeId);
|
121 |
+
} else {
|
122 |
+
$config['item_updates'] = '';
|
123 |
+
}
|
124 |
+
|
125 |
+
$config['shipping_prices'] = @unserialize(Mage::getStoreConfig('channable/advanced/shipping_price', $storeId));
|
126 |
+
$config['shipping_method'] = Mage::getStoreConfig('channable/advanced/shipping_method', $storeId);
|
127 |
+
$config['field'] = $this->getFeedAttributes($config, $storeId);
|
128 |
+
$config['category_exclude'] = 'channable_exclude';
|
129 |
+
$config['category_data'] = $feed->getCategoryData($config, $storeId);
|
130 |
+
|
131 |
+
return $config;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* @param string $config
|
136 |
+
* @param int $storeId
|
137 |
+
* @return mixed
|
138 |
+
*/
|
139 |
+
public function getFeedAttributes($config = '', $storeId = 0)
|
140 |
+
{
|
141 |
+
$attributes = array();
|
142 |
+
$attributes['id'] = array(
|
143 |
+
'label' => 'id',
|
144 |
+
'source' => 'entity_id'
|
145 |
+
);
|
146 |
+
$attributes['name'] = array(
|
147 |
+
'label' => 'name',
|
148 |
+
'source' => Mage::getStoreConfig('channable/data/name', $storeId)
|
149 |
+
);
|
150 |
+
$attributes['description'] = array(
|
151 |
+
'label' => 'description',
|
152 |
+
'source' => Mage::getStoreConfig('channable/data/description', $storeId)
|
153 |
+
);
|
154 |
+
$attributes['product_url'] = array(
|
155 |
+
'label' => 'url',
|
156 |
+
'source' => ''
|
157 |
+
);
|
158 |
+
$attributes['image_link'] = array(
|
159 |
+
'label' => 'image',
|
160 |
+
'source' => Mage::getStoreConfig('channable/data/default_image', $storeId)
|
161 |
+
);
|
162 |
+
$attributes['price'] = array(
|
163 |
+
'label' => 'price',
|
164 |
+
'source' => ''
|
165 |
+
);
|
166 |
+
$attributes['sku'] = array(
|
167 |
+
'label' => 'sku',
|
168 |
+
'source' => Mage::getStoreConfig('channable/data/sku', $storeId)
|
169 |
+
);
|
170 |
+
$attributes['brand'] = array(
|
171 |
+
'label' => 'brand',
|
172 |
+
'source' => Mage::getStoreConfig('channable/data/brand', $storeId)
|
173 |
+
);
|
174 |
+
$attributes['size'] = array(
|
175 |
+
'label' => 'size',
|
176 |
+
'source' => Mage::getStoreConfig('channable/data/size', $storeId)
|
177 |
+
);
|
178 |
+
$attributes['color'] = array(
|
179 |
+
'label' => 'color',
|
180 |
+
'source' => Mage::getStoreConfig('channable/data/color', $storeId)
|
181 |
+
);
|
182 |
+
$attributes['material'] = array(
|
183 |
+
'label' => 'material',
|
184 |
+
'source' => Mage::getStoreConfig('channable/data/material', $storeId)
|
185 |
+
);
|
186 |
+
$attributes['gender'] = array(
|
187 |
+
'label' => 'gender',
|
188 |
+
'source' => Mage::getStoreConfig('channable/data/gender', $storeId)
|
189 |
+
);
|
190 |
+
$attributes['ean'] = array(
|
191 |
+
'label' => 'ean',
|
192 |
+
'source' => Mage::getStoreConfig('channable/data/ean', $storeId)
|
193 |
+
);
|
194 |
+
$attributes['categories'] = array(
|
195 |
+
'label' => 'categories',
|
196 |
+
'source' => '',
|
197 |
+
'parent' => 1
|
198 |
+
);
|
199 |
+
$attributes['type'] = array(
|
200 |
+
'label' => 'type',
|
201 |
+
'source' => 'type_id'
|
202 |
+
);
|
203 |
+
$attributes['status'] = array(
|
204 |
+
'label' => 'status',
|
205 |
+
'source' => 'status',
|
206 |
+
'parent' => 1
|
207 |
+
);
|
208 |
+
$attributes['visibility'] = array(
|
209 |
+
'label' => 'visibility',
|
210 |
+
'source' => 'visibility'
|
211 |
+
);
|
212 |
+
$attributes['parent_id'] = array(
|
213 |
+
'label' => 'item_group_id',
|
214 |
+
'source' => 'entity_id',
|
215 |
+
'parent' => 1
|
216 |
+
);
|
217 |
+
$attributes['weight'] = array(
|
218 |
+
'label' => 'weight',
|
219 |
+
'source' => ''
|
220 |
+
);
|
221 |
+
$attributes['is_in_stock'] = array(
|
222 |
+
'label' => 'is_in_stock',
|
223 |
+
'source' => 'is_in_stock'
|
224 |
+
);
|
225 |
+
|
226 |
+
if (Mage::getStoreConfig('channable/data/stock', $storeId)) {
|
227 |
+
$attributes['stock'] = array(
|
228 |
+
'label' => 'qty',
|
229 |
+
'source' => 'qty',
|
230 |
+
'action' => 'round'
|
231 |
+
);
|
232 |
+
}
|
233 |
+
|
234 |
+
if (Mage::getStoreConfig('channable/data/delivery', $storeId) == 'attribute') {
|
235 |
+
$attributes['delivery'] = array(
|
236 |
+
'label' => 'delivery',
|
237 |
+
'source' => Mage::getStoreConfig('channable/data/delivery_att', $storeId)
|
238 |
+
);
|
239 |
+
}
|
240 |
+
|
241 |
+
if (Mage::getStoreConfig('channable/data/delivery_be', $storeId) == 'attribute') {
|
242 |
+
$attributes['delivery_be'] = array(
|
243 |
+
'label' => 'delivery_be',
|
244 |
+
'source' => Mage::getStoreConfig('channable/data/delivery_att_be', $storeId)
|
245 |
+
);
|
246 |
+
}
|
247 |
+
|
248 |
+
if ($extraFields = @unserialize(Mage::getStoreConfig('channable/advanced/extra', $storeId))) {
|
249 |
+
foreach ($extraFields as $extraField) {
|
250 |
+
$attributes[$extraField['attribute']] = array(
|
251 |
+
'label' => $extraField['label'],
|
252 |
+
'source' => $extraField['attribute'],
|
253 |
+
'action' => ''
|
254 |
+
);
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
return Mage::helper('channable')->addAttributeData($attributes, $config);
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* @param $storeId
|
263 |
+
* @param $page
|
264 |
+
*/
|
265 |
+
protected function cleanItemUpdates($storeId, $page)
|
266 |
+
{
|
267 |
+
if (empty($page)) {
|
268 |
+
if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) {
|
269 |
+
Mage::getModel('channableapi/items')->cleanItemStore($storeId);
|
270 |
+
}
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* @param $products
|
276 |
+
* @param $config
|
277 |
+
* @param $timeStart
|
278 |
+
* @param $prices
|
279 |
+
* @param $page
|
280 |
+
* @return array
|
281 |
+
*/
|
282 |
+
public function getFeedData($products, $config, $timeStart, $prices, $page)
|
283 |
+
{
|
284 |
+
$count = $this->getProducts($config, '', '', 'count');
|
285 |
+
foreach ($products as $product) {
|
286 |
+
if ($parentId = Mage::helper('channable')->getParentData($product, $config)) {
|
287 |
+
$parent = $this->loadParentProduct($parentId, $config['store_id'], $config['parent_att']);
|
288 |
+
} else {
|
289 |
+
$parent = '';
|
290 |
+
}
|
291 |
+
|
292 |
+
if ($productData = Mage::helper('channable')->getProductDataRow($product, $config, $parent)) {
|
293 |
+
foreach ($productData as $key => $value) {
|
294 |
+
if (!is_array($value)) {
|
295 |
+
$productRow[$key] = $value;
|
296 |
+
}
|
297 |
+
}
|
298 |
+
|
299 |
+
if ($extraData = $this->getExtraDataFields($productData, $config, $product, $prices)) {
|
300 |
+
$productRow = array_merge($productRow, $extraData);
|
301 |
+
}
|
302 |
+
|
303 |
+
$feed['products'][] = $productRow;
|
304 |
+
if ($config['item_updates']) {
|
305 |
+
$this->processItemUpdates($productRow, $config['store_id']);
|
306 |
+
}
|
307 |
+
|
308 |
+
unset($productRow);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
if (!empty($feed)) {
|
313 |
+
$returnFeed = array();
|
314 |
+
$returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart, count($feed['products']), $page);
|
315 |
+
$returnFeed['products'] = $feed['products'];
|
316 |
+
|
317 |
+
return $returnFeed;
|
318 |
+
} else {
|
319 |
+
$returnFeed = array();
|
320 |
+
$returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart);
|
321 |
+
|
322 |
+
return $returnFeed;
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* @param $productData
|
328 |
+
* @param $config
|
329 |
+
* @param $product
|
330 |
+
* @param $prices
|
331 |
+
* @return array
|
332 |
+
*/
|
333 |
+
public function getExtraDataFields($productData, $config, $product, $prices)
|
334 |
+
{
|
335 |
+
$extra = array();
|
336 |
+
if (!empty($productData['price'])) {
|
337 |
+
if(!empty($productData['item_group_id'])) {
|
338 |
+
$itemGroupId = $productData['item_group_id'];
|
339 |
+
} else {
|
340 |
+
$itemGroupId = '';
|
341 |
+
}
|
342 |
+
|
343 |
+
if ($priceData = $this->getPrices($productData['price'], $prices, $product, $config['currency'], $itemGroupId)) {
|
344 |
+
$extra = array_merge($extra, $priceData);
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
if ($stockData = $this->getStockData($productData, $config, $product)) {
|
349 |
+
$extra = array_merge($extra, $stockData);
|
350 |
+
}
|
351 |
+
|
352 |
+
if ($shippingData = $this->getShipping($productData, $config, $product->getWeight(), $product, $stockData)) {
|
353 |
+
$extra = array_merge($extra, $shippingData);
|
354 |
+
}
|
355 |
+
|
356 |
+
if ($categoryData = $this->getCategoryData($productData)) {
|
357 |
+
$extra = array_merge($extra, $categoryData);
|
358 |
+
}
|
359 |
+
|
360 |
+
if ($config['images'] == 'all') {
|
361 |
+
if ($imageData = $this->getImages($productData, $config)) {
|
362 |
+
$extra = array_merge($extra, $imageData);
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
return $extra;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* @param $data
|
371 |
+
* @param $confPrices
|
372 |
+
* @param $product
|
373 |
+
* @param $currency
|
374 |
+
* @param $itemGroupId
|
375 |
+
* @return array
|
376 |
+
*/
|
377 |
+
public function getPrices($data, $confPrices, $product, $currency, $itemGroupId)
|
378 |
+
{
|
379 |
+
$prices = array();
|
380 |
+
$id = $product->getEntityId();
|
381 |
+
$parentPriceIndex = $itemGroupId . '_' . $id;
|
382 |
+
if ($itemGroupId && !empty($confPrices[$parentPriceIndex])) {
|
383 |
+
$confPrice = Mage::helper('tax')->getPrice($product, $confPrices[$parentPriceIndex], true);
|
384 |
+
$confPriceReg = Mage::helper('tax')->getPrice($product, $confPrices[$parentPriceIndex . '_reg'], true);
|
385 |
+
if ($confPriceReg > $confPrice) {
|
386 |
+
$prices['special_price'] = number_format($confPrice, 2, '.', '') . ' ' . $currency;
|
387 |
+
$prices['price'] = number_format($confPriceReg, 2, '.', '') . ' ' . $currency;
|
388 |
+
} else {
|
389 |
+
$prices['price'] = number_format($confPrice, 2, '.', '') . ' ' . $currency;
|
390 |
+
}
|
391 |
+
} else {
|
392 |
+
$prices['price'] = $data['price'];
|
393 |
+
$prices['special_price'] = '';
|
394 |
+
$prices['special_price_from'] = '';
|
395 |
+
$prices['special_price_to'] = '';
|
396 |
+
if (isset($data['sales_price'])) {
|
397 |
+
$prices['price'] = $data['regular_price'];
|
398 |
+
$prices['special_price'] = $data['sales_price'];
|
399 |
+
if (isset($data['sales_date_start'])) {
|
400 |
+
$prices['special_price_from'] = $data['sales_date_start'];
|
401 |
+
}
|
402 |
+
|
403 |
+
if (isset($data['sales_date_end'])) {
|
404 |
+
$prices['special_price_to'] = $data['sales_date_end'];
|
405 |
+
}
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
return $prices;
|
410 |
+
}
|
411 |
+
|
412 |
+
/**
|
413 |
+
* @param $data
|
414 |
+
* @param $config
|
415 |
+
* @param $weight
|
416 |
+
* @param $product
|
417 |
+
* @param $stock
|
418 |
+
* @return array
|
419 |
+
*/
|
420 |
+
public function getShipping($data, $config, $weight, $product, $stock)
|
421 |
+
{
|
422 |
+
$shippingArray = array();
|
423 |
+
|
424 |
+
if ($config['delivery'] == 'fixed') {
|
425 |
+
if (!empty($stock['manage_stock'])) {
|
426 |
+
if (!empty($stock['is_in_stock'])) {
|
427 |
+
if (!empty($config['delivery_in'])) {
|
428 |
+
$shippingArray['delivery'] = $config['delivery_in'];
|
429 |
+
}
|
430 |
+
} else {
|
431 |
+
if (!empty($config['delivery_out'])) {
|
432 |
+
$shippingArray['delivery'] = $config['delivery_out'];
|
433 |
+
}
|
434 |
+
}
|
435 |
+
} else {
|
436 |
+
if (!empty($config['delivery_in'])) {
|
437 |
+
$shippingArray['delivery'] = $config['delivery_in'];
|
438 |
+
}
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
if ($config['delivery_be'] == 'fixed') {
|
443 |
+
if (!empty($stock['manage_stock'])) {
|
444 |
+
if (!empty($stock['is_in_stock'])) {
|
445 |
+
if (!empty($config['delivery_in_be'])) {
|
446 |
+
$shippingArray['delivery_be'] = $config['delivery_in_be'];
|
447 |
+
}
|
448 |
+
} else {
|
449 |
+
if (!empty($config['delivery_out'])) {
|
450 |
+
$shippingArray['delivery_be'] = $config['delivery_out_be'];
|
451 |
+
}
|
452 |
+
}
|
453 |
+
} else {
|
454 |
+
if (!empty($config['delivery_in'])) {
|
455 |
+
$shippingArray['delivery_be'] = $config['delivery_in_be'];
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
if ($config['shipping_method'] == 'weight') {
|
461 |
+
$calValue = $weight;
|
462 |
+
} else {
|
463 |
+
if (isset($data['price']['final_price_clean'])) {
|
464 |
+
$calValue = $data['price']['final_price_clean'];
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
if (!empty($config['shipping_prices'])) {
|
469 |
+
foreach ($config['shipping_prices'] as $shippingPrice) {
|
470 |
+
if (($calValue >= $shippingPrice['price_from']) && ($calValue <= $shippingPrice['price_to'])) {
|
471 |
+
$shippingCost = $shippingPrice['cost'];
|
472 |
+
|
473 |
+
$shippingCost = number_format($shippingCost, 2, '.', '') . ' ' . $config['currency'];
|
474 |
+
if (empty($shippingPrice['country'])) {
|
475 |
+
$shippingArray['shipping'] = $shippingCost;
|
476 |
+
} else {
|
477 |
+
$label = 'shipping_' . strtolower($shippingPrice['country']);
|
478 |
+
$shippingArray[$label] = $shippingCost;
|
479 |
+
if (strtolower($shippingPrice['country']) == 'nl') {
|
480 |
+
$shippingArray['shipping'] = $shippingCost;
|
481 |
+
}
|
482 |
+
}
|
483 |
+
}
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
return $shippingArray;
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* @param $productData
|
492 |
+
* @return array
|
493 |
+
*/
|
494 |
+
public function getCategoryData($productData)
|
495 |
+
{
|
496 |
+
$category = array();
|
497 |
+
$i = 0;
|
498 |
+
if (!empty($productData['categories'])) {
|
499 |
+
foreach ($productData['categories'] as $cat) {
|
500 |
+
if (!empty($cat['path'])) {
|
501 |
+
if ($i == 0) {
|
502 |
+
$category['category'] = implode(' > ', $cat['path']);
|
503 |
+
}
|
504 |
+
|
505 |
+
$category['categories'][] = implode(' > ', $cat['path']);
|
506 |
+
$i++;
|
507 |
+
}
|
508 |
+
}
|
509 |
+
}
|
510 |
+
|
511 |
+
return $category;
|
512 |
+
}
|
513 |
+
|
514 |
+
/**
|
515 |
+
* @param $productData
|
516 |
+
* @param $config
|
517 |
+
* @param $product
|
518 |
+
* @return array
|
519 |
+
*/
|
520 |
+
public function getStockData($productData, $config, $product)
|
521 |
+
{
|
522 |
+
$stockData = array();
|
523 |
+
$stockData['is_in_stock'] = $productData['is_in_stock'];
|
524 |
+
|
525 |
+
if (!empty($productData['qty'])) {
|
526 |
+
$stockData['qty'] = $productData['qty'];
|
527 |
+
} else {
|
528 |
+
$stockData['qty'] = (string)'0';
|
529 |
+
}
|
530 |
+
|
531 |
+
if ($product->getUseConfigManageStock()) {
|
532 |
+
$stockData['manage_stock'] = (string)$config['stock_manage'];
|
533 |
+
} else {
|
534 |
+
$stockData['manage_stock'] = (string)$product->getManageStock();
|
535 |
+
}
|
536 |
+
|
537 |
+
if (!empty($product['min_sale_qty'])) {
|
538 |
+
$stockData['min_sale_qty'] = (string)round($product['min_sale_qty']);
|
539 |
+
} else {
|
540 |
+
$stockData['min_sale_qty'] = '1';
|
541 |
+
}
|
542 |
+
|
543 |
+
if ($product->getUseEnableQtyIncrements()) {
|
544 |
+
if (!empty($config['use_qty_increments'])) {
|
545 |
+
$stockData['qty_increments'] = (string)$config['qty_increments'];
|
546 |
+
}
|
547 |
+
} else {
|
548 |
+
if ($product->getUseConfigQtyIncrements()) {
|
549 |
+
$stockData['qty_increments'] = (string)$config['qty_increments'];
|
550 |
+
} else {
|
551 |
+
$stockData['qty_increments'] = round($product['qty_increments']);
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
if (empty($stockData['qty_increments'])) {
|
556 |
+
$stockData['qty_increments'] = '1';
|
557 |
+
}
|
558 |
+
|
559 |
+
return $stockData;
|
560 |
+
}
|
561 |
+
|
562 |
+
/**
|
563 |
+
* @param $productData
|
564 |
+
* @param $config
|
565 |
+
* @return array
|
566 |
+
*/
|
567 |
+
public function getImages($productData, $config)
|
568 |
+
{
|
569 |
+
$_images = array();
|
570 |
+
|
571 |
+
if (!empty($config['default_image'])) {
|
572 |
+
if (!empty($productData['image'][$config['default_image']])) {
|
573 |
+
$_images['image_link'] = $productData['image'][$config['default_image']];
|
574 |
+
}
|
575 |
+
} else {
|
576 |
+
if (!empty($productData['image']['base'])) {
|
577 |
+
$_images['image_link'] = $productData['image']['base'];
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
if (empty($_images['image_link'])) {
|
582 |
+
if (!empty($productData['image_link'])) {
|
583 |
+
$_images['image_link'] = $productData['image_link'];
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
if (!empty($productData['image']['all'])) {
|
588 |
+
$_additional = array();
|
589 |
+
foreach ($productData['image']['all'] as $image) {
|
590 |
+
if (empty($_images['image_link'])) {
|
591 |
+
$_images['image_link'] = $image;
|
592 |
+
}
|
593 |
+
|
594 |
+
if ($image != $_images['image_link']) {
|
595 |
+
$_additional[] = $image;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
|
599 |
+
if (count($_additional) > 0) {
|
600 |
+
$_images['additional_imagelinks'] = $_additional;
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
return $_images;
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* @param $productRow
|
609 |
+
* @param $storeId
|
610 |
+
*/
|
611 |
+
public function processItemUpdates($productRow, $storeId)
|
612 |
+
{
|
613 |
+
Mage::getModel('channableapi/items')->saveItemFeed($productRow, $storeId);
|
614 |
+
}
|
615 |
+
|
616 |
+
/**
|
617 |
+
* @param $config
|
618 |
+
* @param $count
|
619 |
+
* @param $timeStart
|
620 |
+
* @param int $productCount
|
621 |
+
* @param int $page
|
622 |
+
* @return array
|
623 |
+
*/
|
624 |
+
public function getFeedHeader($config, $count, $timeStart, $productCount = 0, $page = 1)
|
625 |
+
{
|
626 |
+
$header = array();
|
627 |
+
$header['system'] = 'Magento';
|
628 |
+
$header['extension'] = 'Magmodules_Channable';
|
629 |
+
$header['extension_version'] = $config['version'];
|
630 |
+
$header['store'] = $config['website_name'];
|
631 |
+
$header['url'] = $config['website_url'];
|
632 |
+
$header['products_total'] = $count;
|
633 |
+
$header['products_limit'] = $config['limit'];
|
634 |
+
$header['products_output'] = $productCount;
|
635 |
+
$header['products_pages'] = (($config['limit']) && ($count > $config['limit'])) ? ceil($count / $config['limit']) : 1;
|
636 |
+
$header['current_page'] = ($page) ? $page : 1;
|
637 |
+
$header['processing_time'] = number_format((microtime(true) - $timeStart), 4);
|
638 |
+
if ($header['products_pages'] > $header['current_page']) {
|
639 |
+
$header['next_page'] = 'true';
|
640 |
+
} else {
|
641 |
+
$header['next_page'] = 'false';
|
642 |
+
}
|
643 |
+
|
644 |
+
return $header;
|
645 |
+
}
|
646 |
}
|
app/code/community/Magmodules/Channable/Model/Common.php
CHANGED
@@ -11,221 +11,272 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
{
|
22 |
-
|
23 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
24 |
-
$collection->setStore($
|
25 |
-
$collection->addStoreFilter($
|
26 |
$collection->addFinalPrice();
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
if($filter['type'] == 'select') {
|
149 |
-
$attribute = $filter['attribute'] . '_value';
|
150 |
-
}
|
151 |
-
$condition = $filter['condition'];
|
152 |
-
$value = $filter['value'];
|
153 |
-
switch ($condition) {
|
154 |
-
case 'nin':
|
155 |
-
if(strpos($value, ',') !== FALSE) { $value = explode(',', $value); }
|
156 |
-
$collection->addAttributeToFilter(array(array('attribute' => $attribute, $condition => $value), array('attribute' => $attribute, 'null' => true)));
|
157 |
-
break;
|
158 |
-
case 'in';
|
159 |
-
if(strpos($value, ',') !== FALSE) { $value = explode(',', $value); }
|
160 |
-
$collection->addAttributeToFilter($attribute, array($condition => $value));
|
161 |
-
break;
|
162 |
-
case 'neq':
|
163 |
-
$collection->addAttributeToFilter(array(array('attribute' => $attribute, $condition => $value), array('attribute' => $attribute, 'null' => true)));
|
164 |
-
break;
|
165 |
-
case 'empty':
|
166 |
-
$collection->addAttributeToFilter($attribute, array('null' => true));
|
167 |
-
break;
|
168 |
-
case 'not-empty':
|
169 |
-
$collection->addAttributeToFilter($attribute, array('notnull' => true));
|
170 |
-
break;
|
171 |
-
default:
|
172 |
-
$collection->addAttributeToFilter($attribute, array($condition => $value));
|
173 |
-
break;
|
174 |
-
}
|
175 |
-
}
|
176 |
-
}
|
177 |
-
if(!empty($config['hide_no_stock'])) {
|
178 |
-
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
|
179 |
-
}
|
180 |
-
|
181 |
-
$products = $collection->getSize();
|
182 |
-
}
|
183 |
return $products;
|
184 |
-
}
|
185 |
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
{
|
188 |
$parent = Mage::getResourceModel('catalog/product_collection')
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
$attributes[] = 'type_id';
|
218 |
-
$attributes[] = 'image';
|
219 |
-
$attributes[] = 'small_image';
|
220 |
-
$attributes[] = 'thumbnail';
|
221 |
-
$attributes[] = 'status';
|
222 |
-
return $attributes;
|
223 |
-
}
|
224 |
-
|
225 |
-
public function getParentAttributeSelection($atts)
|
226 |
{
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
+
class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param $config
|
22 |
+
* @param string $limit
|
23 |
+
* @param int $page
|
24 |
+
* @param string $type
|
25 |
+
* @return mixed
|
26 |
+
*/
|
27 |
+
public function getProducts($config, $limit = '', $page = 1, $type = '')
|
28 |
{
|
29 |
+
$storeId = $config['store_id'];
|
30 |
$collection = Mage::getResourceModel('catalog/product_collection');
|
31 |
+
$collection->setStore($storeId);
|
32 |
+
$collection->addStoreFilter($storeId);
|
33 |
$collection->addFinalPrice();
|
34 |
+
$collection->addUrlRewrite();
|
35 |
+
|
36 |
+
if (!empty($config['filter_enabled'])) {
|
37 |
+
$filterType = $config['filter_type'];
|
38 |
+
$categories = $config['filter_cat'];
|
39 |
+
if ($filterType && $categories) {
|
40 |
+
$table = Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
41 |
+
if ($filterType == 'include') {
|
42 |
+
$collection->getSelect()->join(array('cats' => $table), 'cats.product_id = e.entity_id');
|
43 |
+
$collection->getSelect()->where('cats.category_id in (' . $categories . ')');
|
44 |
+
} else {
|
45 |
+
$collection->getSelect()->join(array('cats' => $table), 'cats.product_id = e.entity_id');
|
46 |
+
$collection->getSelect()->where('cats.category_id not in (' . $categories . ')');
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$collection->addAttributeToFilter('status', 1);
|
52 |
+
|
53 |
+
if (($limit) && ($type != 'count')) {
|
54 |
+
$collection->setPage($page, $limit)->getCurPage();
|
55 |
+
}
|
56 |
+
|
57 |
+
if (empty($config['conf_enabled'])) {
|
58 |
+
$collection->addAttributeToFilter('visibility', array('in' => array(2, 3, 4)));
|
59 |
+
}
|
60 |
+
|
61 |
+
if (!empty($config['filters'])) {
|
62 |
+
$this->addFilters($config['filters'], $collection);
|
63 |
+
}
|
64 |
+
|
65 |
+
if (!empty($config['hide_no_stock'])) {
|
66 |
+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
|
67 |
+
}
|
68 |
+
|
69 |
+
if ($type != 'count') {
|
70 |
+
$attributes = $this->getDefaultAttributes();
|
71 |
+
|
72 |
+
if (!empty($config['filter_exclude'])) {
|
73 |
+
$attributes[] = $config['filter_exclude'];
|
74 |
+
}
|
75 |
+
|
76 |
+
foreach ($config['field'] as $field) {
|
77 |
+
if (!empty($field['source'])) {
|
78 |
+
$attributes[] = $field['source'];
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
if (!empty($config['delivery_att'])) {
|
83 |
+
$attributes[] = $config['delivery_att'];
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!empty($config['delivery_att_be'])) {
|
87 |
+
$attributes[] = $config['delivery_att_be'];
|
88 |
+
}
|
89 |
+
|
90 |
+
if (!empty($config['media_attributes'])) {
|
91 |
+
foreach ($config['media_attributes'] as $mediaAtt) {
|
92 |
+
$attributes[] = $mediaAtt;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$customValues = '';
|
97 |
+
if (isset($config['custom_name'])) {
|
98 |
+
$customValues .= $config['custom_name'] . ' ';
|
99 |
+
}
|
100 |
+
|
101 |
+
if (isset($config['custom_description'])) {
|
102 |
+
$customValues .= $config['custom_description'] . ' ';
|
103 |
+
}
|
104 |
+
|
105 |
+
if (isset($config['category_default'])) {
|
106 |
+
$customValues .= $config['category_default'] . ' ';
|
107 |
+
}
|
108 |
+
|
109 |
+
preg_match_all("/{{([^}]*)}}/", $customValues, $foundAtts);
|
110 |
+
if (!empty($foundAtts)) {
|
111 |
+
foreach ($foundAtts[1] as $att) {
|
112 |
+
$attributes[] = $att;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
$collection->addAttributeToSelect(array_unique($attributes));
|
117 |
+
|
118 |
+
if (!empty($config['filters'])) {
|
119 |
+
$this->addFilters($config['filters'], $collection);
|
120 |
+
}
|
121 |
+
|
122 |
+
$collection->joinTable(
|
123 |
+
'cataloginventory/stock_item', 'product_id=entity_id', array(
|
124 |
+
"qty" => "qty",
|
125 |
+
"is_in_stock" => "is_in_stock",
|
126 |
+
"manage_stock" => "manage_stock",
|
127 |
+
"use_config_manage_stock" => "use_config_manage_stock",
|
128 |
+
"min_sale_qty" => "min_sale_qty",
|
129 |
+
"qty_increments" => "qty_increments",
|
130 |
+
"enable_qty_increments" => "enable_qty_increments",
|
131 |
+
"use_config_qty_increments" => "use_config_qty_increments"
|
132 |
+
)
|
133 |
+
)->addAttributeToSelect(
|
134 |
+
array(
|
135 |
+
'qty',
|
136 |
+
'is_in_stock',
|
137 |
+
'manage_stock',
|
138 |
+
'use_config_manage_stock',
|
139 |
+
'min_sale_qty',
|
140 |
+
'qty_increments',
|
141 |
+
'enable_qty_increments',
|
142 |
+
'use_config_qty_increments'
|
143 |
+
)
|
144 |
+
);
|
145 |
+
$collection->getSelect()->group('e.entity_id');
|
146 |
+
if (!empty($config['hide_no_stock'])) {
|
147 |
+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
|
148 |
+
}
|
149 |
+
|
150 |
+
$products = $collection->load();
|
151 |
+
} else {
|
152 |
+
$products = $collection->getSize();
|
153 |
+
}
|
154 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
return $products;
|
156 |
+
}
|
157 |
|
158 |
+
/**
|
159 |
+
* @return array
|
160 |
+
*/
|
161 |
+
public function getDefaultAttributes()
|
162 |
+
{
|
163 |
+
$attributes = array();
|
164 |
+
$attributes[] = 'url_key';
|
165 |
+
$attributes[] = 'url_path';
|
166 |
+
$attributes[] = 'sku';
|
167 |
+
$attributes[] = 'price';
|
168 |
+
$attributes[] = 'final_price';
|
169 |
+
$attributes[] = 'price_model';
|
170 |
+
$attributes[] = 'price_type';
|
171 |
+
$attributes[] = 'special_price';
|
172 |
+
$attributes[] = 'special_from_date';
|
173 |
+
$attributes[] = 'special_to_date';
|
174 |
+
$attributes[] = 'type_id';
|
175 |
+
$attributes[] = 'tax_class_id';
|
176 |
+
$attributes[] = 'tax_percent';
|
177 |
+
$attributes[] = 'weight';
|
178 |
+
$attributes[] = 'visibility';
|
179 |
+
$attributes[] = 'type_id';
|
180 |
+
$attributes[] = 'image';
|
181 |
+
$attributes[] = 'small_image';
|
182 |
+
$attributes[] = 'thumbnail';
|
183 |
+
$attributes[] = 'status';
|
184 |
+
|
185 |
+
return $attributes;
|
186 |
+
}
|
187 |
+
|
188 |
+
public function loadParentProduct($parentId, $storeId, $attributes)
|
189 |
{
|
190 |
$parent = Mage::getResourceModel('catalog/product_collection')
|
191 |
+
->setStore($storeId)
|
192 |
+
->addStoreFilter($storeId)
|
193 |
+
->addFinalPrice()
|
194 |
+
->addUrlRewrite()
|
195 |
+
->addAttributeToFilter('entity_id', $parentId)
|
196 |
+
->addAttributeToSelect(array_unique($attributes))
|
197 |
+
->getFirstItem();
|
198 |
+
|
199 |
+
return $parent;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @param $atts
|
204 |
+
* @return array
|
205 |
+
*/
|
206 |
+
public function getParentAttributeSelection($atts)
|
207 |
+
{
|
208 |
+
$attributes = $this->getDefaultAttributes();
|
209 |
+
$extraAttributes = explode(',', $atts);
|
210 |
+
|
211 |
+
return array_merge($attributes, $extraAttributes);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* @param $filters
|
216 |
+
* @param $collection
|
217 |
+
*/
|
218 |
+
public function addFilters($filters, $collection)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
{
|
220 |
+
foreach ($filters as $filter) {
|
221 |
+
$attribute = $filter['attribute'];
|
222 |
+
if ($filter['type'] == 'select') {
|
223 |
+
$attribute = $filter['attribute'] . '_value';
|
224 |
+
}
|
225 |
+
|
226 |
+
$condition = $filter['condition'];
|
227 |
+
$value = $filter['value'];
|
228 |
+
|
229 |
+
if ($attribute == 'final_price') {
|
230 |
+
$condionType = array('eq'=> '=', 'neq' => '!=', 'gt' => '>', 'gteq' => '>=', 'lt' => '<', 'lteg' => '<=');
|
231 |
+
if (isset($condionType[$condition])) {
|
232 |
+
$collection->getSelect()->where('price_index.final_price ' . $condionType[$condition] . ' ' . $value);
|
233 |
+
}
|
234 |
+
|
235 |
+
continue;
|
236 |
+
}
|
237 |
+
|
238 |
+
switch ($condition) {
|
239 |
+
case 'nin':
|
240 |
+
if (strpos($value, ',') !== false) {
|
241 |
+
$value = explode(',', $value);
|
242 |
+
}
|
243 |
+
|
244 |
+
$collection->addAttributeToFilter(
|
245 |
+
array(
|
246 |
+
array(
|
247 |
+
'attribute' => $attribute,
|
248 |
+
$condition => $value
|
249 |
+
),
|
250 |
+
array('attribute' => $attribute, 'null' => true)
|
251 |
+
)
|
252 |
+
);
|
253 |
+
break;
|
254 |
+
case 'in';
|
255 |
+
if (strpos($value, ',') !== false) {
|
256 |
+
$value = explode(',', $value);
|
257 |
+
}
|
258 |
+
|
259 |
+
$collection->addAttributeToFilter($attribute, array($condition => $value));
|
260 |
+
break;
|
261 |
+
case 'neq':
|
262 |
+
$collection->addAttributeToFilter(
|
263 |
+
array(
|
264 |
+
array('attribute' => $attribute, $condition => $value),
|
265 |
+
array('attribute' => $attribute, 'null' => true)
|
266 |
+
)
|
267 |
+
);
|
268 |
+
break;
|
269 |
+
case 'empty':
|
270 |
+
$collection->addAttributeToFilter($attribute, array('null' => true));
|
271 |
+
break;
|
272 |
+
case 'not-empty':
|
273 |
+
$collection->addAttributeToFilter($attribute, array('notnull' => true));
|
274 |
+
break;
|
275 |
+
default:
|
276 |
+
$collection->addAttributeToFilter($attribute, array($condition => $value));
|
277 |
+
break;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
|
282 |
}
|
app/code/community/Magmodules/Channable/controllers/Adminhtml/ChannableController.php
CHANGED
@@ -11,25 +11,35 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_Adminhtml_ChannableController extends Mage_Adminhtml_Controller_Action
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
$this->_redirect('adminhtml/system_config/edit/section/channable');
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
return Mage::getSingleton('admin/session')->isAllowed('admin/channable/channable');
|
33 |
-
}
|
34 |
-
|
35 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
+
|
18 |
+
class Magmodules_Channable_Adminhtml_ChannableController extends Mage_Adminhtml_Controller_Action
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
* addToFlat contoller action
|
23 |
+
*/
|
24 |
+
public function addToFlatAction()
|
25 |
+
{
|
26 |
+
$nonFlatAttributes = Mage::helper('channable')->checkFlatCatalog(Mage::getModel("channable/channable")->getFeedAttributes());
|
27 |
+
|
28 |
+
foreach ($nonFlatAttributes as $key => $value) {
|
29 |
+
Mage::getModel('catalog/resource_eav_attribute')->load($key)->setUsedInProductListing(1)->save();
|
30 |
+
}
|
31 |
+
|
32 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('channable')->__('Attributes added to Flat Catalog, please reindex Product Flat Data.'));
|
33 |
+
|
34 |
$this->_redirect('adminhtml/system_config/edit/section/channable');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return mixed
|
39 |
+
*/
|
40 |
+
protected function _isAllowed()
|
41 |
+
{
|
42 |
return Mage::getSingleton('admin/session')->isAllowed('admin/channable/channable');
|
43 |
+
}
|
44 |
+
|
45 |
}
|
app/code/community/Magmodules/Channable/controllers/FeedController.php
CHANGED
@@ -11,37 +11,49 @@
|
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
-
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
-
|
18 |
-
class Magmodules_Channable_FeedController extends Mage_Core_Controller_Front_Action
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
11 |
* @package Magmodules_Channable
|
12 |
* @author Magmodules <info@magmodules.eu>
|
13 |
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
+
|
18 |
+
class Magmodules_Channable_FeedController extends Mage_Core_Controller_Front_Action
|
19 |
+
{
|
20 |
+
|
21 |
+
/**
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
public function getAction()
|
25 |
+
{
|
26 |
+
$storeId = $this->getRequest()->getParam('store');
|
27 |
+
if (Mage::getStoreConfig('channable/connect/enabled', $storeId)) {
|
28 |
+
$code = $this->getRequest()->getParam('code');
|
29 |
+
$page = $this->getRequest()->getParam('page');
|
30 |
+
if ($storeId && $code) {
|
31 |
+
if ($code == Mage::getStoreConfig('channable/connect/token')) {
|
32 |
+
$timeStart = microtime(true);
|
33 |
+
$limit = Mage::getStoreConfig('channable/connect/max_products', $storeId);
|
34 |
+
$appEmulation = Mage::getSingleton('core/app_emulation');
|
35 |
+
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
|
36 |
+
Mage::app()->loadAreaPart(
|
37 |
+
Mage_Core_Model_App_Area::AREA_GLOBAL,
|
38 |
+
Mage_Core_Model_App_Area::PART_EVENTS
|
39 |
+
)->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND);
|
40 |
+
if ($feed = Mage::getModel('channable/channable')->generateFeed(
|
41 |
+
$storeId, $limit, $page,
|
42 |
+
$timeStart
|
43 |
+
)
|
44 |
+
) {
|
45 |
+
if ($this->getRequest()->getParam('array')) {
|
46 |
+
$this->getResponse()->setBody(Zend_Debug::dump($feed, null, false));
|
47 |
+
} else {
|
48 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-type', 'application/json', true);
|
49 |
+
$this->getResponse()->setBody(json_encode($feed));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
}
|
app/code/community/Magmodules/Channable/data/magmodules_channable_setup/data-upgrade-1.4.8-1.4.9.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magmodules.eu - http://www.magmodules.eu - info@magmodules.eu
|
4 |
+
* =============================================================
|
5 |
+
* NOTICE OF LICENSE [Single domain license]
|
6 |
+
* This source file is subject to the EULA that is
|
7 |
+
* available through the world-wide-web at:
|
8 |
+
* http://www.magmodules.eu/license-agreement/
|
9 |
+
* =============================================================
|
10 |
+
* @category Magmodules
|
11 |
+
* @package Magmodules_Channable
|
12 |
+
* @author Magmodules <info@magmodules.eu>
|
13 |
+
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
+
* =============================================================
|
16 |
+
*/
|
17 |
+
|
18 |
+
$token = Mage::getModel('core/config_data')->getCollection()
|
19 |
+
->addFieldToFilter('path', 'channable/connect/token')
|
20 |
+
->addFieldToFilter('scope_id', 0)
|
21 |
+
->addFieldToFilter('scope', 'default')
|
22 |
+
->getFirstItem()
|
23 |
+
->getValue();
|
24 |
+
|
25 |
+
if (empty($token)) {
|
26 |
+
$chars = str_split("abcdefghijklmnopqrstuvwxyz0123456789");
|
27 |
+
for ($i = 0; $i < 32; $i++) {
|
28 |
+
$token .= $chars[array_rand($chars)];
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
Mage::getModel('core/config')->saveConfig('channable/connect/token', Mage::helper('core')->encrypt($token));
|
33 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
app/code/community/Magmodules/Channable/etc/adminhtml.xml
CHANGED
@@ -32,17 +32,17 @@
|
|
32 |
</config>
|
33 |
</children>
|
34 |
</system>
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
</children>
|
47 |
</admin>
|
48 |
</resources>
|
32 |
</config>
|
33 |
</children>
|
34 |
</system>
|
35 |
+
<channable module="channable">
|
36 |
+
<title>Channable</title>
|
37 |
+
<sort_order>200</sort_order>
|
38 |
+
<children>
|
39 |
+
<channable module="channable">
|
40 |
+
<title>Channable</title>
|
41 |
+
<sort_order>100</sort_order>
|
42 |
+
<action>adminhtml/channable/</action>
|
43 |
+
</channable>
|
44 |
+
</children>
|
45 |
+
</channable>
|
46 |
</children>
|
47 |
</admin>
|
48 |
</resources>
|
app/code/community/Magmodules/Channable/etc/config.xml
CHANGED
@@ -17,46 +17,56 @@
|
|
17 |
*/
|
18 |
-->
|
19 |
<config>
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
<product>
|
53 |
<collection>
|
54 |
<attributes>
|
55 |
-
<image
|
56 |
-
|
57 |
</collection>
|
58 |
</product>
|
59 |
-
|
60 |
<admin>
|
61 |
<routers>
|
62 |
<adminhtml>
|
@@ -68,46 +78,46 @@
|
|
68 |
</adminhtml>
|
69 |
</routers>
|
70 |
</admin>
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
</config>
|
17 |
*/
|
18 |
-->
|
19 |
<config>
|
20 |
+
<modules>
|
21 |
+
<Magmodules_Channable>
|
22 |
+
<version>1.5.0</version>
|
23 |
+
</Magmodules_Channable>
|
24 |
+
</modules>
|
25 |
+
<global>
|
26 |
+
<helpers>
|
27 |
+
<channable>
|
28 |
+
<class>Magmodules_Channable_Helper</class>
|
29 |
+
</channable>
|
30 |
+
</helpers>
|
31 |
+
<blocks>
|
32 |
+
<channable>
|
33 |
+
<class>Magmodules_Channable_Block</class>
|
34 |
+
</channable>
|
35 |
+
</blocks>
|
36 |
+
<models>
|
37 |
+
<channable>
|
38 |
+
<class>Magmodules_Channable_Model</class>
|
39 |
+
</channable>
|
40 |
+
</models>
|
41 |
+
<resources>
|
42 |
+
<magmodules_channable_setup>
|
43 |
+
<setup>
|
44 |
+
<module>Magmodules_Channable</module>
|
45 |
+
</setup>
|
46 |
+
<connection>
|
47 |
+
<use>core_setup</use>
|
48 |
+
</connection>
|
49 |
+
</magmodules_channable_setup>
|
50 |
+
</resources>
|
51 |
+
</global>
|
52 |
+
<frontend>
|
53 |
+
<routers>
|
54 |
+
<channable>
|
55 |
+
<use>standard</use>
|
56 |
+
<args>
|
57 |
+
<module>Magmodules_Channable</module>
|
58 |
+
<frontName>channable</frontName>
|
59 |
+
</args>
|
60 |
+
</channable>
|
61 |
+
</routers>
|
62 |
<product>
|
63 |
<collection>
|
64 |
<attributes>
|
65 |
+
<image/>
|
66 |
+
</attributes>
|
67 |
</collection>
|
68 |
</product>
|
69 |
+
</frontend>
|
70 |
<admin>
|
71 |
<routers>
|
72 |
<adminhtml>
|
78 |
</adminhtml>
|
79 |
</routers>
|
80 |
</admin>
|
81 |
+
<adminhtml>
|
82 |
+
<translate>
|
83 |
+
<modules>
|
84 |
+
<magmodules_channable>
|
85 |
+
<files>
|
86 |
+
<default>Magmodules_Channable.csv</default>
|
87 |
+
</files>
|
88 |
+
</magmodules_channable>
|
89 |
+
</modules>
|
90 |
+
</translate>
|
91 |
+
</adminhtml>
|
92 |
+
<default>
|
93 |
+
<channable>
|
94 |
+
<connect>
|
95 |
+
<token backend_model="adminhtml/system_config_backend_encrypted"></token>
|
96 |
+
<enabled>1</enabled>
|
97 |
+
<max_products>200</max_products>
|
98 |
+
</connect>
|
99 |
+
<data>
|
100 |
+
<name>name</name>
|
101 |
+
<description>description</description>
|
102 |
+
<brand>manufacturer</brand>
|
103 |
+
<ean>sku</ean>
|
104 |
+
<sku>sku</sku>
|
105 |
+
<color>color</color>
|
106 |
+
<size></size>
|
107 |
+
<images>all</images>
|
108 |
+
<material></material>
|
109 |
+
<gender></gender>
|
110 |
+
<delivery>fixed</delivery>
|
111 |
+
<delivery_in>24 Hours</delivery_in>
|
112 |
+
<delivery_out>1-7 Days</delivery_out>
|
113 |
+
<stock_status>1</stock_status>
|
114 |
+
<stock>1</stock>
|
115 |
+
</data>
|
116 |
+
<server>
|
117 |
+
<memory_limit>1024M</memory_limit>
|
118 |
+
<max_execution_time>300</max_execution_time>
|
119 |
+
<overwrite>0</overwrite>
|
120 |
+
</server>
|
121 |
+
</channable>
|
122 |
+
</default>
|
123 |
</config>
|
app/code/community/Magmodules/Channable/etc/system.xml
CHANGED
@@ -32,14 +32,14 @@
|
|
32 |
<show_in_default>1</show_in_default>
|
33 |
<show_in_website>1</show_in_website>
|
34 |
<show_in_store>1</show_in_store>
|
35 |
-
<groups>
|
36 |
<info>
|
37 |
<frontend_model>channable/adminhtml_widget_info_info</frontend_model>
|
38 |
<sort_order>1</sort_order>
|
39 |
<show_in_default>1</show_in_default>
|
40 |
<show_in_website>1</show_in_website>
|
41 |
<show_in_store>1</show_in_store>
|
42 |
-
</info>
|
43 |
<connect translate="label" module="channable">
|
44 |
<label>General - Settings</label>
|
45 |
<frontend_type>text</frontend_type>
|
@@ -58,7 +58,7 @@
|
|
58 |
<show_in_website>0</show_in_website>
|
59 |
<show_in_store>0</show_in_store>
|
60 |
</version>
|
61 |
-
<
|
62 |
<label>Connect Token</label>
|
63 |
<frontend_type>text</frontend_type>
|
64 |
<frontend_model>channable/adminhtml_system_config_form_field_token</frontend_model>
|
@@ -66,7 +66,7 @@
|
|
66 |
<show_in_default>1</show_in_default>
|
67 |
<show_in_website>0</show_in_website>
|
68 |
<show_in_store>0</show_in_store>
|
69 |
-
</
|
70 |
<connect_heading translate="label">
|
71 |
<label>Feed settings</label>
|
72 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -74,7 +74,7 @@
|
|
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 |
-
</connect_heading>
|
78 |
<enabled translate="label">
|
79 |
<label>Enabled Feed</label>
|
80 |
<frontend_type>select</frontend_type>
|
@@ -92,7 +92,7 @@
|
|
92 |
<show_in_website>1</show_in_website>
|
93 |
<show_in_store>1</show_in_store>
|
94 |
<comment>Limits the amount of product Channable will import per run. This setting wil not limit the total products sent to Channable!</comment>
|
95 |
-
</max_products>
|
96 |
</fields>
|
97 |
</connect>
|
98 |
<data translate="label" module="channable">
|
@@ -111,7 +111,7 @@
|
|
111 |
<show_in_default>1</show_in_default>
|
112 |
<show_in_website>1</show_in_website>
|
113 |
<show_in_store>1</show_in_store>
|
114 |
-
</note>
|
115 |
<heading_general translate="label">
|
116 |
<label>The General Fields</label>
|
117 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -128,7 +128,7 @@
|
|
128 |
<show_in_default>1</show_in_default>
|
129 |
<show_in_website>1</show_in_website>
|
130 |
<show_in_store>1</show_in_store>
|
131 |
-
</name>
|
132 |
<description translate="label">
|
133 |
<label>Description</label>
|
134 |
<frontend_type>select</frontend_type>
|
@@ -163,7 +163,7 @@
|
|
163 |
<show_in_default>1</show_in_default>
|
164 |
<show_in_website>1</show_in_website>
|
165 |
<show_in_store>1</show_in_store>
|
166 |
-
</heading_images>
|
167 |
<images translate="label">
|
168 |
<label>Images</label>
|
169 |
<frontend_type>select</frontend_type>
|
@@ -181,8 +181,8 @@
|
|
181 |
<show_in_default>1</show_in_default>
|
182 |
<show_in_website>1</show_in_website>
|
183 |
<show_in_store>1</show_in_store>
|
184 |
-
<depends><images>all</images></depends>
|
185 |
-
</default_image>
|
186 |
<heading_additional translate="label">
|
187 |
<label>The Additional Fields</label>
|
188 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -199,7 +199,7 @@
|
|
199 |
<show_in_default>1</show_in_default>
|
200 |
<show_in_website>1</show_in_website>
|
201 |
<show_in_store>1</show_in_store>
|
202 |
-
</sku>
|
203 |
<size translate="label">
|
204 |
<label>Size</label>
|
205 |
<frontend_type>select</frontend_type>
|
@@ -244,15 +244,6 @@
|
|
244 |
<show_in_website>1</show_in_website>
|
245 |
<show_in_store>1</show_in_store>
|
246 |
</heading_stock>
|
247 |
-
<stock_status translate="label">
|
248 |
-
<label>Send Status</label>
|
249 |
-
<frontend_type>select</frontend_type>
|
250 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
251 |
-
<sort_order>31</sort_order>
|
252 |
-
<show_in_default>1</show_in_default>
|
253 |
-
<show_in_website>1</show_in_website>
|
254 |
-
<show_in_store>1</show_in_store>
|
255 |
-
</stock_status>
|
256 |
<stock translate="label">
|
257 |
<label>Send Stock Level</label>
|
258 |
<frontend_type>select</frontend_type>
|
@@ -351,7 +342,7 @@
|
|
351 |
<show_in_website>1</show_in_website>
|
352 |
<show_in_store>1</show_in_store>
|
353 |
<depends><delivery_be>fixed</delivery_be></depends>
|
354 |
-
</delivery_out_be>
|
355 |
<weight_heading translate="label">
|
356 |
<label>Weight</label>
|
357 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -377,8 +368,8 @@
|
|
377 |
<show_in_default>1</show_in_default>
|
378 |
<show_in_website>1</show_in_website>
|
379 |
<show_in_store>1</show_in_store>
|
380 |
-
<depends><weight>1</weight></depends>
|
381 |
-
</weight_units>
|
382 |
<price_heading translate="label">
|
383 |
<label>Price Customization</label>
|
384 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -386,7 +377,7 @@
|
|
386 |
<show_in_default>1</show_in_default>
|
387 |
<show_in_website>1</show_in_website>
|
388 |
<show_in_store>1</show_in_store>
|
389 |
-
</price_heading>
|
390 |
<force_tax translate="label">
|
391 |
<label>Force the Tax Usage</label>
|
392 |
<frontend_type>select</frontend_type>
|
@@ -412,9 +403,9 @@
|
|
412 |
<show_in_default>1</show_in_default>
|
413 |
<show_in_website>1</show_in_website>
|
414 |
<show_in_store>1</show_in_store>
|
415 |
-
<comment><![CDATA[When the tax percentage is 21% use 21.]]></comment>
|
416 |
<depends><add_tax>1</add_tax></depends>
|
417 |
-
</tax_percentage>
|
418 |
<configurable_heading translate="label">
|
419 |
<label>Configurable & Grouped data linkage</label>
|
420 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -431,7 +422,7 @@
|
|
431 |
<show_in_default>1</show_in_default>
|
432 |
<show_in_website>1</show_in_website>
|
433 |
<show_in_store>1</show_in_store>
|
434 |
-
</conf_enabled>
|
435 |
<conf_fields translate="label">
|
436 |
<label>Use the Parent Data for Simple</label>
|
437 |
<frontend_type>multiselect</frontend_type>
|
@@ -441,7 +432,7 @@
|
|
441 |
<show_in_website>0</show_in_website>
|
442 |
<show_in_store>0</show_in_store>
|
443 |
<depends><conf_enabled>1</conf_enabled></depends>
|
444 |
-
<comment>Use the parent data</comment>
|
445 |
</conf_fields>
|
446 |
<conf_switch_urls translate="label">
|
447 |
<label>Configurable Switch Urls</label>
|
@@ -453,7 +444,7 @@
|
|
453 |
<show_in_store>1</show_in_store>
|
454 |
<depends><conf_enabled>1</conf_enabled></depends>
|
455 |
<comment>Create a specific url for the simple products inside the configurable products to make sure the prices and information is correct.</comment>
|
456 |
-
</conf_switch_urls>
|
457 |
<grouped_price translate="label">
|
458 |
<label>Grouped Price</label>
|
459 |
<frontend_type>select</frontend_type>
|
@@ -462,7 +453,7 @@
|
|
462 |
<show_in_default>1</show_in_default>
|
463 |
<show_in_website>1</show_in_website>
|
464 |
<show_in_store>1</show_in_store>
|
465 |
-
</grouped_price>
|
466 |
</fields>
|
467 |
</data>
|
468 |
<advanced translate="label" module="channable">
|
@@ -481,7 +472,7 @@
|
|
481 |
<show_in_default>1</show_in_default>
|
482 |
<show_in_website>1</show_in_website>
|
483 |
<show_in_store>1</show_in_store>
|
484 |
-
</note>
|
485 |
<extra_heading translate="label">
|
486 |
<label>The Additional Fields</label>
|
487 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -489,16 +480,16 @@
|
|
489 |
<show_in_default>1</show_in_default>
|
490 |
<show_in_website>1</show_in_website>
|
491 |
<show_in_store>1</show_in_store>
|
492 |
-
</extra_heading>
|
493 |
<extra>
|
494 |
<label>The Additional Fields</label>
|
495 |
<frontend_model>channable/adminhtml_config_form_field_extra</frontend_model>
|
496 |
-
<backend_model>channable/adminhtml_system_config_backend_design_extra</backend_model>
|
497 |
<sort_order>32</sort_order>
|
498 |
<show_in_default>1</show_in_default>
|
499 |
<show_in_website>1</show_in_website>
|
500 |
<show_in_store>1</show_in_store>
|
501 |
-
</extra>
|
502 |
<heading_shipping translate="label">
|
503 |
<label>The Shipping Price</label>
|
504 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -506,7 +497,7 @@
|
|
506 |
<show_in_default>1</show_in_default>
|
507 |
<show_in_website>1</show_in_website>
|
508 |
<show_in_store>1</show_in_store>
|
509 |
-
</heading_shipping>
|
510 |
<shipping_method translate="label">
|
511 |
<label>Shipping Calculation method</label>
|
512 |
<frontend_type>select</frontend_type>
|
@@ -524,9 +515,9 @@
|
|
524 |
<show_in_default>1</show_in_default>
|
525 |
<show_in_website>1</show_in_website>
|
526 |
<show_in_store>1</show_in_store>
|
527 |
-
</shipping_price>
|
528 |
</fields>
|
529 |
-
</advanced>
|
530 |
<filter translate="label" module="channable">
|
531 |
<label>Channable - Filter Conditions</label>
|
532 |
<frontend_type>text</frontend_type>
|
@@ -534,7 +525,7 @@
|
|
534 |
<show_in_default>1</show_in_default>
|
535 |
<show_in_website>1</show_in_website>
|
536 |
<show_in_store>1</show_in_store>
|
537 |
-
<expanded>1</expanded>
|
538 |
<fields>
|
539 |
<note translate="label">
|
540 |
<label><![CDATA[This option allows you to include/exclude product from the Channable feed. <br>]]></label>
|
@@ -542,8 +533,8 @@
|
|
542 |
<sort_order>1</sort_order>
|
543 |
<show_in_default>1</show_in_default>
|
544 |
<show_in_website>1</show_in_website>
|
545 |
-
<show_in_store>1</show_in_store>
|
546 |
-
</note>
|
547 |
<category_heading translate="label">
|
548 |
<label>Filter based on Category</label>
|
549 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
@@ -551,7 +542,7 @@
|
|
551 |
<show_in_default>1</show_in_default>
|
552 |
<show_in_website>1</show_in_website>
|
553 |
<show_in_store>1</show_in_store>
|
554 |
-
</category_heading>
|
555 |
<category_enabled translate="label">
|
556 |
<label>Enabled</label>
|
557 |
<frontend_type>select</frontend_type>
|
@@ -560,7 +551,7 @@
|
|
560 |
<show_in_default>1</show_in_default>
|
561 |
<show_in_website>1</show_in_website>
|
562 |
<show_in_store>1</show_in_store>
|
563 |
-
</category_enabled>
|
564 |
<category_type translate="label">
|
565 |
<label>Type of the filter</label>
|
566 |
<frontend_type>select</frontend_type>
|
@@ -570,7 +561,7 @@
|
|
570 |
<show_in_website>1</show_in_website>
|
571 |
<show_in_store>1</show_in_store>
|
572 |
<depends><category_enabled>1</category_enabled></depends>
|
573 |
-
</category_type>
|
574 |
<categories translate="label">
|
575 |
<label>Category</label>
|
576 |
<frontend_type>multiselect</frontend_type>
|
@@ -605,7 +596,7 @@
|
|
605 |
<show_in_default>1</show_in_default>
|
606 |
<show_in_website>1</show_in_website>
|
607 |
<show_in_store>1</show_in_store>
|
608 |
-
</advanced_heading>
|
609 |
<advanced>
|
610 |
<label>Advanced Filter</label>
|
611 |
<frontend_model>channable/adminhtml_config_form_field_filter</frontend_model>
|
@@ -614,9 +605,9 @@
|
|
614 |
<show_in_default>1</show_in_default>
|
615 |
<show_in_website>1</show_in_website>
|
616 |
<show_in_store>1</show_in_store>
|
617 |
-
</advanced>
|
618 |
-
</fields>
|
619 |
-
</filter>
|
620 |
<server translate="label" module="channable">
|
621 |
<label>Overwrite the server settings</label>
|
622 |
<frontend_type>text</frontend_type>
|
@@ -624,8 +615,8 @@
|
|
624 |
<show_in_default>1</show_in_default>
|
625 |
<show_in_website>1</show_in_website>
|
626 |
<show_in_store>1</show_in_store>
|
627 |
-
<expanded>1</expanded>
|
628 |
-
<fields>
|
629 |
<overwrite translate="label">
|
630 |
<label>Enabled</label>
|
631 |
<frontend_type>select</frontend_type>
|
@@ -635,7 +626,7 @@
|
|
635 |
<show_in_website>0</show_in_website>
|
636 |
<show_in_store>0</show_in_store>
|
637 |
<tooltip>Only use this option if it's necessary to overwrite this setting because of your server memory limit or execution time.</tooltip>
|
638 |
-
</overwrite>
|
639 |
<memory_limit translate="label">
|
640 |
<label>The Memory Limit</label>
|
641 |
<frontend_type>text</frontend_type>
|
@@ -644,8 +635,8 @@
|
|
644 |
<show_in_website>0</show_in_website>
|
645 |
<show_in_store>0</show_in_store>
|
646 |
<depends><overwrite>1</overwrite></depends>
|
647 |
-
<comment><![CDATA[This overwrites the maximum amount of memory in bytes that a script is allowed to allocate, eg 1024M.]]></comment>
|
648 |
-
</memory_limit>
|
649 |
<max_execution_time translate="label">
|
650 |
<label>The Max Execution Time</label>
|
651 |
<frontend_type>text</frontend_type>
|
@@ -654,10 +645,10 @@
|
|
654 |
<show_in_website>0</show_in_website>
|
655 |
<show_in_store>0</show_in_store>
|
656 |
<depends><overwrite>1</overwrite></depends>
|
657 |
-
<comment><![CDATA[This overwrites the maximum time in seconds a script is allowed to run before it is terminated by the parser, eg: 300 (for 5 minutes).]]></comment>
|
658 |
</max_execution_time>
|
659 |
-
</fields>
|
660 |
-
</server>
|
661 |
<settings translate="label" module="channable">
|
662 |
<label>Feeds - Available</label>
|
663 |
<frontend_type>text</frontend_type>
|
@@ -665,16 +656,16 @@
|
|
665 |
<show_in_default>1</show_in_default>
|
666 |
<show_in_website>1</show_in_website>
|
667 |
<show_in_store>1</show_in_store>
|
668 |
-
<expanded>1</expanded>
|
669 |
-
<fields>
|
670 |
<note translate="label">
|
671 |
<label><![CDATA[Each store view will have their own Channable feed. Use the auto connect button to connect the Feed with your Channable account.]]></label>
|
672 |
<frontend_model>channable/adminhtml_system_config_form_field_note</frontend_model>
|
673 |
<sort_order>1</sort_order>
|
674 |
<show_in_default>1</show_in_default>
|
675 |
<show_in_website>1</show_in_website>
|
676 |
-
<show_in_store>1</show_in_store>
|
677 |
-
</note>
|
678 |
<feeds_text translate="label">
|
679 |
<label>Text</label>
|
680 |
<frontend_model>channable/adminhtml_system_config_form_field_feeds</frontend_model>
|
@@ -682,10 +673,10 @@
|
|
682 |
<show_in_default>1</show_in_default>
|
683 |
<show_in_website>1</show_in_website>
|
684 |
<show_in_store>1</show_in_store>
|
685 |
-
</feeds_text>
|
686 |
-
</fields>
|
687 |
-
</settings>
|
688 |
-
</groups>
|
689 |
</channable>
|
690 |
</sections>
|
691 |
</config>
|
32 |
<show_in_default>1</show_in_default>
|
33 |
<show_in_website>1</show_in_website>
|
34 |
<show_in_store>1</show_in_store>
|
35 |
+
<groups>
|
36 |
<info>
|
37 |
<frontend_model>channable/adminhtml_widget_info_info</frontend_model>
|
38 |
<sort_order>1</sort_order>
|
39 |
<show_in_default>1</show_in_default>
|
40 |
<show_in_website>1</show_in_website>
|
41 |
<show_in_store>1</show_in_store>
|
42 |
+
</info>
|
43 |
<connect translate="label" module="channable">
|
44 |
<label>General - Settings</label>
|
45 |
<frontend_type>text</frontend_type>
|
58 |
<show_in_website>0</show_in_website>
|
59 |
<show_in_store>0</show_in_store>
|
60 |
</version>
|
61 |
+
<token_encrypted translate="label">
|
62 |
<label>Connect Token</label>
|
63 |
<frontend_type>text</frontend_type>
|
64 |
<frontend_model>channable/adminhtml_system_config_form_field_token</frontend_model>
|
66 |
<show_in_default>1</show_in_default>
|
67 |
<show_in_website>0</show_in_website>
|
68 |
<show_in_store>0</show_in_store>
|
69 |
+
</token_encrypted>
|
70 |
<connect_heading translate="label">
|
71 |
<label>Feed settings</label>
|
72 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
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 |
+
</connect_heading>
|
78 |
<enabled translate="label">
|
79 |
<label>Enabled Feed</label>
|
80 |
<frontend_type>select</frontend_type>
|
92 |
<show_in_website>1</show_in_website>
|
93 |
<show_in_store>1</show_in_store>
|
94 |
<comment>Limits the amount of product Channable will import per run. This setting wil not limit the total products sent to Channable!</comment>
|
95 |
+
</max_products>
|
96 |
</fields>
|
97 |
</connect>
|
98 |
<data translate="label" module="channable">
|
111 |
<show_in_default>1</show_in_default>
|
112 |
<show_in_website>1</show_in_website>
|
113 |
<show_in_store>1</show_in_store>
|
114 |
+
</note>
|
115 |
<heading_general translate="label">
|
116 |
<label>The General Fields</label>
|
117 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
128 |
<show_in_default>1</show_in_default>
|
129 |
<show_in_website>1</show_in_website>
|
130 |
<show_in_store>1</show_in_store>
|
131 |
+
</name>
|
132 |
<description translate="label">
|
133 |
<label>Description</label>
|
134 |
<frontend_type>select</frontend_type>
|
163 |
<show_in_default>1</show_in_default>
|
164 |
<show_in_website>1</show_in_website>
|
165 |
<show_in_store>1</show_in_store>
|
166 |
+
</heading_images>
|
167 |
<images translate="label">
|
168 |
<label>Images</label>
|
169 |
<frontend_type>select</frontend_type>
|
181 |
<show_in_default>1</show_in_default>
|
182 |
<show_in_website>1</show_in_website>
|
183 |
<show_in_store>1</show_in_store>
|
184 |
+
<depends><images>all</images></depends>
|
185 |
+
</default_image>
|
186 |
<heading_additional translate="label">
|
187 |
<label>The Additional Fields</label>
|
188 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
199 |
<show_in_default>1</show_in_default>
|
200 |
<show_in_website>1</show_in_website>
|
201 |
<show_in_store>1</show_in_store>
|
202 |
+
</sku>
|
203 |
<size translate="label">
|
204 |
<label>Size</label>
|
205 |
<frontend_type>select</frontend_type>
|
244 |
<show_in_website>1</show_in_website>
|
245 |
<show_in_store>1</show_in_store>
|
246 |
</heading_stock>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
<stock translate="label">
|
248 |
<label>Send Stock Level</label>
|
249 |
<frontend_type>select</frontend_type>
|
342 |
<show_in_website>1</show_in_website>
|
343 |
<show_in_store>1</show_in_store>
|
344 |
<depends><delivery_be>fixed</delivery_be></depends>
|
345 |
+
</delivery_out_be>
|
346 |
<weight_heading translate="label">
|
347 |
<label>Weight</label>
|
348 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
368 |
<show_in_default>1</show_in_default>
|
369 |
<show_in_website>1</show_in_website>
|
370 |
<show_in_store>1</show_in_store>
|
371 |
+
<depends><weight>1</weight></depends>
|
372 |
+
</weight_units>
|
373 |
<price_heading translate="label">
|
374 |
<label>Price Customization</label>
|
375 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
377 |
<show_in_default>1</show_in_default>
|
378 |
<show_in_website>1</show_in_website>
|
379 |
<show_in_store>1</show_in_store>
|
380 |
+
</price_heading>
|
381 |
<force_tax translate="label">
|
382 |
<label>Force the Tax Usage</label>
|
383 |
<frontend_type>select</frontend_type>
|
403 |
<show_in_default>1</show_in_default>
|
404 |
<show_in_website>1</show_in_website>
|
405 |
<show_in_store>1</show_in_store>
|
406 |
+
<comment><![CDATA[When the tax percentage is 21% use 21.]]></comment>
|
407 |
<depends><add_tax>1</add_tax></depends>
|
408 |
+
</tax_percentage>
|
409 |
<configurable_heading translate="label">
|
410 |
<label>Configurable & Grouped data linkage</label>
|
411 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
422 |
<show_in_default>1</show_in_default>
|
423 |
<show_in_website>1</show_in_website>
|
424 |
<show_in_store>1</show_in_store>
|
425 |
+
</conf_enabled>
|
426 |
<conf_fields translate="label">
|
427 |
<label>Use the Parent Data for Simple</label>
|
428 |
<frontend_type>multiselect</frontend_type>
|
432 |
<show_in_website>0</show_in_website>
|
433 |
<show_in_store>0</show_in_store>
|
434 |
<depends><conf_enabled>1</conf_enabled></depends>
|
435 |
+
<comment>Use the parent data</comment>
|
436 |
</conf_fields>
|
437 |
<conf_switch_urls translate="label">
|
438 |
<label>Configurable Switch Urls</label>
|
444 |
<show_in_store>1</show_in_store>
|
445 |
<depends><conf_enabled>1</conf_enabled></depends>
|
446 |
<comment>Create a specific url for the simple products inside the configurable products to make sure the prices and information is correct.</comment>
|
447 |
+
</conf_switch_urls>
|
448 |
<grouped_price translate="label">
|
449 |
<label>Grouped Price</label>
|
450 |
<frontend_type>select</frontend_type>
|
453 |
<show_in_default>1</show_in_default>
|
454 |
<show_in_website>1</show_in_website>
|
455 |
<show_in_store>1</show_in_store>
|
456 |
+
</grouped_price>
|
457 |
</fields>
|
458 |
</data>
|
459 |
<advanced translate="label" module="channable">
|
472 |
<show_in_default>1</show_in_default>
|
473 |
<show_in_website>1</show_in_website>
|
474 |
<show_in_store>1</show_in_store>
|
475 |
+
</note>
|
476 |
<extra_heading translate="label">
|
477 |
<label>The Additional Fields</label>
|
478 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
480 |
<show_in_default>1</show_in_default>
|
481 |
<show_in_website>1</show_in_website>
|
482 |
<show_in_store>1</show_in_store>
|
483 |
+
</extra_heading>
|
484 |
<extra>
|
485 |
<label>The Additional Fields</label>
|
486 |
<frontend_model>channable/adminhtml_config_form_field_extra</frontend_model>
|
487 |
+
<backend_model>channable/adminhtml_system_config_backend_design_extra</backend_model>
|
488 |
<sort_order>32</sort_order>
|
489 |
<show_in_default>1</show_in_default>
|
490 |
<show_in_website>1</show_in_website>
|
491 |
<show_in_store>1</show_in_store>
|
492 |
+
</extra>
|
493 |
<heading_shipping translate="label">
|
494 |
<label>The Shipping Price</label>
|
495 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
497 |
<show_in_default>1</show_in_default>
|
498 |
<show_in_website>1</show_in_website>
|
499 |
<show_in_store>1</show_in_store>
|
500 |
+
</heading_shipping>
|
501 |
<shipping_method translate="label">
|
502 |
<label>Shipping Calculation method</label>
|
503 |
<frontend_type>select</frontend_type>
|
515 |
<show_in_default>1</show_in_default>
|
516 |
<show_in_website>1</show_in_website>
|
517 |
<show_in_store>1</show_in_store>
|
518 |
+
</shipping_price>
|
519 |
</fields>
|
520 |
+
</advanced>
|
521 |
<filter translate="label" module="channable">
|
522 |
<label>Channable - Filter Conditions</label>
|
523 |
<frontend_type>text</frontend_type>
|
525 |
<show_in_default>1</show_in_default>
|
526 |
<show_in_website>1</show_in_website>
|
527 |
<show_in_store>1</show_in_store>
|
528 |
+
<expanded>1</expanded>
|
529 |
<fields>
|
530 |
<note translate="label">
|
531 |
<label><![CDATA[This option allows you to include/exclude product from the Channable feed. <br>]]></label>
|
533 |
<sort_order>1</sort_order>
|
534 |
<show_in_default>1</show_in_default>
|
535 |
<show_in_website>1</show_in_website>
|
536 |
+
<show_in_store>1</show_in_store>
|
537 |
+
</note>
|
538 |
<category_heading translate="label">
|
539 |
<label>Filter based on Category</label>
|
540 |
<frontend_model>channable/adminhtml_system_config_form_field_heading</frontend_model>
|
542 |
<show_in_default>1</show_in_default>
|
543 |
<show_in_website>1</show_in_website>
|
544 |
<show_in_store>1</show_in_store>
|
545 |
+
</category_heading>
|
546 |
<category_enabled translate="label">
|
547 |
<label>Enabled</label>
|
548 |
<frontend_type>select</frontend_type>
|
551 |
<show_in_default>1</show_in_default>
|
552 |
<show_in_website>1</show_in_website>
|
553 |
<show_in_store>1</show_in_store>
|
554 |
+
</category_enabled>
|
555 |
<category_type translate="label">
|
556 |
<label>Type of the filter</label>
|
557 |
<frontend_type>select</frontend_type>
|
561 |
<show_in_website>1</show_in_website>
|
562 |
<show_in_store>1</show_in_store>
|
563 |
<depends><category_enabled>1</category_enabled></depends>
|
564 |
+
</category_type>
|
565 |
<categories translate="label">
|
566 |
<label>Category</label>
|
567 |
<frontend_type>multiselect</frontend_type>
|
596 |
<show_in_default>1</show_in_default>
|
597 |
<show_in_website>1</show_in_website>
|
598 |
<show_in_store>1</show_in_store>
|
599 |
+
</advanced_heading>
|
600 |
<advanced>
|
601 |
<label>Advanced Filter</label>
|
602 |
<frontend_model>channable/adminhtml_config_form_field_filter</frontend_model>
|
605 |
<show_in_default>1</show_in_default>
|
606 |
<show_in_website>1</show_in_website>
|
607 |
<show_in_store>1</show_in_store>
|
608 |
+
</advanced>
|
609 |
+
</fields>
|
610 |
+
</filter>
|
611 |
<server translate="label" module="channable">
|
612 |
<label>Overwrite the server settings</label>
|
613 |
<frontend_type>text</frontend_type>
|
615 |
<show_in_default>1</show_in_default>
|
616 |
<show_in_website>1</show_in_website>
|
617 |
<show_in_store>1</show_in_store>
|
618 |
+
<expanded>1</expanded>
|
619 |
+
<fields>
|
620 |
<overwrite translate="label">
|
621 |
<label>Enabled</label>
|
622 |
<frontend_type>select</frontend_type>
|
626 |
<show_in_website>0</show_in_website>
|
627 |
<show_in_store>0</show_in_store>
|
628 |
<tooltip>Only use this option if it's necessary to overwrite this setting because of your server memory limit or execution time.</tooltip>
|
629 |
+
</overwrite>
|
630 |
<memory_limit translate="label">
|
631 |
<label>The Memory Limit</label>
|
632 |
<frontend_type>text</frontend_type>
|
635 |
<show_in_website>0</show_in_website>
|
636 |
<show_in_store>0</show_in_store>
|
637 |
<depends><overwrite>1</overwrite></depends>
|
638 |
+
<comment><![CDATA[This overwrites the maximum amount of memory in bytes that a script is allowed to allocate, eg 1024M.]]></comment>
|
639 |
+
</memory_limit>
|
640 |
<max_execution_time translate="label">
|
641 |
<label>The Max Execution Time</label>
|
642 |
<frontend_type>text</frontend_type>
|
645 |
<show_in_website>0</show_in_website>
|
646 |
<show_in_store>0</show_in_store>
|
647 |
<depends><overwrite>1</overwrite></depends>
|
648 |
+
<comment><![CDATA[This overwrites the maximum time in seconds a script is allowed to run before it is terminated by the parser, eg: 300 (for 5 minutes).]]></comment>
|
649 |
</max_execution_time>
|
650 |
+
</fields>
|
651 |
+
</server>
|
652 |
<settings translate="label" module="channable">
|
653 |
<label>Feeds - Available</label>
|
654 |
<frontend_type>text</frontend_type>
|
656 |
<show_in_default>1</show_in_default>
|
657 |
<show_in_website>1</show_in_website>
|
658 |
<show_in_store>1</show_in_store>
|
659 |
+
<expanded>1</expanded>
|
660 |
+
<fields>
|
661 |
<note translate="label">
|
662 |
<label><![CDATA[Each store view will have their own Channable feed. Use the auto connect button to connect the Feed with your Channable account.]]></label>
|
663 |
<frontend_model>channable/adminhtml_system_config_form_field_note</frontend_model>
|
664 |
<sort_order>1</sort_order>
|
665 |
<show_in_default>1</show_in_default>
|
666 |
<show_in_website>1</show_in_website>
|
667 |
+
<show_in_store>1</show_in_store>
|
668 |
+
</note>
|
669 |
<feeds_text translate="label">
|
670 |
<label>Text</label>
|
671 |
<frontend_model>channable/adminhtml_system_config_form_field_feeds</frontend_model>
|
673 |
<show_in_default>1</show_in_default>
|
674 |
<show_in_website>1</show_in_website>
|
675 |
<show_in_store>1</show_in_store>
|
676 |
+
</feeds_text>
|
677 |
+
</fields>
|
678 |
+
</settings>
|
679 |
+
</groups>
|
680 |
</channable>
|
681 |
</sections>
|
682 |
</config>
|
app/code/community/Magmodules/Channable/sql/magmodules_channable_setup/upgrade-1.4.8-1.4.9.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magmodules.eu - http://www.magmodules.eu - info@magmodules.eu
|
4 |
+
* =============================================================
|
5 |
+
* NOTICE OF LICENSE [Single domain license]
|
6 |
+
* This source file is subject to the EULA that is
|
7 |
+
* available through the world-wide-web at:
|
8 |
+
* http://www.magmodules.eu/license-agreement/
|
9 |
+
* =============================================================
|
10 |
+
* @category Magmodules
|
11 |
+
* @package Magmodules_Channable
|
12 |
+
* @author Magmodules <info@magmodules.eu>
|
13 |
+
* @copyright Copyright (c) 2016 (http://www.magmodules.eu)
|
14 |
+
* @license http://www.magmodules.eu/license-agreement/
|
15 |
+
* =============================================================
|
16 |
+
*/
|
17 |
+
|
18 |
+
$installer = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
|
19 |
+
$installer->startSetup();
|
20 |
+
|
21 |
+
$installer->addAttribute(
|
22 |
+
'catalog_category', 'channable_exclude', array(
|
23 |
+
'group' => 'Feeds',
|
24 |
+
'input' => 'select',
|
25 |
+
'type' => 'int',
|
26 |
+
'source' => 'eav/entity_attribute_source_boolean',
|
27 |
+
'label' => 'Exclude Category for Channable',
|
28 |
+
'required' => false,
|
29 |
+
'user_defined' => true,
|
30 |
+
'visible' => true,
|
31 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
32 |
+
'position' => 99,
|
33 |
+
)
|
34 |
+
);
|
35 |
+
|
36 |
+
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Magmodules_Channable</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.magmodules.eu/license-agreement/">Single Server License</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Magmodules_Channable</description>
|
11 |
<notes>Channable Connect</notes>
|
12 |
<authors><author><name>Magmodules</name><user>magmodules</user><email>info@magmodules.nl</email></author></authors>
|
13 |
-
<date>2016-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Magmodules"><dir name="Channable"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Extra.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>7.9.9</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Magmodules_Channable</name>
|
4 |
+
<version>1.5.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.magmodules.eu/license-agreement/">Single Server License</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Magmodules_Channable</description>
|
11 |
<notes>Channable Connect</notes>
|
12 |
<authors><author><name>Magmodules</name><user>magmodules</user><email>info@magmodules.nl</email></author></authors>
|
13 |
+
<date>2016-12-05</date>
|
14 |
+
<time>14:13:52</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Magmodules"><dir name="Channable"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Extra.php" hash="c3de2d254516fb969aa32e77e420cec0"/><file name="Filter.php" hash="c18a5c2b289ef4c8cb1950990aad824a"/><file name="Shipping.php" hash="6ff0ceaf1170cc1c8d6e322377d51c55"/></dir><dir name="Renderer"><file name="Select.php" hash="de38e69b1251f094e1818615a02278fb"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Feeds.php" hash="14f14219d1c08ad938a6db512f71eacf"/><file name="Heading.php" hash="4b406e44f5b9d36cdf15f3c52984df88"/><file name="Note.php" hash="f0898ebfb7883e3d1e4ef2aba7c4b1f6"/><file name="Token.php" hash="7c0a7173abe2dc5e0763f62236c57875"/><file name="Version.php" hash="afcf324b22f7b496eb24ee0e5c4827ed"/></dir></dir></dir></dir><dir name="Widget"><dir name="Info"><file name="Info.php" hash="086595fa1457f59c4b536703376ff34f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="94a0e39086abfe29c38a98163a088323"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Design"><file name="Extra.php" hash="8ed25fdc80ab735ad7d20f565bff4d65"/><file name="Filter.php" hash="c396481ef9e8ec62629a7ed0c9a6aef4"/><file name="Shipping.php" hash="126481e0e3599cb62b9613ac5d462dbe"/></dir></dir><dir name="Source"><file name="Action.php" hash="f9eef61712b067c43db7a32c6e5933f1"/><file name="Attribute.php" hash="c278ab2184e9129dece4a22121e22e33"/><file name="Category.php" hash="c877eb5be8f84a8ec352b933e7ac2cd1"/><file name="Categorytype.php" hash="b330bd5d575592b933c810384f95acbc"/><file name="Conditions.php" hash="aa7c3018a74f60fb41388c307e4d928d"/><file name="Configurable.php" hash="24a00a6d577ab18f3a4b20200f92cad0"/><file name="Countries.php" hash="c678e1f8625630313f78654901ed7275"/><file name="Images.php" hash="847f4d99908923bf835cefc826fbbd4a"/><file name="Mainimage.php" hash="96a2d8df1920956113f5b4509506df47"/><file name="Name.php" hash="0bdf3102e7e52e74bcbbdbb6640f0c01"/><file name="Pricemodel.php" hash="d93cbeed02dd5d38e4dc835ed06cc46f"/><file name="Selectattribute.php" hash="eea82ac436e2b999d37954c4706c690d"/><file name="Shipping.php" hash="8a8b0753092eac24484508f541a317c0"/><file name="Tax.php" hash="fbdc14e6c556d3281f8fdf652c8c637f"/><file name="Textattribute.php" hash="b601321ea8f84413c201f6f1bd5da15d"/><file name="Type.php" hash="f0bd14bb3c19b0fe59e64e2f9d96ae7f"/><file name="Visibility.php" hash="ca3d49287963398b35a905f068cfd647"/><file name="Weight.php" hash="1b05f0f69a7ebd6e0ea445ae11544fc9"/></dir></dir></dir></dir><file name="Channable.php" hash="22fa09e1d9c0de472390e29027e1e457"/><file name="Common.php" hash="04c04f73e7e259f3668c921db1d7b46d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ChannableController.php" hash="957b06156e54c3e78c3ee2fa1549f358"/></dir><file name="FeedController.php" hash="6f1e1a0077e68a221f311412cab4a6e3"/></dir><dir name="data"><dir name="magmodules_channable_setup"><file name="data-upgrade-1.4.8-1.4.9.php" hash="66a5f5720815c9e738b54a039877c9c9"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0bc11d7499e07c074d3b7ecab3a2400b"/><file name="config.xml" hash="cab3cdcccd3d4c857766a7760035bf23"/><file name="system.xml" hash="1868aa41d072cb856e044e8bc6eb92a8"/></dir><dir name="sql"><dir name="magmodules_channable_setup"><file name="upgrade-1.4.8-1.4.9.php" hash="572c087cac6aa281aa23af1ad4b7ef6e"/></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Magmodules_Channable.csv" hash="b7f6f15de57f502ccf1c98e71006a823"/></dir><dir name="nl_NL"><file name="Magmodules_Channable.csv" hash="2eaec8847182a0005c575e0acf6e1c1d"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magmodules_Channable.xml" hash="061032d718f1ddd64de211fc7133685c"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>7.9.9</max></php></required></dependencies>
|
18 |
</package>
|