Version Notes
First Version public in Magento Connect
Download this release
Release Info
Developer | Anymarket |
Extension | d7db67d0d012350a01ce05c31f91754d |
Version | 2.4.6 |
Comparing to | |
See all releases |
Code changes from version 2.3.4 to 2.4.6
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes.php +43 -43
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit.php +75 -75
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Form.php +51 -51
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Form.php +102 -102
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Stores.php +50 -50
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tabs.php +79 -79
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Grid.php +174 -174
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands.php +49 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit.php +82 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Form.php +52 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Form.php +91 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Stores.php +58 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tabs.php +87 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Grid.php +236 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories.php +55 -48
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit.php +82 -82
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Form.php +52 -52
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Form.php +114 -114
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Stores.php +58 -58
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tabs.php +87 -87
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Grid.php +287 -287
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog.php +47 -44
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit.php +56 -56
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Form.php +52 -51
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Form.php +99 -99
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Stores.php +58 -58
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tabs.php +74 -74
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Grid.php +199 -189
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders.php +47 -53
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit.php +82 -82
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Form.php +52 -52
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Form.php +109 -109
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Stores.php +58 -58
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tabs.php +87 -87
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Grid.php +254 -242
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts.php +47 -53
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit.php +82 -82
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Form.php +52 -52
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Form.php +132 -132
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Stores.php +58 -58
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tabs.php +87 -87
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Grid.php +272 -271
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue.php +47 -41
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit.php +81 -81
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Form.php +51 -51
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Form.php +119 -119
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Stores.php +57 -57
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tabs.php +86 -86
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Grid.php +223 -223
- app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/Callback.php +24 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/buttoncheckconfig.php +52 -0
- app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusammg/Values.php +54 -54
- app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusmgam/Values.php +52 -52
- app/code/community/DB1/AnyMarket/Block/System/Config/Source/Products/Values.php +53 -53
- app/code/community/DB1/AnyMarket/Controller/Adminhtml/AnyMarket.php +61 -61
- app/code/community/DB1/AnyMarket/Helper/Brand.php +57 -0
- app/code/community/DB1/AnyMarket/Helper/Category.php +383 -113
- app/code/community/DB1/AnyMarket/Helper/Customergenerator.php +153 -151
- app/code/community/DB1/AnyMarket/Helper/Data.php +287 -213
- app/code/community/DB1/AnyMarket/Helper/Order.php +1045 -888
- app/code/community/DB1/AnyMarket/Helper/Ordergenerator.php +415 -404
- app/code/community/DB1/AnyMarket/Helper/Product.php +2172 -1310
- app/code/community/DB1/AnyMarket/Helper/Productgenerator.php +280 -288
- app/code/community/DB1/AnyMarket/Helper/Queue.php +233 -147
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketattributes.php +60 -60
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketbrands.php +60 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketlog.php +60 -60
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketorders.php +60 -60
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketproducts.php +60 -60
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketqueue.php +60 -60
- app/code/community/DB1/AnyMarket/Model/Anymarketattributes.php +104 -104
- app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api.php +162 -162
- app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api/V2.php +33 -33
- app/code/community/DB1/AnyMarket/Model/Anymarketbrands.php +104 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api.php +162 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api/V2.php +33 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketcategories.php +115 -104
- app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api.php +162 -162
- app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api/V2.php +33 -33
- app/code/community/DB1/AnyMarket/Model/Anymarketlog.php +138 -104
- app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api.php +162 -162
- app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api/V2.php +33 -33
- app/code/community/DB1/AnyMarket/Model/Anymarketorders.php +104 -104
- app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api.php +162 -162
- app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api/V2.php +33 -33
- app/code/community/DB1/AnyMarket/Model/Anymarketproducts.php +104 -104
- app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api.php +162 -162
- app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api/V2.php +33 -33
- app/code/community/DB1/AnyMarket/Model/Anymarketqueue.php +103 -103
- app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api.php +162 -162
- app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api/V2.php +33 -33
- app/code/community/DB1/AnyMarket/Model/Cron.php +44 -65
- app/code/community/DB1/AnyMarket/Model/Observer.php +329 -177
- app/code/community/DB1/AnyMarket/Model/PaymentMethod.php +37 -37
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes.php +133 -133
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes/Collection.php +136 -136
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands.php +133 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands/Collection.php +136 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories.php +133 -133
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories/Collection.php +136 -136
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog.php +133 -133
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog/Collection.php +136 -136
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders.php +133 -133
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders/Collection.php +136 -136
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts.php +133 -133
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts/Collection.php +136 -136
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue.php +132 -132
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue/Collection.php +135 -135
- app/code/community/DB1/AnyMarket/Model/Resource/Setup.php +26 -26
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Group/Values.php +14 -14
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Street/Values.php +15 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Values.php +16 -16
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Booleantp/Values.php +23 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Price/Values.php +25 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Values.php +20 -20
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Set/Values.php +14 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Categories/Values.php +70 -67
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Logs/Values.php +14 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Massunit/Values.php +12 -12
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Measurementunit/Values.php +15 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Orders/Values.php +17 -17
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Typesync/Order/Values.php +11 -11
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketattributesController.php +328 -328
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketbrandsController.php +307 -0
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes.php
CHANGED
@@ -1,43 +1,43 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes admin block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
$this->_controller = 'adminhtml_anymarketattributes';
|
35 |
-
$this->_blockGroup = 'db1_anymarket';
|
36 |
-
parent::__construct();
|
37 |
-
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Attributes');
|
38 |
-
$this->_removeButton('add');
|
39 |
-
|
40 |
-
Mage::helper('db1_anymarket')->massInsertAttribute();
|
41 |
-
|
42 |
-
}
|
43 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->_controller = 'adminhtml_anymarketattributes';
|
35 |
+
$this->_blockGroup = 'db1_anymarket';
|
36 |
+
parent::__construct();
|
37 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Attributes');
|
38 |
+
$this->_removeButton('add');
|
39 |
+
|
40 |
+
Mage::helper('db1_anymarket')->massInsertAttribute();
|
41 |
+
|
42 |
+
}
|
43 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit.php
CHANGED
@@ -1,75 +1,75 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* @category DB1
|
6 |
-
* @package DB1_AnyMarket
|
7 |
-
* @copyright Copyright (c) 2015
|
8 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
9 |
-
*/
|
10 |
-
/**
|
11 |
-
* Anymarket Attributes admin edit form
|
12 |
-
*
|
13 |
-
* @category DB1
|
14 |
-
* @package DB1_AnyMarket
|
15 |
-
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* constructor
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @return void
|
24 |
-
|
25 |
-
*/
|
26 |
-
public function __construct()
|
27 |
-
{
|
28 |
-
parent::__construct();
|
29 |
-
$this->_blockGroup = 'db1_anymarket';
|
30 |
-
$this->_controller = 'adminhtml_anymarketattributes';
|
31 |
-
$this->_updateButton(
|
32 |
-
'save',
|
33 |
-
'label',
|
34 |
-
Mage::helper('db1_anymarket')->__('Save Anymarket Attributes')
|
35 |
-
);
|
36 |
-
$this->_updateButton(
|
37 |
-
'delete',
|
38 |
-
'label',
|
39 |
-
Mage::helper('db1_anymarket')->__('Delete Anymarket Attributes')
|
40 |
-
);
|
41 |
-
$this->_addButton(
|
42 |
-
'saveandcontinue',
|
43 |
-
array(
|
44 |
-
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
45 |
-
'onclick' => 'saveAndContinueEdit()',
|
46 |
-
'class' => 'save',
|
47 |
-
),
|
48 |
-
-100
|
49 |
-
);
|
50 |
-
$this->_formScripts[] = "
|
51 |
-
function saveAndContinueEdit() {
|
52 |
-
editForm.submit($('edit_form').action+'back/edit/');
|
53 |
-
}
|
54 |
-
";
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* get the edit form header
|
59 |
-
*
|
60 |
-
* @access public
|
61 |
-
* @return string
|
62 |
-
|
63 |
-
*/
|
64 |
-
public function getHeaderText()
|
65 |
-
{
|
66 |
-
if (Mage::registry('current_anymarketattributes') && Mage::registry('current_anymarketattributes')->getId()) {
|
67 |
-
return Mage::helper('db1_anymarket')->__(
|
68 |
-
"Edit Anymarket Attributes '%s'",
|
69 |
-
$this->escapeHtml(Mage::registry('current_anymarketattributes')->getNmaDesc())
|
70 |
-
);
|
71 |
-
} else {
|
72 |
-
return Mage::helper('db1_anymarket')->__('Add Anymarket Attributes');
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* @category DB1
|
6 |
+
* @package DB1_AnyMarket
|
7 |
+
* @copyright Copyright (c) 2015
|
8 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
9 |
+
*/
|
10 |
+
/**
|
11 |
+
* Anymarket Attributes admin edit form
|
12 |
+
*
|
13 |
+
* @category DB1
|
14 |
+
* @package DB1_AnyMarket
|
15 |
+
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* constructor
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @return void
|
24 |
+
|
25 |
+
*/
|
26 |
+
public function __construct()
|
27 |
+
{
|
28 |
+
parent::__construct();
|
29 |
+
$this->_blockGroup = 'db1_anymarket';
|
30 |
+
$this->_controller = 'adminhtml_anymarketattributes';
|
31 |
+
$this->_updateButton(
|
32 |
+
'save',
|
33 |
+
'label',
|
34 |
+
Mage::helper('db1_anymarket')->__('Save Anymarket Attributes')
|
35 |
+
);
|
36 |
+
$this->_updateButton(
|
37 |
+
'delete',
|
38 |
+
'label',
|
39 |
+
Mage::helper('db1_anymarket')->__('Delete Anymarket Attributes')
|
40 |
+
);
|
41 |
+
$this->_addButton(
|
42 |
+
'saveandcontinue',
|
43 |
+
array(
|
44 |
+
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
45 |
+
'onclick' => 'saveAndContinueEdit()',
|
46 |
+
'class' => 'save',
|
47 |
+
),
|
48 |
+
-100
|
49 |
+
);
|
50 |
+
$this->_formScripts[] = "
|
51 |
+
function saveAndContinueEdit() {
|
52 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
53 |
+
}
|
54 |
+
";
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* get the edit form header
|
59 |
+
*
|
60 |
+
* @access public
|
61 |
+
* @return string
|
62 |
+
|
63 |
+
*/
|
64 |
+
public function getHeaderText()
|
65 |
+
{
|
66 |
+
if (Mage::registry('current_anymarketattributes') && Mage::registry('current_anymarketattributes')->getId()) {
|
67 |
+
return Mage::helper('db1_anymarket')->__(
|
68 |
+
"Edit Anymarket Attributes '%s'",
|
69 |
+
$this->escapeHtml(Mage::registry('current_anymarketattributes')->getNmaDesc())
|
70 |
+
);
|
71 |
+
} else {
|
72 |
+
return Mage::helper('db1_anymarket')->__('Add Anymarket Attributes');
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Form.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* prepare form
|
27 |
-
*
|
28 |
-
* @access protected
|
29 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Form
|
30 |
-
|
31 |
-
*/
|
32 |
-
protected function _prepareForm()
|
33 |
-
{
|
34 |
-
$form = new Varien_Data_Form(
|
35 |
-
array(
|
36 |
-
'id' => 'edit_form',
|
37 |
-
'action' => $this->getUrl(
|
38 |
-
'*/*/save',
|
39 |
-
array(
|
40 |
-
'id' => $this->getRequest()->getParam('id')
|
41 |
-
)
|
42 |
-
),
|
43 |
-
'method' => 'post',
|
44 |
-
'enctype' => 'multipart/form-data'
|
45 |
-
)
|
46 |
-
);
|
47 |
-
$form->setUseContainer(true);
|
48 |
-
$this->setForm($form);
|
49 |
-
return parent::_prepareForm();
|
50 |
-
}
|
51 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* prepare form
|
27 |
+
*
|
28 |
+
* @access protected
|
29 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Form
|
30 |
+
|
31 |
+
*/
|
32 |
+
protected function _prepareForm()
|
33 |
+
{
|
34 |
+
$form = new Varien_Data_Form(
|
35 |
+
array(
|
36 |
+
'id' => 'edit_form',
|
37 |
+
'action' => $this->getUrl(
|
38 |
+
'*/*/save',
|
39 |
+
array(
|
40 |
+
'id' => $this->getRequest()->getParam('id')
|
41 |
+
)
|
42 |
+
),
|
43 |
+
'method' => 'post',
|
44 |
+
'enctype' => 'multipart/form-data'
|
45 |
+
)
|
46 |
+
);
|
47 |
+
$form->setUseContainer(true);
|
48 |
+
$this->setForm($form);
|
49 |
+
return parent::_prepareForm();
|
50 |
+
}
|
51 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Form.php
CHANGED
@@ -1,102 +1,102 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @category DB1
|
7 |
-
* @package DB1_AnyMarket
|
8 |
-
* @copyright Copyright (c) 2015
|
9 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
10 |
-
*/
|
11 |
-
/**
|
12 |
-
* Anymarket Attributes edit form tab
|
13 |
-
*
|
14 |
-
* @category DB1
|
15 |
-
* @package DB1_AnyMarket
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* prepare the form
|
21 |
-
*
|
22 |
-
* @access protected
|
23 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Form
|
24 |
-
|
25 |
-
*/
|
26 |
-
protected function _prepareForm()
|
27 |
-
{
|
28 |
-
$form = new Varien_Data_Form();
|
29 |
-
$form->setHtmlIdPrefix('anymarketattributes_');
|
30 |
-
$form->setFieldNameSuffix('anymarketattributes');
|
31 |
-
$this->setForm($form);
|
32 |
-
$fieldset = $form->addFieldset(
|
33 |
-
'anymarketattributes_form',
|
34 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'))
|
35 |
-
);
|
36 |
-
|
37 |
-
$fieldset->addField(
|
38 |
-
'nma_id_attr',
|
39 |
-
'text',
|
40 |
-
array(
|
41 |
-
'label' => Mage::helper('db1_anymarket')->__('Attribute Code'),
|
42 |
-
'name' => 'nma_id_attr',
|
43 |
-
'required' => true,
|
44 |
-
'class' => 'required-entry',
|
45 |
-
|
46 |
-
)
|
47 |
-
);
|
48 |
-
|
49 |
-
$fieldset->addField(
|
50 |
-
'nma_desc',
|
51 |
-
'text',
|
52 |
-
array(
|
53 |
-
'label' => Mage::helper('db1_anymarket')->__('Attribute Description'),
|
54 |
-
'name' => 'nma_desc',
|
55 |
-
'required' => true,
|
56 |
-
'class' => 'required-entry',
|
57 |
-
|
58 |
-
)
|
59 |
-
);
|
60 |
-
$fieldset->addField(
|
61 |
-
'status',
|
62 |
-
'select',
|
63 |
-
array(
|
64 |
-
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
65 |
-
'name' => 'status',
|
66 |
-
'values' => array(
|
67 |
-
array(
|
68 |
-
'value' => 1,
|
69 |
-
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
70 |
-
),
|
71 |
-
array(
|
72 |
-
'value' => 0,
|
73 |
-
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
74 |
-
),
|
75 |
-
),
|
76 |
-
)
|
77 |
-
);
|
78 |
-
if (Mage::app()->isSingleStoreMode()) {
|
79 |
-
$fieldset->addField(
|
80 |
-
'store_id',
|
81 |
-
'hidden',
|
82 |
-
array(
|
83 |
-
'name' => 'stores[]',
|
84 |
-
'value' => Mage::app()->getStore(true)->getId()
|
85 |
-
)
|
86 |
-
);
|
87 |
-
Mage::registry('current_anymarketattributes')->setStoreId(Mage::app()->getStore(true)->getId());
|
88 |
-
}
|
89 |
-
$formValues = Mage::registry('current_anymarketattributes')->getDefaultValues();
|
90 |
-
if (!is_array($formValues)) {
|
91 |
-
$formValues = array();
|
92 |
-
}
|
93 |
-
if (Mage::getSingleton('adminhtml/session')->getAnymarketattributesData()) {
|
94 |
-
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketattributesData());
|
95 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketattributesData(null);
|
96 |
-
} elseif (Mage::registry('current_anymarketattributes')) {
|
97 |
-
$formValues = array_merge($formValues, Mage::registry('current_anymarketattributes')->getData());
|
98 |
-
}
|
99 |
-
$form->setValues($formValues);
|
100 |
-
return parent::_prepareForm();
|
101 |
-
}
|
102 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* @category DB1
|
7 |
+
* @package DB1_AnyMarket
|
8 |
+
* @copyright Copyright (c) 2015
|
9 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Anymarket Attributes edit form tab
|
13 |
+
*
|
14 |
+
* @category DB1
|
15 |
+
* @package DB1_AnyMarket
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* prepare the form
|
21 |
+
*
|
22 |
+
* @access protected
|
23 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Form
|
24 |
+
|
25 |
+
*/
|
26 |
+
protected function _prepareForm()
|
27 |
+
{
|
28 |
+
$form = new Varien_Data_Form();
|
29 |
+
$form->setHtmlIdPrefix('anymarketattributes_');
|
30 |
+
$form->setFieldNameSuffix('anymarketattributes');
|
31 |
+
$this->setForm($form);
|
32 |
+
$fieldset = $form->addFieldset(
|
33 |
+
'anymarketattributes_form',
|
34 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'))
|
35 |
+
);
|
36 |
+
|
37 |
+
$fieldset->addField(
|
38 |
+
'nma_id_attr',
|
39 |
+
'text',
|
40 |
+
array(
|
41 |
+
'label' => Mage::helper('db1_anymarket')->__('Attribute Code'),
|
42 |
+
'name' => 'nma_id_attr',
|
43 |
+
'required' => true,
|
44 |
+
'class' => 'required-entry',
|
45 |
+
|
46 |
+
)
|
47 |
+
);
|
48 |
+
|
49 |
+
$fieldset->addField(
|
50 |
+
'nma_desc',
|
51 |
+
'text',
|
52 |
+
array(
|
53 |
+
'label' => Mage::helper('db1_anymarket')->__('Attribute Description'),
|
54 |
+
'name' => 'nma_desc',
|
55 |
+
'required' => true,
|
56 |
+
'class' => 'required-entry',
|
57 |
+
|
58 |
+
)
|
59 |
+
);
|
60 |
+
$fieldset->addField(
|
61 |
+
'status',
|
62 |
+
'select',
|
63 |
+
array(
|
64 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
65 |
+
'name' => 'status',
|
66 |
+
'values' => array(
|
67 |
+
array(
|
68 |
+
'value' => 1,
|
69 |
+
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
70 |
+
),
|
71 |
+
array(
|
72 |
+
'value' => 0,
|
73 |
+
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
74 |
+
),
|
75 |
+
),
|
76 |
+
)
|
77 |
+
);
|
78 |
+
if (Mage::app()->isSingleStoreMode()) {
|
79 |
+
$fieldset->addField(
|
80 |
+
'store_id',
|
81 |
+
'hidden',
|
82 |
+
array(
|
83 |
+
'name' => 'stores[]',
|
84 |
+
'value' => Mage::app()->getStore(true)->getId()
|
85 |
+
)
|
86 |
+
);
|
87 |
+
Mage::registry('current_anymarketattributes')->setStoreId(Mage::app()->getStore(true)->getId());
|
88 |
+
}
|
89 |
+
$formValues = Mage::registry('current_anymarketattributes')->getDefaultValues();
|
90 |
+
if (!is_array($formValues)) {
|
91 |
+
$formValues = array();
|
92 |
+
}
|
93 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketattributesData()) {
|
94 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketattributesData());
|
95 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketattributesData(null);
|
96 |
+
} elseif (Mage::registry('current_anymarketattributes')) {
|
97 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketattributes')->getData());
|
98 |
+
}
|
99 |
+
$form->setValues($formValues);
|
100 |
+
return parent::_prepareForm();
|
101 |
+
}
|
102 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Stores.php
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* @category DB1
|
6 |
-
* @package DB1_AnyMarket
|
7 |
-
* @copyright Copyright (c) 2015
|
8 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
9 |
-
*/
|
10 |
-
/**
|
11 |
-
* store selection tab
|
12 |
-
*
|
13 |
-
* @category DB1
|
14 |
-
* @package DB1_AnyMarket
|
15 |
-
*/
|
16 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* prepare the form
|
20 |
-
*
|
21 |
-
* @access protected
|
22 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Stores
|
23 |
-
|
24 |
-
*/
|
25 |
-
protected function _prepareForm()
|
26 |
-
{
|
27 |
-
$form = new Varien_Data_Form();
|
28 |
-
$form->setFieldNameSuffix('anymarketattributes');
|
29 |
-
$this->setForm($form);
|
30 |
-
$fieldset = $form->addFieldset(
|
31 |
-
'anymarketattributes_stores_form',
|
32 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
33 |
-
);
|
34 |
-
$field = $fieldset->addField(
|
35 |
-
'store_id',
|
36 |
-
'multiselect',
|
37 |
-
array(
|
38 |
-
'name' => 'stores[]',
|
39 |
-
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
40 |
-
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
41 |
-
'required' => true,
|
42 |
-
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
43 |
-
)
|
44 |
-
);
|
45 |
-
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
46 |
-
$field->setRenderer($renderer);
|
47 |
-
$form->addValues(Mage::registry('current_anymarketattributes')->getData());
|
48 |
-
return parent::_prepareForm();
|
49 |
-
}
|
50 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* @category DB1
|
6 |
+
* @package DB1_AnyMarket
|
7 |
+
* @copyright Copyright (c) 2015
|
8 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
9 |
+
*/
|
10 |
+
/**
|
11 |
+
* store selection tab
|
12 |
+
*
|
13 |
+
* @category DB1
|
14 |
+
* @package DB1_AnyMarket
|
15 |
+
*/
|
16 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* prepare the form
|
20 |
+
*
|
21 |
+
* @access protected
|
22 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tab_Stores
|
23 |
+
|
24 |
+
*/
|
25 |
+
protected function _prepareForm()
|
26 |
+
{
|
27 |
+
$form = new Varien_Data_Form();
|
28 |
+
$form->setFieldNameSuffix('anymarketattributes');
|
29 |
+
$this->setForm($form);
|
30 |
+
$fieldset = $form->addFieldset(
|
31 |
+
'anymarketattributes_stores_form',
|
32 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
33 |
+
);
|
34 |
+
$field = $fieldset->addField(
|
35 |
+
'store_id',
|
36 |
+
'multiselect',
|
37 |
+
array(
|
38 |
+
'name' => 'stores[]',
|
39 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
40 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
41 |
+
'required' => true,
|
42 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
43 |
+
)
|
44 |
+
);
|
45 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
46 |
+
$field->setRenderer($renderer);
|
47 |
+
$form->addValues(Mage::registry('current_anymarketattributes')->getData());
|
48 |
+
return parent::_prepareForm();
|
49 |
+
}
|
50 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tabs.php
CHANGED
@@ -1,79 +1,79 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* @category DB1
|
6 |
-
* @package DB1_AnyMarket
|
7 |
-
* @copyright Copyright (c) 2015
|
8 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
9 |
-
*/
|
10 |
-
/**
|
11 |
-
* Anymarket Attributes admin edit tabs
|
12 |
-
*
|
13 |
-
* @category DB1
|
14 |
-
* @package DB1_AnyMarket
|
15 |
-
*/
|
16 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* Initialize Tabs
|
20 |
-
*
|
21 |
-
* @access public
|
22 |
-
|
23 |
-
*/
|
24 |
-
public function __construct()
|
25 |
-
{
|
26 |
-
parent::__construct();
|
27 |
-
$this->setId('anymarketattributes_tabs');
|
28 |
-
$this->setDestElementId('edit_form');
|
29 |
-
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Attributes'));
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* before render html
|
34 |
-
*
|
35 |
-
* @access protected
|
36 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tabs
|
37 |
-
|
38 |
-
*/
|
39 |
-
protected function _beforeToHtml()
|
40 |
-
{
|
41 |
-
$this->addTab(
|
42 |
-
'form_anymarketattributes',
|
43 |
-
array(
|
44 |
-
'label' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'),
|
45 |
-
'title' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'),
|
46 |
-
'content' => $this->getLayout()->createBlock(
|
47 |
-
'db1_anymarket/adminhtml_anymarketattributes_edit_tab_form'
|
48 |
-
)
|
49 |
-
->toHtml(),
|
50 |
-
)
|
51 |
-
);
|
52 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
53 |
-
$this->addTab(
|
54 |
-
'form_store_anymarketattributes',
|
55 |
-
array(
|
56 |
-
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
57 |
-
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
58 |
-
'content' => $this->getLayout()->createBlock(
|
59 |
-
'db1_anymarket/adminhtml_anymarketattributes_edit_tab_stores'
|
60 |
-
)
|
61 |
-
->toHtml(),
|
62 |
-
)
|
63 |
-
);
|
64 |
-
}
|
65 |
-
return parent::_beforeToHtml();
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Retrieve anymarket attributes entity
|
70 |
-
*
|
71 |
-
* @access public
|
72 |
-
* @return DB1_AnyMarket_Model_Anymarketattributes
|
73 |
-
|
74 |
-
*/
|
75 |
-
public function getAnymarketattributes()
|
76 |
-
{
|
77 |
-
return Mage::registry('current_anymarketattributes');
|
78 |
-
}
|
79 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* @category DB1
|
6 |
+
* @package DB1_AnyMarket
|
7 |
+
* @copyright Copyright (c) 2015
|
8 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
9 |
+
*/
|
10 |
+
/**
|
11 |
+
* Anymarket Attributes admin edit tabs
|
12 |
+
*
|
13 |
+
* @category DB1
|
14 |
+
* @package DB1_AnyMarket
|
15 |
+
*/
|
16 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Initialize Tabs
|
20 |
+
*
|
21 |
+
* @access public
|
22 |
+
|
23 |
+
*/
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
parent::__construct();
|
27 |
+
$this->setId('anymarketattributes_tabs');
|
28 |
+
$this->setDestElementId('edit_form');
|
29 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Attributes'));
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* before render html
|
34 |
+
*
|
35 |
+
* @access protected
|
36 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Edit_Tabs
|
37 |
+
|
38 |
+
*/
|
39 |
+
protected function _beforeToHtml()
|
40 |
+
{
|
41 |
+
$this->addTab(
|
42 |
+
'form_anymarketattributes',
|
43 |
+
array(
|
44 |
+
'label' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'),
|
45 |
+
'title' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'),
|
46 |
+
'content' => $this->getLayout()->createBlock(
|
47 |
+
'db1_anymarket/adminhtml_anymarketattributes_edit_tab_form'
|
48 |
+
)
|
49 |
+
->toHtml(),
|
50 |
+
)
|
51 |
+
);
|
52 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
53 |
+
$this->addTab(
|
54 |
+
'form_store_anymarketattributes',
|
55 |
+
array(
|
56 |
+
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
57 |
+
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
58 |
+
'content' => $this->getLayout()->createBlock(
|
59 |
+
'db1_anymarket/adminhtml_anymarketattributes_edit_tab_stores'
|
60 |
+
)
|
61 |
+
->toHtml(),
|
62 |
+
)
|
63 |
+
);
|
64 |
+
}
|
65 |
+
return parent::_beforeToHtml();
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Retrieve anymarket attributes entity
|
70 |
+
*
|
71 |
+
* @access public
|
72 |
+
* @return DB1_AnyMarket_Model_Anymarketattributes
|
73 |
+
|
74 |
+
*/
|
75 |
+
public function getAnymarketattributes()
|
76 |
+
{
|
77 |
+
return Mage::registry('current_anymarketattributes');
|
78 |
+
}
|
79 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Grid.php
CHANGED
@@ -1,174 +1,174 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes admin grid block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* constructor
|
27 |
-
*
|
28 |
-
* @access public
|
29 |
-
*/
|
30 |
-
public function __construct()
|
31 |
-
{
|
32 |
-
parent::__construct();
|
33 |
-
$this->setId('anymarketattributesGrid');
|
34 |
-
$this->setDefaultSort('entity_id');
|
35 |
-
$this->setDefaultDir('ASC');
|
36 |
-
$this->setSaveParametersInSession(true);
|
37 |
-
$this->setUseAjax(true);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* prepare collection
|
42 |
-
*
|
43 |
-
* @access protected
|
44 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
45 |
-
*/
|
46 |
-
protected function _prepareCollection()
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketattributes')
|
49 |
-
->getCollection();
|
50 |
-
|
51 |
-
$this->setCollection($collection);
|
52 |
-
return parent::_prepareCollection();
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* prepare grid collection
|
57 |
-
*
|
58 |
-
* @access protected
|
59 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
60 |
-
*/
|
61 |
-
protected function _prepareColumns()
|
62 |
-
{
|
63 |
-
$this->addColumn(
|
64 |
-
'nma_desc',
|
65 |
-
array(
|
66 |
-
'header' => Mage::helper('db1_anymarket')->__('Descrição do Atributo'),
|
67 |
-
'align' => 'left',
|
68 |
-
'index' => 'nma_desc',
|
69 |
-
)
|
70 |
-
);
|
71 |
-
|
72 |
-
$this->addColumn(
|
73 |
-
'status',
|
74 |
-
array(
|
75 |
-
'header' => Mage::helper('db1_anymarket')->__('Status'),
|
76 |
-
'index' => 'status',
|
77 |
-
'type' => 'options',
|
78 |
-
'options' => array(
|
79 |
-
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
80 |
-
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
81 |
-
)
|
82 |
-
)
|
83 |
-
);
|
84 |
-
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
85 |
-
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
86 |
-
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
87 |
-
return parent::_prepareColumns();
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* prepare mass action
|
92 |
-
*
|
93 |
-
* @access protected
|
94 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
95 |
-
*/
|
96 |
-
protected function _prepareMassaction()
|
97 |
-
{
|
98 |
-
$this->setMassactionIdField('entity_id');
|
99 |
-
$this->getMassactionBlock()->setFormFieldName('anymarketattributes');
|
100 |
-
$this->getMassactionBlock()->addItem(
|
101 |
-
'status',
|
102 |
-
array(
|
103 |
-
'label' => Mage::helper('db1_anymarket')->__('Change status'),
|
104 |
-
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
105 |
-
'additional' => array(
|
106 |
-
'status' => array(
|
107 |
-
'name' => 'status',
|
108 |
-
'type' => 'select',
|
109 |
-
'class' => 'required-entry',
|
110 |
-
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
111 |
-
'values' => array(
|
112 |
-
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
113 |
-
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
114 |
-
)
|
115 |
-
)
|
116 |
-
)
|
117 |
-
)
|
118 |
-
);
|
119 |
-
return $this;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* get the row url
|
124 |
-
*
|
125 |
-
* @access public
|
126 |
-
* @param DB1_AnyMarket_Model_Anymarketattributes
|
127 |
-
* @return string
|
128 |
-
*/
|
129 |
-
public function getRowUrl($row)
|
130 |
-
{
|
131 |
-
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
132 |
-
return Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product_attribute/edit', array('attribute_id' => $row->getNmaIdAttr() ));
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* get the grid url
|
137 |
-
*
|
138 |
-
* @access public
|
139 |
-
* @return string
|
140 |
-
*/
|
141 |
-
public function getGridUrl()
|
142 |
-
{
|
143 |
-
return $this->getUrl('*/*/grid', array('_current'=>true));
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* after collection load
|
148 |
-
*
|
149 |
-
* @access protected
|
150 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
151 |
-
*/
|
152 |
-
protected function _afterLoadCollection()
|
153 |
-
{
|
154 |
-
$this->getCollection()->walk('afterLoad');
|
155 |
-
parent::_afterLoadCollection();
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* filter store column
|
160 |
-
*
|
161 |
-
* @access protected
|
162 |
-
* @param DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection $collection
|
163 |
-
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
164 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
165 |
-
*/
|
166 |
-
protected function _filterStoreCondition($collection, $column)
|
167 |
-
{
|
168 |
-
if (!$value = $column->getFilter()->getValue()) {
|
169 |
-
return;
|
170 |
-
}
|
171 |
-
$collection->addStoreFilter($value);
|
172 |
-
return $this;
|
173 |
-
}
|
174 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
*/
|
30 |
+
public function __construct()
|
31 |
+
{
|
32 |
+
parent::__construct();
|
33 |
+
$this->setId('anymarketattributesGrid');
|
34 |
+
$this->setDefaultSort('entity_id');
|
35 |
+
$this->setDefaultDir('ASC');
|
36 |
+
$this->setSaveParametersInSession(true);
|
37 |
+
$this->setUseAjax(true);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* prepare collection
|
42 |
+
*
|
43 |
+
* @access protected
|
44 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
45 |
+
*/
|
46 |
+
protected function _prepareCollection()
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketattributes')
|
49 |
+
->getCollection();
|
50 |
+
|
51 |
+
$this->setCollection($collection);
|
52 |
+
return parent::_prepareCollection();
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* prepare grid collection
|
57 |
+
*
|
58 |
+
* @access protected
|
59 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
60 |
+
*/
|
61 |
+
protected function _prepareColumns()
|
62 |
+
{
|
63 |
+
$this->addColumn(
|
64 |
+
'nma_desc',
|
65 |
+
array(
|
66 |
+
'header' => Mage::helper('db1_anymarket')->__('Descrição do Atributo'),
|
67 |
+
'align' => 'left',
|
68 |
+
'index' => 'nma_desc',
|
69 |
+
)
|
70 |
+
);
|
71 |
+
|
72 |
+
$this->addColumn(
|
73 |
+
'status',
|
74 |
+
array(
|
75 |
+
'header' => Mage::helper('db1_anymarket')->__('Status'),
|
76 |
+
'index' => 'status',
|
77 |
+
'type' => 'options',
|
78 |
+
'options' => array(
|
79 |
+
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
80 |
+
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
81 |
+
)
|
82 |
+
)
|
83 |
+
);
|
84 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
85 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
86 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
87 |
+
return parent::_prepareColumns();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* prepare mass action
|
92 |
+
*
|
93 |
+
* @access protected
|
94 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
95 |
+
*/
|
96 |
+
protected function _prepareMassaction()
|
97 |
+
{
|
98 |
+
$this->setMassactionIdField('entity_id');
|
99 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketattributes');
|
100 |
+
$this->getMassactionBlock()->addItem(
|
101 |
+
'status',
|
102 |
+
array(
|
103 |
+
'label' => Mage::helper('db1_anymarket')->__('Change status'),
|
104 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
105 |
+
'additional' => array(
|
106 |
+
'status' => array(
|
107 |
+
'name' => 'status',
|
108 |
+
'type' => 'select',
|
109 |
+
'class' => 'required-entry',
|
110 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
111 |
+
'values' => array(
|
112 |
+
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
113 |
+
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
114 |
+
)
|
115 |
+
)
|
116 |
+
)
|
117 |
+
)
|
118 |
+
);
|
119 |
+
return $this;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* get the row url
|
124 |
+
*
|
125 |
+
* @access public
|
126 |
+
* @param DB1_AnyMarket_Model_Anymarketattributes
|
127 |
+
* @return string
|
128 |
+
*/
|
129 |
+
public function getRowUrl($row)
|
130 |
+
{
|
131 |
+
//return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
132 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product_attribute/edit', array('attribute_id' => $row->getNmaIdAttr() ));
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* get the grid url
|
137 |
+
*
|
138 |
+
* @access public
|
139 |
+
* @return string
|
140 |
+
*/
|
141 |
+
public function getGridUrl()
|
142 |
+
{
|
143 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* after collection load
|
148 |
+
*
|
149 |
+
* @access protected
|
150 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
151 |
+
*/
|
152 |
+
protected function _afterLoadCollection()
|
153 |
+
{
|
154 |
+
$this->getCollection()->walk('afterLoad');
|
155 |
+
parent::_afterLoadCollection();
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* filter store column
|
160 |
+
*
|
161 |
+
* @access protected
|
162 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection $collection
|
163 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
164 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketattributes_Grid
|
165 |
+
*/
|
166 |
+
protected function _filterStoreCondition($collection, $column)
|
167 |
+
{
|
168 |
+
if (!$value = $column->getFilter()->getValue()) {
|
169 |
+
return;
|
170 |
+
}
|
171 |
+
$collection->addStoreFilter($value);
|
172 |
+
return $this;
|
173 |
+
}
|
174 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands.php
ADDED
@@ -0,0 +1,49 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->_controller = 'adminhtml_anymarketbrands';
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
parent::__construct();
|
38 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Brands');
|
39 |
+
//$this->_updateButton('add', 'label', Mage::helper('db1_anymarket')->__('Add Brands'));
|
40 |
+
$this->_removeButton('add');
|
41 |
+
|
42 |
+
$this->_addButton('sinc_brands', array(
|
43 |
+
'label' => Mage::helper('db1_anymarket')->__('Synchronize Brands'),
|
44 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/sincBrands')}')",
|
45 |
+
'class' => 'add'
|
46 |
+
));
|
47 |
+
|
48 |
+
}
|
49 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit.php
ADDED
@@ -0,0 +1,82 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands admin edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
$this->_controller = 'adminhtml_anymarketbrands';
|
38 |
+
$this->_updateButton(
|
39 |
+
'save',
|
40 |
+
'label',
|
41 |
+
Mage::helper('db1_anymarket')->__('Save Brand')
|
42 |
+
);
|
43 |
+
$this->_updateButton(
|
44 |
+
'delete',
|
45 |
+
'label',
|
46 |
+
Mage::helper('db1_anymarket')->__('Delete Brand')
|
47 |
+
);
|
48 |
+
$this->_addButton(
|
49 |
+
'saveandcontinue',
|
50 |
+
array(
|
51 |
+
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
+
'onclick' => 'saveAndContinueEdit()',
|
53 |
+
'class' => 'save',
|
54 |
+
),
|
55 |
+
-100
|
56 |
+
);
|
57 |
+
$this->_formScripts[] = "
|
58 |
+
function saveAndContinueEdit() {
|
59 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
+
}
|
61 |
+
";
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* get the edit form header
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @return string
|
69 |
+
|
70 |
+
*/
|
71 |
+
public function getHeaderText()
|
72 |
+
{
|
73 |
+
if (Mage::registry('current_anymarketbrands') && Mage::registry('current_anymarketbrands')->getId()) {
|
74 |
+
return Mage::helper('db1_anymarket')->__(
|
75 |
+
"Edit Anymarketbrands '%s'",
|
76 |
+
$this->escapeHtml(Mage::registry('current_anymarketbrands')->getBrdId())
|
77 |
+
);
|
78 |
+
} else {
|
79 |
+
return Mage::helper('db1_anymarket')->__('Add Brand');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Form.php
ADDED
@@ -0,0 +1,52 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Form
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form(
|
36 |
+
array(
|
37 |
+
'id' => 'edit_form',
|
38 |
+
'action' => $this->getUrl(
|
39 |
+
'*/*/save',
|
40 |
+
array(
|
41 |
+
'id' => $this->getRequest()->getParam('id')
|
42 |
+
)
|
43 |
+
),
|
44 |
+
'method' => 'post',
|
45 |
+
'enctype' => 'multipart/form-data'
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$form->setUseContainer(true);
|
49 |
+
$this->setForm($form);
|
50 |
+
return parent::_prepareForm();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,91 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands edit form tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Tab_Form
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setHtmlIdPrefix('anymarketbrands_');
|
37 |
+
$form->setFieldNameSuffix('anymarketbrands');
|
38 |
+
$this->setForm($form);
|
39 |
+
$fieldset = $form->addFieldset(
|
40 |
+
'anymarketbrands_form',
|
41 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Brand'))
|
42 |
+
);
|
43 |
+
|
44 |
+
$fieldset->addField(
|
45 |
+
'brd_id',
|
46 |
+
'text',
|
47 |
+
array(
|
48 |
+
'label' => Mage::helper('db1_anymarket')->__('Brand Code'),
|
49 |
+
'name' => 'brd_id',
|
50 |
+
'required' => true,
|
51 |
+
'class' => 'required-entry',
|
52 |
+
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
$fieldset->addField(
|
57 |
+
'brd_name',
|
58 |
+
'text',
|
59 |
+
array(
|
60 |
+
'label' => Mage::helper('db1_anymarket')->__('Brand Description'),
|
61 |
+
'name' => 'brd_name',
|
62 |
+
'required' => true,
|
63 |
+
'class' => 'required-entry',
|
64 |
+
|
65 |
+
)
|
66 |
+
);
|
67 |
+
if (Mage::app()->isSingleStoreMode()) {
|
68 |
+
$fieldset->addField(
|
69 |
+
'store_id',
|
70 |
+
'hidden',
|
71 |
+
array(
|
72 |
+
'name' => 'stores[]',
|
73 |
+
'value' => Mage::app()->getStore(true)->getId()
|
74 |
+
)
|
75 |
+
);
|
76 |
+
Mage::registry('current_anymarketbrands')->setStoreId(Mage::app()->getStore(true)->getId());
|
77 |
+
}
|
78 |
+
$formValues = Mage::registry('current_anymarketbrands')->getDefaultValues();
|
79 |
+
if (!is_array($formValues)) {
|
80 |
+
$formValues = array();
|
81 |
+
}
|
82 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketbrandsData()) {
|
83 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketbrandsData());
|
84 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketbrandsData(null);
|
85 |
+
} elseif (Mage::registry('current_anymarketbrands')) {
|
86 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketbrands')->getData());
|
87 |
+
}
|
88 |
+
$form->setValues($formValues);
|
89 |
+
return parent::_prepareForm();
|
90 |
+
}
|
91 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Stores.php
ADDED
@@ -0,0 +1,58 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* store selection tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Tab_Stores
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setFieldNameSuffix('anymarketbrands');
|
37 |
+
$this->setForm($form);
|
38 |
+
$fieldset = $form->addFieldset(
|
39 |
+
'anymarketbrands_stores_form',
|
40 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
+
);
|
42 |
+
$field = $fieldset->addField(
|
43 |
+
'store_id',
|
44 |
+
'multiselect',
|
45 |
+
array(
|
46 |
+
'name' => 'stores[]',
|
47 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
+
'required' => true,
|
50 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
+
$field->setRenderer($renderer);
|
55 |
+
$form->addValues(Mage::registry('current_anymarketbrands')->getData());
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tabs.php
ADDED
@@ -0,0 +1,87 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands admin edit tabs
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Initialize Tabs
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketbrands_tabs');
|
36 |
+
$this->setDestElementId('edit_form');
|
37 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('Brand'));
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* before render html
|
42 |
+
*
|
43 |
+
* @access protected
|
44 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Edit_Tabs
|
45 |
+
|
46 |
+
*/
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
$this->addTab(
|
50 |
+
'form_anymarketbrands',
|
51 |
+
array(
|
52 |
+
'label' => Mage::helper('db1_anymarket')->__('Brand'),
|
53 |
+
'title' => Mage::helper('db1_anymarket')->__('Brand'),
|
54 |
+
'content' => $this->getLayout()->createBlock(
|
55 |
+
'db1_anymarket/adminhtml_anymarketbrands_edit_tab_form'
|
56 |
+
)
|
57 |
+
->toHtml(),
|
58 |
+
)
|
59 |
+
);
|
60 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
+
$this->addTab(
|
62 |
+
'form_store_anymarketbrands',
|
63 |
+
array(
|
64 |
+
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
+
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
+
'content' => $this->getLayout()->createBlock(
|
67 |
+
'db1_anymarket/adminhtml_anymarketbrands_edit_tab_stores'
|
68 |
+
)
|
69 |
+
->toHtml(),
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
return parent::_beforeToHtml();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Retrieve anymarketbrands entity
|
78 |
+
*
|
79 |
+
* @access public
|
80 |
+
* @return DB1_AnyMarket_Model_Anymarketbrands
|
81 |
+
|
82 |
+
*/
|
83 |
+
public function getAnymarketbrands()
|
84 |
+
{
|
85 |
+
return Mage::registry('current_anymarketbrands');
|
86 |
+
}
|
87 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Grid.php
ADDED
@@ -0,0 +1,236 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketbrandsGrid');
|
36 |
+
$this->setDefaultSort('entity_id');
|
37 |
+
$this->setDefaultDir('ASC');
|
38 |
+
$this->setSaveParametersInSession(true);
|
39 |
+
$this->setUseAjax(true);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* get current store scope
|
44 |
+
*
|
45 |
+
* @access protected
|
46 |
+
* @return store view
|
47 |
+
|
48 |
+
*/
|
49 |
+
protected function _getStore()
|
50 |
+
{
|
51 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
+
return Mage::app()->getStore($storeId);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* prepare collection
|
57 |
+
*
|
58 |
+
* @access protected
|
59 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Grid
|
60 |
+
|
61 |
+
*/
|
62 |
+
protected function _prepareCollection()
|
63 |
+
{
|
64 |
+
$store_id = $this->_getStore();
|
65 |
+
Mage::app()->setCurrentStore($store_id);
|
66 |
+
$store_id = Mage::app()->getStore()->getId();
|
67 |
+
Mage::getSingleton('core/session')->setStoreBrandVariable($store_id);
|
68 |
+
$collection = Mage::getModel('db1_anymarket/anymarketbrands')
|
69 |
+
->getCollection();
|
70 |
+
|
71 |
+
$this->setCollection($collection);
|
72 |
+
return parent::_prepareCollection();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* prepare grid collection
|
77 |
+
*
|
78 |
+
* @access protected
|
79 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Grid
|
80 |
+
|
81 |
+
*/
|
82 |
+
protected function _prepareColumns()
|
83 |
+
{
|
84 |
+
$this->addColumn(
|
85 |
+
'brd_id',
|
86 |
+
array(
|
87 |
+
'header' => Mage::helper('db1_anymarket')->__('Brand Code'),
|
88 |
+
'align' => 'left',
|
89 |
+
'index' => 'brd_id',
|
90 |
+
'type' => 'number'
|
91 |
+
)
|
92 |
+
);
|
93 |
+
$this->addColumn(
|
94 |
+
'brd_name',
|
95 |
+
array(
|
96 |
+
'header' => Mage::helper('db1_anymarket')->__('Brand Description'),
|
97 |
+
'index' => 'brd_name',
|
98 |
+
'type'=> 'text',
|
99 |
+
|
100 |
+
)
|
101 |
+
);
|
102 |
+
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
103 |
+
$this->addColumn(
|
104 |
+
'store_id',
|
105 |
+
array(
|
106 |
+
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
107 |
+
'index' => 'store_id',
|
108 |
+
'type' => 'store',
|
109 |
+
'store_all' => true,
|
110 |
+
'store_view' => true,
|
111 |
+
'sortable' => false,
|
112 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
113 |
+
)
|
114 |
+
);
|
115 |
+
}
|
116 |
+
$this->addColumn(
|
117 |
+
'created_at',
|
118 |
+
array(
|
119 |
+
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
120 |
+
'index' => 'created_at',
|
121 |
+
'width' => '120px',
|
122 |
+
'type' => 'datetime',
|
123 |
+
)
|
124 |
+
);
|
125 |
+
$this->addColumn(
|
126 |
+
'updated_at',
|
127 |
+
array(
|
128 |
+
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
129 |
+
'index' => 'updated_at',
|
130 |
+
'width' => '120px',
|
131 |
+
'type' => 'datetime',
|
132 |
+
)
|
133 |
+
);
|
134 |
+
$this->addColumn(
|
135 |
+
'action',
|
136 |
+
array(
|
137 |
+
'header' => Mage::helper('db1_anymarket')->__('Action'),
|
138 |
+
'width' => '100',
|
139 |
+
'type' => 'action',
|
140 |
+
'getter' => 'getId',
|
141 |
+
'actions' => array(
|
142 |
+
array(
|
143 |
+
'caption' => Mage::helper('db1_anymarket')->__('Edit'),
|
144 |
+
'url' => array('base'=> '*/*/edit'),
|
145 |
+
'field' => 'id'
|
146 |
+
)
|
147 |
+
),
|
148 |
+
'filter' => false,
|
149 |
+
'is_system' => true,
|
150 |
+
'sortable' => false,
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
154 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
155 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
156 |
+
return parent::_prepareColumns();
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* prepare mass action
|
161 |
+
*
|
162 |
+
* @access protected
|
163 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Grid
|
164 |
+
|
165 |
+
*/
|
166 |
+
protected function _prepareMassaction()
|
167 |
+
{
|
168 |
+
$this->setMassactionIdField('entity_id');
|
169 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketbrands');
|
170 |
+
$this->getMassactionBlock()->addItem(
|
171 |
+
'delete',
|
172 |
+
array(
|
173 |
+
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
174 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
175 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure?')
|
176 |
+
)
|
177 |
+
);
|
178 |
+
return $this;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* get the row url
|
183 |
+
*
|
184 |
+
* @access public
|
185 |
+
* @param DB1_AnyMarket_Model_Anymarketbrands
|
186 |
+
* @return string
|
187 |
+
|
188 |
+
*/
|
189 |
+
public function getRowUrl($row)
|
190 |
+
{
|
191 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* get the grid url
|
196 |
+
*
|
197 |
+
* @access public
|
198 |
+
* @return string
|
199 |
+
|
200 |
+
*/
|
201 |
+
public function getGridUrl()
|
202 |
+
{
|
203 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* after collection load
|
208 |
+
*
|
209 |
+
* @access protected
|
210 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Grid
|
211 |
+
|
212 |
+
*/
|
213 |
+
protected function _afterLoadCollection()
|
214 |
+
{
|
215 |
+
$this->getCollection()->walk('afterLoad');
|
216 |
+
parent::_afterLoadCollection();
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* filter store column
|
221 |
+
*
|
222 |
+
* @access protected
|
223 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketbrands_Collection $collection
|
224 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
225 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketbrands_Grid
|
226 |
+
|
227 |
+
*/
|
228 |
+
protected function _filterStoreCondition($collection, $column)
|
229 |
+
{
|
230 |
+
if (!$value = $column->getFilter()->getValue()) {
|
231 |
+
return;
|
232 |
+
}
|
233 |
+
$collection->addStoreFilter($value);
|
234 |
+
return $this;
|
235 |
+
}
|
236 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories.php
CHANGED
@@ -1,48 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories admin block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
$this->_controller = 'adminhtml_anymarketcategories';
|
36 |
-
$this->_blockGroup = 'db1_anymarket';
|
37 |
-
parent::__construct();
|
38 |
-
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Categories');
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
'
|
44 |
-
'
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
$this->_controller = 'adminhtml_anymarketcategories';
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
parent::__construct();
|
38 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Categories');
|
39 |
+
$this->_removeButton('add');
|
40 |
+
|
41 |
+
$this->_addButton('sinc_categ', array(
|
42 |
+
'label' => Mage::helper('db1_anymarket')->__('Import Categories'),
|
43 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/sincCategs')}')",
|
44 |
+
'class' => 'add'
|
45 |
+
));
|
46 |
+
|
47 |
+
$message = Mage::helper('db1_anymarket')->__('Are you sure you want to export the categories?');
|
48 |
+
$this->_addButton('export_categ', array(
|
49 |
+
'label' => Mage::helper('db1_anymarket')->__('Export Categories'),
|
50 |
+
'onclick' => "confirmSetLocation('{$message}', '{$this->getUrl('*/*/exportCategs')}')",
|
51 |
+
'class' => 'scalable go'
|
52 |
+
));
|
53 |
+
|
54 |
+
}
|
55 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit.php
CHANGED
@@ -1,82 +1,82 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories admin edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
parent::__construct();
|
36 |
-
$this->_blockGroup = 'db1_anymarket';
|
37 |
-
$this->_controller = 'adminhtml_anymarketcategories';
|
38 |
-
$this->_updateButton(
|
39 |
-
'save',
|
40 |
-
'label',
|
41 |
-
Mage::helper('db1_anymarket')->__('Save Anymarket Categories')
|
42 |
-
);
|
43 |
-
$this->_updateButton(
|
44 |
-
'delete',
|
45 |
-
'label',
|
46 |
-
Mage::helper('db1_anymarket')->__('Delete Anymarket Categories')
|
47 |
-
);
|
48 |
-
$this->_addButton(
|
49 |
-
'saveandcontinue',
|
50 |
-
array(
|
51 |
-
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
-
'onclick' => 'saveAndContinueEdit()',
|
53 |
-
'class' => 'save',
|
54 |
-
),
|
55 |
-
-100
|
56 |
-
);
|
57 |
-
$this->_formScripts[] = "
|
58 |
-
function saveAndContinueEdit() {
|
59 |
-
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
-
}
|
61 |
-
";
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* get the edit form header
|
66 |
-
*
|
67 |
-
* @access public
|
68 |
-
* @return string
|
69 |
-
|
70 |
-
*/
|
71 |
-
public function getHeaderText()
|
72 |
-
{
|
73 |
-
if (Mage::registry('current_anymarketcategories') && Mage::registry('current_anymarketcategories')->getId()) {
|
74 |
-
return Mage::helper('db1_anymarket')->__(
|
75 |
-
"Edit Anymarket Categories '%s'",
|
76 |
-
$this->escapeHtml(Mage::registry('current_anymarketcategories')->getNmcCatDesc())
|
77 |
-
);
|
78 |
-
} else {
|
79 |
-
return Mage::helper('db1_anymarket')->__('Add Anymarket Categories');
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories admin edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
$this->_controller = 'adminhtml_anymarketcategories';
|
38 |
+
$this->_updateButton(
|
39 |
+
'save',
|
40 |
+
'label',
|
41 |
+
Mage::helper('db1_anymarket')->__('Save Anymarket Categories')
|
42 |
+
);
|
43 |
+
$this->_updateButton(
|
44 |
+
'delete',
|
45 |
+
'label',
|
46 |
+
Mage::helper('db1_anymarket')->__('Delete Anymarket Categories')
|
47 |
+
);
|
48 |
+
$this->_addButton(
|
49 |
+
'saveandcontinue',
|
50 |
+
array(
|
51 |
+
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
+
'onclick' => 'saveAndContinueEdit()',
|
53 |
+
'class' => 'save',
|
54 |
+
),
|
55 |
+
-100
|
56 |
+
);
|
57 |
+
$this->_formScripts[] = "
|
58 |
+
function saveAndContinueEdit() {
|
59 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
+
}
|
61 |
+
";
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* get the edit form header
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @return string
|
69 |
+
|
70 |
+
*/
|
71 |
+
public function getHeaderText()
|
72 |
+
{
|
73 |
+
if (Mage::registry('current_anymarketcategories') && Mage::registry('current_anymarketcategories')->getId()) {
|
74 |
+
return Mage::helper('db1_anymarket')->__(
|
75 |
+
"Edit Anymarket Categories '%s'",
|
76 |
+
$this->escapeHtml(Mage::registry('current_anymarketcategories')->getNmcCatDesc())
|
77 |
+
);
|
78 |
+
} else {
|
79 |
+
return Mage::helper('db1_anymarket')->__('Add Anymarket Categories');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Form.php
CHANGED
@@ -1,52 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Form
|
31 |
-
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form(
|
36 |
-
array(
|
37 |
-
'id' => 'edit_form',
|
38 |
-
'action' => $this->getUrl(
|
39 |
-
'*/*/save',
|
40 |
-
array(
|
41 |
-
'id' => $this->getRequest()->getParam('id')
|
42 |
-
)
|
43 |
-
),
|
44 |
-
'method' => 'post',
|
45 |
-
'enctype' => 'multipart/form-data'
|
46 |
-
)
|
47 |
-
);
|
48 |
-
$form->setUseContainer(true);
|
49 |
-
$this->setForm($form);
|
50 |
-
return parent::_prepareForm();
|
51 |
-
}
|
52 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Form
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form(
|
36 |
+
array(
|
37 |
+
'id' => 'edit_form',
|
38 |
+
'action' => $this->getUrl(
|
39 |
+
'*/*/save',
|
40 |
+
array(
|
41 |
+
'id' => $this->getRequest()->getParam('id')
|
42 |
+
)
|
43 |
+
),
|
44 |
+
'method' => 'post',
|
45 |
+
'enctype' => 'multipart/form-data'
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$form->setUseContainer(true);
|
49 |
+
$this->setForm($form);
|
50 |
+
return parent::_prepareForm();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Form.php
CHANGED
@@ -1,114 +1,114 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
*
|
6 |
-
* @category DB1
|
7 |
-
* @package DB1_AnyMarket
|
8 |
-
* @copyright Copyright (c) 2015
|
9 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
10 |
-
*/
|
11 |
-
/**
|
12 |
-
* Anymarket Categories edit form tab
|
13 |
-
*
|
14 |
-
* @category DB1
|
15 |
-
* @package DB1_AnyMarket
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* prepare the form
|
21 |
-
*
|
22 |
-
* @access protected
|
23 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Form
|
24 |
-
|
25 |
-
*/
|
26 |
-
protected function _prepareForm()
|
27 |
-
{
|
28 |
-
$form = new Varien_Data_Form();
|
29 |
-
$form->setHtmlIdPrefix('anymarketcategories_');
|
30 |
-
$form->setFieldNameSuffix('anymarketcategories');
|
31 |
-
$this->setForm($form);
|
32 |
-
$fieldset = $form->addFieldset(
|
33 |
-
'anymarketcategories_form',
|
34 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Categories'))
|
35 |
-
);
|
36 |
-
|
37 |
-
$fieldset->addField(
|
38 |
-
'nmc_cat_id',
|
39 |
-
'text',
|
40 |
-
array(
|
41 |
-
'label' => Mage::helper('db1_anymarket')->__('Complete code Category'),
|
42 |
-
'name' => 'nmc_cat_id',
|
43 |
-
'required' => true,
|
44 |
-
'class' => 'required-entry',
|
45 |
-
|
46 |
-
)
|
47 |
-
);
|
48 |
-
|
49 |
-
$fieldset->addField(
|
50 |
-
'nmc_cat_root_id',
|
51 |
-
'text',
|
52 |
-
array(
|
53 |
-
'label' => Mage::helper('db1_anymarket')->__('Code of predecessor category'),
|
54 |
-
'name' => 'nmc_cat_root_id',
|
55 |
-
'required' => true,
|
56 |
-
'class' => 'required-entry',
|
57 |
-
|
58 |
-
)
|
59 |
-
);
|
60 |
-
|
61 |
-
$fieldset->addField(
|
62 |
-
'nmc_cat_desc',
|
63 |
-
'text',
|
64 |
-
array(
|
65 |
-
'label' => Mage::helper('db1_anymarket')->__('Category description'),
|
66 |
-
'name' => 'nmc_cat_desc',
|
67 |
-
'required' => true,
|
68 |
-
'class' => 'required-entry',
|
69 |
-
|
70 |
-
)
|
71 |
-
);
|
72 |
-
$fieldset->addField(
|
73 |
-
'status',
|
74 |
-
'select',
|
75 |
-
array(
|
76 |
-
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
77 |
-
'name' => 'status',
|
78 |
-
'values' => array(
|
79 |
-
array(
|
80 |
-
'value' => 1,
|
81 |
-
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
82 |
-
),
|
83 |
-
array(
|
84 |
-
'value' => 0,
|
85 |
-
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
86 |
-
),
|
87 |
-
),
|
88 |
-
)
|
89 |
-
);
|
90 |
-
if (Mage::app()->isSingleStoreMode()) {
|
91 |
-
$fieldset->addField(
|
92 |
-
'store_id',
|
93 |
-
'hidden',
|
94 |
-
array(
|
95 |
-
'name' => 'stores[]',
|
96 |
-
'value' => Mage::app()->getStore(true)->getId()
|
97 |
-
)
|
98 |
-
);
|
99 |
-
Mage::registry('current_anymarketcategories')->setStoreId(Mage::app()->getStore(true)->getId());
|
100 |
-
}
|
101 |
-
$formValues = Mage::registry('current_anymarketcategories')->getDefaultValues();
|
102 |
-
if (!is_array($formValues)) {
|
103 |
-
$formValues = array();
|
104 |
-
}
|
105 |
-
if (Mage::getSingleton('adminhtml/session')->getAnymarketcategoriesData()) {
|
106 |
-
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketcategoriesData());
|
107 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketcategoriesData(null);
|
108 |
-
} elseif (Mage::registry('current_anymarketcategories')) {
|
109 |
-
$formValues = array_merge($formValues, Mage::registry('current_anymarketcategories')->getData());
|
110 |
-
}
|
111 |
-
$form->setValues($formValues);
|
112 |
-
return parent::_prepareForm();
|
113 |
-
}
|
114 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* @category DB1
|
7 |
+
* @package DB1_AnyMarket
|
8 |
+
* @copyright Copyright (c) 2015
|
9 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Anymarket Categories edit form tab
|
13 |
+
*
|
14 |
+
* @category DB1
|
15 |
+
* @package DB1_AnyMarket
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* prepare the form
|
21 |
+
*
|
22 |
+
* @access protected
|
23 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Form
|
24 |
+
|
25 |
+
*/
|
26 |
+
protected function _prepareForm()
|
27 |
+
{
|
28 |
+
$form = new Varien_Data_Form();
|
29 |
+
$form->setHtmlIdPrefix('anymarketcategories_');
|
30 |
+
$form->setFieldNameSuffix('anymarketcategories');
|
31 |
+
$this->setForm($form);
|
32 |
+
$fieldset = $form->addFieldset(
|
33 |
+
'anymarketcategories_form',
|
34 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Categories'))
|
35 |
+
);
|
36 |
+
|
37 |
+
$fieldset->addField(
|
38 |
+
'nmc_cat_id',
|
39 |
+
'text',
|
40 |
+
array(
|
41 |
+
'label' => Mage::helper('db1_anymarket')->__('Complete code Category'),
|
42 |
+
'name' => 'nmc_cat_id',
|
43 |
+
'required' => true,
|
44 |
+
'class' => 'required-entry',
|
45 |
+
|
46 |
+
)
|
47 |
+
);
|
48 |
+
|
49 |
+
$fieldset->addField(
|
50 |
+
'nmc_cat_root_id',
|
51 |
+
'text',
|
52 |
+
array(
|
53 |
+
'label' => Mage::helper('db1_anymarket')->__('Code of predecessor category'),
|
54 |
+
'name' => 'nmc_cat_root_id',
|
55 |
+
'required' => true,
|
56 |
+
'class' => 'required-entry',
|
57 |
+
|
58 |
+
)
|
59 |
+
);
|
60 |
+
|
61 |
+
$fieldset->addField(
|
62 |
+
'nmc_cat_desc',
|
63 |
+
'text',
|
64 |
+
array(
|
65 |
+
'label' => Mage::helper('db1_anymarket')->__('Category description'),
|
66 |
+
'name' => 'nmc_cat_desc',
|
67 |
+
'required' => true,
|
68 |
+
'class' => 'required-entry',
|
69 |
+
|
70 |
+
)
|
71 |
+
);
|
72 |
+
$fieldset->addField(
|
73 |
+
'status',
|
74 |
+
'select',
|
75 |
+
array(
|
76 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
77 |
+
'name' => 'status',
|
78 |
+
'values' => array(
|
79 |
+
array(
|
80 |
+
'value' => 1,
|
81 |
+
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
82 |
+
),
|
83 |
+
array(
|
84 |
+
'value' => 0,
|
85 |
+
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
86 |
+
),
|
87 |
+
),
|
88 |
+
)
|
89 |
+
);
|
90 |
+
if (Mage::app()->isSingleStoreMode()) {
|
91 |
+
$fieldset->addField(
|
92 |
+
'store_id',
|
93 |
+
'hidden',
|
94 |
+
array(
|
95 |
+
'name' => 'stores[]',
|
96 |
+
'value' => Mage::app()->getStore(true)->getId()
|
97 |
+
)
|
98 |
+
);
|
99 |
+
Mage::registry('current_anymarketcategories')->setStoreId(Mage::app()->getStore(true)->getId());
|
100 |
+
}
|
101 |
+
$formValues = Mage::registry('current_anymarketcategories')->getDefaultValues();
|
102 |
+
if (!is_array($formValues)) {
|
103 |
+
$formValues = array();
|
104 |
+
}
|
105 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketcategoriesData()) {
|
106 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketcategoriesData());
|
107 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketcategoriesData(null);
|
108 |
+
} elseif (Mage::registry('current_anymarketcategories')) {
|
109 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketcategories')->getData());
|
110 |
+
}
|
111 |
+
$form->setValues($formValues);
|
112 |
+
return parent::_prepareForm();
|
113 |
+
}
|
114 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Stores.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* store selection tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Stores
|
31 |
-
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setFieldNameSuffix('anymarketcategories');
|
37 |
-
$this->setForm($form);
|
38 |
-
$fieldset = $form->addFieldset(
|
39 |
-
'anymarketcategories_stores_form',
|
40 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
-
);
|
42 |
-
$field = $fieldset->addField(
|
43 |
-
'store_id',
|
44 |
-
'multiselect',
|
45 |
-
array(
|
46 |
-
'name' => 'stores[]',
|
47 |
-
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
-
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
-
'required' => true,
|
50 |
-
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
-
)
|
52 |
-
);
|
53 |
-
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
-
$field->setRenderer($renderer);
|
55 |
-
$form->addValues(Mage::registry('current_anymarketcategories')->getData());
|
56 |
-
return parent::_prepareForm();
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* store selection tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tab_Stores
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setFieldNameSuffix('anymarketcategories');
|
37 |
+
$this->setForm($form);
|
38 |
+
$fieldset = $form->addFieldset(
|
39 |
+
'anymarketcategories_stores_form',
|
40 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
+
);
|
42 |
+
$field = $fieldset->addField(
|
43 |
+
'store_id',
|
44 |
+
'multiselect',
|
45 |
+
array(
|
46 |
+
'name' => 'stores[]',
|
47 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
+
'required' => true,
|
50 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
+
$field->setRenderer($renderer);
|
55 |
+
$form->addValues(Mage::registry('current_anymarketcategories')->getData());
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tabs.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories admin edit tabs
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Initialize Tabs
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketcategories_tabs');
|
36 |
-
$this->setDestElementId('edit_form');
|
37 |
-
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Categories'));
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* before render html
|
42 |
-
*
|
43 |
-
* @access protected
|
44 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tabs
|
45 |
-
|
46 |
-
*/
|
47 |
-
protected function _beforeToHtml()
|
48 |
-
{
|
49 |
-
$this->addTab(
|
50 |
-
'form_anymarketcategories',
|
51 |
-
array(
|
52 |
-
'label' => Mage::helper('db1_anymarket')->__('Anymarket Categories'),
|
53 |
-
'title' => Mage::helper('db1_anymarket')->__('Anymarket Categories'),
|
54 |
-
'content' => $this->getLayout()->createBlock(
|
55 |
-
'db1_anymarket/adminhtml_anymarketcategories_edit_tab_form'
|
56 |
-
)
|
57 |
-
->toHtml(),
|
58 |
-
)
|
59 |
-
);
|
60 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
-
$this->addTab(
|
62 |
-
'form_store_anymarketcategories',
|
63 |
-
array(
|
64 |
-
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
-
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
-
'content' => $this->getLayout()->createBlock(
|
67 |
-
'db1_anymarket/adminhtml_anymarketcategories_edit_tab_stores'
|
68 |
-
)
|
69 |
-
->toHtml(),
|
70 |
-
)
|
71 |
-
);
|
72 |
-
}
|
73 |
-
return parent::_beforeToHtml();
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Retrieve anymarket categories entity
|
78 |
-
*
|
79 |
-
* @access public
|
80 |
-
* @return DB1_AnyMarket_Model_Anymarketcategories
|
81 |
-
|
82 |
-
*/
|
83 |
-
public function getAnymarketcategories()
|
84 |
-
{
|
85 |
-
return Mage::registry('current_anymarketcategories');
|
86 |
-
}
|
87 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories admin edit tabs
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Initialize Tabs
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketcategories_tabs');
|
36 |
+
$this->setDestElementId('edit_form');
|
37 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Categories'));
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* before render html
|
42 |
+
*
|
43 |
+
* @access protected
|
44 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Edit_Tabs
|
45 |
+
|
46 |
+
*/
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
$this->addTab(
|
50 |
+
'form_anymarketcategories',
|
51 |
+
array(
|
52 |
+
'label' => Mage::helper('db1_anymarket')->__('Anymarket Categories'),
|
53 |
+
'title' => Mage::helper('db1_anymarket')->__('Anymarket Categories'),
|
54 |
+
'content' => $this->getLayout()->createBlock(
|
55 |
+
'db1_anymarket/adminhtml_anymarketcategories_edit_tab_form'
|
56 |
+
)
|
57 |
+
->toHtml(),
|
58 |
+
)
|
59 |
+
);
|
60 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
+
$this->addTab(
|
62 |
+
'form_store_anymarketcategories',
|
63 |
+
array(
|
64 |
+
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
+
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
+
'content' => $this->getLayout()->createBlock(
|
67 |
+
'db1_anymarket/adminhtml_anymarketcategories_edit_tab_stores'
|
68 |
+
)
|
69 |
+
->toHtml(),
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
return parent::_beforeToHtml();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Retrieve anymarket categories entity
|
78 |
+
*
|
79 |
+
* @access public
|
80 |
+
* @return DB1_AnyMarket_Model_Anymarketcategories
|
81 |
+
|
82 |
+
*/
|
83 |
+
public function getAnymarketcategories()
|
84 |
+
{
|
85 |
+
return Mage::registry('current_anymarketcategories');
|
86 |
+
}
|
87 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Grid.php
CHANGED
@@ -1,287 +1,287 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories admin grid block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketcategoriesGrid');
|
36 |
-
$this->setDefaultSort('entity_id');
|
37 |
-
$this->setDefaultDir('ASC');
|
38 |
-
$this->setSaveParametersInSession(true);
|
39 |
-
$this->setUseAjax(true);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* get current store scope
|
44 |
-
*
|
45 |
-
* @access protected
|
46 |
-
* @return store view
|
47 |
-
|
48 |
-
*/
|
49 |
-
protected function _getStore()
|
50 |
-
{
|
51 |
-
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
-
return Mage::app()->getStore($storeId);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* prepare collection
|
57 |
-
*
|
58 |
-
* @access protected
|
59 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
60 |
-
|
61 |
-
*/
|
62 |
-
protected function _prepareCollection()
|
63 |
-
{
|
64 |
-
$store_id = $this->_getStore();
|
65 |
-
Mage::app()->setCurrentStore($store_id);
|
66 |
-
$store_id = Mage::
|
67 |
-
Mage::getSingleton('core/session')->setStoreCategVariable($store_id);
|
68 |
-
$collection = Mage::getModel('db1_anymarket/anymarketcategories')
|
69 |
-
->getCollection();
|
70 |
-
|
71 |
-
$this->setCollection($collection);
|
72 |
-
return parent::_prepareCollection();
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* prepare grid collection
|
77 |
-
*
|
78 |
-
* @access protected
|
79 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
80 |
-
|
81 |
-
*/
|
82 |
-
protected function _prepareColumns()
|
83 |
-
{
|
84 |
-
$this->addColumn(
|
85 |
-
'entity_id',
|
86 |
-
array(
|
87 |
-
'header' => Mage::helper('db1_anymarket')->__('Id'),
|
88 |
-
'index' => 'entity_id',
|
89 |
-
'type' => 'number'
|
90 |
-
)
|
91 |
-
);
|
92 |
-
$this->addColumn(
|
93 |
-
'nmc_cat_desc',
|
94 |
-
array(
|
95 |
-
'header' => Mage::helper('db1_anymarket')->__('Category description'),
|
96 |
-
'align' => 'left',
|
97 |
-
'index' => 'nmc_cat_desc',
|
98 |
-
)
|
99 |
-
);
|
100 |
-
|
101 |
-
$this->addColumn(
|
102 |
-
'status',
|
103 |
-
array(
|
104 |
-
'header' => Mage::helper('db1_anymarket')->__('Status'),
|
105 |
-
'index' => 'status',
|
106 |
-
'type' => 'options',
|
107 |
-
'options' => array(
|
108 |
-
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
109 |
-
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
110 |
-
)
|
111 |
-
)
|
112 |
-
);
|
113 |
-
$this->addColumn(
|
114 |
-
'nmc_cat_id',
|
115 |
-
array(
|
116 |
-
'header' => Mage::helper('db1_anymarket')->__('Complete code Category'),
|
117 |
-
'index' => 'nmc_cat_id',
|
118 |
-
'type'=> 'text',
|
119 |
-
|
120 |
-
)
|
121 |
-
);
|
122 |
-
$this->addColumn(
|
123 |
-
'nmc_cat_root_id',
|
124 |
-
array(
|
125 |
-
'header' => Mage::helper('db1_anymarket')->__('Code of predecessor category'),
|
126 |
-
'index' => 'nmc_cat_root_id',
|
127 |
-
'type'=> 'text',
|
128 |
-
|
129 |
-
)
|
130 |
-
);
|
131 |
-
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
132 |
-
$this->addColumn(
|
133 |
-
'store_id',
|
134 |
-
array(
|
135 |
-
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
136 |
-
'index' => 'store_id',
|
137 |
-
'type' => 'store',
|
138 |
-
'store_all' => true,
|
139 |
-
'store_view' => true,
|
140 |
-
'sortable' => false,
|
141 |
-
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
142 |
-
)
|
143 |
-
);
|
144 |
-
}
|
145 |
-
$this->addColumn(
|
146 |
-
'created_at',
|
147 |
-
array(
|
148 |
-
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
149 |
-
'index' => 'created_at',
|
150 |
-
'width' => '120px',
|
151 |
-
'type' => 'datetime',
|
152 |
-
)
|
153 |
-
);
|
154 |
-
$this->addColumn(
|
155 |
-
'updated_at',
|
156 |
-
array(
|
157 |
-
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
158 |
-
'index' => 'updated_at',
|
159 |
-
'width' => '120px',
|
160 |
-
'type' => 'datetime',
|
161 |
-
)
|
162 |
-
);
|
163 |
-
$this->addColumn(
|
164 |
-
'action',
|
165 |
-
array(
|
166 |
-
'header' => Mage::helper('db1_anymarket')->__('Action'),
|
167 |
-
'width' => '100',
|
168 |
-
'type' => 'action',
|
169 |
-
'getter' => 'getId',
|
170 |
-
'actions' => array(
|
171 |
-
array(
|
172 |
-
'caption' => Mage::helper('db1_anymarket')->__('Edit'),
|
173 |
-
'url' => array('base'=> '*/*/edit'),
|
174 |
-
'field' => 'id'
|
175 |
-
)
|
176 |
-
),
|
177 |
-
'filter' => false,
|
178 |
-
'is_system' => true,
|
179 |
-
'sortable' => false,
|
180 |
-
)
|
181 |
-
);
|
182 |
-
|
183 |
-
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
184 |
-
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
185 |
-
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
186 |
-
return parent::_prepareColumns();
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* prepare mass action
|
191 |
-
*
|
192 |
-
* @access protected
|
193 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
194 |
-
|
195 |
-
*/
|
196 |
-
protected function _prepareMassaction()
|
197 |
-
{
|
198 |
-
|
199 |
-
$this->setMassactionIdField('entity_id');
|
200 |
-
$this->getMassactionBlock()->setFormFieldName('anymarketcategories');
|
201 |
-
$this->getMassactionBlock()->addItem(
|
202 |
-
'delete',
|
203 |
-
array(
|
204 |
-
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
205 |
-
'url' => $this->getUrl('*/*/massDelete'),
|
206 |
-
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure?')
|
207 |
-
)
|
208 |
-
);
|
209 |
-
$this->getMassactionBlock()->addItem(
|
210 |
-
'status',
|
211 |
-
array(
|
212 |
-
'label' => Mage::helper('db1_anymarket')->__('Change status'),
|
213 |
-
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
214 |
-
'additional' => array(
|
215 |
-
'status' => array(
|
216 |
-
'name' => 'status',
|
217 |
-
'type' => 'select',
|
218 |
-
'class' => 'required-entry',
|
219 |
-
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
220 |
-
'values' => array(
|
221 |
-
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
222 |
-
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
223 |
-
)
|
224 |
-
)
|
225 |
-
)
|
226 |
-
)
|
227 |
-
);
|
228 |
-
|
229 |
-
return $this;
|
230 |
-
}
|
231 |
-
|
232 |
-
/**
|
233 |
-
* get the row url
|
234 |
-
*
|
235 |
-
* @access public
|
236 |
-
* @param DB1_AnyMarket_Model_Anymarketcategories
|
237 |
-
* @return string
|
238 |
-
|
239 |
-
*/
|
240 |
-
public function getRowUrl($row)
|
241 |
-
{
|
242 |
-
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* get the grid url
|
247 |
-
*
|
248 |
-
* @access public
|
249 |
-
* @return string
|
250 |
-
|
251 |
-
*/
|
252 |
-
public function getGridUrl()
|
253 |
-
{
|
254 |
-
return $this->getUrl('*/*/grid', array('_current'=>true));
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* after collection load
|
259 |
-
*
|
260 |
-
* @access protected
|
261 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
262 |
-
|
263 |
-
*/
|
264 |
-
protected function _afterLoadCollection()
|
265 |
-
{
|
266 |
-
$this->getCollection()->walk('afterLoad');
|
267 |
-
parent::_afterLoadCollection();
|
268 |
-
}
|
269 |
-
|
270 |
-
/**
|
271 |
-
* filter store column
|
272 |
-
*
|
273 |
-
* @access protected
|
274 |
-
* @param DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection $collection
|
275 |
-
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
276 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
277 |
-
|
278 |
-
*/
|
279 |
-
protected function _filterStoreCondition($collection, $column)
|
280 |
-
{
|
281 |
-
if (!$value = $column->getFilter()->getValue()) {
|
282 |
-
return;
|
283 |
-
}
|
284 |
-
$collection->addStoreFilter($value);
|
285 |
-
return $this;
|
286 |
-
}
|
287 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketcategoriesGrid');
|
36 |
+
$this->setDefaultSort('entity_id');
|
37 |
+
$this->setDefaultDir('ASC');
|
38 |
+
$this->setSaveParametersInSession(true);
|
39 |
+
$this->setUseAjax(true);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* get current store scope
|
44 |
+
*
|
45 |
+
* @access protected
|
46 |
+
* @return store view
|
47 |
+
|
48 |
+
*/
|
49 |
+
protected function _getStore()
|
50 |
+
{
|
51 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
+
return Mage::app()->getStore($storeId);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* prepare collection
|
57 |
+
*
|
58 |
+
* @access protected
|
59 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
60 |
+
|
61 |
+
*/
|
62 |
+
protected function _prepareCollection()
|
63 |
+
{
|
64 |
+
$store_id = $this->_getStore();
|
65 |
+
Mage::app()->setCurrentStore($store_id);
|
66 |
+
$store_id = Mage::helper('db1_anymarket')->getCurrentStoreView();
|
67 |
+
Mage::getSingleton('core/session')->setStoreCategVariable($store_id);
|
68 |
+
$collection = Mage::getModel('db1_anymarket/anymarketcategories')
|
69 |
+
->getCollection();
|
70 |
+
|
71 |
+
$this->setCollection($collection);
|
72 |
+
return parent::_prepareCollection();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* prepare grid collection
|
77 |
+
*
|
78 |
+
* @access protected
|
79 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
80 |
+
|
81 |
+
*/
|
82 |
+
protected function _prepareColumns()
|
83 |
+
{
|
84 |
+
$this->addColumn(
|
85 |
+
'entity_id',
|
86 |
+
array(
|
87 |
+
'header' => Mage::helper('db1_anymarket')->__('Id'),
|
88 |
+
'index' => 'entity_id',
|
89 |
+
'type' => 'number'
|
90 |
+
)
|
91 |
+
);
|
92 |
+
$this->addColumn(
|
93 |
+
'nmc_cat_desc',
|
94 |
+
array(
|
95 |
+
'header' => Mage::helper('db1_anymarket')->__('Category description'),
|
96 |
+
'align' => 'left',
|
97 |
+
'index' => 'nmc_cat_desc',
|
98 |
+
)
|
99 |
+
);
|
100 |
+
|
101 |
+
$this->addColumn(
|
102 |
+
'status',
|
103 |
+
array(
|
104 |
+
'header' => Mage::helper('db1_anymarket')->__('Status'),
|
105 |
+
'index' => 'status',
|
106 |
+
'type' => 'options',
|
107 |
+
'options' => array(
|
108 |
+
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
109 |
+
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
110 |
+
)
|
111 |
+
)
|
112 |
+
);
|
113 |
+
$this->addColumn(
|
114 |
+
'nmc_cat_id',
|
115 |
+
array(
|
116 |
+
'header' => Mage::helper('db1_anymarket')->__('Complete code Category'),
|
117 |
+
'index' => 'nmc_cat_id',
|
118 |
+
'type'=> 'text',
|
119 |
+
|
120 |
+
)
|
121 |
+
);
|
122 |
+
$this->addColumn(
|
123 |
+
'nmc_cat_root_id',
|
124 |
+
array(
|
125 |
+
'header' => Mage::helper('db1_anymarket')->__('Code of predecessor category'),
|
126 |
+
'index' => 'nmc_cat_root_id',
|
127 |
+
'type'=> 'text',
|
128 |
+
|
129 |
+
)
|
130 |
+
);
|
131 |
+
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
132 |
+
$this->addColumn(
|
133 |
+
'store_id',
|
134 |
+
array(
|
135 |
+
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
136 |
+
'index' => 'store_id',
|
137 |
+
'type' => 'store',
|
138 |
+
'store_all' => true,
|
139 |
+
'store_view' => true,
|
140 |
+
'sortable' => false,
|
141 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
142 |
+
)
|
143 |
+
);
|
144 |
+
}
|
145 |
+
$this->addColumn(
|
146 |
+
'created_at',
|
147 |
+
array(
|
148 |
+
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
149 |
+
'index' => 'created_at',
|
150 |
+
'width' => '120px',
|
151 |
+
'type' => 'datetime',
|
152 |
+
)
|
153 |
+
);
|
154 |
+
$this->addColumn(
|
155 |
+
'updated_at',
|
156 |
+
array(
|
157 |
+
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
158 |
+
'index' => 'updated_at',
|
159 |
+
'width' => '120px',
|
160 |
+
'type' => 'datetime',
|
161 |
+
)
|
162 |
+
);
|
163 |
+
$this->addColumn(
|
164 |
+
'action',
|
165 |
+
array(
|
166 |
+
'header' => Mage::helper('db1_anymarket')->__('Action'),
|
167 |
+
'width' => '100',
|
168 |
+
'type' => 'action',
|
169 |
+
'getter' => 'getId',
|
170 |
+
'actions' => array(
|
171 |
+
array(
|
172 |
+
'caption' => Mage::helper('db1_anymarket')->__('Edit'),
|
173 |
+
'url' => array('base'=> '*/*/edit'),
|
174 |
+
'field' => 'id'
|
175 |
+
)
|
176 |
+
),
|
177 |
+
'filter' => false,
|
178 |
+
'is_system' => true,
|
179 |
+
'sortable' => false,
|
180 |
+
)
|
181 |
+
);
|
182 |
+
|
183 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
184 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
185 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
186 |
+
return parent::_prepareColumns();
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* prepare mass action
|
191 |
+
*
|
192 |
+
* @access protected
|
193 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
194 |
+
|
195 |
+
*/
|
196 |
+
protected function _prepareMassaction()
|
197 |
+
{
|
198 |
+
|
199 |
+
$this->setMassactionIdField('entity_id');
|
200 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketcategories');
|
201 |
+
$this->getMassactionBlock()->addItem(
|
202 |
+
'delete',
|
203 |
+
array(
|
204 |
+
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
205 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
206 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure?')
|
207 |
+
)
|
208 |
+
);
|
209 |
+
$this->getMassactionBlock()->addItem(
|
210 |
+
'status',
|
211 |
+
array(
|
212 |
+
'label' => Mage::helper('db1_anymarket')->__('Change status'),
|
213 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
214 |
+
'additional' => array(
|
215 |
+
'status' => array(
|
216 |
+
'name' => 'status',
|
217 |
+
'type' => 'select',
|
218 |
+
'class' => 'required-entry',
|
219 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
220 |
+
'values' => array(
|
221 |
+
'1' => Mage::helper('db1_anymarket')->__('Enabled'),
|
222 |
+
'0' => Mage::helper('db1_anymarket')->__('Disabled'),
|
223 |
+
)
|
224 |
+
)
|
225 |
+
)
|
226 |
+
)
|
227 |
+
);
|
228 |
+
|
229 |
+
return $this;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* get the row url
|
234 |
+
*
|
235 |
+
* @access public
|
236 |
+
* @param DB1_AnyMarket_Model_Anymarketcategories
|
237 |
+
* @return string
|
238 |
+
|
239 |
+
*/
|
240 |
+
public function getRowUrl($row)
|
241 |
+
{
|
242 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* get the grid url
|
247 |
+
*
|
248 |
+
* @access public
|
249 |
+
* @return string
|
250 |
+
|
251 |
+
*/
|
252 |
+
public function getGridUrl()
|
253 |
+
{
|
254 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* after collection load
|
259 |
+
*
|
260 |
+
* @access protected
|
261 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
262 |
+
|
263 |
+
*/
|
264 |
+
protected function _afterLoadCollection()
|
265 |
+
{
|
266 |
+
$this->getCollection()->walk('afterLoad');
|
267 |
+
parent::_afterLoadCollection();
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* filter store column
|
272 |
+
*
|
273 |
+
* @access protected
|
274 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection $collection
|
275 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
276 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketcategories_Grid
|
277 |
+
|
278 |
+
*/
|
279 |
+
protected function _filterStoreCondition($collection, $column)
|
280 |
+
{
|
281 |
+
if (!$value = $column->getFilter()->getValue()) {
|
282 |
+
return;
|
283 |
+
}
|
284 |
+
$collection->addStoreFilter($value);
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog.php
CHANGED
@@ -1,44 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log admin block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
*
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
$this->
|
36 |
-
|
37 |
-
|
38 |
-
$this->
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->_controller = 'adminhtml_anymarketlog';
|
35 |
+
$this->_blockGroup = 'db1_anymarket';
|
36 |
+
parent::__construct();
|
37 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Log Description');
|
38 |
+
$this->_removeButton('add');
|
39 |
+
|
40 |
+
//$this->_addButton('clean_log', array(
|
41 |
+
// 'label' => Mage::helper('db1_anymarket')->__('Clean Logs'),
|
42 |
+
// 'onclick' => "setLocation('{$this->getUrl('*/*/cleanLogs')}')",
|
43 |
+
// 'class' => 'back'
|
44 |
+
//));
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit.php
CHANGED
@@ -1,56 +1,56 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log admin edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
parent::__construct();
|
36 |
-
$this->_blockGroup = 'db1_anymarket';
|
37 |
-
$this->_controller = 'adminhtml_anymarketlog';
|
38 |
-
$this->_removeButton('save');
|
39 |
-
$this->_removeButton('delete');
|
40 |
-
$this->_removeButton('reset');
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* get the edit form header
|
45 |
-
*
|
46 |
-
* @access public
|
47 |
-
* @return string
|
48 |
-
*
|
49 |
-
*/
|
50 |
-
public function getHeaderText()
|
51 |
-
{
|
52 |
-
if (Mage::registry('current_anymarketlog') && Mage::registry('current_anymarketlog')->getId()) {
|
53 |
-
return Mage::helper('db1_anymarket')->__('Log of ID Order/Product: '. $this->escapeHtml(Mage::registry('current_anymarketlog')->getLogId()));
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log admin edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
$this->_controller = 'adminhtml_anymarketlog';
|
38 |
+
$this->_removeButton('save');
|
39 |
+
$this->_removeButton('delete');
|
40 |
+
$this->_removeButton('reset');
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* get the edit form header
|
45 |
+
*
|
46 |
+
* @access public
|
47 |
+
* @return string
|
48 |
+
*
|
49 |
+
*/
|
50 |
+
public function getHeaderText()
|
51 |
+
{
|
52 |
+
if (Mage::registry('current_anymarketlog') && Mage::registry('current_anymarketlog')->getId()) {
|
53 |
+
return Mage::helper('db1_anymarket')->__('Log of ID Order/Product: '. $this->escapeHtml(Mage::registry('current_anymarketlog')->getLogId()));
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Form.php
CHANGED
@@ -1,51 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
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 |
-
}
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Form
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form(
|
36 |
+
array(
|
37 |
+
'id' => 'edit_form',
|
38 |
+
'action' => $this->getUrl(
|
39 |
+
'*/*/save',
|
40 |
+
array(
|
41 |
+
'id' => $this->getRequest()->getParam('id')
|
42 |
+
)
|
43 |
+
),
|
44 |
+
'method' => 'post',
|
45 |
+
'enctype' => 'multipart/form-data'
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$form->setUseContainer(true);
|
49 |
+
$this->setForm($form);
|
50 |
+
return parent::_prepareForm();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Form.php
CHANGED
@@ -1,99 +1,99 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log edit form tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Form
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setHtmlIdPrefix('anymarketlog_');
|
37 |
-
$form->setFieldNameSuffix('anymarketlog');
|
38 |
-
$this->setForm($form);
|
39 |
-
$fieldset = $form->addFieldset(
|
40 |
-
'anymarketlog_form',
|
41 |
-
array('legend' => Mage::helper('db1_anymarket')->__('AnyMarket Log'))
|
42 |
-
);
|
43 |
-
|
44 |
-
$fieldset->addField(
|
45 |
-
'created_at',
|
46 |
-
'text',
|
47 |
-
array(
|
48 |
-
'label' => Mage::helper('db1_anymarket')->__('Created At'),
|
49 |
-
'name' => 'created_at',
|
50 |
-
'readonly' => true,
|
51 |
-
)
|
52 |
-
);
|
53 |
-
|
54 |
-
$fieldset->addField(
|
55 |
-
'log_desc',
|
56 |
-
'textarea',
|
57 |
-
array(
|
58 |
-
'label' => Mage::helper('db1_anymarket')->__('Log Description'),
|
59 |
-
'name' => 'log_desc',
|
60 |
-
'readonly' => true,
|
61 |
-
'style' => "width: 600px",
|
62 |
-
)
|
63 |
-
);
|
64 |
-
|
65 |
-
$fieldset->addField(
|
66 |
-
'log_json',
|
67 |
-
'textarea',
|
68 |
-
array(
|
69 |
-
'label' => Mage::helper('db1_anymarket')->__('JSON'),
|
70 |
-
'name' => 'log_json',
|
71 |
-
'readonly' => true,
|
72 |
-
'style' => "width: 600px",
|
73 |
-
)
|
74 |
-
);
|
75 |
-
if (Mage::app()->isSingleStoreMode()) {
|
76 |
-
$fieldset->addField(
|
77 |
-
'store_id',
|
78 |
-
'hidden',
|
79 |
-
array(
|
80 |
-
'name' => 'stores[]',
|
81 |
-
'value' => Mage::app()->getStore(true)->getId()
|
82 |
-
)
|
83 |
-
);
|
84 |
-
Mage::registry('current_anymarketlog')->setStoreId(Mage::app()->getStore(true)->getId());
|
85 |
-
}
|
86 |
-
$formValues = Mage::registry('current_anymarketlog')->getDefaultValues();
|
87 |
-
if (!is_array($formValues)) {
|
88 |
-
$formValues = array();
|
89 |
-
}
|
90 |
-
if (Mage::getSingleton('adminhtml/session')->getAnymarketlogData()) {
|
91 |
-
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketlogData());
|
92 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketlogData(null);
|
93 |
-
} elseif (Mage::registry('current_anymarketlog')) {
|
94 |
-
$formValues = array_merge($formValues, Mage::registry('current_anymarketlog')->getData());
|
95 |
-
}
|
96 |
-
$form->setValues($formValues);
|
97 |
-
return parent::_prepareForm();
|
98 |
-
}
|
99 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log edit form tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Form
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setHtmlIdPrefix('anymarketlog_');
|
37 |
+
$form->setFieldNameSuffix('anymarketlog');
|
38 |
+
$this->setForm($form);
|
39 |
+
$fieldset = $form->addFieldset(
|
40 |
+
'anymarketlog_form',
|
41 |
+
array('legend' => Mage::helper('db1_anymarket')->__('AnyMarket Log'))
|
42 |
+
);
|
43 |
+
|
44 |
+
$fieldset->addField(
|
45 |
+
'created_at',
|
46 |
+
'text',
|
47 |
+
array(
|
48 |
+
'label' => Mage::helper('db1_anymarket')->__('Created At'),
|
49 |
+
'name' => 'created_at',
|
50 |
+
'readonly' => true,
|
51 |
+
)
|
52 |
+
);
|
53 |
+
|
54 |
+
$fieldset->addField(
|
55 |
+
'log_desc',
|
56 |
+
'textarea',
|
57 |
+
array(
|
58 |
+
'label' => Mage::helper('db1_anymarket')->__('Log Description'),
|
59 |
+
'name' => 'log_desc',
|
60 |
+
'readonly' => true,
|
61 |
+
'style' => "width: 600px",
|
62 |
+
)
|
63 |
+
);
|
64 |
+
|
65 |
+
$fieldset->addField(
|
66 |
+
'log_json',
|
67 |
+
'textarea',
|
68 |
+
array(
|
69 |
+
'label' => Mage::helper('db1_anymarket')->__('JSON'),
|
70 |
+
'name' => 'log_json',
|
71 |
+
'readonly' => true,
|
72 |
+
'style' => "width: 600px",
|
73 |
+
)
|
74 |
+
);
|
75 |
+
if (Mage::app()->isSingleStoreMode()) {
|
76 |
+
$fieldset->addField(
|
77 |
+
'store_id',
|
78 |
+
'hidden',
|
79 |
+
array(
|
80 |
+
'name' => 'stores[]',
|
81 |
+
'value' => Mage::app()->getStore(true)->getId()
|
82 |
+
)
|
83 |
+
);
|
84 |
+
Mage::registry('current_anymarketlog')->setStoreId(Mage::app()->getStore(true)->getId());
|
85 |
+
}
|
86 |
+
$formValues = Mage::registry('current_anymarketlog')->getDefaultValues();
|
87 |
+
if (!is_array($formValues)) {
|
88 |
+
$formValues = array();
|
89 |
+
}
|
90 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketlogData()) {
|
91 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketlogData());
|
92 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketlogData(null);
|
93 |
+
} elseif (Mage::registry('current_anymarketlog')) {
|
94 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketlog')->getData());
|
95 |
+
}
|
96 |
+
$form->setValues($formValues);
|
97 |
+
return parent::_prepareForm();
|
98 |
+
}
|
99 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Stores.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* store selection tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Stores
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setFieldNameSuffix('anymarketlog');
|
37 |
-
$this->setForm($form);
|
38 |
-
$fieldset = $form->addFieldset(
|
39 |
-
'anymarketlog_stores_form',
|
40 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
-
);
|
42 |
-
$field = $fieldset->addField(
|
43 |
-
'store_id',
|
44 |
-
'multiselect',
|
45 |
-
array(
|
46 |
-
'name' => 'stores[]',
|
47 |
-
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
-
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
-
'required' => true,
|
50 |
-
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
-
)
|
52 |
-
);
|
53 |
-
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
-
$field->setRenderer($renderer);
|
55 |
-
$form->addValues(Mage::registry('current_anymarketlog')->getData());
|
56 |
-
return parent::_prepareForm();
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* store selection tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tab_Stores
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setFieldNameSuffix('anymarketlog');
|
37 |
+
$this->setForm($form);
|
38 |
+
$fieldset = $form->addFieldset(
|
39 |
+
'anymarketlog_stores_form',
|
40 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
+
);
|
42 |
+
$field = $fieldset->addField(
|
43 |
+
'store_id',
|
44 |
+
'multiselect',
|
45 |
+
array(
|
46 |
+
'name' => 'stores[]',
|
47 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
+
'required' => true,
|
50 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
+
$field->setRenderer($renderer);
|
55 |
+
$form->addValues(Mage::registry('current_anymarketlog')->getData());
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tabs.php
CHANGED
@@ -1,74 +1,74 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log admin edit tabs
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Initialize Tabs
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
*
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketlog_tabs');
|
36 |
-
$this->setDestElementId('edit_form');
|
37 |
-
$this->setTitle(Mage::helper('db1_anymarket')->__('AnyMarket Log'));
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* before render html
|
42 |
-
*
|
43 |
-
* @access protected
|
44 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tabs
|
45 |
-
*
|
46 |
-
*/
|
47 |
-
protected function _beforeToHtml()
|
48 |
-
{
|
49 |
-
$this->addTab(
|
50 |
-
'form_anymarketlog',
|
51 |
-
array(
|
52 |
-
'label' => Mage::helper('db1_anymarket')->__('AnyMarket Log'),
|
53 |
-
'title' => Mage::helper('db1_anymarket')->__('AnyMarket Log'),
|
54 |
-
'content' => $this->getLayout()->createBlock(
|
55 |
-
'db1_anymarket/adminhtml_anymarketlog_edit_tab_form'
|
56 |
-
)
|
57 |
-
->toHtml(),
|
58 |
-
)
|
59 |
-
);
|
60 |
-
return parent::_beforeToHtml();
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Retrieve anymarket log entity
|
65 |
-
*
|
66 |
-
* @access public
|
67 |
-
* @return DB1_AnyMarket_Model_Anymarketlog
|
68 |
-
*
|
69 |
-
*/
|
70 |
-
public function getAnymarketlog()
|
71 |
-
{
|
72 |
-
return Mage::registry('current_anymarketlog');
|
73 |
-
}
|
74 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log admin edit tabs
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Initialize Tabs
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketlog_tabs');
|
36 |
+
$this->setDestElementId('edit_form');
|
37 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('AnyMarket Log'));
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* before render html
|
42 |
+
*
|
43 |
+
* @access protected
|
44 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Edit_Tabs
|
45 |
+
*
|
46 |
+
*/
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
$this->addTab(
|
50 |
+
'form_anymarketlog',
|
51 |
+
array(
|
52 |
+
'label' => Mage::helper('db1_anymarket')->__('AnyMarket Log'),
|
53 |
+
'title' => Mage::helper('db1_anymarket')->__('AnyMarket Log'),
|
54 |
+
'content' => $this->getLayout()->createBlock(
|
55 |
+
'db1_anymarket/adminhtml_anymarketlog_edit_tab_form'
|
56 |
+
)
|
57 |
+
->toHtml(),
|
58 |
+
)
|
59 |
+
);
|
60 |
+
return parent::_beforeToHtml();
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Retrieve anymarket log entity
|
65 |
+
*
|
66 |
+
* @access public
|
67 |
+
* @return DB1_AnyMarket_Model_Anymarketlog
|
68 |
+
*
|
69 |
+
*/
|
70 |
+
public function getAnymarketlog()
|
71 |
+
{
|
72 |
+
return Mage::registry('current_anymarketlog');
|
73 |
+
}
|
74 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Grid.php
CHANGED
@@ -1,189 +1,199 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log admin grid block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
*
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketlogGrid');
|
36 |
-
$this->setDefaultSort('entity_id');
|
37 |
-
$this->setDefaultDir('
|
38 |
-
$this->setSaveParametersInSession(true);
|
39 |
-
$this->setUseAjax(true);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* prepare collection
|
44 |
-
*
|
45 |
-
* @access protected
|
46 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid
|
47 |
-
*
|
48 |
-
*/
|
49 |
-
protected function _prepareCollection()
|
50 |
-
{
|
51 |
-
$collection = Mage::getModel('db1_anymarket/anymarketlog')
|
52 |
-
->getCollection()
|
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 |
-
$this->addExportType('*/*/
|
117 |
-
$this->addExportType('*/*/
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketlogGrid');
|
36 |
+
$this->setDefaultSort('entity_id');
|
37 |
+
$this->setDefaultDir('DESC');
|
38 |
+
$this->setSaveParametersInSession(true);
|
39 |
+
$this->setUseAjax(true);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* prepare collection
|
44 |
+
*
|
45 |
+
* @access protected
|
46 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid
|
47 |
+
*
|
48 |
+
*/
|
49 |
+
protected function _prepareCollection()
|
50 |
+
{
|
51 |
+
$collection = Mage::getModel('db1_anymarket/anymarketlog')
|
52 |
+
->getCollection()
|
53 |
+
->setOrder('entity_id','DESC');
|
54 |
+
|
55 |
+
$this->setCollection($collection);
|
56 |
+
return parent::_prepareCollection();
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* prepare grid collection
|
61 |
+
*
|
62 |
+
* @access protected
|
63 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid
|
64 |
+
*
|
65 |
+
*/
|
66 |
+
protected function _prepareColumns()
|
67 |
+
{
|
68 |
+
$this->addColumn(
|
69 |
+
'log_id',
|
70 |
+
array(
|
71 |
+
'header' => Mage::helper('db1_anymarket')->__('#ID PED/PROD'),
|
72 |
+
'align' => 'left',
|
73 |
+
'index' => 'log_id',
|
74 |
+
)
|
75 |
+
);
|
76 |
+
$this->addColumn(
|
77 |
+
'log_desc',
|
78 |
+
array(
|
79 |
+
'header' => Mage::helper('db1_anymarket')->__('Log Description'),
|
80 |
+
'align' => 'left',
|
81 |
+
'index' => 'log_desc',
|
82 |
+
)
|
83 |
+
);
|
84 |
+
$this->addColumn(
|
85 |
+
'log_json',
|
86 |
+
array(
|
87 |
+
'header' => Mage::helper('db1_anymarket')->__('Log Json'),
|
88 |
+
'align' => 'left',
|
89 |
+
'index' => 'log_json',
|
90 |
+
)
|
91 |
+
);
|
92 |
+
|
93 |
+
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
94 |
+
$this->addColumn(
|
95 |
+
'store_id',
|
96 |
+
array(
|
97 |
+
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
98 |
+
'index' => 'store_id',
|
99 |
+
'type' => 'store',
|
100 |
+
'store_all' => true,
|
101 |
+
'store_view' => true,
|
102 |
+
'sortable' => false,
|
103 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
104 |
+
)
|
105 |
+
);
|
106 |
+
}
|
107 |
+
$this->addColumn(
|
108 |
+
'created_at',
|
109 |
+
array(
|
110 |
+
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
111 |
+
'index' => 'created_at',
|
112 |
+
'width' => '120px',
|
113 |
+
'type' => 'datetime',
|
114 |
+
)
|
115 |
+
);
|
116 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
117 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
118 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
119 |
+
return parent::_prepareColumns();
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* prepare mass action
|
124 |
+
*
|
125 |
+
* @access protected
|
126 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid
|
127 |
+
*
|
128 |
+
*/
|
129 |
+
protected function _prepareMassaction()
|
130 |
+
{
|
131 |
+
$this->setMassactionIdField('entity_id');
|
132 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketlog');
|
133 |
+
$this->getMassactionBlock()->addItem(
|
134 |
+
'delete',
|
135 |
+
array(
|
136 |
+
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
137 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
138 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure? The entire log will be written to a file.')
|
139 |
+
)
|
140 |
+
);
|
141 |
+
return $this;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* get the row url
|
146 |
+
*
|
147 |
+
* @access public
|
148 |
+
* @param DB1_AnyMarket_Model_Anymarketlog
|
149 |
+
* @return string
|
150 |
+
*
|
151 |
+
*/
|
152 |
+
public function getRowUrl($row)
|
153 |
+
{
|
154 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* get the grid url
|
159 |
+
*
|
160 |
+
* @access public
|
161 |
+
* @return string
|
162 |
+
*
|
163 |
+
*/
|
164 |
+
public function getGridUrl()
|
165 |
+
{
|
166 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* after collection load
|
171 |
+
*
|
172 |
+
* @access protected
|
173 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid
|
174 |
+
*
|
175 |
+
*/
|
176 |
+
protected function _afterLoadCollection()
|
177 |
+
{
|
178 |
+
$this->getCollection()->walk('afterLoad');
|
179 |
+
parent::_afterLoadCollection();
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* filter store column
|
184 |
+
*
|
185 |
+
* @access protected
|
186 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketlog_Collection $collection
|
187 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
188 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketlog_Grid
|
189 |
+
*
|
190 |
+
*/
|
191 |
+
protected function _filterStoreCondition($collection, $column)
|
192 |
+
{
|
193 |
+
if (!$value = $column->getFilter()->getValue()) {
|
194 |
+
return;
|
195 |
+
}
|
196 |
+
$collection->addStoreFilter($value);
|
197 |
+
return $this;
|
198 |
+
}
|
199 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders.php
CHANGED
@@ -1,53 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders admin block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
$this->_controller = 'adminhtml_anymarketorders';
|
35 |
-
$this->_blockGroup = 'db1_anymarket';
|
36 |
-
parent::__construct();
|
37 |
-
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Orders');
|
38 |
-
$this->_removeButton('add');
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'onclick' => "setLocation('{$this->getUrl('*/*/listOrders')}')",
|
49 |
-
'class' => 'add'
|
50 |
-
));
|
51 |
-
|
52 |
-
}
|
53 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->_controller = 'adminhtml_anymarketorders';
|
35 |
+
$this->_blockGroup = 'db1_anymarket';
|
36 |
+
parent::__construct();
|
37 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Orders');
|
38 |
+
$this->_removeButton('add');
|
39 |
+
|
40 |
+
$this->_addButton('list_orders', array(
|
41 |
+
'label' => Mage::helper('db1_anymarket')->__('Orders list'),
|
42 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/listOrders')}')",
|
43 |
+
'class' => 'add'
|
44 |
+
));
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit.php
CHANGED
@@ -1,82 +1,82 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders admin edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
parent::__construct();
|
36 |
-
$this->_blockGroup = 'db1_anymarket';
|
37 |
-
$this->_controller = 'adminhtml_anymarketorders';
|
38 |
-
$this->_updateButton(
|
39 |
-
'save',
|
40 |
-
'label',
|
41 |
-
Mage::helper('db1_anymarket')->__('Save Anymarket Orders')
|
42 |
-
);
|
43 |
-
$this->_updateButton(
|
44 |
-
'delete',
|
45 |
-
'label',
|
46 |
-
Mage::helper('db1_anymarket')->__('Delete Anymarket Orders')
|
47 |
-
);
|
48 |
-
$this->_addButton(
|
49 |
-
'saveandcontinue',
|
50 |
-
array(
|
51 |
-
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
-
'onclick' => 'saveAndContinueEdit()',
|
53 |
-
'class' => 'save',
|
54 |
-
),
|
55 |
-
-100
|
56 |
-
);
|
57 |
-
$this->_formScripts[] = "
|
58 |
-
function saveAndContinueEdit() {
|
59 |
-
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
-
}
|
61 |
-
";
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* get the edit form header
|
66 |
-
*
|
67 |
-
* @access public
|
68 |
-
* @return string
|
69 |
-
|
70 |
-
*/
|
71 |
-
public function getHeaderText()
|
72 |
-
{
|
73 |
-
if (Mage::registry('current_anymarketorders') && Mage::registry('current_anymarketorders')->getId()) {
|
74 |
-
return Mage::helper('db1_anymarket')->__(
|
75 |
-
"Edit Anymarket Orders '%s'",
|
76 |
-
$this->escapeHtml(Mage::registry('current_anymarketorders')->getNmoIdOrder())
|
77 |
-
);
|
78 |
-
} else {
|
79 |
-
return Mage::helper('db1_anymarket')->__('Add Anymarket Orders');
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders admin edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
$this->_controller = 'adminhtml_anymarketorders';
|
38 |
+
$this->_updateButton(
|
39 |
+
'save',
|
40 |
+
'label',
|
41 |
+
Mage::helper('db1_anymarket')->__('Save Anymarket Orders')
|
42 |
+
);
|
43 |
+
$this->_updateButton(
|
44 |
+
'delete',
|
45 |
+
'label',
|
46 |
+
Mage::helper('db1_anymarket')->__('Delete Anymarket Orders')
|
47 |
+
);
|
48 |
+
$this->_addButton(
|
49 |
+
'saveandcontinue',
|
50 |
+
array(
|
51 |
+
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
+
'onclick' => 'saveAndContinueEdit()',
|
53 |
+
'class' => 'save',
|
54 |
+
),
|
55 |
+
-100
|
56 |
+
);
|
57 |
+
$this->_formScripts[] = "
|
58 |
+
function saveAndContinueEdit() {
|
59 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
+
}
|
61 |
+
";
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* get the edit form header
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @return string
|
69 |
+
|
70 |
+
*/
|
71 |
+
public function getHeaderText()
|
72 |
+
{
|
73 |
+
if (Mage::registry('current_anymarketorders') && Mage::registry('current_anymarketorders')->getId()) {
|
74 |
+
return Mage::helper('db1_anymarket')->__(
|
75 |
+
"Edit Anymarket Orders '%s'",
|
76 |
+
$this->escapeHtml(Mage::registry('current_anymarketorders')->getNmoIdOrder())
|
77 |
+
);
|
78 |
+
} else {
|
79 |
+
return Mage::helper('db1_anymarket')->__('Add Anymarket Orders');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Form.php
CHANGED
@@ -1,52 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Form
|
31 |
-
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form(
|
36 |
-
array(
|
37 |
-
'id' => 'edit_form',
|
38 |
-
'action' => $this->getUrl(
|
39 |
-
'*/*/save',
|
40 |
-
array(
|
41 |
-
'id' => $this->getRequest()->getParam('id')
|
42 |
-
)
|
43 |
-
),
|
44 |
-
'method' => 'post',
|
45 |
-
'enctype' => 'multipart/form-data'
|
46 |
-
)
|
47 |
-
);
|
48 |
-
$form->setUseContainer(true);
|
49 |
-
$this->setForm($form);
|
50 |
-
return parent::_prepareForm();
|
51 |
-
}
|
52 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Form
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form(
|
36 |
+
array(
|
37 |
+
'id' => 'edit_form',
|
38 |
+
'action' => $this->getUrl(
|
39 |
+
'*/*/save',
|
40 |
+
array(
|
41 |
+
'id' => $this->getRequest()->getParam('id')
|
42 |
+
)
|
43 |
+
),
|
44 |
+
'method' => 'post',
|
45 |
+
'enctype' => 'multipart/form-data'
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$form->setUseContainer(true);
|
49 |
+
$this->setForm($form);
|
50 |
+
return parent::_prepareForm();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Form.php
CHANGED
@@ -1,109 +1,109 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders edit form tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Form
|
31 |
-
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setHtmlIdPrefix('anymarketorders_');
|
37 |
-
$form->setFieldNameSuffix('anymarketorders');
|
38 |
-
$this->setForm($form);
|
39 |
-
$fieldset = $form->addFieldset(
|
40 |
-
'anymarketorders_form',
|
41 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Orders'))
|
42 |
-
);
|
43 |
-
|
44 |
-
$fieldset->addField(
|
45 |
-
'nmo_id_anymarket',
|
46 |
-
'text',
|
47 |
-
array(
|
48 |
-
'label' => Mage::helper('db1_anymarket')->__('Code Anymarket'),
|
49 |
-
'name' => 'nmo_id_anymarket',
|
50 |
-
'required' => true,
|
51 |
-
'class' => 'required-entry',
|
52 |
-
|
53 |
-
)
|
54 |
-
);
|
55 |
-
|
56 |
-
$fieldset->addField(
|
57 |
-
'nmo_id_order',
|
58 |
-
'text',
|
59 |
-
array(
|
60 |
-
'label' => Mage::helper('db1_anymarket')->__('Code Order Magento'),
|
61 |
-
'name' => 'nmo_id_order',
|
62 |
-
'required' => true,
|
63 |
-
'class' => 'required-entry',
|
64 |
-
|
65 |
-
)
|
66 |
-
);
|
67 |
-
$fieldset->addField(
|
68 |
-
'status',
|
69 |
-
'select',
|
70 |
-
array(
|
71 |
-
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
72 |
-
'name' => 'status',
|
73 |
-
'values' => array(
|
74 |
-
array(
|
75 |
-
'value' => 1,
|
76 |
-
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
77 |
-
),
|
78 |
-
array(
|
79 |
-
'value' => 0,
|
80 |
-
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
81 |
-
),
|
82 |
-
),
|
83 |
-
)
|
84 |
-
);
|
85 |
-
if (Mage::app()->isSingleStoreMode()) {
|
86 |
-
$fieldset->addField(
|
87 |
-
'store_id',
|
88 |
-
'hidden',
|
89 |
-
array(
|
90 |
-
'name' => 'stores[]',
|
91 |
-
'value' => Mage::app()->getStore(true)->getId()
|
92 |
-
)
|
93 |
-
);
|
94 |
-
Mage::registry('current_anymarketorders')->setStoreId(Mage::app()->getStore(true)->getId());
|
95 |
-
}
|
96 |
-
$formValues = Mage::registry('current_anymarketorders')->getDefaultValues();
|
97 |
-
if (!is_array($formValues)) {
|
98 |
-
$formValues = array();
|
99 |
-
}
|
100 |
-
if (Mage::getSingleton('adminhtml/session')->getAnymarketordersData()) {
|
101 |
-
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketordersData());
|
102 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketordersData(null);
|
103 |
-
} elseif (Mage::registry('current_anymarketorders')) {
|
104 |
-
$formValues = array_merge($formValues, Mage::registry('current_anymarketorders')->getData());
|
105 |
-
}
|
106 |
-
$form->setValues($formValues);
|
107 |
-
return parent::_prepareForm();
|
108 |
-
}
|
109 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders edit form tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Form
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setHtmlIdPrefix('anymarketorders_');
|
37 |
+
$form->setFieldNameSuffix('anymarketorders');
|
38 |
+
$this->setForm($form);
|
39 |
+
$fieldset = $form->addFieldset(
|
40 |
+
'anymarketorders_form',
|
41 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Orders'))
|
42 |
+
);
|
43 |
+
|
44 |
+
$fieldset->addField(
|
45 |
+
'nmo_id_anymarket',
|
46 |
+
'text',
|
47 |
+
array(
|
48 |
+
'label' => Mage::helper('db1_anymarket')->__('Code Anymarket'),
|
49 |
+
'name' => 'nmo_id_anymarket',
|
50 |
+
'required' => true,
|
51 |
+
'class' => 'required-entry',
|
52 |
+
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
$fieldset->addField(
|
57 |
+
'nmo_id_order',
|
58 |
+
'text',
|
59 |
+
array(
|
60 |
+
'label' => Mage::helper('db1_anymarket')->__('Code Order Magento'),
|
61 |
+
'name' => 'nmo_id_order',
|
62 |
+
'required' => true,
|
63 |
+
'class' => 'required-entry',
|
64 |
+
|
65 |
+
)
|
66 |
+
);
|
67 |
+
$fieldset->addField(
|
68 |
+
'status',
|
69 |
+
'select',
|
70 |
+
array(
|
71 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
72 |
+
'name' => 'status',
|
73 |
+
'values' => array(
|
74 |
+
array(
|
75 |
+
'value' => 1,
|
76 |
+
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'value' => 0,
|
80 |
+
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
81 |
+
),
|
82 |
+
),
|
83 |
+
)
|
84 |
+
);
|
85 |
+
if (Mage::app()->isSingleStoreMode()) {
|
86 |
+
$fieldset->addField(
|
87 |
+
'store_id',
|
88 |
+
'hidden',
|
89 |
+
array(
|
90 |
+
'name' => 'stores[]',
|
91 |
+
'value' => Mage::app()->getStore(true)->getId()
|
92 |
+
)
|
93 |
+
);
|
94 |
+
Mage::registry('current_anymarketorders')->setStoreId(Mage::app()->getStore(true)->getId());
|
95 |
+
}
|
96 |
+
$formValues = Mage::registry('current_anymarketorders')->getDefaultValues();
|
97 |
+
if (!is_array($formValues)) {
|
98 |
+
$formValues = array();
|
99 |
+
}
|
100 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketordersData()) {
|
101 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketordersData());
|
102 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketordersData(null);
|
103 |
+
} elseif (Mage::registry('current_anymarketorders')) {
|
104 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketorders')->getData());
|
105 |
+
}
|
106 |
+
$form->setValues($formValues);
|
107 |
+
return parent::_prepareForm();
|
108 |
+
}
|
109 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Stores.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* store selection tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Stores
|
31 |
-
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setFieldNameSuffix('anymarketorders');
|
37 |
-
$this->setForm($form);
|
38 |
-
$fieldset = $form->addFieldset(
|
39 |
-
'anymarketorders_stores_form',
|
40 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
-
);
|
42 |
-
$field = $fieldset->addField(
|
43 |
-
'store_id',
|
44 |
-
'multiselect',
|
45 |
-
array(
|
46 |
-
'name' => 'stores[]',
|
47 |
-
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
-
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
-
'required' => true,
|
50 |
-
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
-
)
|
52 |
-
);
|
53 |
-
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
-
$field->setRenderer($renderer);
|
55 |
-
$form->addValues(Mage::registry('current_anymarketorders')->getData());
|
56 |
-
return parent::_prepareForm();
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* store selection tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tab_Stores
|
31 |
+
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setFieldNameSuffix('anymarketorders');
|
37 |
+
$this->setForm($form);
|
38 |
+
$fieldset = $form->addFieldset(
|
39 |
+
'anymarketorders_stores_form',
|
40 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
+
);
|
42 |
+
$field = $fieldset->addField(
|
43 |
+
'store_id',
|
44 |
+
'multiselect',
|
45 |
+
array(
|
46 |
+
'name' => 'stores[]',
|
47 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
+
'required' => true,
|
50 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
+
$field->setRenderer($renderer);
|
55 |
+
$form->addValues(Mage::registry('current_anymarketorders')->getData());
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tabs.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders admin edit tabs
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Initialize Tabs
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketorders_tabs');
|
36 |
-
$this->setDestElementId('edit_form');
|
37 |
-
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Orders'));
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* before render html
|
42 |
-
*
|
43 |
-
* @access protected
|
44 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tabs
|
45 |
-
|
46 |
-
*/
|
47 |
-
protected function _beforeToHtml()
|
48 |
-
{
|
49 |
-
$this->addTab(
|
50 |
-
'form_anymarketorders',
|
51 |
-
array(
|
52 |
-
'label' => Mage::helper('db1_anymarket')->__('Anymarket Orders'),
|
53 |
-
'title' => Mage::helper('db1_anymarket')->__('Anymarket Orders'),
|
54 |
-
'content' => $this->getLayout()->createBlock(
|
55 |
-
'db1_anymarket/adminhtml_anymarketorders_edit_tab_form'
|
56 |
-
)
|
57 |
-
->toHtml(),
|
58 |
-
)
|
59 |
-
);
|
60 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
-
$this->addTab(
|
62 |
-
'form_store_anymarketorders',
|
63 |
-
array(
|
64 |
-
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
-
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
-
'content' => $this->getLayout()->createBlock(
|
67 |
-
'db1_anymarket/adminhtml_anymarketorders_edit_tab_stores'
|
68 |
-
)
|
69 |
-
->toHtml(),
|
70 |
-
)
|
71 |
-
);
|
72 |
-
}
|
73 |
-
return parent::_beforeToHtml();
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Retrieve anymarket orders entity
|
78 |
-
*
|
79 |
-
* @access public
|
80 |
-
* @return DB1_AnyMarket_Model_Anymarketorders
|
81 |
-
|
82 |
-
*/
|
83 |
-
public function getAnymarketorders()
|
84 |
-
{
|
85 |
-
return Mage::registry('current_anymarketorders');
|
86 |
-
}
|
87 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders admin edit tabs
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Initialize Tabs
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketorders_tabs');
|
36 |
+
$this->setDestElementId('edit_form');
|
37 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Orders'));
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* before render html
|
42 |
+
*
|
43 |
+
* @access protected
|
44 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Edit_Tabs
|
45 |
+
|
46 |
+
*/
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
$this->addTab(
|
50 |
+
'form_anymarketorders',
|
51 |
+
array(
|
52 |
+
'label' => Mage::helper('db1_anymarket')->__('Anymarket Orders'),
|
53 |
+
'title' => Mage::helper('db1_anymarket')->__('Anymarket Orders'),
|
54 |
+
'content' => $this->getLayout()->createBlock(
|
55 |
+
'db1_anymarket/adminhtml_anymarketorders_edit_tab_form'
|
56 |
+
)
|
57 |
+
->toHtml(),
|
58 |
+
)
|
59 |
+
);
|
60 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
+
$this->addTab(
|
62 |
+
'form_store_anymarketorders',
|
63 |
+
array(
|
64 |
+
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
+
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
+
'content' => $this->getLayout()->createBlock(
|
67 |
+
'db1_anymarket/adminhtml_anymarketorders_edit_tab_stores'
|
68 |
+
)
|
69 |
+
->toHtml(),
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
return parent::_beforeToHtml();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Retrieve anymarket orders entity
|
78 |
+
*
|
79 |
+
* @access public
|
80 |
+
* @return DB1_AnyMarket_Model_Anymarketorders
|
81 |
+
|
82 |
+
*/
|
83 |
+
public function getAnymarketorders()
|
84 |
+
{
|
85 |
+
return Mage::registry('current_anymarketorders');
|
86 |
+
}
|
87 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Grid.php
CHANGED
@@ -1,242 +1,254 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders admin grid block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketordersGrid');
|
36 |
-
$this->setDefaultSort('entity_id');
|
37 |
-
$this->setDefaultDir('
|
38 |
-
$this->setSaveParametersInSession(true);
|
39 |
-
$this->setUseAjax(true);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* get current store scope
|
44 |
-
*
|
45 |
-
* @access protected
|
46 |
-
* @return store view
|
47 |
-
|
48 |
-
*/
|
49 |
-
protected function _getStore()
|
50 |
-
{
|
51 |
-
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
-
return Mage::app()->getStore($storeId);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* prepare collection
|
57 |
-
*
|
58 |
-
* @access protected
|
59 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid
|
60 |
-
|
61 |
-
*/
|
62 |
-
protected function _prepareCollection()
|
63 |
-
{
|
64 |
-
$store_id = $this->_getStore();
|
65 |
-
Mage::app()->setCurrentStore($store_id);
|
66 |
-
$store_id = Mage::app()->getStore()->getId();
|
67 |
-
Mage::getSingleton('core/session')->setStoreListOrderVariable($store_id);
|
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 |
-
$this->addExportType('*/*/
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
*
|
161 |
-
*
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$this->getMassactionBlock()->
|
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 |
-
* @access
|
216 |
-
* @return
|
217 |
-
|
218 |
-
*/
|
219 |
-
|
220 |
-
{
|
221 |
-
$this->
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
*
|
227 |
-
*
|
228 |
-
* @
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketordersGrid');
|
36 |
+
$this->setDefaultSort('entity_id');
|
37 |
+
$this->setDefaultDir('DESC');
|
38 |
+
$this->setSaveParametersInSession(true);
|
39 |
+
$this->setUseAjax(true);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* get current store scope
|
44 |
+
*
|
45 |
+
* @access protected
|
46 |
+
* @return store view
|
47 |
+
|
48 |
+
*/
|
49 |
+
protected function _getStore()
|
50 |
+
{
|
51 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
+
return Mage::app()->getStore($storeId);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* prepare collection
|
57 |
+
*
|
58 |
+
* @access protected
|
59 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid
|
60 |
+
|
61 |
+
*/
|
62 |
+
protected function _prepareCollection()
|
63 |
+
{
|
64 |
+
$store_id = $this->_getStore();
|
65 |
+
Mage::app()->setCurrentStore($store_id);
|
66 |
+
$store_id = Mage::app()->getStore()->getId();
|
67 |
+
Mage::getSingleton('core/session')->setStoreListOrderVariable($store_id);
|
68 |
+
|
69 |
+
$collection = Mage::getModel('db1_anymarket/anymarketorders')
|
70 |
+
->getCollection()
|
71 |
+
->setOrder('entity_id','DESC');
|
72 |
+
|
73 |
+
$this->setCollection($collection);
|
74 |
+
return parent::_prepareCollection();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* prepare grid collection
|
79 |
+
*
|
80 |
+
* @access protected
|
81 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid
|
82 |
+
|
83 |
+
*/
|
84 |
+
protected function _prepareColumns()
|
85 |
+
{
|
86 |
+
$this->addColumn(
|
87 |
+
'nmo_id_order',
|
88 |
+
array(
|
89 |
+
'header' => Mage::helper('db1_anymarket')->__('Code Order Magento'),
|
90 |
+
'align' => 'left',
|
91 |
+
'index' => 'nmo_id_order',
|
92 |
+
)
|
93 |
+
);
|
94 |
+
$this->addColumn(
|
95 |
+
'nmo_id_anymarket',
|
96 |
+
array(
|
97 |
+
'header' => Mage::helper('db1_anymarket')->__('Code Anymarket'),
|
98 |
+
'index' => 'nmo_id_anymarket',
|
99 |
+
'type'=> 'text',
|
100 |
+
|
101 |
+
)
|
102 |
+
);
|
103 |
+
$this->addColumn(
|
104 |
+
'nmo_status_int',
|
105 |
+
array(
|
106 |
+
'header' => Mage::helper('db1_anymarket')->__('Integration status'),
|
107 |
+
'index' => 'nmo_status_int',
|
108 |
+
'type'=> 'text',
|
109 |
+
|
110 |
+
)
|
111 |
+
);
|
112 |
+
$this->addColumn(
|
113 |
+
'nmo_desc_error',
|
114 |
+
array(
|
115 |
+
'header' => Mage::helper('db1_anymarket')->__('Error Message'),
|
116 |
+
'index' => 'nmo_desc_error',
|
117 |
+
'type'=> 'text',
|
118 |
+
|
119 |
+
)
|
120 |
+
);
|
121 |
+
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
122 |
+
$this->addColumn(
|
123 |
+
'store_id',
|
124 |
+
array(
|
125 |
+
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
126 |
+
'index' => 'store_id',
|
127 |
+
'type' => 'store',
|
128 |
+
'store_all' => true,
|
129 |
+
'store_view' => true,
|
130 |
+
'sortable' => false,
|
131 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
132 |
+
)
|
133 |
+
);
|
134 |
+
}
|
135 |
+
$this->addColumn(
|
136 |
+
'created_at',
|
137 |
+
array(
|
138 |
+
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
139 |
+
'index' => 'created_at',
|
140 |
+
'width' => '120px',
|
141 |
+
'type' => 'datetime',
|
142 |
+
)
|
143 |
+
);
|
144 |
+
$this->addColumn(
|
145 |
+
'updated_at',
|
146 |
+
array(
|
147 |
+
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
148 |
+
'index' => 'updated_at',
|
149 |
+
'width' => '120px',
|
150 |
+
'type' => 'datetime',
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
154 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
155 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
156 |
+
return parent::_prepareColumns();
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* prepare mass action
|
161 |
+
*
|
162 |
+
* @access protected
|
163 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid
|
164 |
+
|
165 |
+
*/
|
166 |
+
protected function _prepareMassaction()
|
167 |
+
{
|
168 |
+
|
169 |
+
$this->setMassactionIdField('entity_id');
|
170 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketorders');
|
171 |
+
|
172 |
+
$this->getMassactionBlock()->addItem(
|
173 |
+
'sincronizar',
|
174 |
+
array(
|
175 |
+
'label'=> Mage::helper('db1_anymarket')->__('Synchronize'),
|
176 |
+
'url' => $this->getUrl('*/*/massSincOrder'),
|
177 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure you want to sync?')
|
178 |
+
)
|
179 |
+
);
|
180 |
+
|
181 |
+
|
182 |
+
$this->getMassactionBlock()->addItem(
|
183 |
+
'delete',
|
184 |
+
array(
|
185 |
+
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
186 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
187 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Os itens deletados irão ser gravados nos logs?')
|
188 |
+
)
|
189 |
+
);
|
190 |
+
|
191 |
+
return $this;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* get the row url
|
196 |
+
*
|
197 |
+
* @access public
|
198 |
+
* @param DB1_AnyMarket_Model_Anymarketorders
|
199 |
+
* @return string
|
200 |
+
|
201 |
+
*/
|
202 |
+
public function getRowUrl($row)
|
203 |
+
{
|
204 |
+
$_pullOrder = Mage::getModel('sales/order')->loadByIncrementId( $row->getNmoIdOrder() );
|
205 |
+
if($_pullOrder != null){
|
206 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array('order_id' => $_pullOrder->getId()));
|
207 |
+
}else{
|
208 |
+
return null;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* get the grid url
|
214 |
+
*
|
215 |
+
* @access public
|
216 |
+
* @return string
|
217 |
+
|
218 |
+
*/
|
219 |
+
public function getGridUrl()
|
220 |
+
{
|
221 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* after collection load
|
226 |
+
*
|
227 |
+
* @access protected
|
228 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid
|
229 |
+
|
230 |
+
*/
|
231 |
+
protected function _afterLoadCollection()
|
232 |
+
{
|
233 |
+
$this->getCollection()->walk('afterLoad');
|
234 |
+
parent::_afterLoadCollection();
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* filter store column
|
239 |
+
*
|
240 |
+
* @access protected
|
241 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketorders_Collection $collection
|
242 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
243 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketorders_Grid
|
244 |
+
|
245 |
+
*/
|
246 |
+
protected function _filterStoreCondition($collection, $column)
|
247 |
+
{
|
248 |
+
if (!$value = $column->getFilter()->getValue()) {
|
249 |
+
return;
|
250 |
+
}
|
251 |
+
$collection->addStoreFilter($value);
|
252 |
+
return $this;
|
253 |
+
}
|
254 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts.php
CHANGED
@@ -1,53 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products admin block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
$this->_controller = 'adminhtml_anymarketproducts';
|
35 |
-
$this->_blockGroup = 'db1_anymarket';
|
36 |
-
parent::__construct();
|
37 |
-
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Products');
|
38 |
-
$this->_removeButton('add');
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
'onclick' => "setLocation('{$this->getUrl('*/*/listProds')}')",
|
49 |
-
'class' => 'add'
|
50 |
-
));
|
51 |
-
|
52 |
-
}
|
53 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts extends Mage_Adminhtml_Block_Widget_Grid_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->_controller = 'adminhtml_anymarketproducts';
|
35 |
+
$this->_blockGroup = 'db1_anymarket';
|
36 |
+
parent::__construct();
|
37 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Products');
|
38 |
+
$this->_removeButton('add');
|
39 |
+
|
40 |
+
$this->_addButton('list_prods', array(
|
41 |
+
'label' => Mage::helper('db1_anymarket')->__('Products list'),
|
42 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/listProds')}')",
|
43 |
+
'class' => 'add'
|
44 |
+
));
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit.php
CHANGED
@@ -1,82 +1,82 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products admin edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return void
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
public function __construct()
|
34 |
-
{
|
35 |
-
parent::__construct();
|
36 |
-
$this->_blockGroup = 'db1_anymarket';
|
37 |
-
$this->_controller = 'adminhtml_anymarketproducts';
|
38 |
-
$this->_updateButton(
|
39 |
-
'save',
|
40 |
-
'label',
|
41 |
-
Mage::helper('db1_anymarket')->__('Save Anymarket Products')
|
42 |
-
);
|
43 |
-
$this->_updateButton(
|
44 |
-
'delete',
|
45 |
-
'label',
|
46 |
-
Mage::helper('db1_anymarket')->__('Delete Anymarket Products')
|
47 |
-
);
|
48 |
-
$this->_addButton(
|
49 |
-
'saveandcontinue',
|
50 |
-
array(
|
51 |
-
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
-
'onclick' => 'saveAndContinueEdit()',
|
53 |
-
'class' => 'save',
|
54 |
-
),
|
55 |
-
-100
|
56 |
-
);
|
57 |
-
$this->_formScripts[] = "
|
58 |
-
function saveAndContinueEdit() {
|
59 |
-
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
-
}
|
61 |
-
";
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* get the edit form header
|
66 |
-
*
|
67 |
-
* @access public
|
68 |
-
* @return string
|
69 |
-
*
|
70 |
-
*/
|
71 |
-
public function getHeaderText()
|
72 |
-
{
|
73 |
-
if (Mage::registry('current_anymarketproducts') && Mage::registry('current_anymarketproducts')->getId()) {
|
74 |
-
return Mage::helper('db1_anymarket')->__(
|
75 |
-
"Edit Anymarket Products '%s'",
|
76 |
-
$this->escapeHtml(Mage::registry('current_anymarketproducts')->getNmpDescError())
|
77 |
-
);
|
78 |
-
} else {
|
79 |
-
return Mage::helper('db1_anymarket')->__('Add Anymarket Products');
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products admin edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return void
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function __construct()
|
34 |
+
{
|
35 |
+
parent::__construct();
|
36 |
+
$this->_blockGroup = 'db1_anymarket';
|
37 |
+
$this->_controller = 'adminhtml_anymarketproducts';
|
38 |
+
$this->_updateButton(
|
39 |
+
'save',
|
40 |
+
'label',
|
41 |
+
Mage::helper('db1_anymarket')->__('Save Anymarket Products')
|
42 |
+
);
|
43 |
+
$this->_updateButton(
|
44 |
+
'delete',
|
45 |
+
'label',
|
46 |
+
Mage::helper('db1_anymarket')->__('Delete Anymarket Products')
|
47 |
+
);
|
48 |
+
$this->_addButton(
|
49 |
+
'saveandcontinue',
|
50 |
+
array(
|
51 |
+
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
52 |
+
'onclick' => 'saveAndContinueEdit()',
|
53 |
+
'class' => 'save',
|
54 |
+
),
|
55 |
+
-100
|
56 |
+
);
|
57 |
+
$this->_formScripts[] = "
|
58 |
+
function saveAndContinueEdit() {
|
59 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
60 |
+
}
|
61 |
+
";
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* get the edit form header
|
66 |
+
*
|
67 |
+
* @access public
|
68 |
+
* @return string
|
69 |
+
*
|
70 |
+
*/
|
71 |
+
public function getHeaderText()
|
72 |
+
{
|
73 |
+
if (Mage::registry('current_anymarketproducts') && Mage::registry('current_anymarketproducts')->getId()) {
|
74 |
+
return Mage::helper('db1_anymarket')->__(
|
75 |
+
"Edit Anymarket Products '%s'",
|
76 |
+
$this->escapeHtml(Mage::registry('current_anymarketproducts')->getNmpDescError())
|
77 |
+
);
|
78 |
+
} else {
|
79 |
+
return Mage::helper('db1_anymarket')->__('Add Anymarket Products');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Form.php
CHANGED
@@ -1,52 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Form
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form(
|
36 |
-
array(
|
37 |
-
'id' => 'edit_form',
|
38 |
-
'action' => $this->getUrl(
|
39 |
-
'*/*/save',
|
40 |
-
array(
|
41 |
-
'id' => $this->getRequest()->getParam('id')
|
42 |
-
)
|
43 |
-
),
|
44 |
-
'method' => 'post',
|
45 |
-
'enctype' => 'multipart/form-data'
|
46 |
-
)
|
47 |
-
);
|
48 |
-
$form->setUseContainer(true);
|
49 |
-
$this->setForm($form);
|
50 |
-
return parent::_prepareForm();
|
51 |
-
}
|
52 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Form
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form(
|
36 |
+
array(
|
37 |
+
'id' => 'edit_form',
|
38 |
+
'action' => $this->getUrl(
|
39 |
+
'*/*/save',
|
40 |
+
array(
|
41 |
+
'id' => $this->getRequest()->getParam('id')
|
42 |
+
)
|
43 |
+
),
|
44 |
+
'method' => 'post',
|
45 |
+
'enctype' => 'multipart/form-data'
|
46 |
+
)
|
47 |
+
);
|
48 |
+
$form->setUseContainer(true);
|
49 |
+
$this->setForm($form);
|
50 |
+
return parent::_prepareForm();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Form.php
CHANGED
@@ -1,132 +1,132 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products edit form tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Form
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setHtmlIdPrefix('anymarketproducts_');
|
37 |
-
$form->setFieldNameSuffix('anymarketproducts');
|
38 |
-
$this->setForm($form);
|
39 |
-
$fieldset = $form->addFieldset(
|
40 |
-
'anymarketproducts_form',
|
41 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Products'))
|
42 |
-
);
|
43 |
-
|
44 |
-
$fieldset->addField(
|
45 |
-
'nmp_sku',
|
46 |
-
'text',
|
47 |
-
array(
|
48 |
-
'label' => Mage::helper('db1_anymarket')->__('Product SKU'),
|
49 |
-
'name' => 'nmp_sku',
|
50 |
-
'required' => true,
|
51 |
-
'class' => 'required-entry',
|
52 |
-
|
53 |
-
)
|
54 |
-
);
|
55 |
-
|
56 |
-
$fieldset->addField(
|
57 |
-
'nmp_name',
|
58 |
-
'text',
|
59 |
-
array(
|
60 |
-
'label' => Mage::helper('db1_anymarket')->__('Product Name'),
|
61 |
-
'name' => 'nmp_name',
|
62 |
-
'required' => true,
|
63 |
-
'class' => 'required-entry',
|
64 |
-
|
65 |
-
)
|
66 |
-
);
|
67 |
-
|
68 |
-
$fieldset->addField(
|
69 |
-
'nmp_desc_error',
|
70 |
-
'text',
|
71 |
-
array(
|
72 |
-
'label' => Mage::helper('db1_anymarket')->__('Error Description'),
|
73 |
-
'name' => 'nmp_desc_error',
|
74 |
-
'required' => true,
|
75 |
-
'class' => 'required-entry',
|
76 |
-
|
77 |
-
)
|
78 |
-
);
|
79 |
-
$fieldset->addField(
|
80 |
-
'nmp_status_int',
|
81 |
-
'text',
|
82 |
-
array(
|
83 |
-
'label' => Mage::helper('db1_anymarket')->__('Integration status'),
|
84 |
-
'name' => 'nmp_status_int',
|
85 |
-
'required' => true,
|
86 |
-
'class' => 'required-entry',
|
87 |
-
|
88 |
-
)
|
89 |
-
);
|
90 |
-
$fieldset->addField(
|
91 |
-
'status',
|
92 |
-
'select',
|
93 |
-
array(
|
94 |
-
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
95 |
-
'name' => 'status',
|
96 |
-
'values' => array(
|
97 |
-
array(
|
98 |
-
'value' => 1,
|
99 |
-
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
100 |
-
),
|
101 |
-
array(
|
102 |
-
'value' => 0,
|
103 |
-
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
104 |
-
),
|
105 |
-
),
|
106 |
-
)
|
107 |
-
);
|
108 |
-
if (Mage::app()->isSingleStoreMode()) {
|
109 |
-
$fieldset->addField(
|
110 |
-
'store_id',
|
111 |
-
'hidden',
|
112 |
-
array(
|
113 |
-
'name' => 'stores[]',
|
114 |
-
'value' => Mage::app()->getStore(true)->getId()
|
115 |
-
)
|
116 |
-
);
|
117 |
-
Mage::registry('current_anymarketproducts')->setStoreId(Mage::app()->getStore(true)->getId());
|
118 |
-
}
|
119 |
-
$formValues = Mage::registry('current_anymarketproducts')->getDefaultValues();
|
120 |
-
if (!is_array($formValues)) {
|
121 |
-
$formValues = array();
|
122 |
-
}
|
123 |
-
if (Mage::getSingleton('adminhtml/session')->getAnymarketproductsData()) {
|
124 |
-
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketproductsData());
|
125 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketproductsData(null);
|
126 |
-
} elseif (Mage::registry('current_anymarketproducts')) {
|
127 |
-
$formValues = array_merge($formValues, Mage::registry('current_anymarketproducts')->getData());
|
128 |
-
}
|
129 |
-
$form->setValues($formValues);
|
130 |
-
return parent::_prepareForm();
|
131 |
-
}
|
132 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products edit form tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Form
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setHtmlIdPrefix('anymarketproducts_');
|
37 |
+
$form->setFieldNameSuffix('anymarketproducts');
|
38 |
+
$this->setForm($form);
|
39 |
+
$fieldset = $form->addFieldset(
|
40 |
+
'anymarketproducts_form',
|
41 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Products'))
|
42 |
+
);
|
43 |
+
|
44 |
+
$fieldset->addField(
|
45 |
+
'nmp_sku',
|
46 |
+
'text',
|
47 |
+
array(
|
48 |
+
'label' => Mage::helper('db1_anymarket')->__('Product SKU'),
|
49 |
+
'name' => 'nmp_sku',
|
50 |
+
'required' => true,
|
51 |
+
'class' => 'required-entry',
|
52 |
+
|
53 |
+
)
|
54 |
+
);
|
55 |
+
|
56 |
+
$fieldset->addField(
|
57 |
+
'nmp_name',
|
58 |
+
'text',
|
59 |
+
array(
|
60 |
+
'label' => Mage::helper('db1_anymarket')->__('Product Name'),
|
61 |
+
'name' => 'nmp_name',
|
62 |
+
'required' => true,
|
63 |
+
'class' => 'required-entry',
|
64 |
+
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$fieldset->addField(
|
69 |
+
'nmp_desc_error',
|
70 |
+
'text',
|
71 |
+
array(
|
72 |
+
'label' => Mage::helper('db1_anymarket')->__('Error Description'),
|
73 |
+
'name' => 'nmp_desc_error',
|
74 |
+
'required' => true,
|
75 |
+
'class' => 'required-entry',
|
76 |
+
|
77 |
+
)
|
78 |
+
);
|
79 |
+
$fieldset->addField(
|
80 |
+
'nmp_status_int',
|
81 |
+
'text',
|
82 |
+
array(
|
83 |
+
'label' => Mage::helper('db1_anymarket')->__('Integration status'),
|
84 |
+
'name' => 'nmp_status_int',
|
85 |
+
'required' => true,
|
86 |
+
'class' => 'required-entry',
|
87 |
+
|
88 |
+
)
|
89 |
+
);
|
90 |
+
$fieldset->addField(
|
91 |
+
'status',
|
92 |
+
'select',
|
93 |
+
array(
|
94 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
95 |
+
'name' => 'status',
|
96 |
+
'values' => array(
|
97 |
+
array(
|
98 |
+
'value' => 1,
|
99 |
+
'label' => Mage::helper('db1_anymarket')->__('Enabled'),
|
100 |
+
),
|
101 |
+
array(
|
102 |
+
'value' => 0,
|
103 |
+
'label' => Mage::helper('db1_anymarket')->__('Disabled'),
|
104 |
+
),
|
105 |
+
),
|
106 |
+
)
|
107 |
+
);
|
108 |
+
if (Mage::app()->isSingleStoreMode()) {
|
109 |
+
$fieldset->addField(
|
110 |
+
'store_id',
|
111 |
+
'hidden',
|
112 |
+
array(
|
113 |
+
'name' => 'stores[]',
|
114 |
+
'value' => Mage::app()->getStore(true)->getId()
|
115 |
+
)
|
116 |
+
);
|
117 |
+
Mage::registry('current_anymarketproducts')->setStoreId(Mage::app()->getStore(true)->getId());
|
118 |
+
}
|
119 |
+
$formValues = Mage::registry('current_anymarketproducts')->getDefaultValues();
|
120 |
+
if (!is_array($formValues)) {
|
121 |
+
$formValues = array();
|
122 |
+
}
|
123 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketproductsData()) {
|
124 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketproductsData());
|
125 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketproductsData(null);
|
126 |
+
} elseif (Mage::registry('current_anymarketproducts')) {
|
127 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketproducts')->getData());
|
128 |
+
}
|
129 |
+
$form->setValues($formValues);
|
130 |
+
return parent::_prepareForm();
|
131 |
+
}
|
132 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Stores.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* store selection tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* prepare the form
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Stores
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
protected function _prepareForm()
|
34 |
-
{
|
35 |
-
$form = new Varien_Data_Form();
|
36 |
-
$form->setFieldNameSuffix('anymarketproducts');
|
37 |
-
$this->setForm($form);
|
38 |
-
$fieldset = $form->addFieldset(
|
39 |
-
'anymarketproducts_stores_form',
|
40 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
-
);
|
42 |
-
$field = $fieldset->addField(
|
43 |
-
'store_id',
|
44 |
-
'multiselect',
|
45 |
-
array(
|
46 |
-
'name' => 'stores[]',
|
47 |
-
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
-
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
-
'required' => true,
|
50 |
-
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
-
)
|
52 |
-
);
|
53 |
-
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
-
$field->setRenderer($renderer);
|
55 |
-
$form->addValues(Mage::registry('current_anymarketproducts')->getData());
|
56 |
-
return parent::_prepareForm();
|
57 |
-
}
|
58 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* store selection tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* prepare the form
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tab_Stores
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
protected function _prepareForm()
|
34 |
+
{
|
35 |
+
$form = new Varien_Data_Form();
|
36 |
+
$form->setFieldNameSuffix('anymarketproducts');
|
37 |
+
$this->setForm($form);
|
38 |
+
$fieldset = $form->addFieldset(
|
39 |
+
'anymarketproducts_stores_form',
|
40 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
41 |
+
);
|
42 |
+
$field = $fieldset->addField(
|
43 |
+
'store_id',
|
44 |
+
'multiselect',
|
45 |
+
array(
|
46 |
+
'name' => 'stores[]',
|
47 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
49 |
+
'required' => true,
|
50 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
54 |
+
$field->setRenderer($renderer);
|
55 |
+
$form->addValues(Mage::registry('current_anymarketproducts')->getData());
|
56 |
+
return parent::_prepareForm();
|
57 |
+
}
|
58 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tabs.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products admin edit tabs
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Initialize Tabs
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
*
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketproducts_tabs');
|
36 |
-
$this->setDestElementId('edit_form');
|
37 |
-
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Products'));
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* before render html
|
42 |
-
*
|
43 |
-
* @access protected
|
44 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tabs
|
45 |
-
*
|
46 |
-
*/
|
47 |
-
protected function _beforeToHtml()
|
48 |
-
{
|
49 |
-
$this->addTab(
|
50 |
-
'form_anymarketproducts',
|
51 |
-
array(
|
52 |
-
'label' => Mage::helper('db1_anymarket')->__('Anymarket Products'),
|
53 |
-
'title' => Mage::helper('db1_anymarket')->__('Anymarket Products'),
|
54 |
-
'content' => $this->getLayout()->createBlock(
|
55 |
-
'db1_anymarket/adminhtml_anymarketproducts_edit_tab_form'
|
56 |
-
)
|
57 |
-
->toHtml(),
|
58 |
-
)
|
59 |
-
);
|
60 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
-
$this->addTab(
|
62 |
-
'form_store_anymarketproducts',
|
63 |
-
array(
|
64 |
-
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
-
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
-
'content' => $this->getLayout()->createBlock(
|
67 |
-
'db1_anymarket/adminhtml_anymarketproducts_edit_tab_stores'
|
68 |
-
)
|
69 |
-
->toHtml(),
|
70 |
-
)
|
71 |
-
);
|
72 |
-
}
|
73 |
-
return parent::_beforeToHtml();
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Retrieve anymarket products entity
|
78 |
-
*
|
79 |
-
* @access public
|
80 |
-
* @return DB1_AnyMarket_Model_Anymarketproducts
|
81 |
-
*
|
82 |
-
*/
|
83 |
-
public function getAnymarketproducts()
|
84 |
-
{
|
85 |
-
return Mage::registry('current_anymarketproducts');
|
86 |
-
}
|
87 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products admin edit tabs
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Initialize Tabs
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketproducts_tabs');
|
36 |
+
$this->setDestElementId('edit_form');
|
37 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Products'));
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* before render html
|
42 |
+
*
|
43 |
+
* @access protected
|
44 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Edit_Tabs
|
45 |
+
*
|
46 |
+
*/
|
47 |
+
protected function _beforeToHtml()
|
48 |
+
{
|
49 |
+
$this->addTab(
|
50 |
+
'form_anymarketproducts',
|
51 |
+
array(
|
52 |
+
'label' => Mage::helper('db1_anymarket')->__('Anymarket Products'),
|
53 |
+
'title' => Mage::helper('db1_anymarket')->__('Anymarket Products'),
|
54 |
+
'content' => $this->getLayout()->createBlock(
|
55 |
+
'db1_anymarket/adminhtml_anymarketproducts_edit_tab_form'
|
56 |
+
)
|
57 |
+
->toHtml(),
|
58 |
+
)
|
59 |
+
);
|
60 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
+
$this->addTab(
|
62 |
+
'form_store_anymarketproducts',
|
63 |
+
array(
|
64 |
+
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
+
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
66 |
+
'content' => $this->getLayout()->createBlock(
|
67 |
+
'db1_anymarket/adminhtml_anymarketproducts_edit_tab_stores'
|
68 |
+
)
|
69 |
+
->toHtml(),
|
70 |
+
)
|
71 |
+
);
|
72 |
+
}
|
73 |
+
return parent::_beforeToHtml();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Retrieve anymarket products entity
|
78 |
+
*
|
79 |
+
* @access public
|
80 |
+
* @return DB1_AnyMarket_Model_Anymarketproducts
|
81 |
+
*
|
82 |
+
*/
|
83 |
+
public function getAnymarketproducts()
|
84 |
+
{
|
85 |
+
return Mage::registry('current_anymarketproducts');
|
86 |
+
}
|
87 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Grid.php
CHANGED
@@ -1,271 +1,272 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products admin grid block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
*
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->setId('anymarketproductsGrid');
|
36 |
-
$this->setDefaultSort('entity_id');
|
37 |
-
$this->setDefaultDir('
|
38 |
-
$this->setSaveParametersInSession(true);
|
39 |
-
$this->setUseAjax(true);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* get current store scope
|
44 |
-
*
|
45 |
-
* @access protected
|
46 |
-
* @return store view
|
47 |
-
|
48 |
-
*/
|
49 |
-
protected function _getStore()
|
50 |
-
{
|
51 |
-
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
-
return Mage::app()->getStore($storeId);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* prepare collection
|
57 |
-
*
|
58 |
-
* @access protected
|
59 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid
|
60 |
-
*
|
61 |
-
*/
|
62 |
-
protected function _prepareCollection()
|
63 |
-
{
|
64 |
-
$store_id = $this->_getStore();
|
65 |
-
Mage::app()->setCurrentStore($store_id);
|
66 |
-
$store_id = Mage::app()->getStore()->getId();
|
67 |
-
Mage::getSingleton('core/session')->setStoreListProdVariable($store_id);
|
68 |
-
$collection = Mage::getModel('db1_anymarket/anymarketproducts')
|
69 |
-
->getCollection()
|
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 |
-
$this->addExportType('*/*/
|
164 |
-
$this->addExportType('*/*/
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
*
|
171 |
-
*
|
172 |
-
* @
|
173 |
-
*
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
$this->
|
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 |
-
* @param
|
260 |
-
* @
|
261 |
-
*
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
}
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setId('anymarketproductsGrid');
|
36 |
+
$this->setDefaultSort('entity_id');
|
37 |
+
$this->setDefaultDir('DESC');
|
38 |
+
$this->setSaveParametersInSession(true);
|
39 |
+
$this->setUseAjax(true);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* get current store scope
|
44 |
+
*
|
45 |
+
* @access protected
|
46 |
+
* @return store view
|
47 |
+
|
48 |
+
*/
|
49 |
+
protected function _getStore()
|
50 |
+
{
|
51 |
+
$storeId = (int) $this->getRequest()->getParam('store', 0);
|
52 |
+
return Mage::app()->getStore($storeId);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* prepare collection
|
57 |
+
*
|
58 |
+
* @access protected
|
59 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid
|
60 |
+
*
|
61 |
+
*/
|
62 |
+
protected function _prepareCollection()
|
63 |
+
{
|
64 |
+
$store_id = $this->_getStore();
|
65 |
+
Mage::app()->setCurrentStore($store_id);
|
66 |
+
$store_id = Mage::app()->getStore()->getId();
|
67 |
+
Mage::getSingleton('core/session')->setStoreListProdVariable($store_id);
|
68 |
+
$collection = Mage::getModel('db1_anymarket/anymarketproducts')
|
69 |
+
->getCollection()
|
70 |
+
->setOrder('entity_id','DESC');
|
71 |
+
|
72 |
+
$this->setCollection($collection);
|
73 |
+
return parent::_prepareCollection();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* prepare grid collection
|
78 |
+
*
|
79 |
+
* @access protected
|
80 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid
|
81 |
+
*
|
82 |
+
*/
|
83 |
+
protected function _prepareColumns()
|
84 |
+
{
|
85 |
+
$this->addColumn(
|
86 |
+
'nmp_sku',
|
87 |
+
array(
|
88 |
+
'header' => Mage::helper('db1_anymarket')->__('Product SKU'),
|
89 |
+
'index' => 'nmp_sku',
|
90 |
+
'type'=> 'text',
|
91 |
+
|
92 |
+
)
|
93 |
+
);
|
94 |
+
$this->addColumn(
|
95 |
+
'nmp_name',
|
96 |
+
array(
|
97 |
+
'header' => Mage::helper('db1_anymarket')->__('Product Name'),
|
98 |
+
'index' => 'nmp_name',
|
99 |
+
'type'=> 'text',
|
100 |
+
|
101 |
+
)
|
102 |
+
);
|
103 |
+
$this->addColumn(
|
104 |
+
'status',
|
105 |
+
array(
|
106 |
+
'header' => Mage::helper('db1_anymarket')->__('Will be integrated'),
|
107 |
+
'index' => 'status',
|
108 |
+
'type' => 'options',
|
109 |
+
'options' => array(
|
110 |
+
'1' => Mage::helper('db1_anymarket')->__('Yes'),
|
111 |
+
'0' => Mage::helper('db1_anymarket')->__('No'),
|
112 |
+
)
|
113 |
+
)
|
114 |
+
);
|
115 |
+
$this->addColumn(
|
116 |
+
'nmp_status_int',
|
117 |
+
array(
|
118 |
+
'header' => Mage::helper('db1_anymarket')->__('Integration status'),
|
119 |
+
'align' => 'left',
|
120 |
+
'index' => 'nmp_status_int',
|
121 |
+
)
|
122 |
+
);
|
123 |
+
$this->addColumn(
|
124 |
+
'nmp_desc_error',
|
125 |
+
array(
|
126 |
+
'header' => Mage::helper('db1_anymarket')->__('Integration message'),
|
127 |
+
'align' => 'left',
|
128 |
+
'index' => 'nmp_desc_error',
|
129 |
+
)
|
130 |
+
);
|
131 |
+
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
132 |
+
$this->addColumn(
|
133 |
+
'store_id',
|
134 |
+
array(
|
135 |
+
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
136 |
+
'index' => 'store_id',
|
137 |
+
'type' => 'store',
|
138 |
+
'store_all' => true,
|
139 |
+
'store_view' => true,
|
140 |
+
'sortable' => false,
|
141 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
142 |
+
)
|
143 |
+
);
|
144 |
+
}
|
145 |
+
$this->addColumn(
|
146 |
+
'created_at',
|
147 |
+
array(
|
148 |
+
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
149 |
+
'index' => 'created_at',
|
150 |
+
'width' => '120px',
|
151 |
+
'type' => 'datetime',
|
152 |
+
)
|
153 |
+
);
|
154 |
+
$this->addColumn(
|
155 |
+
'updated_at',
|
156 |
+
array(
|
157 |
+
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
158 |
+
'index' => 'updated_at',
|
159 |
+
'width' => '120px',
|
160 |
+
'type' => 'datetime',
|
161 |
+
)
|
162 |
+
);
|
163 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
164 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
165 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
166 |
+
return parent::_prepareColumns();
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* prepare mass action
|
171 |
+
*
|
172 |
+
* @access protected
|
173 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid
|
174 |
+
*
|
175 |
+
*/
|
176 |
+
protected function _prepareMassaction()
|
177 |
+
{
|
178 |
+
$this->setMassactionIdField('entity_id');
|
179 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketproducts');
|
180 |
+
|
181 |
+
$this->getMassactionBlock()->addItem(
|
182 |
+
'sincronizar',
|
183 |
+
array(
|
184 |
+
'label'=> Mage::helper('db1_anymarket')->__('Synchronize'),
|
185 |
+
'url' => $this->getUrl('*/*/massSincProduct'),
|
186 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure you want to sync?')
|
187 |
+
)
|
188 |
+
);
|
189 |
+
|
190 |
+
$this->getMassactionBlock()->addItem(
|
191 |
+
'status',
|
192 |
+
array(
|
193 |
+
'label' => Mage::helper('db1_anymarket')->__('Status change Integration'),
|
194 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
195 |
+
'additional' => array(
|
196 |
+
'status' => array(
|
197 |
+
'name' => 'status',
|
198 |
+
'type' => 'select',
|
199 |
+
'class' => 'required-entry',
|
200 |
+
'label' => Mage::helper('db1_anymarket')->__('Status'),
|
201 |
+
'values' => array(
|
202 |
+
'1' => Mage::helper('db1_anymarket')->__('Yes'),
|
203 |
+
'0' => Mage::helper('db1_anymarket')->__('No'),
|
204 |
+
)
|
205 |
+
)
|
206 |
+
)
|
207 |
+
)
|
208 |
+
);
|
209 |
+
return $this;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* get the row url
|
214 |
+
*
|
215 |
+
* @access public
|
216 |
+
* @param DB1_AnyMarket_Model_Anymarketproducts
|
217 |
+
* @return string
|
218 |
+
*
|
219 |
+
*/
|
220 |
+
public function getRowUrl($row)
|
221 |
+
{
|
222 |
+
$_pullProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', $row->getNmpSku());
|
223 |
+
if($_pullProduct != null){
|
224 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array('id' => $_pullProduct->getId()));
|
225 |
+
}else{
|
226 |
+
return null;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* get the grid url
|
232 |
+
*
|
233 |
+
* @access public
|
234 |
+
* @return string
|
235 |
+
*
|
236 |
+
*/
|
237 |
+
public function getGridUrl()
|
238 |
+
{
|
239 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* after collection load
|
244 |
+
*
|
245 |
+
* @access protected
|
246 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid
|
247 |
+
*
|
248 |
+
*/
|
249 |
+
protected function _afterLoadCollection()
|
250 |
+
{
|
251 |
+
$this->getCollection()->walk('afterLoad');
|
252 |
+
parent::_afterLoadCollection();
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* filter store column
|
257 |
+
*
|
258 |
+
* @access protected
|
259 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection $collection
|
260 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
261 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketproducts_Grid
|
262 |
+
*
|
263 |
+
*/
|
264 |
+
protected function _filterStoreCondition($collection, $column)
|
265 |
+
{
|
266 |
+
if (!$value = $column->getFilter()->getValue()) {
|
267 |
+
return;
|
268 |
+
}
|
269 |
+
$collection->addStoreFilter($value);
|
270 |
+
return $this;
|
271 |
+
}
|
272 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue.php
CHANGED
@@ -1,41 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue admin block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue extends Mage_Adminhtml_Block_Widget_Grid_Container
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* constructor
|
27 |
-
*
|
28 |
-
* @access public
|
29 |
-
* @return void
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
$this->_controller = 'adminhtml_anymarketqueue';
|
35 |
-
$this->_blockGroup = 'db1_anymarket';
|
36 |
-
parent::__construct();
|
37 |
-
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Queue');
|
38 |
-
$this->_removeButton('add');
|
39 |
-
|
40 |
-
|
41 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue admin block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue extends Mage_Adminhtml_Block_Widget_Grid_Container
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
* @return void
|
30 |
+
*
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
$this->_controller = 'adminhtml_anymarketqueue';
|
35 |
+
$this->_blockGroup = 'db1_anymarket';
|
36 |
+
parent::__construct();
|
37 |
+
$this->_headerText = Mage::helper('db1_anymarket')->__('Anymarket Queue');
|
38 |
+
$this->_removeButton('add');
|
39 |
+
|
40 |
+
$this->_addButton('proc_cron', array(
|
41 |
+
'label' => Mage::helper('db1_anymarket')->__('Process Queue'),
|
42 |
+
'onclick' => "setLocation('{$this->getUrl('*/*/procCron')}')",
|
43 |
+
'class' => 'scalable go'
|
44 |
+
));
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit.php
CHANGED
@@ -1,81 +1,81 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue admin edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* constructor
|
27 |
-
*
|
28 |
-
* @access public
|
29 |
-
* @return void
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function __construct()
|
33 |
-
{
|
34 |
-
parent::__construct();
|
35 |
-
$this->_blockGroup = 'db1_anymarket';
|
36 |
-
$this->_controller = 'adminhtml_anymarketqueue';
|
37 |
-
$this->_updateButton(
|
38 |
-
'save',
|
39 |
-
'label',
|
40 |
-
Mage::helper('db1_anymarket')->__('Save Anymarket Queue')
|
41 |
-
);
|
42 |
-
$this->_updateButton(
|
43 |
-
'delete',
|
44 |
-
'label',
|
45 |
-
Mage::helper('db1_anymarket')->__('Delete Anymarket Queue')
|
46 |
-
);
|
47 |
-
$this->_addButton(
|
48 |
-
'saveandcontinue',
|
49 |
-
array(
|
50 |
-
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
51 |
-
'onclick' => 'saveAndContinueEdit()',
|
52 |
-
'class' => 'save',
|
53 |
-
),
|
54 |
-
-100
|
55 |
-
);
|
56 |
-
$this->_formScripts[] = "
|
57 |
-
function saveAndContinueEdit() {
|
58 |
-
editForm.submit($('edit_form').action+'back/edit/');
|
59 |
-
}
|
60 |
-
";
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* get the edit form header
|
65 |
-
*
|
66 |
-
* @access public
|
67 |
-
* @return string
|
68 |
-
|
69 |
-
*/
|
70 |
-
public function getHeaderText()
|
71 |
-
{
|
72 |
-
if (Mage::registry('current_anymarketqueue') && Mage::registry('current_anymarketqueue')->getId()) {
|
73 |
-
return Mage::helper('db1_anymarket')->__(
|
74 |
-
"Edit Anymarket Queue '%s'",
|
75 |
-
$this->escapeHtml(Mage::registry('current_anymarketqueue')->getNmqId())
|
76 |
-
);
|
77 |
-
} else {
|
78 |
-
return Mage::helper('db1_anymarket')->__('Add Anymarket Queue');
|
79 |
-
}
|
80 |
-
}
|
81 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue admin edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
* @return void
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->_blockGroup = 'db1_anymarket';
|
36 |
+
$this->_controller = 'adminhtml_anymarketqueue';
|
37 |
+
$this->_updateButton(
|
38 |
+
'save',
|
39 |
+
'label',
|
40 |
+
Mage::helper('db1_anymarket')->__('Save Anymarket Queue')
|
41 |
+
);
|
42 |
+
$this->_updateButton(
|
43 |
+
'delete',
|
44 |
+
'label',
|
45 |
+
Mage::helper('db1_anymarket')->__('Delete Anymarket Queue')
|
46 |
+
);
|
47 |
+
$this->_addButton(
|
48 |
+
'saveandcontinue',
|
49 |
+
array(
|
50 |
+
'label' => Mage::helper('db1_anymarket')->__('Save And Continue Edit'),
|
51 |
+
'onclick' => 'saveAndContinueEdit()',
|
52 |
+
'class' => 'save',
|
53 |
+
),
|
54 |
+
-100
|
55 |
+
);
|
56 |
+
$this->_formScripts[] = "
|
57 |
+
function saveAndContinueEdit() {
|
58 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
59 |
+
}
|
60 |
+
";
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* get the edit form header
|
65 |
+
*
|
66 |
+
* @access public
|
67 |
+
* @return string
|
68 |
+
|
69 |
+
*/
|
70 |
+
public function getHeaderText()
|
71 |
+
{
|
72 |
+
if (Mage::registry('current_anymarketqueue') && Mage::registry('current_anymarketqueue')->getId()) {
|
73 |
+
return Mage::helper('db1_anymarket')->__(
|
74 |
+
"Edit Anymarket Queue '%s'",
|
75 |
+
$this->escapeHtml(Mage::registry('current_anymarketqueue')->getNmqId())
|
76 |
+
);
|
77 |
+
} else {
|
78 |
+
return Mage::helper('db1_anymarket')->__('Add Anymarket Queue');
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Form.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue edit form
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* prepare form
|
27 |
-
*
|
28 |
-
* @access protected
|
29 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Form
|
30 |
-
|
31 |
-
*/
|
32 |
-
protected function _prepareForm()
|
33 |
-
{
|
34 |
-
$form = new Varien_Data_Form(
|
35 |
-
array(
|
36 |
-
'id' => 'edit_form',
|
37 |
-
'action' => $this->getUrl(
|
38 |
-
'*/*/save',
|
39 |
-
array(
|
40 |
-
'id' => $this->getRequest()->getParam('id')
|
41 |
-
)
|
42 |
-
),
|
43 |
-
'method' => 'post',
|
44 |
-
'enctype' => 'multipart/form-data'
|
45 |
-
)
|
46 |
-
);
|
47 |
-
$form->setUseContainer(true);
|
48 |
-
$this->setForm($form);
|
49 |
-
return parent::_prepareForm();
|
50 |
-
}
|
51 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue edit form
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* prepare form
|
27 |
+
*
|
28 |
+
* @access protected
|
29 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Form
|
30 |
+
|
31 |
+
*/
|
32 |
+
protected function _prepareForm()
|
33 |
+
{
|
34 |
+
$form = new Varien_Data_Form(
|
35 |
+
array(
|
36 |
+
'id' => 'edit_form',
|
37 |
+
'action' => $this->getUrl(
|
38 |
+
'*/*/save',
|
39 |
+
array(
|
40 |
+
'id' => $this->getRequest()->getParam('id')
|
41 |
+
)
|
42 |
+
),
|
43 |
+
'method' => 'post',
|
44 |
+
'enctype' => 'multipart/form-data'
|
45 |
+
)
|
46 |
+
);
|
47 |
+
$form->setUseContainer(true);
|
48 |
+
$this->setForm($form);
|
49 |
+
return parent::_prepareForm();
|
50 |
+
}
|
51 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Form.php
CHANGED
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue edit form tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* prepare the form
|
27 |
-
*
|
28 |
-
* @access protected
|
29 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Form
|
30 |
-
|
31 |
-
*/
|
32 |
-
protected function _prepareForm()
|
33 |
-
{
|
34 |
-
$form = new Varien_Data_Form();
|
35 |
-
$form->setHtmlIdPrefix('anymarketqueue_');
|
36 |
-
$form->setFieldNameSuffix('anymarketqueue');
|
37 |
-
$this->setForm($form);
|
38 |
-
$fieldset = $form->addFieldset(
|
39 |
-
'anymarketqueue_form',
|
40 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Queue'))
|
41 |
-
);
|
42 |
-
|
43 |
-
$fieldset->addField(
|
44 |
-
'nmq_id',
|
45 |
-
'text',
|
46 |
-
array(
|
47 |
-
'label' => Mage::helper('db1_anymarket')->__('Item code that is waiting in the queue'),
|
48 |
-
'name' => 'nmq_id',
|
49 |
-
'required' => true,
|
50 |
-
'class' => 'required-entry',
|
51 |
-
|
52 |
-
)
|
53 |
-
);
|
54 |
-
|
55 |
-
$fieldset->addField(
|
56 |
-
'nmq_type',
|
57 |
-
'select',
|
58 |
-
array(
|
59 |
-
'label' => Mage::helper('db1_anymarket')->__('Type of Operation'),
|
60 |
-
'name' => 'nmq_type',
|
61 |
-
'required' => true,
|
62 |
-
'values' => array(
|
63 |
-
array(
|
64 |
-
'value' => 'IMP',
|
65 |
-
'label' => Mage::helper('db1_anymarket')->__('IMP'),
|
66 |
-
),
|
67 |
-
array(
|
68 |
-
'value' => 'EXP',
|
69 |
-
'label' => Mage::helper('db1_anymarket')->__('EXP'),
|
70 |
-
),
|
71 |
-
),
|
72 |
-
)
|
73 |
-
);
|
74 |
-
|
75 |
-
$fieldset->addField(
|
76 |
-
'nmq_table',
|
77 |
-
'select',
|
78 |
-
array(
|
79 |
-
'label' => Mage::helper('db1_anymarket')->__('Source table'),
|
80 |
-
'name' => 'nmq_table',
|
81 |
-
'required' => true,
|
82 |
-
'values' => array(
|
83 |
-
array(
|
84 |
-
'value' => 'ORDER',
|
85 |
-
'label' => Mage::helper('db1_anymarket')->__('Order'),
|
86 |
-
),
|
87 |
-
array(
|
88 |
-
'value' => 'PRODUCT',
|
89 |
-
'label' => Mage::helper('db1_anymarket')->__('Product'),
|
90 |
-
),
|
91 |
-
),
|
92 |
-
)
|
93 |
-
);
|
94 |
-
|
95 |
-
if (Mage::app()->isSingleStoreMode()) {
|
96 |
-
$fieldset->addField(
|
97 |
-
'store_id',
|
98 |
-
'hidden',
|
99 |
-
array(
|
100 |
-
'name' => 'stores[]',
|
101 |
-
'value' => Mage::app()->getStore(true)->getId()
|
102 |
-
)
|
103 |
-
);
|
104 |
-
Mage::registry('current_anymarketqueue')->setStoreId(Mage::app()->getStore(true)->getId());
|
105 |
-
}
|
106 |
-
$formValues = Mage::registry('current_anymarketqueue')->getDefaultValues();
|
107 |
-
if (!is_array($formValues)) {
|
108 |
-
$formValues = array();
|
109 |
-
}
|
110 |
-
if (Mage::getSingleton('adminhtml/session')->getAnymarketqueueData()) {
|
111 |
-
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketqueueData());
|
112 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketqueueData(null);
|
113 |
-
} elseif (Mage::registry('current_anymarketqueue')) {
|
114 |
-
$formValues = array_merge($formValues, Mage::registry('current_anymarketqueue')->getData());
|
115 |
-
}
|
116 |
-
$form->setValues($formValues);
|
117 |
-
return parent::_prepareForm();
|
118 |
-
}
|
119 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue edit form tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* prepare the form
|
27 |
+
*
|
28 |
+
* @access protected
|
29 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Form
|
30 |
+
|
31 |
+
*/
|
32 |
+
protected function _prepareForm()
|
33 |
+
{
|
34 |
+
$form = new Varien_Data_Form();
|
35 |
+
$form->setHtmlIdPrefix('anymarketqueue_');
|
36 |
+
$form->setFieldNameSuffix('anymarketqueue');
|
37 |
+
$this->setForm($form);
|
38 |
+
$fieldset = $form->addFieldset(
|
39 |
+
'anymarketqueue_form',
|
40 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Anymarket Queue'))
|
41 |
+
);
|
42 |
+
|
43 |
+
$fieldset->addField(
|
44 |
+
'nmq_id',
|
45 |
+
'text',
|
46 |
+
array(
|
47 |
+
'label' => Mage::helper('db1_anymarket')->__('Item code that is waiting in the queue'),
|
48 |
+
'name' => 'nmq_id',
|
49 |
+
'required' => true,
|
50 |
+
'class' => 'required-entry',
|
51 |
+
|
52 |
+
)
|
53 |
+
);
|
54 |
+
|
55 |
+
$fieldset->addField(
|
56 |
+
'nmq_type',
|
57 |
+
'select',
|
58 |
+
array(
|
59 |
+
'label' => Mage::helper('db1_anymarket')->__('Type of Operation'),
|
60 |
+
'name' => 'nmq_type',
|
61 |
+
'required' => true,
|
62 |
+
'values' => array(
|
63 |
+
array(
|
64 |
+
'value' => 'IMP',
|
65 |
+
'label' => Mage::helper('db1_anymarket')->__('IMP'),
|
66 |
+
),
|
67 |
+
array(
|
68 |
+
'value' => 'EXP',
|
69 |
+
'label' => Mage::helper('db1_anymarket')->__('EXP'),
|
70 |
+
),
|
71 |
+
),
|
72 |
+
)
|
73 |
+
);
|
74 |
+
|
75 |
+
$fieldset->addField(
|
76 |
+
'nmq_table',
|
77 |
+
'select',
|
78 |
+
array(
|
79 |
+
'label' => Mage::helper('db1_anymarket')->__('Source table'),
|
80 |
+
'name' => 'nmq_table',
|
81 |
+
'required' => true,
|
82 |
+
'values' => array(
|
83 |
+
array(
|
84 |
+
'value' => 'ORDER',
|
85 |
+
'label' => Mage::helper('db1_anymarket')->__('Order'),
|
86 |
+
),
|
87 |
+
array(
|
88 |
+
'value' => 'PRODUCT',
|
89 |
+
'label' => Mage::helper('db1_anymarket')->__('Product'),
|
90 |
+
),
|
91 |
+
),
|
92 |
+
)
|
93 |
+
);
|
94 |
+
|
95 |
+
if (Mage::app()->isSingleStoreMode()) {
|
96 |
+
$fieldset->addField(
|
97 |
+
'store_id',
|
98 |
+
'hidden',
|
99 |
+
array(
|
100 |
+
'name' => 'stores[]',
|
101 |
+
'value' => Mage::app()->getStore(true)->getId()
|
102 |
+
)
|
103 |
+
);
|
104 |
+
Mage::registry('current_anymarketqueue')->setStoreId(Mage::app()->getStore(true)->getId());
|
105 |
+
}
|
106 |
+
$formValues = Mage::registry('current_anymarketqueue')->getDefaultValues();
|
107 |
+
if (!is_array($formValues)) {
|
108 |
+
$formValues = array();
|
109 |
+
}
|
110 |
+
if (Mage::getSingleton('adminhtml/session')->getAnymarketqueueData()) {
|
111 |
+
$formValues = array_merge($formValues, Mage::getSingleton('adminhtml/session')->getAnymarketqueueData());
|
112 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketqueueData(null);
|
113 |
+
} elseif (Mage::registry('current_anymarketqueue')) {
|
114 |
+
$formValues = array_merge($formValues, Mage::registry('current_anymarketqueue')->getData());
|
115 |
+
}
|
116 |
+
$form->setValues($formValues);
|
117 |
+
return parent::_prepareForm();
|
118 |
+
}
|
119 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Stores.php
CHANGED
@@ -1,57 +1,57 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* store selection tab
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* prepare the form
|
27 |
-
*
|
28 |
-
* @access protected
|
29 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Stores
|
30 |
-
|
31 |
-
*/
|
32 |
-
protected function _prepareForm()
|
33 |
-
{
|
34 |
-
$form = new Varien_Data_Form();
|
35 |
-
$form->setFieldNameSuffix('anymarketqueue');
|
36 |
-
$this->setForm($form);
|
37 |
-
$fieldset = $form->addFieldset(
|
38 |
-
'anymarketqueue_stores_form',
|
39 |
-
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
40 |
-
);
|
41 |
-
$field = $fieldset->addField(
|
42 |
-
'store_id',
|
43 |
-
'multiselect',
|
44 |
-
array(
|
45 |
-
'name' => 'stores[]',
|
46 |
-
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
47 |
-
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
-
'required' => true,
|
49 |
-
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
50 |
-
)
|
51 |
-
);
|
52 |
-
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
53 |
-
$field->setRenderer($renderer);
|
54 |
-
$form->addValues(Mage::registry('current_anymarketqueue')->getData());
|
55 |
-
return parent::_prepareForm();
|
56 |
-
}
|
57 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* store selection tab
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Stores extends Mage_Adminhtml_Block_Widget_Form
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* prepare the form
|
27 |
+
*
|
28 |
+
* @access protected
|
29 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tab_Stores
|
30 |
+
|
31 |
+
*/
|
32 |
+
protected function _prepareForm()
|
33 |
+
{
|
34 |
+
$form = new Varien_Data_Form();
|
35 |
+
$form->setFieldNameSuffix('anymarketqueue');
|
36 |
+
$this->setForm($form);
|
37 |
+
$fieldset = $form->addFieldset(
|
38 |
+
'anymarketqueue_stores_form',
|
39 |
+
array('legend' => Mage::helper('db1_anymarket')->__('Store views'))
|
40 |
+
);
|
41 |
+
$field = $fieldset->addField(
|
42 |
+
'store_id',
|
43 |
+
'multiselect',
|
44 |
+
array(
|
45 |
+
'name' => 'stores[]',
|
46 |
+
'label' => Mage::helper('db1_anymarket')->__('Store Views'),
|
47 |
+
'title' => Mage::helper('db1_anymarket')->__('Store Views'),
|
48 |
+
'required' => true,
|
49 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
|
50 |
+
)
|
51 |
+
);
|
52 |
+
$renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
|
53 |
+
$field->setRenderer($renderer);
|
54 |
+
$form->addValues(Mage::registry('current_anymarketqueue')->getData());
|
55 |
+
return parent::_prepareForm();
|
56 |
+
}
|
57 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tabs.php
CHANGED
@@ -1,86 +1,86 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue admin edit tabs
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Initialize Tabs
|
27 |
-
*
|
28 |
-
* @access public
|
29 |
-
|
30 |
-
*/
|
31 |
-
public function __construct()
|
32 |
-
{
|
33 |
-
parent::__construct();
|
34 |
-
$this->setId('anymarketqueue_tabs');
|
35 |
-
$this->setDestElementId('edit_form');
|
36 |
-
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Queue'));
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* before render html
|
41 |
-
*
|
42 |
-
* @access protected
|
43 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tabs
|
44 |
-
|
45 |
-
*/
|
46 |
-
protected function _beforeToHtml()
|
47 |
-
{
|
48 |
-
$this->addTab(
|
49 |
-
'form_anymarketqueue',
|
50 |
-
array(
|
51 |
-
'label' => Mage::helper('db1_anymarket')->__('Anymarket Queue'),
|
52 |
-
'title' => Mage::helper('db1_anymarket')->__('Anymarket Queue'),
|
53 |
-
'content' => $this->getLayout()->createBlock(
|
54 |
-
'db1_anymarket/adminhtml_anymarketqueue_edit_tab_form'
|
55 |
-
)
|
56 |
-
->toHtml(),
|
57 |
-
)
|
58 |
-
);
|
59 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
60 |
-
$this->addTab(
|
61 |
-
'form_store_anymarketqueue',
|
62 |
-
array(
|
63 |
-
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
64 |
-
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
-
'content' => $this->getLayout()->createBlock(
|
66 |
-
'db1_anymarket/adminhtml_anymarketqueue_edit_tab_stores'
|
67 |
-
)
|
68 |
-
->toHtml(),
|
69 |
-
)
|
70 |
-
);
|
71 |
-
}
|
72 |
-
return parent::_beforeToHtml();
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Retrieve anymarket queue entity
|
77 |
-
*
|
78 |
-
* @access public
|
79 |
-
* @return DB1_AnyMarket_Model_Anymarketqueue
|
80 |
-
|
81 |
-
*/
|
82 |
-
public function getAnymarketqueue()
|
83 |
-
{
|
84 |
-
return Mage::registry('current_anymarketqueue');
|
85 |
-
}
|
86 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue admin edit tabs
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* Initialize Tabs
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
|
30 |
+
*/
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
parent::__construct();
|
34 |
+
$this->setId('anymarketqueue_tabs');
|
35 |
+
$this->setDestElementId('edit_form');
|
36 |
+
$this->setTitle(Mage::helper('db1_anymarket')->__('Anymarket Queue'));
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* before render html
|
41 |
+
*
|
42 |
+
* @access protected
|
43 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Edit_Tabs
|
44 |
+
|
45 |
+
*/
|
46 |
+
protected function _beforeToHtml()
|
47 |
+
{
|
48 |
+
$this->addTab(
|
49 |
+
'form_anymarketqueue',
|
50 |
+
array(
|
51 |
+
'label' => Mage::helper('db1_anymarket')->__('Anymarket Queue'),
|
52 |
+
'title' => Mage::helper('db1_anymarket')->__('Anymarket Queue'),
|
53 |
+
'content' => $this->getLayout()->createBlock(
|
54 |
+
'db1_anymarket/adminhtml_anymarketqueue_edit_tab_form'
|
55 |
+
)
|
56 |
+
->toHtml(),
|
57 |
+
)
|
58 |
+
);
|
59 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
60 |
+
$this->addTab(
|
61 |
+
'form_store_anymarketqueue',
|
62 |
+
array(
|
63 |
+
'label' => Mage::helper('db1_anymarket')->__('Store views'),
|
64 |
+
'title' => Mage::helper('db1_anymarket')->__('Store views'),
|
65 |
+
'content' => $this->getLayout()->createBlock(
|
66 |
+
'db1_anymarket/adminhtml_anymarketqueue_edit_tab_stores'
|
67 |
+
)
|
68 |
+
->toHtml(),
|
69 |
+
)
|
70 |
+
);
|
71 |
+
}
|
72 |
+
return parent::_beforeToHtml();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Retrieve anymarket queue entity
|
77 |
+
*
|
78 |
+
* @access public
|
79 |
+
* @return DB1_AnyMarket_Model_Anymarketqueue
|
80 |
+
|
81 |
+
*/
|
82 |
+
public function getAnymarketqueue()
|
83 |
+
{
|
84 |
+
return Mage::registry('current_anymarketqueue');
|
85 |
+
}
|
86 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Grid.php
CHANGED
@@ -1,223 +1,223 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue admin grid block
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* constructor
|
27 |
-
*
|
28 |
-
* @access public
|
29 |
-
|
30 |
-
*/
|
31 |
-
public function __construct()
|
32 |
-
{
|
33 |
-
parent::__construct();
|
34 |
-
$this->setId('anymarketqueueGrid');
|
35 |
-
$this->setDefaultSort('entity_id');
|
36 |
-
$this->setDefaultDir('ASC');
|
37 |
-
$this->setSaveParametersInSession(true);
|
38 |
-
$this->setUseAjax(true);
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* prepare collection
|
43 |
-
*
|
44 |
-
* @access protected
|
45 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
46 |
-
|
47 |
-
*/
|
48 |
-
protected function _prepareCollection()
|
49 |
-
{
|
50 |
-
$collection = Mage::getModel('db1_anymarket/anymarketqueue')
|
51 |
-
->getCollection();
|
52 |
-
|
53 |
-
$this->setCollection($collection);
|
54 |
-
return parent::_prepareCollection();
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* prepare grid collection
|
59 |
-
*
|
60 |
-
* @access protected
|
61 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
62 |
-
|
63 |
-
*/
|
64 |
-
protected function _prepareColumns()
|
65 |
-
{
|
66 |
-
$this->addColumn(
|
67 |
-
'entity_id',
|
68 |
-
array(
|
69 |
-
'header' => Mage::helper('db1_anymarket')->__('Id'),
|
70 |
-
'index' => 'entity_id',
|
71 |
-
'type' => 'number'
|
72 |
-
)
|
73 |
-
);
|
74 |
-
$this->addColumn(
|
75 |
-
'nmq_id',
|
76 |
-
array(
|
77 |
-
'header' => Mage::helper('db1_anymarket')->__('Item code that is waiting in the queue'),
|
78 |
-
'align' => 'left',
|
79 |
-
'index' => 'nmq_id',
|
80 |
-
)
|
81 |
-
);
|
82 |
-
$this->addColumn(
|
83 |
-
'nmq_type',
|
84 |
-
array(
|
85 |
-
'header' => Mage::helper('db1_anymarket')->__('Type of Operation (Import/Emport)'),
|
86 |
-
'index' => 'nmq_type',
|
87 |
-
'type' => 'options',
|
88 |
-
'options' => array(
|
89 |
-
'IMP' => Mage::helper('db1_anymarket')->__('Import'),
|
90 |
-
'EXP' => Mage::helper('db1_anymarket')->__('Export'),
|
91 |
-
)
|
92 |
-
|
93 |
-
)
|
94 |
-
);
|
95 |
-
$this->addColumn(
|
96 |
-
'nmq_table',
|
97 |
-
array(
|
98 |
-
'header' => Mage::helper('db1_anymarket')->__('Source table'),
|
99 |
-
'index' => 'nmq_table',
|
100 |
-
'type' => 'options',
|
101 |
-
'options' => array(
|
102 |
-
'ORDER' => Mage::helper('db1_anymarket')->__('Order'),
|
103 |
-
'PRODUCT' => Mage::helper('db1_anymarket')->__('Product'),
|
104 |
-
)
|
105 |
-
|
106 |
-
)
|
107 |
-
);
|
108 |
-
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
109 |
-
$this->addColumn(
|
110 |
-
'store_id',
|
111 |
-
array(
|
112 |
-
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
113 |
-
'index' => 'store_id',
|
114 |
-
'type' => 'store',
|
115 |
-
'store_all' => true,
|
116 |
-
'store_view' => true,
|
117 |
-
'sortable' => false,
|
118 |
-
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
119 |
-
)
|
120 |
-
);
|
121 |
-
}
|
122 |
-
$this->addColumn(
|
123 |
-
'created_at',
|
124 |
-
array(
|
125 |
-
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
126 |
-
'index' => 'created_at',
|
127 |
-
'width' => '120px',
|
128 |
-
'type' => 'datetime',
|
129 |
-
)
|
130 |
-
);
|
131 |
-
$this->addColumn(
|
132 |
-
'updated_at',
|
133 |
-
array(
|
134 |
-
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
135 |
-
'index' => 'updated_at',
|
136 |
-
'width' => '120px',
|
137 |
-
'type' => 'datetime',
|
138 |
-
)
|
139 |
-
);
|
140 |
-
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
141 |
-
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
142 |
-
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
143 |
-
return parent::_prepareColumns();
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* prepare mass action
|
148 |
-
*
|
149 |
-
* @access protected
|
150 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
151 |
-
|
152 |
-
*/
|
153 |
-
protected function _prepareMassaction()
|
154 |
-
{
|
155 |
-
$this->setMassactionIdField('entity_id');
|
156 |
-
$this->getMassactionBlock()->setFormFieldName('anymarketqueue');
|
157 |
-
$this->getMassactionBlock()->addItem(
|
158 |
-
'delete',
|
159 |
-
array(
|
160 |
-
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
161 |
-
'url' => $this->getUrl('*/*/massDelete'),
|
162 |
-
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure?')
|
163 |
-
)
|
164 |
-
);
|
165 |
-
return $this;
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* get the row url
|
170 |
-
*
|
171 |
-
* @access public
|
172 |
-
* @param DB1_AnyMarket_Model_Anymarketqueue
|
173 |
-
* @return string
|
174 |
-
|
175 |
-
*/
|
176 |
-
public function getRowUrl($row)
|
177 |
-
{
|
178 |
-
return null;
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* get the grid url
|
183 |
-
*
|
184 |
-
* @access public
|
185 |
-
* @return string
|
186 |
-
|
187 |
-
*/
|
188 |
-
public function getGridUrl()
|
189 |
-
{
|
190 |
-
return $this->getUrl('*/*/grid', array('_current'=>true));
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* after collection load
|
195 |
-
*
|
196 |
-
* @access protected
|
197 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
198 |
-
|
199 |
-
*/
|
200 |
-
protected function _afterLoadCollection()
|
201 |
-
{
|
202 |
-
$this->getCollection()->walk('afterLoad');
|
203 |
-
parent::_afterLoadCollection();
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* filter store column
|
208 |
-
*
|
209 |
-
* @access protected
|
210 |
-
* @param DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection $collection
|
211 |
-
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
212 |
-
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
213 |
-
|
214 |
-
*/
|
215 |
-
protected function _filterStoreCondition($collection, $column)
|
216 |
-
{
|
217 |
-
if (!$value = $column->getFilter()->getValue()) {
|
218 |
-
return;
|
219 |
-
}
|
220 |
-
$collection->addStoreFilter($value);
|
221 |
-
return $this;
|
222 |
-
}
|
223 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue admin grid block
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* constructor
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
|
30 |
+
*/
|
31 |
+
public function __construct()
|
32 |
+
{
|
33 |
+
parent::__construct();
|
34 |
+
$this->setId('anymarketqueueGrid');
|
35 |
+
$this->setDefaultSort('entity_id');
|
36 |
+
$this->setDefaultDir('ASC');
|
37 |
+
$this->setSaveParametersInSession(true);
|
38 |
+
$this->setUseAjax(true);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* prepare collection
|
43 |
+
*
|
44 |
+
* @access protected
|
45 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
46 |
+
|
47 |
+
*/
|
48 |
+
protected function _prepareCollection()
|
49 |
+
{
|
50 |
+
$collection = Mage::getModel('db1_anymarket/anymarketqueue')
|
51 |
+
->getCollection();
|
52 |
+
|
53 |
+
$this->setCollection($collection);
|
54 |
+
return parent::_prepareCollection();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* prepare grid collection
|
59 |
+
*
|
60 |
+
* @access protected
|
61 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
62 |
+
|
63 |
+
*/
|
64 |
+
protected function _prepareColumns()
|
65 |
+
{
|
66 |
+
$this->addColumn(
|
67 |
+
'entity_id',
|
68 |
+
array(
|
69 |
+
'header' => Mage::helper('db1_anymarket')->__('Id'),
|
70 |
+
'index' => 'entity_id',
|
71 |
+
'type' => 'number'
|
72 |
+
)
|
73 |
+
);
|
74 |
+
$this->addColumn(
|
75 |
+
'nmq_id',
|
76 |
+
array(
|
77 |
+
'header' => Mage::helper('db1_anymarket')->__('Item code that is waiting in the queue'),
|
78 |
+
'align' => 'left',
|
79 |
+
'index' => 'nmq_id',
|
80 |
+
)
|
81 |
+
);
|
82 |
+
$this->addColumn(
|
83 |
+
'nmq_type',
|
84 |
+
array(
|
85 |
+
'header' => Mage::helper('db1_anymarket')->__('Type of Operation (Import/Emport)'),
|
86 |
+
'index' => 'nmq_type',
|
87 |
+
'type' => 'options',
|
88 |
+
'options' => array(
|
89 |
+
'IMP' => Mage::helper('db1_anymarket')->__('Import'),
|
90 |
+
'EXP' => Mage::helper('db1_anymarket')->__('Export'),
|
91 |
+
)
|
92 |
+
|
93 |
+
)
|
94 |
+
);
|
95 |
+
$this->addColumn(
|
96 |
+
'nmq_table',
|
97 |
+
array(
|
98 |
+
'header' => Mage::helper('db1_anymarket')->__('Source table'),
|
99 |
+
'index' => 'nmq_table',
|
100 |
+
'type' => 'options',
|
101 |
+
'options' => array(
|
102 |
+
'ORDER' => Mage::helper('db1_anymarket')->__('Order'),
|
103 |
+
'PRODUCT' => Mage::helper('db1_anymarket')->__('Product'),
|
104 |
+
)
|
105 |
+
|
106 |
+
)
|
107 |
+
);
|
108 |
+
if (!Mage::app()->isSingleStoreMode() && !$this->_isExport) {
|
109 |
+
$this->addColumn(
|
110 |
+
'store_id',
|
111 |
+
array(
|
112 |
+
'header' => Mage::helper('db1_anymarket')->__('Store Views'),
|
113 |
+
'index' => 'store_id',
|
114 |
+
'type' => 'store',
|
115 |
+
'store_all' => true,
|
116 |
+
'store_view' => true,
|
117 |
+
'sortable' => false,
|
118 |
+
'filter_condition_callback'=> array($this, '_filterStoreCondition'),
|
119 |
+
)
|
120 |
+
);
|
121 |
+
}
|
122 |
+
$this->addColumn(
|
123 |
+
'created_at',
|
124 |
+
array(
|
125 |
+
'header' => Mage::helper('db1_anymarket')->__('Created at'),
|
126 |
+
'index' => 'created_at',
|
127 |
+
'width' => '120px',
|
128 |
+
'type' => 'datetime',
|
129 |
+
)
|
130 |
+
);
|
131 |
+
$this->addColumn(
|
132 |
+
'updated_at',
|
133 |
+
array(
|
134 |
+
'header' => Mage::helper('db1_anymarket')->__('Updated at'),
|
135 |
+
'index' => 'updated_at',
|
136 |
+
'width' => '120px',
|
137 |
+
'type' => 'datetime',
|
138 |
+
)
|
139 |
+
);
|
140 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('db1_anymarket')->__('CSV'));
|
141 |
+
$this->addExportType('*/*/exportExcel', Mage::helper('db1_anymarket')->__('Excel'));
|
142 |
+
$this->addExportType('*/*/exportXml', Mage::helper('db1_anymarket')->__('XML'));
|
143 |
+
return parent::_prepareColumns();
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* prepare mass action
|
148 |
+
*
|
149 |
+
* @access protected
|
150 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
151 |
+
|
152 |
+
*/
|
153 |
+
protected function _prepareMassaction()
|
154 |
+
{
|
155 |
+
$this->setMassactionIdField('entity_id');
|
156 |
+
$this->getMassactionBlock()->setFormFieldName('anymarketqueue');
|
157 |
+
$this->getMassactionBlock()->addItem(
|
158 |
+
'delete',
|
159 |
+
array(
|
160 |
+
'label'=> Mage::helper('db1_anymarket')->__('Delete'),
|
161 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
162 |
+
'confirm' => Mage::helper('db1_anymarket')->__('Are you sure?')
|
163 |
+
)
|
164 |
+
);
|
165 |
+
return $this;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* get the row url
|
170 |
+
*
|
171 |
+
* @access public
|
172 |
+
* @param DB1_AnyMarket_Model_Anymarketqueue
|
173 |
+
* @return string
|
174 |
+
|
175 |
+
*/
|
176 |
+
public function getRowUrl($row)
|
177 |
+
{
|
178 |
+
return null;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* get the grid url
|
183 |
+
*
|
184 |
+
* @access public
|
185 |
+
* @return string
|
186 |
+
|
187 |
+
*/
|
188 |
+
public function getGridUrl()
|
189 |
+
{
|
190 |
+
return $this->getUrl('*/*/grid', array('_current'=>true));
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* after collection load
|
195 |
+
*
|
196 |
+
* @access protected
|
197 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
198 |
+
|
199 |
+
*/
|
200 |
+
protected function _afterLoadCollection()
|
201 |
+
{
|
202 |
+
$this->getCollection()->walk('afterLoad');
|
203 |
+
parent::_afterLoadCollection();
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* filter store column
|
208 |
+
*
|
209 |
+
* @access protected
|
210 |
+
* @param DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection $collection
|
211 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
212 |
+
* @return DB1_AnyMarket_Block_Adminhtml_Anymarketqueue_Grid
|
213 |
+
|
214 |
+
*/
|
215 |
+
protected function _filterStoreCondition($collection, $column)
|
216 |
+
{
|
217 |
+
if (!$value = $column->getFilter()->getValue()) {
|
218 |
+
return;
|
219 |
+
}
|
220 |
+
$collection->addStoreFilter($value);
|
221 |
+
return $this;
|
222 |
+
}
|
223 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/Callback.php
ADDED
@@ -0,0 +1,24 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Block_Adminhtml_System_Config_Form_Callback
|
4 |
+
extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Render element html
|
8 |
+
*
|
9 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
10 |
+
* @return string
|
11 |
+
*/
|
12 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
13 |
+
{
|
14 |
+
$useContainerId = $element->getData('use_container_id');
|
15 |
+
return sprintf('<tr id="row_%s">
|
16 |
+
<td class="label">
|
17 |
+
<h4 id="%s">%s</h4>
|
18 |
+
</td>
|
19 |
+
<td class="label">%s</td>
|
20 |
+
</tr>',
|
21 |
+
$element->getHtmlId(), $element->getHtmlId(), $element->getLabel(), Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)."index.php/anymarketcallback/index/sinc"
|
22 |
+
);
|
23 |
+
}
|
24 |
+
}
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/buttoncheckconfig.php
ADDED
@@ -0,0 +1,52 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class DB1_AnyMarket_Block_Adminhtml_System_Config_Form_Buttoncheckconfig extends Mage_Adminhtml_Block_System_Config_Form_Field
|
3 |
+
{
|
4 |
+
/*
|
5 |
+
* Set template
|
6 |
+
*/
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
parent::_construct();
|
10 |
+
$this->setTemplate('db1/anymarket/system/config/form/field/button_check_configuration.phtml');
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Return element html
|
15 |
+
*
|
16 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
20 |
+
{
|
21 |
+
return $this->_toHtml();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return ajax url for button
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function getAjaxCheckConfigUrl()
|
30 |
+
{
|
31 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/anymarket/checkconfig');
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Generate button html
|
36 |
+
*
|
37 |
+
* @return string
|
38 |
+
*/
|
39 |
+
public function getButtonHtml()
|
40 |
+
{
|
41 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
42 |
+
->setData(array(
|
43 |
+
'id' => 'check_anymarket_button',
|
44 |
+
'label' => Mage::helper('db1_anymarket')->__('Check Configuration'),
|
45 |
+
'onclick' => 'javascript:checkconfig(); return false;'
|
46 |
+
));
|
47 |
+
|
48 |
+
return $button->toHtml();
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
?>
|
app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusammg/Values.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Block_System_Config_Source_Orders_Statusammg_Values extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
-
{
|
5 |
-
protected $magentoAttributes;
|
6 |
-
|
7 |
-
// public function _prepareToRender()
|
8 |
-
public function __construct()
|
9 |
-
{
|
10 |
-
$this->addColumn('orderStatusAM', array(
|
11 |
-
'label' => Mage::helper('adminhtml')->__('Status Order Anymarket'),
|
12 |
-
'size' => 28
|
13 |
-
));
|
14 |
-
|
15 |
-
$this->addColumn('orderStatusMG', array(
|
16 |
-
'label' => Mage::helper('adminhtml')->__('Status Order Magento'),
|
17 |
-
'size' => 28,
|
18 |
-
));
|
19 |
-
|
20 |
-
$this->_addAfter = false;
|
21 |
-
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new Status');
|
22 |
-
|
23 |
-
parent::__construct();
|
24 |
-
$this->setTemplate('db1/anymarket/system/config/form/field/array_dropdown.phtml');
|
25 |
-
}
|
26 |
-
|
27 |
-
protected function _renderCellTemplate($columnName)
|
28 |
-
{
|
29 |
-
if (empty($this->_columns[$columnName])) {
|
30 |
-
throw new Exception('Wrong column name specified.');
|
31 |
-
}
|
32 |
-
$column = $this->_columns[$columnName];
|
33 |
-
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
34 |
-
|
35 |
-
$rendered = '<select name="'.$inputName.'">';
|
36 |
-
if ($columnName == 'orderStatusAM') {
|
37 |
-
$rendered .= '<option value="CONCLUDED">Concluido (CONCLUDED)</option>';
|
38 |
-
$rendered .= '<option value="PENDING">Pendente (PENDING)</option>';
|
39 |
-
$rendered .= '<option value="INVOICED">Faturado (INVOICED)</option>';
|
40 |
-
$rendered .= '<option value="PAID_WAITING_DELIVERY">Enviado (PAID_WAITING_DELIVERY)</option>';
|
41 |
-
$rendered .= '<option value="PAID_WAITING_SHIP">Pago (PAID_WAITING_SHIP)</option>';
|
42 |
-
$rendered .= '<option value="CANCELED">Cancelado (CANCELED)</option>';
|
43 |
-
} else {
|
44 |
-
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
45 |
-
foreach($orderStatusCollection as $orderStatus) {
|
46 |
-
$rendered .= '<option value="'.$orderStatus['status'].'">'.$orderStatus['label'].' ('.$orderStatus['status'].')</option>';
|
47 |
-
}
|
48 |
-
$rendered .= '<option value="new">New (new)</option>';
|
49 |
-
}
|
50 |
-
$rendered .= '</select>';
|
51 |
-
|
52 |
-
return $rendered;
|
53 |
-
}
|
54 |
-
|
55 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Block_System_Config_Source_Orders_Statusammg_Values extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
+
{
|
5 |
+
protected $magentoAttributes;
|
6 |
+
|
7 |
+
// public function _prepareToRender()
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
$this->addColumn('orderStatusAM', array(
|
11 |
+
'label' => Mage::helper('adminhtml')->__('Status Order Anymarket'),
|
12 |
+
'size' => 28
|
13 |
+
));
|
14 |
+
|
15 |
+
$this->addColumn('orderStatusMG', array(
|
16 |
+
'label' => Mage::helper('adminhtml')->__('Status Order Magento'),
|
17 |
+
'size' => 28,
|
18 |
+
));
|
19 |
+
|
20 |
+
$this->_addAfter = false;
|
21 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new Status');
|
22 |
+
|
23 |
+
parent::__construct();
|
24 |
+
$this->setTemplate('db1/anymarket/system/config/form/field/array_dropdown.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _renderCellTemplate($columnName)
|
28 |
+
{
|
29 |
+
if (empty($this->_columns[$columnName])) {
|
30 |
+
throw new Exception('Wrong column name specified.');
|
31 |
+
}
|
32 |
+
$column = $this->_columns[$columnName];
|
33 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
34 |
+
|
35 |
+
$rendered = '<select name="'.$inputName.'">';
|
36 |
+
if ($columnName == 'orderStatusAM') {
|
37 |
+
$rendered .= '<option value="CONCLUDED">Concluido (CONCLUDED)</option>';
|
38 |
+
$rendered .= '<option value="PENDING">Pendente (PENDING)</option>';
|
39 |
+
$rendered .= '<option value="INVOICED">Faturado (INVOICED)</option>';
|
40 |
+
$rendered .= '<option value="PAID_WAITING_DELIVERY">Enviado (PAID_WAITING_DELIVERY)</option>';
|
41 |
+
$rendered .= '<option value="PAID_WAITING_SHIP">Pago (PAID_WAITING_SHIP)</option>';
|
42 |
+
$rendered .= '<option value="CANCELED">Cancelado (CANCELED)</option>';
|
43 |
+
} else {
|
44 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
45 |
+
foreach($orderStatusCollection as $orderStatus) {
|
46 |
+
$rendered .= '<option value="'.$orderStatus['status'].'">'.$orderStatus['label'].' ('.$orderStatus['status'].')</option>';
|
47 |
+
}
|
48 |
+
$rendered .= '<option value="new">New (new)</option>';
|
49 |
+
}
|
50 |
+
$rendered .= '</select>';
|
51 |
+
|
52 |
+
return $rendered;
|
53 |
+
}
|
54 |
+
|
55 |
Â
}
|
app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusmgam/Values.php
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Block_System_Config_Source_Orders_Statusmgam_Values extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
-
{
|
5 |
-
protected $magentoAttributes;
|
6 |
-
|
7 |
-
// public function _prepareToRender()
|
8 |
-
public function __construct()
|
9 |
-
{
|
10 |
-
$this->addColumn('orderStatusMG', array(
|
11 |
-
'label' => Mage::helper('adminhtml')->__('Status Order Magento'),
|
12 |
-
'size' => 28,
|
13 |
-
));
|
14 |
-
$this->addColumn('orderStatusAM', array(
|
15 |
-
'label' => Mage::helper('adminhtml')->__('Status Order Anymarket'),
|
16 |
-
'size' => 28
|
17 |
-
));
|
18 |
-
$this->_addAfter = false;
|
19 |
-
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new Status');
|
20 |
-
|
21 |
-
parent::__construct();
|
22 |
-
$this->setTemplate('db1/anymarket/system/config/form/field/array_dropdown.phtml');
|
23 |
-
}
|
24 |
-
|
25 |
-
protected function _renderCellTemplate($columnName)
|
26 |
-
{
|
27 |
-
if (empty($this->_columns[$columnName])) {
|
28 |
-
throw new Exception('Wrong column name specified.');
|
29 |
-
}
|
30 |
-
$column = $this->_columns[$columnName];
|
31 |
-
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
32 |
-
|
33 |
-
$rendered = '<select name="'.$inputName.'">';
|
34 |
-
if ($columnName == 'orderStatusAM') {
|
35 |
-
$rendered .= '<option value="CONCLUDED">Concluido (CONCLUDED)</option>';
|
36 |
-
$rendered .= '<option value="PENDING">Pendente (PENDING)</option>';
|
37 |
-
$rendered .= '<option value="INVOICED">Faturado (INVOICED)</option>';
|
38 |
-
$rendered .= '<option value="PAID_WAITING_DELIVERY">Enviado (PAID_WAITING_DELIVERY)</option>';
|
39 |
-
$rendered .= '<option value="PAID_WAITING_SHIP">Pago (PAID_WAITING_SHIP)</option>';
|
40 |
-
$rendered .= '<option value="CANCELED">Cancelado (CANCELED)</option>';
|
41 |
-
} else {
|
42 |
-
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
43 |
-
foreach($orderStatusCollection as $orderStatus) {
|
44 |
-
$rendered .= '<option value="'.$orderStatus['status'].'">'.$orderStatus['label'].' ('.$orderStatus['status'].')</option>';
|
45 |
-
}
|
46 |
-
$rendered .= '<option value="new">New (new)</option>';
|
47 |
-
}
|
48 |
-
$rendered .= '</select>';
|
49 |
-
|
50 |
-
return $rendered;
|
51 |
-
}
|
52 |
-
|
53 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Block_System_Config_Source_Orders_Statusmgam_Values extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
+
{
|
5 |
+
protected $magentoAttributes;
|
6 |
+
|
7 |
+
// public function _prepareToRender()
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
$this->addColumn('orderStatusMG', array(
|
11 |
+
'label' => Mage::helper('adminhtml')->__('Status Order Magento'),
|
12 |
+
'size' => 28,
|
13 |
+
));
|
14 |
+
$this->addColumn('orderStatusAM', array(
|
15 |
+
'label' => Mage::helper('adminhtml')->__('Status Order Anymarket'),
|
16 |
+
'size' => 28
|
17 |
+
));
|
18 |
+
$this->_addAfter = false;
|
19 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new Status');
|
20 |
+
|
21 |
+
parent::__construct();
|
22 |
+
$this->setTemplate('db1/anymarket/system/config/form/field/array_dropdown.phtml');
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _renderCellTemplate($columnName)
|
26 |
+
{
|
27 |
+
if (empty($this->_columns[$columnName])) {
|
28 |
+
throw new Exception('Wrong column name specified.');
|
29 |
+
}
|
30 |
+
$column = $this->_columns[$columnName];
|
31 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
32 |
+
|
33 |
+
$rendered = '<select name="'.$inputName.'">';
|
34 |
+
if ($columnName == 'orderStatusAM') {
|
35 |
+
$rendered .= '<option value="CONCLUDED">Concluido (CONCLUDED)</option>';
|
36 |
+
$rendered .= '<option value="PENDING">Pendente (PENDING)</option>';
|
37 |
+
$rendered .= '<option value="INVOICED">Faturado (INVOICED)</option>';
|
38 |
+
$rendered .= '<option value="PAID_WAITING_DELIVERY">Enviado (PAID_WAITING_DELIVERY)</option>';
|
39 |
+
$rendered .= '<option value="PAID_WAITING_SHIP">Pago (PAID_WAITING_SHIP)</option>';
|
40 |
+
$rendered .= '<option value="CANCELED">Cancelado (CANCELED)</option>';
|
41 |
+
} else {
|
42 |
+
$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
|
43 |
+
foreach($orderStatusCollection as $orderStatus) {
|
44 |
+
$rendered .= '<option value="'.$orderStatus['status'].'">'.$orderStatus['label'].' ('.$orderStatus['status'].')</option>';
|
45 |
+
}
|
46 |
+
$rendered .= '<option value="new">New (new)</option>';
|
47 |
+
}
|
48 |
+
$rendered .= '</select>';
|
49 |
+
|
50 |
+
return $rendered;
|
51 |
+
}
|
52 |
+
|
53 |
Â
}
|
app/code/community/DB1/AnyMarket/Block/System/Config/Source/Products/Values.php
CHANGED
@@ -1,54 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Block_System_Config_Source_Products_Values extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
-
{
|
5 |
-
protected $magentoAttributes;
|
6 |
-
|
7 |
-
// public function _prepareToRender()
|
8 |
-
public function __construct()
|
9 |
-
{
|
10 |
-
$this->addColumn('descProduct', array(
|
11 |
-
'label' => Mage::helper('adminhtml')->__('Description Product'),
|
12 |
-
'size' => 28
|
13 |
-
));
|
14 |
-
|
15 |
-
$this->_addAfter = false;
|
16 |
-
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new Field');
|
17 |
-
|
18 |
-
parent::__construct();
|
19 |
-
$this->setTemplate('db1/anymarket/system/config/form/field/array_dropdown.phtml');
|
20 |
-
}
|
21 |
-
|
22 |
-
protected function _renderCellTemplate($columnName)
|
23 |
-
{
|
24 |
-
if (empty($this->_columns[$columnName])) {
|
25 |
-
throw new Exception('Wrong column name specified.');
|
26 |
-
}
|
27 |
-
$column = $this->_columns[$columnName];
|
28 |
-
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
29 |
-
|
30 |
-
$rendered = '<select name="'.$inputName.'">';
|
31 |
-
if ($columnName == 'descProduct') {
|
32 |
-
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
33 |
-
|
34 |
-
foreach ($productAttrs as $productAttr) {
|
35 |
-
if($productAttr->getFrontendLabel() != null){
|
36 |
-
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeCode(), 'nma_id_attr');
|
37 |
-
|
38 |
-
if($attrCheck->getData('nma_id_attr') == null){
|
39 |
-
$descAttr = $productAttr->getFrontendLabel();
|
40 |
-
if($descAttr != ''){
|
41 |
-
$descAttr = str_replace("'", "", $descAttr);
|
42 |
-
$rendered .= '<option value="'.$productAttr->getAttributeCode().'">'.$descAttr.' ('.$productAttr->getAttributeCode().')</option>';
|
43 |
-
}
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
}
|
48 |
-
}
|
49 |
-
$rendered .= '</select>';
|
50 |
-
|
51 |
-
return $rendered;
|
52 |
-
}
|
53 |
-
|
54 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Block_System_Config_Source_Products_Values extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
4 |
+
{
|
5 |
+
protected $magentoAttributes;
|
6 |
+
|
7 |
+
// public function _prepareToRender()
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
$this->addColumn('descProduct', array(
|
11 |
+
'label' => Mage::helper('adminhtml')->__('Description Product'),
|
12 |
+
'size' => 28
|
13 |
+
));
|
14 |
+
|
15 |
+
$this->_addAfter = false;
|
16 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__('Add new Field');
|
17 |
+
|
18 |
+
parent::__construct();
|
19 |
+
$this->setTemplate('db1/anymarket/system/config/form/field/array_dropdown.phtml');
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _renderCellTemplate($columnName)
|
23 |
+
{
|
24 |
+
if (empty($this->_columns[$columnName])) {
|
25 |
+
throw new Exception('Wrong column name specified.');
|
26 |
+
}
|
27 |
+
$column = $this->_columns[$columnName];
|
28 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
|
29 |
+
|
30 |
+
$rendered = '<select name="'.$inputName.'">';
|
31 |
+
if ($columnName == 'descProduct') {
|
32 |
+
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
33 |
+
|
34 |
+
foreach ($productAttrs as $productAttr) {
|
35 |
+
if($productAttr->getFrontendLabel() != null){
|
36 |
+
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeCode(), 'nma_id_attr');
|
37 |
+
|
38 |
+
if($attrCheck->getData('nma_id_attr') == null){
|
39 |
+
$descAttr = $productAttr->getFrontendLabel();
|
40 |
+
if($descAttr != ''){
|
41 |
+
$descAttr = str_replace("'", "", $descAttr);
|
42 |
+
$rendered .= '<option value="'.$productAttr->getAttributeCode().'">'.$descAttr.' ('.$productAttr->getAttributeCode().')</option>';
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
48 |
+
}
|
49 |
+
$rendered .= '</select>';
|
50 |
+
|
51 |
+
return $rendered;
|
52 |
+
}
|
53 |
+
|
54 |
Â
}
|
app/code/community/DB1/AnyMarket/Controller/Adminhtml/AnyMarket.php
CHANGED
@@ -1,61 +1,61 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* module base admin controller
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Controller_Adminhtml_AnyMarket extends Mage_Adminhtml_Controller_Action
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* upload file and get the uploaded name
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
* @param string $input
|
32 |
-
* @param string $destinationFolder
|
33 |
-
* @param array $data
|
34 |
-
* @return string
|
35 |
-
*
|
36 |
-
*/
|
37 |
-
protected function _uploadAndGetName($input, $destinationFolder, $data)
|
38 |
-
{
|
39 |
-
try {
|
40 |
-
if (isset($data[$input]['delete'])) {
|
41 |
-
return '';
|
42 |
-
} else {
|
43 |
-
$uploader = new Varien_File_Uploader($input);
|
44 |
-
$uploader->setAllowRenameFiles(true);
|
45 |
-
$uploader->setFilesDispersion(true);
|
46 |
-
$uploader->setAllowCreateFolders(true);
|
47 |
-
$result = $uploader->save($destinationFolder);
|
48 |
-
return $result['file'];
|
49 |
-
}
|
50 |
-
} catch (Exception $e) {
|
51 |
-
if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
|
52 |
-
throw $e;
|
53 |
-
} else {
|
54 |
-
if (isset($data[$input]['value'])) {
|
55 |
-
return $data[$input]['value'];
|
56 |
-
}
|
57 |
-
}
|
58 |
-
}
|
59 |
-
return '';
|
60 |
-
}
|
61 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* module base admin controller
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Controller_Adminhtml_AnyMarket extends Mage_Adminhtml_Controller_Action
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* upload file and get the uploaded name
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
* @param string $input
|
32 |
+
* @param string $destinationFolder
|
33 |
+
* @param array $data
|
34 |
+
* @return string
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
protected function _uploadAndGetName($input, $destinationFolder, $data)
|
38 |
+
{
|
39 |
+
try {
|
40 |
+
if (isset($data[$input]['delete'])) {
|
41 |
+
return '';
|
42 |
+
} else {
|
43 |
+
$uploader = new Varien_File_Uploader($input);
|
44 |
+
$uploader->setAllowRenameFiles(true);
|
45 |
+
$uploader->setFilesDispersion(true);
|
46 |
+
$uploader->setAllowCreateFolders(true);
|
47 |
+
$result = $uploader->save($destinationFolder);
|
48 |
+
return $result['file'];
|
49 |
+
}
|
50 |
+
} catch (Exception $e) {
|
51 |
+
if ($e->getCode() != Varien_File_Uploader::TMP_NAME_EMPTY) {
|
52 |
+
throw $e;
|
53 |
+
} else {
|
54 |
+
if (isset($data[$input]['value'])) {
|
55 |
+
return $data[$input]['value'];
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
return '';
|
60 |
+
}
|
61 |
+
}
|
app/code/community/DB1/AnyMarket/Helper/Brand.php
ADDED
@@ -0,0 +1,57 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_Brand extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* get all brands from magento
|
7 |
+
*
|
8 |
+
* @access public
|
9 |
+
*/
|
10 |
+
public function getBrands($storeID){
|
11 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
12 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
13 |
+
|
14 |
+
$headers = array(
|
15 |
+
"Content-type: application/json",
|
16 |
+
"gumgaToken: ".$TOKEN
|
17 |
+
);
|
18 |
+
|
19 |
+
$retCountBrand = 0;
|
20 |
+
$startRec = 0;
|
21 |
+
$countRec = 1;
|
22 |
+
while ($startRec <= $countRec) {
|
23 |
+
$brandGetRet = $this->CallAPICurl("GET", $HOST . "/v2/brands/?offset=" . $startRec . "&limit=30", $headers, null);
|
24 |
+
|
25 |
+
if ($brandGetRet['error'] == '0') {
|
26 |
+
$brandJSON = $brandGetRet['return'];
|
27 |
+
|
28 |
+
$startRec = $startRec + $brandJSON->page->size;
|
29 |
+
$countRec = $brandJSON->page->totalElements;
|
30 |
+
|
31 |
+
foreach ($brandJSON->content as $brand) {
|
32 |
+
$mBrands = Mage::getModel('db1_anymarket/anymarketbrands')->load($brand->id, 'brd_id');
|
33 |
+
$mBrands->setBrdId($brand->id);
|
34 |
+
$mBrands->setBrdName($brand->name);
|
35 |
+
$mBrands->setStatus("1");
|
36 |
+
$mBrands->setStores(array($storeID));
|
37 |
+
$mBrands->save();
|
38 |
+
|
39 |
+
$retCountBrand++;
|
40 |
+
}
|
41 |
+
} else {
|
42 |
+
$startRec = 1;
|
43 |
+
$countRec = 0;
|
44 |
+
|
45 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
46 |
+
$anymarketlog->setLogDesc('Error on get brands (' . $brandGetRet['return'] . ')');
|
47 |
+
$anymarketlog->setStatus("1");
|
48 |
+
$anymarketlog->setStores(array($storeID));
|
49 |
+
$anymarketlog->save();
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $retCountBrand;
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
}
|
app/code/community/DB1/AnyMarket/Helper/Category.php
CHANGED
@@ -1,114 +1,384 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_Category extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
$
|
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 |
-
|
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 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_Category extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
|
6 |
+
protected $arrJSON = array();
|
7 |
+
protected $arrDelCat = array();
|
8 |
+
protected $arrNewCateg = array();
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* export all category to AnyMarket
|
13 |
+
*
|
14 |
+
* @param $storeID
|
15 |
+
* @return integer
|
16 |
+
*/
|
17 |
+
public function exportCategories($storeID){
|
18 |
+
$rootCategoryId = Mage::app()->getStore($storeID)->getRootCategoryId();
|
19 |
+
if($rootCategoryId == 0){
|
20 |
+
$categories = Mage::getModel('catalog/category')
|
21 |
+
->getCollection()
|
22 |
+
->setStoreId($storeID)
|
23 |
+
->addFieldToFilter('is_active', 1)
|
24 |
+
->addAttributeToSelect('*')
|
25 |
+
->addAttributeToSort('position', 'asc');
|
26 |
+
}else{
|
27 |
+
$categories = Mage::getModel('catalog/category')
|
28 |
+
->getCollection()
|
29 |
+
->setStoreId($storeID)
|
30 |
+
->addFieldToFilter('is_active', 1)
|
31 |
+
->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
|
32 |
+
->addAttributeToSelect('*')
|
33 |
+
->addAttributeToSort('position', 'asc');
|
34 |
+
}
|
35 |
+
$fItem = true;
|
36 |
+
$cCateg = 0;
|
37 |
+
foreach ($categories as $category) {
|
38 |
+
$intAM = $category->getData('categ_integra_anymarket');
|
39 |
+
|
40 |
+
if($fItem && $intAM == 0){
|
41 |
+
continue;
|
42 |
+
}
|
43 |
+
$fItem = false;
|
44 |
+
|
45 |
+
if($intAM == 1){
|
46 |
+
$amCategParent = Mage::getModel('db1_anymarket/anymarketcategories')->load($category->getParentId(), 'nmc_id_magento');
|
47 |
+
if( $amCategParent->getData('nmc_cat_id') ){
|
48 |
+
$retuCateg = $this->exportSpecificCategory($category, $amCategParent->getData('nmc_cat_id'), $storeID);
|
49 |
+
}else{
|
50 |
+
$retuCateg = $this->exportSpecificCategory($category, null, $storeID);
|
51 |
+
}
|
52 |
+
if($retuCateg){
|
53 |
+
$cCateg++;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
return $cCateg;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Delete Specific Category Recursively
|
63 |
+
*
|
64 |
+
* @param $category
|
65 |
+
* @param $storeID
|
66 |
+
*/
|
67 |
+
public function deleteCategs($category, $storeID){
|
68 |
+
$this->arrDelCat = array();
|
69 |
+
array_push($this->arrDelCat, $category->getId());
|
70 |
+
$this->deleteCategRecursively($category, $storeID);
|
71 |
+
|
72 |
+
foreach ( array_reverse($this->arrDelCat) as $categ ) {
|
73 |
+
$_category = Mage::getModel('catalog/category')->load($categ);
|
74 |
+
Mage::helper('db1_anymarket/category')->deleteSpecificCategory($_category, $storeID);
|
75 |
+
}
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Delete Specific Category Recursively
|
81 |
+
*
|
82 |
+
* @param $category
|
83 |
+
* @param $storeID
|
84 |
+
*/
|
85 |
+
public function deleteCategRecursively($category, $storeID){
|
86 |
+
$subcats = $category->getChildren();
|
87 |
+
if($subcats != ''){
|
88 |
+
foreach(explode(',',$subcats) as $subCatid){
|
89 |
+
$_category = Mage::getModel('catalog/category')->load($subCatid);
|
90 |
+
|
91 |
+
array_push($this->arrDelCat, $subCatid);
|
92 |
+
if($_category->getChildren() != ''){
|
93 |
+
$this->deleteCategRecursively($_category, $storeID);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Delete Specific Category
|
101 |
+
*
|
102 |
+
* @param $category
|
103 |
+
* @param $storeID
|
104 |
+
*/
|
105 |
+
public function deleteSpecificCategory($category, $storeID){
|
106 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories')->load($category->getId(), 'nmc_id_magento');
|
107 |
+
if( $anymarketcategories->getData('nmc_cat_id') != '' ){
|
108 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
109 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
110 |
+
|
111 |
+
$headers = array(
|
112 |
+
"Content-type: application/json",
|
113 |
+
"Accept: */*",
|
114 |
+
"gumgaToken: ".$TOKEN
|
115 |
+
);
|
116 |
+
|
117 |
+
$returnDelCat = $this->CallAPICurl("DELETE", $HOST."/v2/categories/".$anymarketcategories->getData('nmc_cat_id'), $headers, null);
|
118 |
+
|
119 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
120 |
+
if($returnDelCat['error'] == '1'){
|
121 |
+
$anymarketlog->setLogDesc( 'Error on delete category ('.$category->getName().') - '.is_string($returnDelCat['return']) ? $returnDelCat['return'] : json_encode($returnDelCat['return']) );
|
122 |
+
}else{
|
123 |
+
$anymarketlog->setLogDesc( 'Deleted category ('.$category->getName().')' );
|
124 |
+
$anymarketcategories->delete();
|
125 |
+
}
|
126 |
+
$anymarketlog->setStatus("1");
|
127 |
+
$anymarketlog->setStores(array($storeID));
|
128 |
+
$anymarketlog->save();
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Export Specific Category Recursively
|
134 |
+
*
|
135 |
+
* @param $category
|
136 |
+
* @param $storeID
|
137 |
+
*/
|
138 |
+
public function exportCategRecursively($category, $storeID){
|
139 |
+
$subcats = $category->getChildren();
|
140 |
+
foreach(explode(',',$subcats) as $subCatid){
|
141 |
+
$_category = Mage::getModel('catalog/category')->load($subCatid);
|
142 |
+
if($_category->getData('categ_integra_anymarket') == 1){
|
143 |
+
$this->exportSpecificCategory($_category, $category->getId(), $storeID);
|
144 |
+
|
145 |
+
if($_category->getChildren() != ''){
|
146 |
+
$this->exportCategRecursively($_category, $storeID);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Export Specific Category
|
154 |
+
*
|
155 |
+
* @param $category
|
156 |
+
* @param $IdParent
|
157 |
+
* @param $storeID
|
158 |
+
* @return array|null
|
159 |
+
*/
|
160 |
+
public function exportSpecificCategory($category, $IdParent, $storeID){
|
161 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
162 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
163 |
+
|
164 |
+
$headers = array(
|
165 |
+
"Content-type: application/json",
|
166 |
+
"Accept: */*",
|
167 |
+
"gumgaToken: ".$TOKEN
|
168 |
+
);
|
169 |
+
|
170 |
+
$id = $category->getId();
|
171 |
+
$name = $category->getName();
|
172 |
+
|
173 |
+
$JSON = array(
|
174 |
+
"name" => $name,
|
175 |
+
"partnerId" => $id,
|
176 |
+
"parent" => array("id" => $IdParent),
|
177 |
+
"calculatedPrice" => true
|
178 |
+
);
|
179 |
+
|
180 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories')->load($category->getId(), 'nmc_id_magento');
|
181 |
+
if( $anymarketcategories->getData('nmc_cat_id') == '' ){
|
182 |
+
|
183 |
+
$parentID = $category->getParentId();
|
184 |
+
if($parentID){
|
185 |
+
$amCatPar = Mage::getModel('db1_anymarket/anymarketcategories')->load($parentID, 'nmc_id_magento');
|
186 |
+
$IdParent = $amCatPar->getData('nmc_cat_id');
|
187 |
+
$JSON["parent"] = array("id" => $IdParent);
|
188 |
+
}
|
189 |
+
|
190 |
+
$returnCat = $this->CallAPICurl("POST", $HOST."/v2/categories/", $headers, $JSON);
|
191 |
+
|
192 |
+
if($returnCat['error'] == '1'){
|
193 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
194 |
+
$anymarketlog->setLogDesc( 'Error on export category ('.$name.') - '.is_string($returnCat['return']) ? $returnCat['return'] : json_encode($returnCat['return']) );
|
195 |
+
$anymarketlog->setLogJson($returnCat['json']);
|
196 |
+
$anymarketlog->setStatus("1");
|
197 |
+
$anymarketlog->setStores(array($storeID));
|
198 |
+
$anymarketlog->save();
|
199 |
+
|
200 |
+
return null;
|
201 |
+
}else{
|
202 |
+
$JSONReturn = $returnCat['return'];
|
203 |
+
|
204 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
205 |
+
$anymarketlog->setLogDesc( 'Category successfully exported ('.$name.')' );
|
206 |
+
$anymarketlog->setLogJson($returnCat['json']);
|
207 |
+
$anymarketlog->setStatus("1");
|
208 |
+
$anymarketlog->setStores(array($storeID));
|
209 |
+
$anymarketlog->save();
|
210 |
+
|
211 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories');
|
212 |
+
$anymarketcategories->setNmcCatId( $JSONReturn->id );
|
213 |
+
$anymarketcategories->setNmcCatRootId( $IdParent != null ? $IdParent : '000' );
|
214 |
+
$anymarketcategories->setNmcCatDesc( $name );
|
215 |
+
$anymarketcategories->setNmcIdMagento( $id );
|
216 |
+
$anymarketcategories->setStatus('1');
|
217 |
+
$anymarketcategories->save();
|
218 |
+
|
219 |
+
if($category->getChildren() != ''){
|
220 |
+
$this->exportCategRecursively($category, $storeID);
|
221 |
+
}
|
222 |
+
|
223 |
+
return array($JSONReturn->id);
|
224 |
+
}
|
225 |
+
}else{
|
226 |
+
$amCatPar = Mage::getModel('db1_anymarket/anymarketcategories')->load($IdParent, 'nmc_id_magento');
|
227 |
+
$IdParent = $amCatPar->getData('nmc_cat_id');
|
228 |
+
$JSON["parent"] = array("id" => $IdParent);
|
229 |
+
|
230 |
+
$returnCatPUT = $this->CallAPICurl("PUT", $HOST."/v2/categories/".$anymarketcategories->getNmcCatId(), $headers, $JSON);
|
231 |
+
|
232 |
+
if($returnCatPUT['error'] == '1'){
|
233 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
234 |
+
$anymarketlog->setLogDesc( 'Error on update category ('.$name.') - '.is_string($returnCatPUT['return']) ? $returnCatPUT['return'] : json_encode($returnCatPUT['return']) );
|
235 |
+
$anymarketlog->setLogJson($returnCatPUT['json']);
|
236 |
+
$anymarketlog->setStatus("1");
|
237 |
+
$anymarketlog->setStores(array($storeID));
|
238 |
+
$anymarketlog->save();
|
239 |
+
|
240 |
+
return null;
|
241 |
+
}else{
|
242 |
+
$JSONReturn = $returnCatPUT['return'];
|
243 |
+
|
244 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
245 |
+
$anymarketlog->setLogDesc( 'Category successfully updated ('.$name.')' );
|
246 |
+
$anymarketlog->setLogJson($returnCatPUT['json']);
|
247 |
+
$anymarketlog->setStatus("1");
|
248 |
+
$anymarketlog->setStores(array($storeID));
|
249 |
+
$anymarketlog->save();
|
250 |
+
|
251 |
+
$anymarketcategories->setNmcCatRootId( $IdParent );
|
252 |
+
$anymarketcategories->setNmcCatDesc( $name );
|
253 |
+
$anymarketcategories->save();
|
254 |
+
|
255 |
+
return array($JSONReturn->id);
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
// ------ ANYMARKET
|
261 |
+
/**
|
262 |
+
* get all root category of AM
|
263 |
+
*/
|
264 |
+
public function getCategories($storeID){
|
265 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
266 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
267 |
+
|
268 |
+
$headers = array(
|
269 |
+
"Content-type: application/json",
|
270 |
+
"Accept: */*",
|
271 |
+
"gumgaToken: ".$TOKEN
|
272 |
+
);
|
273 |
+
|
274 |
+
$resCountCateg = 0;
|
275 |
+
$startRec = 0;
|
276 |
+
$countRec = 1;
|
277 |
+
$arrOrderCod = null;
|
278 |
+
$this->arrNewCateg = array();
|
279 |
+
while ($startRec <= $countRec) {
|
280 |
+
$returnCat = $this->CallAPICurl("GET", $HOST."/rest/api/v2/categories/?offset=".$startRec."&limit=30", $headers, null);
|
281 |
+
|
282 |
+
if($returnCat['error'] == '1'){
|
283 |
+
$startRec = 1;
|
284 |
+
$countRec = 0;
|
285 |
+
|
286 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
287 |
+
$anymarketlog->setLogDesc( 'Error on Sincronize Category '. $returnCat['return'] );
|
288 |
+
$anymarketlog->setStatus("1");
|
289 |
+
$anymarketlog->save();
|
290 |
+
}else{
|
291 |
+
$CatJSON = $returnCat['return'];
|
292 |
+
|
293 |
+
$startRec = $startRec + $CatJSON->page->size;
|
294 |
+
$countRec = $CatJSON->page->totalElements;
|
295 |
+
|
296 |
+
foreach ($CatJSON->content as $category) {
|
297 |
+
$IDCat = $category->id;
|
298 |
+
array_push($this->arrNewCateg, $IDCat);
|
299 |
+
$anymarketcategoriesUpdt = Mage::getModel('db1_anymarket/anymarketcategories')->load($IDCat, 'nmc_cat_id');
|
300 |
+
if($anymarketcategoriesUpdt->getData('nmc_cat_id') == null){
|
301 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories');
|
302 |
+
$anymarketcategories->setNmcCatId( $IDCat );
|
303 |
+
$anymarketcategories->setNmcCatRootId( '000' );
|
304 |
+
$anymarketcategories->setStatus('1');
|
305 |
+
$anymarketcategories->setNmcCatDesc( $category->name );
|
306 |
+
$anymarketcategories->setStores(array($storeID));
|
307 |
+
$anymarketcategories->save();
|
308 |
+
}else{
|
309 |
+
$anymarketcategoriesUpdt->setNmcCatDesc( $category->name );
|
310 |
+
$anymarketcategoriesUpdt->save();
|
311 |
+
}
|
312 |
+
|
313 |
+
$resCountCateg += $this->getChildCat($HOST, $headers, $category->id, $IDCat, $storeID);
|
314 |
+
$resCountCateg++;
|
315 |
+
}
|
316 |
+
|
317 |
+
}
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
return $resCountCateg;
|
322 |
+
/*
|
323 |
+
if(!empty($this->arrNewCateg) ){
|
324 |
+
$allCategs = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection();
|
325 |
+
|
326 |
+
foreach ($allCategs as $categ) {
|
327 |
+
if( !in_array($categ->getData('nmc_cat_id'), $this->arrNewCateg) ){
|
328 |
+
$categ->delete();
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
*/
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* get all child category of AM
|
337 |
+
*
|
338 |
+
* @param $HOST
|
339 |
+
* @param $headers
|
340 |
+
* @param $catID
|
341 |
+
* @param $IDCatRoot
|
342 |
+
* @param $id_store
|
343 |
+
*
|
344 |
+
* @return integer
|
345 |
+
*/
|
346 |
+
private function getChildCat($HOST, $headers, $catID, $IDCatRoot, $id_store){
|
347 |
+
$returnCatSpecific = $this->CallAPICurl("GET", $HOST."/rest/api/v2/categories/".$catID, $headers, null);
|
348 |
+
$CatSpecifivJSON = $returnCatSpecific['return'];
|
349 |
+
$retCategCount = 0;
|
350 |
+
if($returnCatSpecific['error'] == '0'){
|
351 |
+
if( isset($CatSpecifivJSON->children) ){
|
352 |
+
foreach ($CatSpecifivJSON->children as $catChild) {
|
353 |
+
|
354 |
+
array_push($this->arrNewCateg, $catChild->id);
|
355 |
+
$anymarketcategoriesUpdt = Mage::getModel('db1_anymarket/anymarketcategories')->load($catChild->id, 'nmc_cat_id');
|
356 |
+
if($anymarketcategoriesUpdt->getData('nmc_cat_id') == null){
|
357 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories');
|
358 |
+
$anymarketcategories->setNmcCatId( $catChild->id );
|
359 |
+
$anymarketcategories->setNmcCatRootId( $IDCatRoot );
|
360 |
+
$anymarketcategories->setStatus('1');
|
361 |
+
$anymarketcategories->setNmcCatDesc( $catChild->name );
|
362 |
+
$anymarketcategories->setStores(array($id_store));
|
363 |
+
$anymarketcategories->save();
|
364 |
+
}else{
|
365 |
+
$anymarketcategoriesUpdt->setNmcCatDesc( $catChild->name );
|
366 |
+
$anymarketcategoriesUpdt->save();
|
367 |
+
}
|
368 |
+
|
369 |
+
$retCategCount += $this->getChildCat($HOST, $headers, $catChild->id, $catChild->id, $id_store);
|
370 |
+
$retCategCount++;
|
371 |
+
}
|
372 |
+
}
|
373 |
+
}else{
|
374 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
375 |
+
$anymarketlog->setLogDesc( $returnCatSpecific['return'] );
|
376 |
+
$anymarketlog->setLogId( $IDCatRoot );
|
377 |
+
$anymarketlog->setStatus("1");
|
378 |
+
$anymarketlog->save();
|
379 |
+
}
|
380 |
+
return $retCategCount;
|
381 |
+
}
|
382 |
+
|
383 |
+
|
384 |
Â
}
|
app/code/community/DB1/AnyMarket/Helper/Customergenerator.php
CHANGED
@@ -1,152 +1,154 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_CustomerGenerator extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
protected $_defaultData = array (
|
6 |
-
'account' => array(
|
7 |
-
'website_id' => '1',
|
8 |
-
'group_id' => '1',
|
9 |
-
'prefix' => '',
|
10 |
-
'firstname' => 'Firstname{id}',
|
11 |
-
'middlename' => '',
|
12 |
-
'lastname' => '
|
13 |
-
'suffix' => '',
|
14 |
-
'email' => 'email{id}@example.net',
|
15 |
-
'dob' => '',
|
16 |
-
'taxvat' => '',
|
17 |
-
'gender' => '',
|
18 |
-
'sendemail_store_id' => '1',
|
19 |
-
'password' => 'a111111',
|
20 |
-
'default_billing' => '_item1',
|
21 |
-
'default_shipping' => '_item1',
|
22 |
-
),
|
23 |
-
'address' => array(
|
24 |
-
'_item1' => array(
|
25 |
-
'prefix' => '',
|
26 |
-
'firstname' => 'Firstname',
|
27 |
-
'middlename' => '',
|
28 |
-
'lastname' => '
|
29 |
-
'suffix' => '',
|
30 |
-
'company' => '',
|
31 |
-
'street' => array(
|
32 |
-
0 => 'Address',
|
33 |
-
1 => '',
|
34 |
-
),
|
35 |
-
'city' => 'City',
|
36 |
-
'country_id' => 'US',
|
37 |
-
'region_id' => '12',
|
38 |
-
'region' => '',
|
39 |
-
'postcode' => '123123',
|
40 |
-
'telephone' => '123123123',
|
41 |
-
'fax' => '',
|
42 |
-
'vat_id' => '',
|
43 |
-
),
|
44 |
-
),
|
45 |
-
);
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @var Mage_Core_Model_Resource_Resource $_resource
|
49 |
-
*/
|
50 |
-
protected $_resource;
|
51 |
-
/**
|
52 |
-
* @var Varien_Db_Adapter_Interface $_adapter
|
53 |
-
*/
|
54 |
-
protected $_adapter;
|
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 |
-
$this->
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$customer
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
$
|
119 |
-
|
120 |
-
$address->
|
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 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_CustomerGenerator extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
protected $_defaultData = array (
|
6 |
+
'account' => array(
|
7 |
+
'website_id' => '1',
|
8 |
+
'group_id' => '1',
|
9 |
+
'prefix' => '',
|
10 |
+
'firstname' => 'Firstname{id}',
|
11 |
+
'middlename' => '',
|
12 |
+
'lastname' => '.',
|
13 |
+
'suffix' => '',
|
14 |
+
'email' => 'email{id}@example.net',
|
15 |
+
'dob' => '',
|
16 |
+
'taxvat' => '',
|
17 |
+
'gender' => '',
|
18 |
+
'sendemail_store_id' => '1',
|
19 |
+
'password' => 'a111111',
|
20 |
+
'default_billing' => '_item1',
|
21 |
+
'default_shipping' => '_item1',
|
22 |
+
),
|
23 |
+
'address' => array(
|
24 |
+
'_item1' => array(
|
25 |
+
'prefix' => '',
|
26 |
+
'firstname' => 'Firstname',
|
27 |
+
'middlename' => '',
|
28 |
+
'lastname' => '.',
|
29 |
+
'suffix' => '',
|
30 |
+
'company' => '',
|
31 |
+
'street' => array(
|
32 |
+
0 => 'Address',
|
33 |
+
1 => '',
|
34 |
+
),
|
35 |
+
'city' => 'City',
|
36 |
+
'country_id' => 'US',
|
37 |
+
'region_id' => '12',
|
38 |
+
'region' => '',
|
39 |
+
'postcode' => '123123',
|
40 |
+
'telephone' => '123123123',
|
41 |
+
'fax' => '',
|
42 |
+
'vat_id' => '',
|
43 |
+
),
|
44 |
+
),
|
45 |
+
);
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var Mage_Core_Model_Resource_Resource $_resource
|
49 |
+
*/
|
50 |
+
protected $_resource;
|
51 |
+
/**
|
52 |
+
* @var Varien_Db_Adapter_Interface $_adapter
|
53 |
+
*/
|
54 |
+
protected $_adapter;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* DB1_AnyMarket_Helper_CustomerGenerator constructor.
|
58 |
+
*/
|
59 |
+
public function __construct()
|
60 |
+
{
|
61 |
+
$this->_resource = Mage::getResourceSingleton('core/resource');
|
62 |
+
$this->_adapter = $this->_resource->getReadConnection();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @param $data
|
67 |
+
*/
|
68 |
+
protected function _processTemplates(&$data)
|
69 |
+
{
|
70 |
+
$config = $this->_adapter->getConfig();
|
71 |
+
|
72 |
+
$select = $this->_adapter->select();
|
73 |
+
$select
|
74 |
+
->from('information_schema.tables', 'AUTO_INCREMENT')
|
75 |
+
->where('table_schema = ?', $config['dbname'])
|
76 |
+
->where(
|
77 |
+
'table_name = ?',
|
78 |
+
$this->_adapter->getTableName('customer_entity')
|
79 |
+
);
|
80 |
+
|
81 |
+
$nextId = $this->_adapter->fetchOne($select);
|
82 |
+
|
83 |
+
foreach ($data['account'] as &$field){
|
84 |
+
$field = str_replace('{id}', $nextId, $field);
|
85 |
+
}
|
86 |
+
|
87 |
+
foreach ($data['address'] as &$address) {
|
88 |
+
foreach ($address as &$field) {
|
89 |
+
$field = str_replace('{id}', $nextId, $field);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @param array $data
|
96 |
+
* @return array
|
97 |
+
*/
|
98 |
+
public function createCustomer($data = array())
|
99 |
+
{
|
100 |
+
$data = array_replace_recursive($this->_defaultData, $data);
|
101 |
+
|
102 |
+
$this->_processTemplates($data);
|
103 |
+
|
104 |
+
/** @var $customer Mage_Customer_Model_Customer */
|
105 |
+
$customer = Mage::getModel('customer/customer');
|
106 |
+
|
107 |
+
$customer->setData($data['account']);
|
108 |
+
|
109 |
+
foreach (array_keys($data['address']) as $index) {
|
110 |
+
$address = Mage::getModel('customer/address');
|
111 |
+
|
112 |
+
$addressData = array_merge($data['account'], $data['address'][$index]);
|
113 |
+
|
114 |
+
// Set default billing and shipping flags to address
|
115 |
+
$isDefaultBilling = isset($data['account']['default_billing'])
|
116 |
+
&& $data['account']['default_billing'] == $index;
|
117 |
+
$address->setIsDefaultBilling($isDefaultBilling);
|
118 |
+
$isDefaultShipping = isset($data['account']['default_shipping'])
|
119 |
+
&& $data['account']['default_shipping'] == $index;
|
120 |
+
$address->setIsDefaultShipping($isDefaultShipping);
|
121 |
+
|
122 |
+
$address->addData($addressData);
|
123 |
+
|
124 |
+
// Set post_index for detect default billing and shipping addresses
|
125 |
+
$address->setPostIndex($index);
|
126 |
+
|
127 |
+
$customer->addAddress($address);
|
128 |
+
}
|
129 |
+
|
130 |
+
// Default billing and shipping
|
131 |
+
if (isset($data['account']['default_billing'])) {
|
132 |
+
$customer->setData('default_billing', $data['account']['default_billing']);
|
133 |
+
}
|
134 |
+
if (isset($data['account']['default_shipping'])) {
|
135 |
+
$customer->setData('default_shipping', $data['account']['default_shipping']);
|
136 |
+
}
|
137 |
+
if (isset($data['account']['confirmation'])) {
|
138 |
+
$customer->setData('confirmation', $data['account']['confirmation']);
|
139 |
+
}
|
140 |
+
|
141 |
+
if (isset($data['account']['sendemail_store_id'])) {
|
142 |
+
$customer->setSendemailStoreId($data['account']['sendemail_store_id']);
|
143 |
+
}
|
144 |
+
|
145 |
+
$customer
|
146 |
+
->setPassword($data['account']['password'])
|
147 |
+
->setForceConfirmed(true)
|
148 |
+
->save()
|
149 |
+
->cleanAllAddresses()
|
150 |
+
;
|
151 |
+
|
152 |
+
return array ("customer" => $customer, "addr" => $address );
|
153 |
+
}
|
154 |
Â
}
|
app/code/community/DB1/AnyMarket/Helper/Data.php
CHANGED
@@ -1,214 +1,288 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* AnyMarket default helper
|
4 |
-
*
|
5 |
-
* @category DB1
|
6 |
-
* @package DB1_AnyMarket
|
7 |
-
*/
|
8 |
-
class DB1_AnyMarket_Helper_Data extends Mage_Core_Helper_Abstract
|
9 |
-
{
|
10 |
-
|
11 |
-
|
12 |
-
*
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
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 |
-
|
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 |
Â
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AnyMarket default helper
|
4 |
+
*
|
5 |
+
* @category DB1
|
6 |
+
* @package DB1_AnyMarket
|
7 |
+
*/
|
8 |
+
class DB1_AnyMarket_Helper_Data extends Mage_Core_Helper_Abstract
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public function getCurrentStoreView(){
|
15 |
+
$storeID = Mage::app()->getStore()->getId();
|
16 |
+
if( $storeID == null || $storeID == 0 ){
|
17 |
+
$storeID = Mage::app()->getDefaultStoreView()->getId();
|
18 |
+
if( $storeID == null ){
|
19 |
+
$storeID = 1;
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
return $storeID;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param $OI
|
28 |
+
* @return array
|
29 |
+
*/
|
30 |
+
public function getTokenByOi($OI) {
|
31 |
+
$allStores = $this->getAllStores();
|
32 |
+
|
33 |
+
$arrStores = array();
|
34 |
+
$OIConfig = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_oi_field', 0);
|
35 |
+
if( $OI == $OIConfig ){
|
36 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', 0);
|
37 |
+
array_push($arrStores, array(
|
38 |
+
"token" => $TOKEN,
|
39 |
+
"storeID" => '0',
|
40 |
+
));
|
41 |
+
}
|
42 |
+
|
43 |
+
foreach ($allStores as $store) {
|
44 |
+
$storeID = $store['store_id'];
|
45 |
+
$OIConfig = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_oi_field', $storeID);
|
46 |
+
if( $OI == $OIConfig ){
|
47 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
48 |
+
array_push($arrStores, array(
|
49 |
+
"token" => $TOKEN,
|
50 |
+
"storeID" => $storeID,
|
51 |
+
));
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
return $arrStores;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* check if module is enabled
|
60 |
+
*/
|
61 |
+
public function anymarketModuleIsEnabled()
|
62 |
+
{
|
63 |
+
$outputPath = "advanced/modules_disable_output/DB1_AnyMarket";
|
64 |
+
|
65 |
+
$enableConfig = new Mage_Core_Model_Config();
|
66 |
+
$enableConfig->saveConfig($outputPath, "1");
|
67 |
+
unset($enableConfig);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* get Document Type
|
72 |
+
*
|
73 |
+
* @param $document
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function getDocumentType($document)
|
77 |
+
{
|
78 |
+
$document = str_replace("/","", str_replace("-","",str_replace(".","",$document)));
|
79 |
+
$docCount = strlen($document);
|
80 |
+
|
81 |
+
$tpDoc = "CPF";
|
82 |
+
if( $docCount == 14 ){
|
83 |
+
$tpDoc = "CNPJ";
|
84 |
+
}
|
85 |
+
|
86 |
+
return $tpDoc;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* convert array to options
|
91 |
+
*
|
92 |
+
* @param $options
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function convertOptions($options)
|
96 |
+
{
|
97 |
+
$converted = array();
|
98 |
+
foreach ($options as $option) {
|
99 |
+
if (isset($option['value']) && !is_array($option['value']) &&
|
100 |
+
isset($option['label']) && !is_array($option['label'])) {
|
101 |
+
$converted[$option['value']] = $option['label'];
|
102 |
+
}
|
103 |
+
}
|
104 |
+
return $converted;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* get substring between two caracter
|
109 |
+
*
|
110 |
+
* @param $content
|
111 |
+
* @param $start
|
112 |
+
* @param $end
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function getBetweenCaract($content, $start, $end)
|
116 |
+
{
|
117 |
+
$r = explode($start, $content);
|
118 |
+
if (isset($r[1])){
|
119 |
+
$r = explode($end, $r[1]);
|
120 |
+
return $r[0];
|
121 |
+
}
|
122 |
+
return '';
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* get all store data
|
127 |
+
*
|
128 |
+
* @param null $websiteID
|
129 |
+
* @return array
|
130 |
+
*/
|
131 |
+
public function getAllStores($websiteID = null)
|
132 |
+
{
|
133 |
+
$arrStores = array();
|
134 |
+
if(!$websiteID){
|
135 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
136 |
+
foreach ($website->getGroups() as $group) {
|
137 |
+
$stores = $group->getStores();
|
138 |
+
foreach ($stores as $store) {
|
139 |
+
array_push($arrStores, $store->getData());
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}else{
|
144 |
+
$website = Mage::getModel('core/website')->load($websiteID);
|
145 |
+
|
146 |
+
foreach ($website->getStoreIds() as $storeid) {
|
147 |
+
$storeDat = Mage::getModel('core/store')->load($storeid);
|
148 |
+
array_push($arrStores, $storeDat->getData());
|
149 |
+
}
|
150 |
+
}
|
151 |
+
array_push($arrStores, array("store_id" => 0) );
|
152 |
+
return $arrStores;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* call curl
|
157 |
+
*
|
158 |
+
* @param $method
|
159 |
+
* @param $url
|
160 |
+
* @param $headers
|
161 |
+
* @param $params
|
162 |
+
* @return array|string
|
163 |
+
*/
|
164 |
+
public function CallAPICurl($method, $url, $headers, $params){
|
165 |
+
$curl = curl_init($url);
|
166 |
+
|
167 |
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
168 |
+
$data_string = "";
|
169 |
+
if ($method == "POST"){
|
170 |
+
$data_string = json_encode($params);
|
171 |
+
curl_setopt($curl, CURLOPT_POST, true);
|
172 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
|
173 |
+
}else if($method == "PUT"){
|
174 |
+
$data_string = json_encode($params);
|
175 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
176 |
+
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
|
177 |
+
}else if($method == "DELETE"){
|
178 |
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
179 |
+
}
|
180 |
+
|
181 |
+
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT ,0);
|
182 |
+
curl_setopt($curl, CURLOPT_TIMEOUT, 400);
|
183 |
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
184 |
+
$curl_response = curl_exec($curl);
|
185 |
+
$err = curl_error($curl);
|
186 |
+
|
187 |
+
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
188 |
+
|
189 |
+
if ( $status == 200 || $status == 204 || $status == 201 ) {
|
190 |
+
$retorno = array("error" => "0", "json" => $data_string, "return" => json_decode($curl_response) );
|
191 |
+
}else{
|
192 |
+
if($err){
|
193 |
+
$retorno = array("error" => "1", "json" => $data_string,"return" => 'Error Curl: '.$err );
|
194 |
+
}else{
|
195 |
+
$retJsonCurlResp = json_decode($curl_response);
|
196 |
+
|
197 |
+
$retString = '';
|
198 |
+
if( isset($retJsonCurlResp->message) ){
|
199 |
+
$retString = 'Message: '.utf8_encode($retJsonCurlResp->message);
|
200 |
+
}
|
201 |
+
|
202 |
+
if( isset($retJsonCurlResp->details) ){
|
203 |
+
$retString .= '; Details: '.utf8_encode($retJsonCurlResp->details);
|
204 |
+
}
|
205 |
+
|
206 |
+
if( isset($retJsonCurlResp->fieldErrors) ){
|
207 |
+
$retString .= '; Field Erros: (';
|
208 |
+
foreach ($retJsonCurlResp->fieldErrors as $error) {
|
209 |
+
$retString .= 'Field: '.utf8_encode($error->field);
|
210 |
+
$retString .= ', Message: '.utf8_encode($error->message).';';
|
211 |
+
}
|
212 |
+
$retString .= ')';
|
213 |
+
}
|
214 |
+
|
215 |
+
if($retString != ''){
|
216 |
+
$retorno = array("error" => "1", "json" => $data_string, "return" => $retString );
|
217 |
+
}else{
|
218 |
+
$retorno = array("error" => "1", "json" => $data_string, "return" => utf8_encode($curl_response) );
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
if($retorno == ""){
|
224 |
+
$retorno = $data_string;
|
225 |
+
}
|
226 |
+
|
227 |
+
curl_close($curl);
|
228 |
+
|
229 |
+
/*
|
230 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
231 |
+
$anymarketlog->setLogDesc( 'Call(MET: '.$method.' URL: '.$url.' JSON: '.json_encode($params).')');
|
232 |
+
$anymarketlog->setLogJson( json_encode($retorno) );
|
233 |
+
$anymarketlog->setStatus("1");
|
234 |
+
$anymarketlog->save();
|
235 |
+
*/
|
236 |
+
return $retorno;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* add message inbox of magento
|
241 |
+
*
|
242 |
+
* @param $title
|
243 |
+
* @param $Desc
|
244 |
+
* @param $URL
|
245 |
+
*/
|
246 |
+
public function addMessageInBox($storeID ,$title, $Desc, $URL){
|
247 |
+
|
248 |
+
$addMsgInbox = Mage::getStoreConfig('anymarket_section/anymarket_logs_group/anymarket_inbox_field', $storeID);
|
249 |
+
if( $addMsgInbox == '1' ) {
|
250 |
+
if (Mage::helper('core')->isModuleEnabled('Mage_AdminNotification')) {
|
251 |
+
$AdminNotice = Mage::getModel('adminnotification/inbox');
|
252 |
+
$AdminNotice->setSeverity('2');
|
253 |
+
$AdminNotice->setTitle($title);
|
254 |
+
$AdminNotice->setDescription($Desc);
|
255 |
+
$AdminNotice->setUrl($URL);
|
256 |
+
$AdminNotice->setDateAdded(date('Y-m-d H:i:s'));
|
257 |
+
$AdminNotice->save();
|
258 |
+
}
|
259 |
+
}
|
260 |
+
Mage::getSingleton('adminhtml/session')->addError($Desc);
|
261 |
+
}
|
262 |
+
|
263 |
+
|
264 |
+
/**
|
265 |
+
*
|
266 |
+
*/
|
267 |
+
public function massInsertAttribute(){
|
268 |
+
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
269 |
+
$storeID = $this->getCurrentStoreView();
|
270 |
+
|
271 |
+
foreach ($productAttrs as $productAttr) {
|
272 |
+
if($productAttr->getFrontendLabel() != null){
|
273 |
+
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeId(), 'nma_id_attr');
|
274 |
+
|
275 |
+
if($attrCheck->getData('nma_id_attr') == null){
|
276 |
+
$anymarketattribute = Mage::getModel('db1_anymarket/anymarketattributes');
|
277 |
+
$anymarketattribute->setNmaIdAttr( $productAttr->getAttributeId() );
|
278 |
+
$anymarketattribute->setNmaDesc( $productAttr->getFrontendLabel() );
|
279 |
+
$anymarketattribute->setStatus( "0" );
|
280 |
+
$anymarketattribute->setStores(array($storeID));
|
281 |
+
$anymarketattribute->save();
|
282 |
+
}
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
|
288 |
Â
}
|
app/code/community/DB1/AnyMarket/Helper/Order.php
CHANGED
@@ -1,888 +1,1045 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
|
6 |
-
|
7 |
-
*
|
8 |
-
*
|
9 |
-
* @param $OrderRowData
|
10 |
-
* @return string
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
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 |
-
|
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 |
-
$AddressShipBill =
|
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 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
$
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
}
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
$
|
494 |
-
|
495 |
-
$
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
$
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
$
|
648 |
-
$
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
$
|
701 |
-
|
702 |
-
$
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
$
|
837 |
-
|
838 |
-
$
|
839 |
-
$
|
840 |
-
|
841 |
-
|
842 |
-
$
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* get status order AM to MG from configs
|
8 |
+
*
|
9 |
+
* @param $OrderRowData
|
10 |
+
* @return string
|
11 |
+
*/
|
12 |
+
private function getStatusAnyMarketToMageOrderConfig($storeID, $OrderRowData){
|
13 |
+
if($OrderRowData == null){
|
14 |
+
$OrderRowData = "new";
|
15 |
+
}
|
16 |
+
|
17 |
+
$StatusOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_status_am_mg_field', $storeID);
|
18 |
+
$OrderReturn = 'ERROR: 1 Não há uma configuração válida para '.$OrderRowData;
|
19 |
+
$StateReturn = "";
|
20 |
+
if ($StatusOrder && $StatusOrder != 'a:0:{}') {
|
21 |
+
$StatusOrder = unserialize($StatusOrder);
|
22 |
+
if (is_array($StatusOrder)) {
|
23 |
+
foreach($StatusOrder as $StatusOrderRow) {
|
24 |
+
if($StatusOrderRow['orderStatusAM'] == $OrderRowData){
|
25 |
+
$OrderReturn = $StatusOrderRow['orderStatusMG'];
|
26 |
+
$statuses = Mage::getModel('sales/order_status')->getCollection()->joinStates()
|
27 |
+
->addFieldToFilter('main_table.status',array('eq'=>$OrderReturn));
|
28 |
+
//->addStatusFilter($OrderReturn);
|
29 |
+
|
30 |
+
$StateReturn = $statuses->getFirstItem()->getData('state');
|
31 |
+
break;
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
return array("status" => $OrderReturn, "state" => $StateReturn);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* create log order magento
|
43 |
+
*
|
44 |
+
* @param $fieldFilter
|
45 |
+
* @param $fieldDataFilter
|
46 |
+
* @param $statusInt
|
47 |
+
* @param $descError
|
48 |
+
* @param $idSeqAnyMarket
|
49 |
+
* @param $IDOrderAnyMarket
|
50 |
+
* @param $nmoIdOrder
|
51 |
+
* @param $storeID
|
52 |
+
*/
|
53 |
+
private function saveLogOrder($fieldFilter, $fieldDataFilter, $statusInt, $descError, $idSeqAnyMarket, $IDOrderAnyMarket, $nmoIdOrder, $storeID){
|
54 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
55 |
+
$anymarketorders->load($fieldDataFilter, $fieldFilter);
|
56 |
+
|
57 |
+
$anymarketorders->setStatus("0");
|
58 |
+
$anymarketorders->setNmoStatusInt($statusInt);
|
59 |
+
$anymarketorders->setNmoDescError($descError);
|
60 |
+
$anymarketorders->setNmoIdSeqAnymarket( $idSeqAnyMarket );
|
61 |
+
$anymarketorders->setNmoIdAnymarket( $IDOrderAnyMarket );
|
62 |
+
$anymarketorders->setNmoIdOrder($nmoIdOrder);
|
63 |
+
$anymarketorders->setStores(array($storeID));
|
64 |
+
$anymarketorders->save();
|
65 |
+
|
66 |
+
if( $descError != "" ) {
|
67 |
+
Mage::getSingleton('adminhtml/session')->addError($descError);
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* get status order MG to AM from configs
|
73 |
+
*
|
74 |
+
* @param $OrderRowData
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
private function getStatusMageToAnyMarketOrderConfig($storeID, $OrderRowData){
|
78 |
+
if($OrderRowData == null){
|
79 |
+
$OrderRowData = "new";
|
80 |
+
}
|
81 |
+
|
82 |
+
$StatusOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_status_mg_am_field', $storeID);
|
83 |
+
$OrderReturn = 'ERROR: 2 Não há uma configuração válida para '.$OrderRowData;
|
84 |
+
if ($StatusOrder && $StatusOrder != 'a:0:{}') {
|
85 |
+
$StatusOrder = unserialize($StatusOrder);
|
86 |
+
if (is_array($StatusOrder)) {
|
87 |
+
foreach($StatusOrder as $StatusOrderRow) {
|
88 |
+
if($StatusOrderRow['orderStatusMG'] == $OrderRowData){
|
89 |
+
$OrderReturn = $StatusOrderRow['orderStatusAM'];
|
90 |
+
break;
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $OrderReturn;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* create order in Magento
|
102 |
+
*
|
103 |
+
* @param $storeID
|
104 |
+
* @param $OrderJSON
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
public function getCompleteAddressOrder($storeID, $OrderJSON){
|
108 |
+
$retArrStreet = array(
|
109 |
+
0 => "Frete não especificado.",
|
110 |
+
1 => " ",
|
111 |
+
2 => " ",
|
112 |
+
3 => " "
|
113 |
+
);
|
114 |
+
|
115 |
+
if( isset($OrderJSON->shipping) ) {
|
116 |
+
if (isset($OrderJSON->shipping->address)) {
|
117 |
+
$OrderJSON = json_decode(json_encode($OrderJSON), true);
|
118 |
+
|
119 |
+
$street1 = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_add1_field', $storeID);
|
120 |
+
$street2 = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_add2_field', $storeID);
|
121 |
+
$street3 = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_add3_field', $storeID);
|
122 |
+
$street4 = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_add4_field', $storeID);
|
123 |
+
|
124 |
+
$street1 = (isset($OrderJSON['shipping'][$street1])) ? $OrderJSON['shipping'][$street1] : $OrderJSON['shipping']['address'];
|
125 |
+
$street2 = (isset($OrderJSON['shipping'][$street2])) ? $OrderJSON['shipping'][$street2] : '';
|
126 |
+
$street3 = (isset($OrderJSON['shipping'][$street3])) ? $OrderJSON['shipping'][$street3] : '';
|
127 |
+
$street4 = (isset($OrderJSON['shipping'][$street4])) ? $OrderJSON['shipping'][$street4] : '';
|
128 |
+
|
129 |
+
$retArrStreet = array(
|
130 |
+
0 => $street1,
|
131 |
+
1 => $street2,
|
132 |
+
2 => $street3,
|
133 |
+
3 => $street4
|
134 |
+
);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
return $retArrStreet;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* create order in Magento
|
143 |
+
*
|
144 |
+
* @param $anymarketordersSpec
|
145 |
+
* @param $products
|
146 |
+
* @param $customer
|
147 |
+
* @param $IDAnyMarket
|
148 |
+
* @param $IDSeqAnyMarket
|
149 |
+
* @param $infoMetPag
|
150 |
+
* @param $Billing
|
151 |
+
* @param $Shipping
|
152 |
+
* @param $shippValue
|
153 |
+
* @return integer
|
154 |
+
*/
|
155 |
+
private function create_order($anymarketordersSpec, $products, $customer, $IDAnyMarket, $IDSeqAnyMarket, $infoMetPag, $Billing, $Shipping, $shippValue, $storeID)
|
156 |
+
{
|
157 |
+
if( ($anymarketordersSpec->getData('nmo_id_anymarket') == null) ||
|
158 |
+
($anymarketordersSpec->getData('nmo_status_int') == "Não integrado (AnyMarket)") ||
|
159 |
+
($anymarketordersSpec->getData('nmo_status_int') == "ERROR 01") ) {
|
160 |
+
$AttrToDoc = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_doc_type_field', $storeID));
|
161 |
+
|
162 |
+
$orderGenerator = Mage::helper('db1_anymarket/ordergenerator');
|
163 |
+
$orderGenerator->_storeId = $storeID;
|
164 |
+
|
165 |
+
$orderGenerator->setShippingMethod('freeshipping_freeshipping');
|
166 |
+
$orderGenerator->setPaymentMethod('db1_anymarket');
|
167 |
+
$orderGenerator->setAdditionalInformation($infoMetPag);
|
168 |
+
$orderGenerator->setShippingValue($shippValue);
|
169 |
+
$orderGenerator->setShipAddress($Shipping);
|
170 |
+
$orderGenerator->setBillAddress($Billing);
|
171 |
+
$orderGenerator->setCustomer($customer);
|
172 |
+
$orderGenerator->setCpfCnpj($customer->getData($AttrToDoc));
|
173 |
+
|
174 |
+
$CodOrder = $orderGenerator->createOrder($products);
|
175 |
+
|
176 |
+
$this->saveLogOrder('nmo_id_anymarket', $IDAnyMarket, 'Integrado', '', $IDSeqAnyMarket, $IDAnyMarket, $CodOrder, $storeID);
|
177 |
+
|
178 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
179 |
+
$anymarketlog->setLogDesc('Order Created: ' . $CodOrder . ' ID Anymarket: ' . $IDAnyMarket);
|
180 |
+
$anymarketlog->setStatus("0");
|
181 |
+
$anymarketlog->setStores(array($storeID));
|
182 |
+
$anymarketlog->save();
|
183 |
+
}else{
|
184 |
+
$CodOrder = $anymarketordersSpec->getData('nmo_id_order');
|
185 |
+
}
|
186 |
+
|
187 |
+
return $CodOrder;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* get all order in feed AnyMarket
|
192 |
+
*/
|
193 |
+
public function getFeedOrdersFromAnyMarket($storeID){
|
194 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
195 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
196 |
+
|
197 |
+
$headers = array(
|
198 |
+
"Content-type: application/json",
|
199 |
+
"Accept: */*",
|
200 |
+
"gumgaToken: ".$TOKEN
|
201 |
+
);
|
202 |
+
|
203 |
+
$returnProd = $this->CallAPICurl("GET", $HOST."/v2/orders/feeds?limit=100", $headers, null);
|
204 |
+
|
205 |
+
if($returnProd['error'] == '1'){
|
206 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
207 |
+
$anymarketlog->setLogDesc( 'Error on get feed orders '. $returnProd['return'] );
|
208 |
+
$anymarketlog->setStatus("1");
|
209 |
+
$anymarketlog->save();
|
210 |
+
}else{
|
211 |
+
$listOrders = $returnProd['return'];
|
212 |
+
|
213 |
+
foreach ($listOrders as $order) {
|
214 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($order->id, 'nmo_id_seq_anymarket');
|
215 |
+
if( $anymarketorders->getData('nmo_id_anymarket') != null ){
|
216 |
+
$this->getSpecificOrderFromAnyMarket($anymarketorders->getData('nmo_id_seq_anymarket'), '', $storeID);
|
217 |
+
}else{
|
218 |
+
$this->getSpecificOrderFromAnyMarket($order->id, $order->token, $storeID);
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* get specific order from AnyMarket
|
226 |
+
*
|
227 |
+
* @param $idSeqAnyMarket
|
228 |
+
* @param $tokenFeed
|
229 |
+
* @param $storeID
|
230 |
+
*/
|
231 |
+
public function getSpecificOrderFromAnyMarket($idSeqAnyMarket, $tokenFeed, $storeID){
|
232 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
233 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
234 |
+
$headers = array(
|
235 |
+
"Content-type: application/json",
|
236 |
+
"Accept: */*",
|
237 |
+
"gumgaToken: ".$TOKEN
|
238 |
+
);
|
239 |
+
|
240 |
+
$stateProds = true;
|
241 |
+
$returnOrderItens = $this->CallAPICurl("GET", $HOST."/v2/orders/".$idSeqAnyMarket, $headers, null);
|
242 |
+
if($returnOrderItens['error'] == '0'){
|
243 |
+
$OrderJSON = $returnOrderItens['return'];
|
244 |
+
$IDOrderAnyMarket = $OrderJSON->marketPlaceId;
|
245 |
+
$anymarketordersSpec = Mage::getModel('db1_anymarket/anymarketorders');
|
246 |
+
$anymarketordersSpec->load($idSeqAnyMarket, 'nmo_id_seq_anymarket');
|
247 |
+
|
248 |
+
|
249 |
+
if( ($anymarketordersSpec->getData('nmo_id_anymarket') == null) ||
|
250 |
+
($anymarketordersSpec->getData('nmo_status_int') == "Não integrado (AnyMarket)") ||
|
251 |
+
($anymarketordersSpec->getData('nmo_status_int') == "ERROR 01") ){
|
252 |
+
$STATUSIMPORT = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_stauts_order_field', $storeID);
|
253 |
+
if (strpos($STATUSIMPORT, $OrderJSON->status) !== false) {
|
254 |
+
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
255 |
+
if($ConfigOrder == 1) {
|
256 |
+
$statsConfig = $this->getStatusAnyMarketToMageOrderConfig($storeID, $OrderJSON->status);
|
257 |
+
$statusMage = $statsConfig["status"];
|
258 |
+
|
259 |
+
if (strpos($statusMage, 'ERROR:') === false) {
|
260 |
+
//TRATA OS PRODUTOS
|
261 |
+
$_products = array();
|
262 |
+
foreach ($OrderJSON->items as $item) {
|
263 |
+
$productLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $item->sku->partnerId);
|
264 |
+
if ($productLoaded) {
|
265 |
+
$arrayTMP = array(
|
266 |
+
'product' => $productLoaded->getId(),
|
267 |
+
'price' => $item->unit,
|
268 |
+
'qty' => $item->amount,
|
269 |
+
);
|
270 |
+
array_push($_products, $arrayTMP);
|
271 |
+
} else {
|
272 |
+
if ($anymarketordersSpec->getData('nmo_id_anymarket') == null) {
|
273 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders');
|
274 |
+
} else {
|
275 |
+
$anymarketorders = $anymarketordersSpec;
|
276 |
+
}
|
277 |
+
|
278 |
+
$this->saveLogOrder('nmo_id_seq_anymarket',
|
279 |
+
$idSeqAnyMarket,
|
280 |
+
'ERROR 01',
|
281 |
+
Mage::helper('db1_anymarket')->__('Product is not registered') . ' (SKU: ' . $item->sku->partnerId . ')',
|
282 |
+
$idSeqAnyMarket,
|
283 |
+
$IDOrderAnyMarket,
|
284 |
+
'',
|
285 |
+
$storeID);
|
286 |
+
|
287 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
288 |
+
$anymarketlog->setLogDesc(Mage::helper('db1_anymarket')->__('Product is not registered') . ' (Order: ' . $idSeqAnyMarket . ', SKU : ' . $item->sku->partnerId . ')');
|
289 |
+
$anymarketlog->setStores(array($storeID));
|
290 |
+
$anymarketlog->setStatus("0");
|
291 |
+
$anymarketlog->save();
|
292 |
+
|
293 |
+
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
294 |
+
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ') . "Anymarket(" . $IDOrderAnyMarket . ") <br/>" .
|
295 |
+
Mage::helper('db1_anymarket')->__('Product is not registered') . ' (SKU: ' . $item->sku->partnerId . ')',
|
296 |
+
'');
|
297 |
+
$stateProds = false;
|
298 |
+
break;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
//verifica se criou o produto
|
303 |
+
if ($stateProds) {
|
304 |
+
//TRATA O CLIENTE
|
305 |
+
$document = null;
|
306 |
+
if (isset($OrderJSON->buyer->document)) {
|
307 |
+
$document = $OrderJSON->buyer->document;
|
308 |
+
}
|
309 |
+
|
310 |
+
if ($document != null) {
|
311 |
+
try {
|
312 |
+
$AttrToDoc = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_doc_type_field', $storeID));
|
313 |
+
$groupCustomer = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_customer_group_field', $storeID);
|
314 |
+
|
315 |
+
$email = $OrderJSON->buyer->email;
|
316 |
+
$customer = Mage::getModel('customer/customer')
|
317 |
+
->getCollection()
|
318 |
+
->addFieldToFilter($AttrToDoc, $document)->load()->getFirstItem();
|
319 |
+
|
320 |
+
$AddressShipBill = null;
|
321 |
+
|
322 |
+
$firstName = $OrderJSON->buyer->name;
|
323 |
+
$lastName = 'Lastname';
|
324 |
+
if ($firstName != '') {
|
325 |
+
$nameComplete = explode(" ", $firstName);
|
326 |
+
|
327 |
+
$lastNameP = array_slice($nameComplete, 1);
|
328 |
+
$lastNameImp = implode(" ", $lastNameP);
|
329 |
+
|
330 |
+
$firstName = array_shift($nameComplete);
|
331 |
+
$lastName = $lastNameImp == '' ? 'Lastname' : $lastNameImp;
|
332 |
+
}
|
333 |
+
|
334 |
+
$addressFullData = $this->getCompleteAddressOrder($storeID, $OrderJSON);
|
335 |
+
$regionCollection = Mage::getModel('directory/region')->getCollection();
|
336 |
+
$regionName = (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado';
|
337 |
+
$regionID = 0;
|
338 |
+
foreach ($regionCollection as $key) {
|
339 |
+
if( $key->getData('name') == $regionName){
|
340 |
+
$regionID = $key->getData('region_id');
|
341 |
+
break;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
$addressFullData = $this->getCompleteAddressOrder($storeID, $OrderJSON);
|
346 |
+
|
347 |
+
if ($customer->getId() == null) {
|
348 |
+
$_DataCustomer = array(
|
349 |
+
'account' => array(
|
350 |
+
'firstname' => $firstName,
|
351 |
+
'lastname' => $lastName,
|
352 |
+
'email' => $email,
|
353 |
+
$AttrToDoc => $document,
|
354 |
+
'password' => 'a111111',
|
355 |
+
'default_billing' => '_item1',
|
356 |
+
'default_shipping' => '_item1',
|
357 |
+
'store_id' => $storeID,
|
358 |
+
'website_id' => Mage::app()->getWebsite()->getId(),
|
359 |
+
'group_id' => $groupCustomer,
|
360 |
+
),
|
361 |
+
'address' => array(
|
362 |
+
'_item1' => array(
|
363 |
+
'firstname' => $firstName,
|
364 |
+
'lastname' => $lastName,
|
365 |
+
'street' => $addressFullData,
|
366 |
+
'city' => (isset($OrderJSON->shipping->city)) ? $OrderJSON->shipping->city : 'Não especificado',
|
367 |
+
'country_id' => 'BR',
|
368 |
+
'region_id' => $regionID,
|
369 |
+
'region' => (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado',
|
370 |
+
'postcode' => (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado',
|
371 |
+
'telephone' => $OrderJSON->buyer->phone,
|
372 |
+
),
|
373 |
+
),
|
374 |
+
);
|
375 |
+
|
376 |
+
$customerRet = Mage::helper('db1_anymarket/customergenerator')->createCustomer($_DataCustomer);
|
377 |
+
$customer = $customerRet['customer'];
|
378 |
+
$AddressShipBill = $customerRet['addr'];
|
379 |
+
} else {
|
380 |
+
//PERCORRE OS ENDERECOS PARA VER SE JA HA CADASTRADO O INFORMADO
|
381 |
+
$needRegister = true;
|
382 |
+
foreach ($customer->getAddresses() as $address) {
|
383 |
+
$zipCodeOrder = (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado';
|
384 |
+
$addressOrder = (isset($OrderJSON->shipping->address)) ? $OrderJSON->shipping->address : 'Frete não especificado.';
|
385 |
+
if (($address->getData('postcode') == $zipCodeOrder) && ($address->getData('street') == $addressOrder)) {
|
386 |
+
$AddressShipBill = $address;
|
387 |
+
$needRegister = false;
|
388 |
+
break;
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
//CRIA O ENDERECO CASO NAO TENHA O INFORMADO
|
393 |
+
if ($needRegister) {
|
394 |
+
$address = Mage::getModel('customer/address');
|
395 |
+
|
396 |
+
$addressData = array(
|
397 |
+
'firstname' => $firstName,
|
398 |
+
'lastname' => $lastName,
|
399 |
+
'street' => $addressFullData,
|
400 |
+
'city' => (isset($OrderJSON->shipping->city)) ? $OrderJSON->shipping->city : 'Não especificado',
|
401 |
+
'country_id' => 'BR',
|
402 |
+
'region' => (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado',
|
403 |
+
'region_id' => $regionID,
|
404 |
+
'postcode' => (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado',
|
405 |
+
'telephone' => $OrderJSON->buyer->phone
|
406 |
+
);
|
407 |
+
|
408 |
+
$address->setIsDefaultBilling(1);
|
409 |
+
$address->setIsDefaultShipping(1);
|
410 |
+
$address->addData($addressData);
|
411 |
+
$address->setPostIndex('_item1');
|
412 |
+
$customer->addAddress($address);
|
413 |
+
$customer->save();
|
414 |
+
}
|
415 |
+
|
416 |
+
}
|
417 |
+
|
418 |
+
$infoMetPag = 'ANYMARKET';
|
419 |
+
foreach ($OrderJSON->payments as $payment) {
|
420 |
+
$infoMetPag = $payment->method;
|
421 |
+
}
|
422 |
+
|
423 |
+
$OrderIDMage = $this->create_order($anymarketordersSpec, $_products, $customer, $IDOrderAnyMarket, $idSeqAnyMarket, $infoMetPag, $AddressShipBill, $AddressShipBill, $OrderJSON->freight, $storeID);
|
424 |
+
$OrderCheck = Mage::getModel('sales/order')->loadByIncrementId($OrderIDMage);
|
425 |
+
|
426 |
+
$this->changeFeedOrder($HOST, $headers, $idSeqAnyMarket, $tokenFeed);
|
427 |
+
|
428 |
+
if ($OrderCheck->getId()) {
|
429 |
+
$this->changeStatusOrder($storeID, $OrderJSON, $OrderIDMage);
|
430 |
+
}
|
431 |
+
} catch (Exception $e) {
|
432 |
+
$this->saveLogOrder('nmo_id_seq_anymarket',
|
433 |
+
$idSeqAnyMarket,
|
434 |
+
'ERROR 01',
|
435 |
+
'System: ' . $e->getMessage(),
|
436 |
+
$idSeqAnyMarket,
|
437 |
+
$IDOrderAnyMarket,
|
438 |
+
'',
|
439 |
+
$storeID);
|
440 |
+
|
441 |
+
}
|
442 |
+
} else {
|
443 |
+
$this->saveLogOrder('nmo_id_seq_anymarket',
|
444 |
+
$idSeqAnyMarket,
|
445 |
+
'ERROR 01',
|
446 |
+
Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'),
|
447 |
+
$idSeqAnyMarket,
|
448 |
+
$IDOrderAnyMarket,
|
449 |
+
'',
|
450 |
+
$storeID);
|
451 |
+
|
452 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
453 |
+
$anymarketlog->setLogDesc('Error on import Order: ' . Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'));
|
454 |
+
$anymarketlog->setStatus("0");
|
455 |
+
$anymarketlog->setStores(array($storeID));
|
456 |
+
$anymarketlog->save();
|
457 |
+
|
458 |
+
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
459 |
+
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ') . "Anymarket(" . $IDOrderAnyMarket . ") <br/>" .
|
460 |
+
Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'),
|
461 |
+
'');
|
462 |
+
}
|
463 |
+
}
|
464 |
+
} else {
|
465 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
466 |
+
$anymarketlog->setLogDesc($statusMage);
|
467 |
+
$anymarketlog->setLogId($IDOrderAnyMarket);
|
468 |
+
$anymarketlog->setStatus("0");
|
469 |
+
$anymarketlog->save();
|
470 |
+
}
|
471 |
+
|
472 |
+
if ($tokenFeed != null) {
|
473 |
+
$paramFeed = array(
|
474 |
+
"token" => $tokenFeed
|
475 |
+
);
|
476 |
+
|
477 |
+
$this->CallAPICurl("PUT", $HOST . "/rest/api/v2/orders/feeds/" . $idSeqAnyMarket, $headers, $paramFeed);
|
478 |
+
}
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}else{
|
482 |
+
$STATUSIMPORT = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_stauts_order_field', $storeID);
|
483 |
+
if (strpos($STATUSIMPORT, $OrderJSON->status) !== false) {
|
484 |
+
if ($anymarketordersSpec->getData('nmo_id_order') != null) {
|
485 |
+
$this->changeStatusOrder($storeID, $OrderJSON, $anymarketordersSpec->getData('nmo_id_order'));
|
486 |
+
}
|
487 |
+
}
|
488 |
+
}
|
489 |
+
}else{
|
490 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
491 |
+
$anymarketlog->setLogDesc( 'Error on import Order: '.$idSeqAnyMarket.' '.$returnOrderItens['return'] );
|
492 |
+
$anymarketlog->setStatus("0");
|
493 |
+
$anymarketlog->save();
|
494 |
+
|
495 |
+
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
496 |
+
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ')."Anymarket(".$idSeqAnyMarket.")",
|
497 |
+
'');
|
498 |
+
}
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* change status feed order
|
503 |
+
*
|
504 |
+
* @param $HOST
|
505 |
+
* @param $headers
|
506 |
+
* @param $IDFeed
|
507 |
+
* @param $tokenFeed
|
508 |
+
*/
|
509 |
+
private function changeFeedOrder($HOST, $headers, $IDFeed, $tokenFeed){
|
510 |
+
if($tokenFeed != 'notoken'){
|
511 |
+
$paramsFeeds = array(
|
512 |
+
"token" => $tokenFeed
|
513 |
+
);
|
514 |
+
|
515 |
+
$returnChangeTrans = $this->CallAPICurl("PUT", $HOST."/v2/orders/feeds/".$IDFeed, $headers, $paramsFeeds);
|
516 |
+
if($returnChangeTrans['error'] == '1'){
|
517 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
518 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('Error update feed order.'));
|
519 |
+
$anymarketlog->setStatus("1");
|
520 |
+
$anymarketlog->save();
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* change status order
|
528 |
+
*
|
529 |
+
* @param $JSON
|
530 |
+
* @param $IDOrderMagento
|
531 |
+
*/
|
532 |
+
private function changeStatusOrder($storeID, $JSON, $IDOrderMagento){
|
533 |
+
$StatusPedAnyMarket = $JSON->status;
|
534 |
+
|
535 |
+
$statsConfig = $this->getStatusAnyMarketToMageOrderConfig($storeID, $StatusPedAnyMarket );
|
536 |
+
$stateMage = $statsConfig["state"];
|
537 |
+
$statusMage = $statsConfig["status"];
|
538 |
+
|
539 |
+
if (strpos($statusMage, 'ERROR:') === false) {
|
540 |
+
Mage::getSingleton('core/session')->setImportOrdersVariable('false');
|
541 |
+
|
542 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId( $IDOrderMagento );
|
543 |
+
$itemsarray = null;
|
544 |
+
if(isset($JSON->invoice)){
|
545 |
+
if( $order->canInvoice() ){
|
546 |
+
if(isset($JSON->invoice->accessKey) ) {
|
547 |
+
$nfe = $JSON->invoice->accessKey;
|
548 |
+
$dateNfe = $JSON->invoice->date;
|
549 |
+
|
550 |
+
$DateTime = strtotime($dateNfe);
|
551 |
+
$fixedDate = date('d/m/Y H:i:s', $DateTime);
|
552 |
+
|
553 |
+
$orderItems = $order->getAllItems();
|
554 |
+
foreach ($orderItems as $_eachItem) {
|
555 |
+
$opid = $_eachItem->getId();
|
556 |
+
$qty = $_eachItem->getQtyOrdered();
|
557 |
+
$itemsarray[$opid] = $qty;
|
558 |
+
}
|
559 |
+
|
560 |
+
if (!$order->hasInvoices()) {
|
561 |
+
$nfeString = 'nfe:' . $nfe . ', emissao:' . $fixedDate;
|
562 |
+
Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(), $itemsarray, $nfeString, 0, 0);
|
563 |
+
}
|
564 |
+
}
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
if(isset($JSON->tracking)){
|
569 |
+
if( $order->canShip() && !$order->hasShipments() ){
|
570 |
+
if(isset($JSON->tracking->number)) {
|
571 |
+
$TrNumber = $JSON->tracking->number;
|
572 |
+
$TrCarrier = strtolower($JSON->tracking->carrier);
|
573 |
+
|
574 |
+
$shipmentId = Mage::getModel('sales/order_shipment_api')->create($order->getIncrementId(), $itemsarray, 'Create by AnyMarket', false, 1);
|
575 |
+
|
576 |
+
$TracCodeArr = Mage::getModel('sales/order_shipment_api')->getCarriers($order->getIncrementId());
|
577 |
+
if (isset($TracCodeArr[$TrCarrier])) {
|
578 |
+
$trackmodel = Mage::getModel('sales/order_shipment_api')->addTrack($shipmentId, $TrCarrier, $TrCarrier, $TrNumber);
|
579 |
+
} else {
|
580 |
+
$arrVar = array_keys($TracCodeArr);
|
581 |
+
$trackmodel = Mage::getModel('sales/order_shipment_api')->addTrack($shipmentId, array_shift($arrVar), 'Não Econtrado(' . $TrCarrier . ')', $TrNumber);
|
582 |
+
}
|
583 |
+
}
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
if($stateMage != Mage_Sales_Model_Order::STATE_NEW){
|
588 |
+
if($stateMage == Mage_Sales_Model_Order::STATE_COMPLETE){
|
589 |
+
$history = $order->addStatusHistoryComment('Finalizado pelo AnyMarket.', false);
|
590 |
+
$history->setIsCustomerNotified(false);
|
591 |
+
}
|
592 |
+
$order->setData('state', $stateMage);
|
593 |
+
$order->setStatus($statusMage, true);
|
594 |
+
$order->save();
|
595 |
+
}
|
596 |
+
|
597 |
+
$this->saveLogOrder('nmo_id_anymarket',
|
598 |
+
$JSON->marketPlaceId,
|
599 |
+
'Integrado',
|
600 |
+
'',
|
601 |
+
$JSON->id,
|
602 |
+
$JSON->marketPlaceId,
|
603 |
+
$IDOrderMagento,
|
604 |
+
$storeID);
|
605 |
+
|
606 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
607 |
+
$anymarketlog->setLogDesc('Order Updated: ' . $IDOrderMagento . ' ID Anymarket: ' . $JSON->marketPlaceId . ' Status: ' . $statusMage);
|
608 |
+
$anymarketlog->setStatus("0");
|
609 |
+
$anymarketlog->setStores(array($storeID));
|
610 |
+
$anymarketlog->save();
|
611 |
+
|
612 |
+
Mage::getSingleton('core/session')->setImportOrdersVariable('true');
|
613 |
+
}else{
|
614 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
615 |
+
$anymarketlog->setLogDesc( $statusMage );
|
616 |
+
$anymarketlog->setLogId( $IDOrderMagento );
|
617 |
+
$anymarketlog->setStatus("0");
|
618 |
+
$anymarketlog->save();
|
619 |
+
/*
|
620 |
+
$this->addMessageInBox(Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
621 |
+
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ')."Magento(".$IDOrderMagento.") <br/>".
|
622 |
+
$statusMage,
|
623 |
+
'');
|
624 |
+
*/
|
625 |
+
}
|
626 |
+
}
|
627 |
+
|
628 |
+
/**
|
629 |
+
* get invoice order
|
630 |
+
*
|
631 |
+
* @param $Order
|
632 |
+
* @return array
|
633 |
+
*/
|
634 |
+
public function getInvoiceOrder($Order){
|
635 |
+
$nfeID = "";
|
636 |
+
$date = "";
|
637 |
+
$chaveAcID = "";
|
638 |
+
if ($Order->hasInvoices()) {
|
639 |
+
foreach ($Order->getInvoiceCollection() as $inv) {
|
640 |
+
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId( $inv->getIncrementId() );
|
641 |
+
foreach ($invoice->getCommentsCollection() as $item) {
|
642 |
+
$CommentCurr = $item->getComment();
|
643 |
+
|
644 |
+
$nfeCount = strpos($CommentCurr, 'nfe:');
|
645 |
+
$emissaoCount = strpos($CommentCurr, 'emiss');
|
646 |
+
if( (strpos($CommentCurr, 'nfe:') !== false) && (strpos($CommentCurr, 'emiss') !== false) ) {
|
647 |
+
$caracts = array("/", "-", ".");
|
648 |
+
$nfeTmp = str_replace($caracts, "", $CommentCurr );
|
649 |
+
$chaveAcID = substr( $nfeTmp, $nfeCount+4, 44);
|
650 |
+
$nfeID = $chaveAcID;
|
651 |
+
|
652 |
+
$date = substr( $CommentCurr, $emissaoCount+8, 19);
|
653 |
+
$dateTmp = str_replace("/", "-", $date );
|
654 |
+
$date = gmdate('Y-m-d\TH:i:s\Z', strtotime( $dateTmp ));
|
655 |
+
}
|
656 |
+
}
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
if( $chaveAcID == "" ) {
|
661 |
+
foreach ($Order->getStatusHistoryCollection() as $item) {
|
662 |
+
$CommentCurr = $item->getComment();
|
663 |
+
|
664 |
+
$CommentCurr = str_replace(array(" ", "<b>", "</b>"), "", $CommentCurr );
|
665 |
+
$chaveAcesso = strpos($CommentCurr, 'ChavedeAcesso:');
|
666 |
+
if( (strpos($CommentCurr, 'ChavedeAcesso:') !== false) ) {
|
667 |
+
$chaveAcID = substr( $CommentCurr, $chaveAcesso+14, 44);
|
668 |
+
|
669 |
+
$notaFiscal = strpos($CommentCurr, 'Notafiscal:');
|
670 |
+
if( (strpos($CommentCurr, 'Notafiscal:') !== false) ) {
|
671 |
+
$endNF = strpos($CommentCurr, '<br/>');
|
672 |
+
$nfeID = substr( $CommentCurr, $notaFiscal+11, $endNF-11);
|
673 |
+
}
|
674 |
+
$date = gmdate('Y-m-d\TH:i:s\Z');
|
675 |
+
break;
|
676 |
+
}
|
677 |
+
}
|
678 |
+
}
|
679 |
+
|
680 |
+
$retArr = array("number" => $nfeID, "date" => $date, "accessKey" => $chaveAcID);
|
681 |
+
return $retArr;
|
682 |
+
}
|
683 |
+
|
684 |
+
/**
|
685 |
+
* get tracking order
|
686 |
+
*
|
687 |
+
* @param $Order
|
688 |
+
* @return array
|
689 |
+
*/
|
690 |
+
public function getTrackingOrder($Order){
|
691 |
+
$TrackNum = '';
|
692 |
+
$TrackCode = '';
|
693 |
+
$TrackCreate = '';
|
694 |
+
$dateTrack = '';
|
695 |
+
|
696 |
+
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
697 |
+
->setOrderFilter($Order)
|
698 |
+
->load();
|
699 |
+
foreach ($shipmentCollection as $shipment){
|
700 |
+
foreach($shipment->getAllTracks() as $tracknum){
|
701 |
+
$TrackNum = $tracknum->getNumber();
|
702 |
+
$TrackCode = $tracknum->getCarrierCode();
|
703 |
+
$TrackCreate = $tracknum->getCreatedAt();
|
704 |
+
|
705 |
+
$dateTmp = str_replace("/", "-", $TrackCreate );
|
706 |
+
$dateTrack = gmdate('Y-m-d\TH:i:s\Z', strtotime( $dateTmp ));
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
return array("number" => $TrackNum, "carrier" => $TrackCode, "date" => $dateTrack, "url" => "");
|
711 |
+
}
|
712 |
+
|
713 |
+
/**
|
714 |
+
* update order in AM
|
715 |
+
*
|
716 |
+
* @param $Order
|
717 |
+
*/
|
718 |
+
public function updateOrderAnyMarket($storeID, $Order){
|
719 |
+
$ImportOrderSession = Mage::getSingleton('core/session')->getImportOrdersVariable();
|
720 |
+
if( $ImportOrderSession != 'false' ) {
|
721 |
+
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
722 |
+
$idOrder = $Order->getIncrementId();
|
723 |
+
$status = $Order->getStatus();
|
724 |
+
$anymarketorderupdt = Mage::getModel('db1_anymarket/anymarketorders')->load($idOrder, 'nmo_id_order');
|
725 |
+
|
726 |
+
if( ($ConfigOrder == 0) ||
|
727 |
+
($anymarketorderupdt->getData('nmo_status_int') == 'Integrado') ||
|
728 |
+
($anymarketorderupdt->getData('nmo_status_int') == 'ERROR 02')){
|
729 |
+
|
730 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
731 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
732 |
+
|
733 |
+
$headers = array(
|
734 |
+
"Content-type: application/json",
|
735 |
+
"Accept: */*",
|
736 |
+
"gumgaToken: ".$TOKEN
|
737 |
+
);
|
738 |
+
|
739 |
+
if( ($anymarketorderupdt->getData('nmo_id_order') != null) && ($anymarketorderupdt->getData('nmo_id_anymarket') != null) ){
|
740 |
+
$statuAM = $this->getStatusMageToAnyMarketOrderConfig($storeID, $status);
|
741 |
+
if (strpos($statuAM, 'ERROR:') === false) {
|
742 |
+
$params = array(
|
743 |
+
"status" => $statuAM
|
744 |
+
);
|
745 |
+
|
746 |
+
$invoiceData = $this->getInvoiceOrder($Order);
|
747 |
+
$trackingData = $this->getTrackingOrder($Order);
|
748 |
+
|
749 |
+
if ($invoiceData['number'] != '') {
|
750 |
+
$params["invoice"] = $invoiceData;
|
751 |
+
}
|
752 |
+
|
753 |
+
if ($trackingData['number'] != '') {
|
754 |
+
$params["tracking"] = $trackingData;
|
755 |
+
}
|
756 |
+
|
757 |
+
if( ($statuAM == "CONCLUDED" || $statuAM == "CANCELED" || $statuAM == "PAID_WAITING_SHIP" || $statuAM == "INVOICED" || $statuAM == "PAID_WAITING_DELIVERY" ) ||
|
758 |
+
(isset($params["tracking"]) || isset($params["invoice"])) ){
|
759 |
+
$IDOrderAnyMarket = $anymarketorderupdt->getData('nmo_id_seq_anymarket');
|
760 |
+
|
761 |
+
$returnOrder = $this->CallAPICurl("PUT", $HOST."/v2/orders/".$IDOrderAnyMarket, $headers, $params);
|
762 |
+
|
763 |
+
if($returnOrder['error'] == '1'){
|
764 |
+
$anymarketorderupdt->setStatus("0");
|
765 |
+
$anymarketorderupdt->setNmoStatusInt('ERROR 02');
|
766 |
+
$anymarketorderupdt->setNmoDescError($returnOrder['return']);
|
767 |
+
$anymarketorderupdt->setStores(array($storeID));
|
768 |
+
$anymarketorderupdt->save();
|
769 |
+
}
|
770 |
+
|
771 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
772 |
+
$anymarketlog->setLogDesc( json_encode($returnOrder['return']) );
|
773 |
+
$anymarketlog->setLogId( $idOrder );
|
774 |
+
$anymarketlog->setLogJson( json_encode($returnOrder['json']) );
|
775 |
+
$anymarketlog->setStores(array($storeID));
|
776 |
+
$anymarketlog->setStatus("0");
|
777 |
+
$anymarketlog->save();
|
778 |
+
}else{
|
779 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
780 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('There was some error getting data Invoice or Tracking.') );
|
781 |
+
$anymarketlog->setLogId( $idOrder );
|
782 |
+
$anymarketlog->setLogJson('');
|
783 |
+
$anymarketlog->setStores(array($storeID));
|
784 |
+
$anymarketlog->setStatus("0");
|
785 |
+
$anymarketlog->save();
|
786 |
+
}
|
787 |
+
}else{
|
788 |
+
if($ConfigOrder == 0){
|
789 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
790 |
+
$anymarketlog->setStatus("0");
|
791 |
+
$anymarketlog->setLogDesc( $statuAM );
|
792 |
+
$anymarketlog->setLogId( $idOrder );
|
793 |
+
$anymarketlog->setStores(array($storeID));
|
794 |
+
$anymarketlog->save();
|
795 |
+
}
|
796 |
+
}
|
797 |
+
}else{
|
798 |
+
$this->sendOrderToAnyMarket($storeID, $idOrder, $HOST, $TOKEN);
|
799 |
+
}
|
800 |
+
}
|
801 |
+
}
|
802 |
+
|
803 |
+
}
|
804 |
+
|
805 |
+
/**
|
806 |
+
* send order to AM
|
807 |
+
*
|
808 |
+
* @param $idOrder
|
809 |
+
* @param $HOST
|
810 |
+
* @param $TOKEN
|
811 |
+
*/
|
812 |
+
private function sendOrderToAnyMarket($storeID, $idOrder, $HOST, $TOKEN){
|
813 |
+
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
814 |
+
if($ConfigOrder == 0){
|
815 |
+
$Order = Mage::getModel('sales/order')->setStoreId($storeID)->loadByIncrementId( $idOrder );
|
816 |
+
|
817 |
+
//TRATA OS ITEMS
|
818 |
+
$orderedItems = $Order->getAllVisibleItems();
|
819 |
+
$orderedProductIds = array();
|
820 |
+
|
821 |
+
foreach ($orderedItems as $item) {
|
822 |
+
$orderedProductIds[] = array(
|
823 |
+
"sku" => array(
|
824 |
+
"partnerId" => $item->getData('sku')
|
825 |
+
),
|
826 |
+
"amount" => $item->getData('qty_ordered'),
|
827 |
+
"unit" => $item->getData('original_price'),
|
828 |
+
"discount" => $item->getData('discount_amount')
|
829 |
+
);
|
830 |
+
}
|
831 |
+
|
832 |
+
//OBTEM OS DADOS DO PAGAMENTO
|
833 |
+
$payment = $Order->getPayment();
|
834 |
+
|
835 |
+
//OBTEM OS DADOS DA ENTREGA
|
836 |
+
$shipping = $Order->getShippingAddress();
|
837 |
+
|
838 |
+
$docField = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_doc_type_field', $storeID));
|
839 |
+
$docData = "";
|
840 |
+
if(!$Order->getCustomerIsGuest() || $Order->getCustomerId() != null ){
|
841 |
+
$customer = Mage::getModel("customer/customer")->load($Order->getCustomerId());
|
842 |
+
$docData = $customer->getData( $docField );
|
843 |
+
}
|
844 |
+
|
845 |
+
if( $docData == "" ){
|
846 |
+
if($Order->getCustomerTaxvat()){
|
847 |
+
$docData = $Order->getCustomerTaxvat();
|
848 |
+
}
|
849 |
+
}
|
850 |
+
|
851 |
+
$statusOrder = $Order->getStatus();
|
852 |
+
if($statusOrder == 'pending'){
|
853 |
+
$statuAM = $this->getStatusMageToAnyMarketOrderConfig($storeID, 'new');
|
854 |
+
}else{
|
855 |
+
$statuAM = $this->getStatusMageToAnyMarketOrderConfig($storeID, $statusOrder);
|
856 |
+
}
|
857 |
+
|
858 |
+
if( (strpos($statuAM, 'ERROR:') === false) && ($statuAM != '') ) {
|
859 |
+
$params = array(
|
860 |
+
'marketPlaceId' => $idOrder,
|
861 |
+
"createdAt" => gmdate('Y-m-d\TH:i:s\Z', strtotime( $Order->getData('created_at') )),
|
862 |
+
"status" => $statuAM,
|
863 |
+
"marketPlace" => "ECOMMERCE",
|
864 |
+
"marketPlaceStatus" => $statuAM,
|
865 |
+
"marketPlaceUrl" => null,
|
866 |
+
"shipping" => array(
|
867 |
+
"city" => $shipping->getCity(),
|
868 |
+
"state" => $shipping->getRegion(),
|
869 |
+
"country" => $shipping->getCountry(),
|
870 |
+
"address" => $shipping->getStreetFull(),
|
871 |
+
"zipCode" => $shipping->getPostcode()
|
872 |
+
),
|
873 |
+
"buyer" => array(
|
874 |
+
"id" => 0,
|
875 |
+
"name" => $Order->getCustomerFirstname()." ".$Order->getCustomerLastname(),
|
876 |
+
"email" => $Order->getCustomerEmail(),
|
877 |
+
"document" => $docData,
|
878 |
+
"documentType" => $this->getDocumentType($docData),
|
879 |
+
"phone" => $shipping->getTelephone(),
|
880 |
+
),
|
881 |
+
"items" => $orderedProductIds,
|
882 |
+
"payments" => array(
|
883 |
+
array(
|
884 |
+
"method" => $payment->getMethodInstance()->getTitle(),
|
885 |
+
"status" => "",
|
886 |
+
"value" => $Order->getBaseGrandTotal()
|
887 |
+
),
|
888 |
+
),
|
889 |
+
"discount" => $Order->getDiscountAmount(),
|
890 |
+
"freight" => $Order->getShippingAmount(),
|
891 |
+
"gross" => $Order->getBaseGrandTotal(),
|
892 |
+
"total" => $Order->getBaseGrandTotal()
|
893 |
+
);
|
894 |
+
|
895 |
+
$arrTracking = $this->getTrackingOrder($Order);
|
896 |
+
$arrInvoice = $this->getInvoiceOrder($Order);
|
897 |
+
|
898 |
+
if($arrTracking["number"] != ''){
|
899 |
+
$params["tracking"] = $arrTracking;
|
900 |
+
};
|
901 |
+
|
902 |
+
if($arrInvoice["number"] != ''){
|
903 |
+
$params["invoice"] = $arrInvoice;
|
904 |
+
};
|
905 |
+
|
906 |
+
$headers = array(
|
907 |
+
"Content-type: application/json",
|
908 |
+
"Accept: */*",
|
909 |
+
"gumgaToken: ".$TOKEN
|
910 |
+
);
|
911 |
+
|
912 |
+
$returnOrder = $this->CallAPICurl("POST", $HOST."/v2/orders/", $headers, $params);
|
913 |
+
|
914 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
915 |
+
$anymarketlog->setLogDesc( json_encode($returnOrder['return']) );
|
916 |
+
|
917 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($idOrder, 'nmo_id_order');
|
918 |
+
$anymarketorders->setStatus("1");
|
919 |
+
$anymarketorders->setStores(array($storeID));
|
920 |
+
if($returnOrder['error'] == '1'){
|
921 |
+
$anymarketorders->setNmoStatusInt('ERROR 02');
|
922 |
+
$anymarketorders->setNmoDescError($returnOrder['return']);
|
923 |
+
}else{
|
924 |
+
$retOrderJSON = $returnOrder['return'];
|
925 |
+
$anymarketorders->setNmoStatusInt('Integrado');
|
926 |
+
$anymarketorders->setNmoDescError('');
|
927 |
+
$anymarketorders->setNmoIdAnymarket( $retOrderJSON->marketPlaceId );
|
928 |
+
$anymarketorders->setNmoIdSeqAnymarket( $retOrderJSON->id );
|
929 |
+
|
930 |
+
$anymarketlog->setLogId( $retOrderJSON->marketPlaceId );
|
931 |
+
}
|
932 |
+
|
933 |
+
$anymarketlog->setStores(array($storeID));
|
934 |
+
$anymarketlog->setLogJson( $returnOrder['json'] );
|
935 |
+
$anymarketlog->setStatus("0");
|
936 |
+
$anymarketlog->save();
|
937 |
+
|
938 |
+
}else{
|
939 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($idOrder, 'nmo_id_order');
|
940 |
+
$anymarketorders->setNmoStatusInt('ERROR 02');
|
941 |
+
$anymarketorders->setStores(array($storeID));
|
942 |
+
if($statuAM != ''){
|
943 |
+
$anymarketorders->setNmoDescError( $statuAM );
|
944 |
+
}else{
|
945 |
+
$anymarketorders->setNmoDescError( 'Status new não foi referenciado.' );
|
946 |
+
}
|
947 |
+
}
|
948 |
+
|
949 |
+
$anymarketorders->setNmoIdOrder($idOrder);
|
950 |
+
$anymarketorders->save();
|
951 |
+
}
|
952 |
+
|
953 |
+
}
|
954 |
+
|
955 |
+
/**
|
956 |
+
* List Order from AnyMarket
|
957 |
+
*
|
958 |
+
* @return int
|
959 |
+
*/
|
960 |
+
public function listOrdersFromAnyMarketMagento($storeID){
|
961 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
962 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
963 |
+
$STATUSIMPORT = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_stauts_order_field', $storeID);
|
964 |
+
|
965 |
+
$headers = array(
|
966 |
+
"Content-type: application/json",
|
967 |
+
"Accept: */*",
|
968 |
+
"gumgaToken: ".$TOKEN
|
969 |
+
);
|
970 |
+
|
971 |
+
$startRec = 0;
|
972 |
+
$countRec = 1;
|
973 |
+
$arrOrderCod = null;
|
974 |
+
|
975 |
+
$contPed = 0;
|
976 |
+
while ($startRec <= $countRec) {
|
977 |
+
$returnOrder = $this->CallAPICurl("GET", $HOST."/v2/orders/?offset=".$startRec."&limit=30", $headers, null);
|
978 |
+
if($returnOrder['error'] == '1'){
|
979 |
+
$startRec = 1;
|
980 |
+
$countRec = 0;
|
981 |
+
|
982 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
983 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('Error on import order from anymarket '). $returnOrder['return'] );
|
984 |
+
$anymarketlog->setStatus("0");
|
985 |
+
$anymarketlog->save();
|
986 |
+
}else {
|
987 |
+
$JsonReturn = $returnOrder['return'];
|
988 |
+
|
989 |
+
$startRec = $startRec + $JsonReturn->page->size;
|
990 |
+
$countRec = $JsonReturn->page->totalElements;
|
991 |
+
|
992 |
+
foreach ($JsonReturn->content as $value) {
|
993 |
+
$IDOrderAnyMarket = $value->marketPlaceId;
|
994 |
+
|
995 |
+
if (strpos($STATUSIMPORT, $value->status) !== false) {
|
996 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
997 |
+
$anymarketorders->load($IDOrderAnyMarket, 'nmo_id_anymarket');
|
998 |
+
if ($anymarketorders->getData('nmo_id_anymarket') == null || (is_array($anymarketorders->getData('store_id')) && !in_array($storeID, $anymarketorders->getData('store_id')))) {
|
999 |
+
$idAnyMarket = $value->id;
|
1000 |
+
|
1001 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders');
|
1002 |
+
$anymarketorders->setStatus("0");
|
1003 |
+
$anymarketorders->setNmoStatusInt('Não integrado (AnyMarket)');
|
1004 |
+
$anymarketorders->setNmoDescError('');
|
1005 |
+
$anymarketorders->setNmoIdSeqAnymarket($idAnyMarket);
|
1006 |
+
$anymarketorders->setNmoIdAnymarket($IDOrderAnyMarket);
|
1007 |
+
$anymarketorders->setNmoIdOrder('');
|
1008 |
+
$anymarketorders->setStores(array($storeID));
|
1009 |
+
$anymarketorders->save();
|
1010 |
+
|
1011 |
+
$contPed = $contPed + 1;
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
}
|
1015 |
+
}
|
1016 |
+
}
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
$salesCollection = Mage::getModel("sales/order")->getCollection();
|
1020 |
+
foreach($salesCollection as $order){
|
1021 |
+
$orderId = $order->getIncrementId();
|
1022 |
+
$storeID = $order->getStoreId();
|
1023 |
+
|
1024 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
1025 |
+
$anymarketorders->load($orderId, 'nmo_id_order');
|
1026 |
+
if($anymarketorders->getData('nmo_id_order') == null || (is_array($anymarketorders->getData('store_id')) && !in_array($storeID, $anymarketorders->getData('store_id')) ) ){
|
1027 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders');
|
1028 |
+
$anymarketorders->setStatus("0");
|
1029 |
+
$anymarketorders->setNmoStatusInt('Não integrado (Magento)');
|
1030 |
+
$anymarketorders->setNmoDescError('');
|
1031 |
+
$anymarketorders->setNmoIdSeqAnymarket('');
|
1032 |
+
$anymarketorders->setNmoIdAnymarket('');
|
1033 |
+
$anymarketorders->setNmoIdOrder( $orderId );
|
1034 |
+
$anymarketorders->setStores(array($storeID));
|
1035 |
+
$anymarketorders->save();
|
1036 |
+
|
1037 |
+
$contPed = $contPed+1;
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
return $contPed;
|
1042 |
+
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
}
|
app/code/community/DB1/AnyMarket/Helper/Ordergenerator.php
CHANGED
@@ -1,404 +1,415 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_OrderGenerator extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
const CUSTOMER_RANDOM = null;
|
6 |
-
|
7 |
-
protected $_shippingMethod = 'freeshipping_freeshipping';
|
8 |
-
protected $_AdditionalInformation = 'anymarket';
|
9 |
-
protected $_paymentMethod = 'cashondelivery';
|
10 |
-
protected $_shippingDescription = 'À Combinar - A forma de entrega será definida no momento do fechamento do pedido.'; //ALTERADO POR JOSE EDUARDO
|
11 |
-
protected $_billing = null;
|
12 |
-
protected $_shipping = null;
|
13 |
-
protected $_shippingValue = 0;
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
protected $
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
public function
|
42 |
-
{
|
43 |
-
$this->
|
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 |
-
if (
|
97 |
-
$this->
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_OrderGenerator extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
const CUSTOMER_RANDOM = null;
|
6 |
+
|
7 |
+
protected $_shippingMethod = 'freeshipping_freeshipping';
|
8 |
+
protected $_AdditionalInformation = 'anymarket';
|
9 |
+
protected $_paymentMethod = 'cashondelivery';
|
10 |
+
protected $_shippingDescription = 'À Combinar - A forma de entrega será definida no momento do fechamento do pedido.'; //ALTERADO POR JOSE EDUARDO
|
11 |
+
protected $_billing = null;
|
12 |
+
protected $_shipping = null;
|
13 |
+
protected $_shippingValue = 0;
|
14 |
+
protected $_cpfcnpj = null;
|
15 |
+
|
16 |
+
protected $_customer = self::CUSTOMER_RANDOM;
|
17 |
+
|
18 |
+
protected $_subTotal = 0;
|
19 |
+
protected $_order;
|
20 |
+
public $_storeId;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param $value
|
24 |
+
*/
|
25 |
+
public function setCpfCnpj($value)
|
26 |
+
{
|
27 |
+
$this->_cpfcnpj = $value;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param $value
|
32 |
+
*/
|
33 |
+
public function setShippingValue($value)
|
34 |
+
{
|
35 |
+
$this->_shippingValue = $value;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param $methodName
|
40 |
+
*/
|
41 |
+
public function setShippingMethod($methodName)
|
42 |
+
{
|
43 |
+
$this->_shippingMethod = $methodName;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param $methodName
|
48 |
+
*/
|
49 |
+
public function setPaymentMethod($methodName)
|
50 |
+
{
|
51 |
+
$this->_paymentMethod = $methodName;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param $billing
|
56 |
+
*/
|
57 |
+
public function setBillAddress($billing)
|
58 |
+
{
|
59 |
+
$this->_billing = $billing;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param $shipping
|
64 |
+
*/
|
65 |
+
public function setShipAddress($shipping)
|
66 |
+
{
|
67 |
+
$this->_shipping = $shipping;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @param $addInfo
|
72 |
+
*/
|
73 |
+
public function setAdditionalInformation($addInfo)
|
74 |
+
{
|
75 |
+
$this->_AdditionalInformation = $addInfo;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param $shippingDesc
|
80 |
+
*/
|
81 |
+
public function setShippingDescription($shippingDesc)
|
82 |
+
{
|
83 |
+
$this->_shippingDescription = $shippingDesc;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* set customer of order
|
88 |
+
*
|
89 |
+
* @param $customer
|
90 |
+
*/
|
91 |
+
public function setCustomer($customer)
|
92 |
+
{
|
93 |
+
if ($customer instanceof Mage_Customer_Model_Customer){
|
94 |
+
$this->_customer = $customer;
|
95 |
+
}
|
96 |
+
if (is_numeric($customer->getId())){
|
97 |
+
$this->_customer = Mage::getModel('customer/customer')->load($customer->getId());
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* create order in MG
|
103 |
+
*
|
104 |
+
* @param $products
|
105 |
+
* @return int
|
106 |
+
*/
|
107 |
+
public function createOrder($products)
|
108 |
+
{
|
109 |
+
if (!($this->_customer instanceof Mage_Customer_Model_Customer)){
|
110 |
+
$this->setCustomer(self::CUSTOMER_RANDOM);
|
111 |
+
}
|
112 |
+
|
113 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
114 |
+
|
115 |
+
if(!$this->_storeId){
|
116 |
+
$this->_storeId = $this->_customer->getStoreId();
|
117 |
+
}
|
118 |
+
|
119 |
+
$reservedOrderId = Mage::getSingleton('eav/config')
|
120 |
+
->getEntityType('order')
|
121 |
+
->fetchNewIncrementId($this->_storeId);
|
122 |
+
|
123 |
+
$currencyCode = Mage::app()->getBaseCurrencyCode();
|
124 |
+
$this->_order = Mage::getModel('sales/order')
|
125 |
+
->setIncrementId($reservedOrderId)
|
126 |
+
->setStoreId($this->_storeId)
|
127 |
+
->setQuoteId(0)
|
128 |
+
->setDiscountAmount(0)
|
129 |
+
->setShippingAmount((float)$this->_shippingValue)
|
130 |
+
->setShippingTaxAmount(0)
|
131 |
+
->setBaseDiscountAmount(0)
|
132 |
+
->setIsVirtual(0)
|
133 |
+
->setBaseShippingAmount((float)$this->_shippingValue)
|
134 |
+
->setBaseShippingTaxAmount(0)
|
135 |
+
->setBaseTaxAmount(0)
|
136 |
+
->setBaseToGlobalRate(1)
|
137 |
+
->setBaseToOrderRate(1)
|
138 |
+
->setStoreToBaseRate(1)
|
139 |
+
->setStoreToOrderRate(1)
|
140 |
+
->setTaxAmount(0)
|
141 |
+
->setGlobalCurrencyCode($currencyCode)
|
142 |
+
->setBaseCurrencyCode($currencyCode)
|
143 |
+
->setStoreCurrencyCode($currencyCode)
|
144 |
+
->setOrderCurrencyCode($currencyCode);
|
145 |
+
|
146 |
+
|
147 |
+
$this->_order->setCustomerEmail($this->_customer->getEmail())
|
148 |
+
->setCustomerFirstname($this->_customer->getFirstname())
|
149 |
+
->setCustomerLastname($this->_customer->getLastname())
|
150 |
+
->setCustomerGroupId($this->_customer->getGroupId())
|
151 |
+
->setCustomerTaxvat($this->_cpfcnpj)
|
152 |
+
->setCustomerIsGuest(0)
|
153 |
+
->setCustomer($this->_customer);
|
154 |
+
|
155 |
+
if($this->_billing == null){
|
156 |
+
$billing = $this->_customer->getDefaultBillingAddress();
|
157 |
+
}else{
|
158 |
+
$billing = $this->_billing;
|
159 |
+
}
|
160 |
+
|
161 |
+
$billingAddress = Mage::getModel('sales/order_address')
|
162 |
+
->setStoreId($this->_storeId)
|
163 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_BILLING)
|
164 |
+
->setCustomerId($this->_customer->getId())
|
165 |
+
->setCustomerAddressId($this->_customer->getDefaultBilling())
|
166 |
+
->setCustomerAddress_id($billing->getEntityId())
|
167 |
+
->setPrefix($billing->getPrefix())
|
168 |
+
->setFirstname($billing->getFirstname())
|
169 |
+
->setMiddlename($billing->getMiddlename())
|
170 |
+
->setLastname($billing->getLastname())
|
171 |
+
->setSuffix($billing->getSuffix())
|
172 |
+
->setCompany($billing->getCompany())
|
173 |
+
->setStreet($billing->getStreet())
|
174 |
+
->setCity($billing->getCity())
|
175 |
+
->setCountry_id($billing->getCountryId())
|
176 |
+
->setRegion($billing->getRegion())
|
177 |
+
->setRegion_id($billing->getRegionId())
|
178 |
+
->setPostcode($billing->getPostcode())
|
179 |
+
->setTelephone($billing->getTelephone())
|
180 |
+
->setFax($billing->getFax());
|
181 |
+
$this->_order->setBillingAddress($billingAddress);
|
182 |
+
|
183 |
+
if($this->_shipping == null){
|
184 |
+
$shipping = $this->_customer->getDefaultShippingAddress();
|
185 |
+
}else{
|
186 |
+
$shipping = $this->_shipping;
|
187 |
+
}
|
188 |
+
$shippingAddress = Mage::getModel('sales/order_address')
|
189 |
+
->setStoreId($this->_storeId)
|
190 |
+
->setAddressType(Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
|
191 |
+
->setCustomerId($this->_customer->getId())
|
192 |
+
->setCustomerAddressId($this->_customer->getDefaultShipping())
|
193 |
+
->setCustomer_address_id($shipping->getEntityId())
|
194 |
+
->setPrefix($shipping->getPrefix())
|
195 |
+
->setFirstname($shipping->getFirstname())
|
196 |
+
->setMiddlename($shipping->getMiddlename())
|
197 |
+
->setLastname($shipping->getLastname())
|
198 |
+
->setSuffix($shipping->getSuffix())
|
199 |
+
->setCompany($shipping->getCompany())
|
200 |
+
->setStreet($shipping->getStreet())
|
201 |
+
->setCity($shipping->getCity())
|
202 |
+
->setCountry_id($shipping->getCountryId())
|
203 |
+
->setRegion($shipping->getRegion())
|
204 |
+
->setRegion_id($shipping->getRegionId())
|
205 |
+
->setPostcode($shipping->getPostcode())
|
206 |
+
->setTelephone($shipping->getTelephone())
|
207 |
+
->setFax($shipping->getFax());
|
208 |
+
|
209 |
+
$this->_order->setShippingAddress($shippingAddress)
|
210 |
+
->setShippingMethod($this->_shippingMethod)
|
211 |
+
->setShippingDescription($this->_shippingDescription); //ALTERADO POR JOSE EDUARDO
|
212 |
+
|
213 |
+
$orderPayment = Mage::getModel('sales/order_payment')
|
214 |
+
->setStoreId($this->_storeId)
|
215 |
+
->setCustomerPaymentId(0)
|
216 |
+
->setMethod($this->_paymentMethod)
|
217 |
+
->setAdditionalInformation('metodo', $this->_AdditionalInformation)
|
218 |
+
->setPoNumber(' – ');
|
219 |
+
|
220 |
+
$this->_order->setPayment($orderPayment);
|
221 |
+
|
222 |
+
$this->_addProducts($products);
|
223 |
+
|
224 |
+
$this->_order->setSubtotal($this->_subTotal)
|
225 |
+
->setBaseSubtotal($this->_subTotal)
|
226 |
+
->setGrandTotal( (float)$this->_subTotal+(float)$this->_shippingValue )
|
227 |
+
->setBaseGrandTotal($this->_subTotal);
|
228 |
+
|
229 |
+
$transaction->addObject($this->_order);
|
230 |
+
$transaction->addCommitCallback(array($this->_order, 'place'));
|
231 |
+
$transaction->addCommitCallback(array($this->_order, 'save'));
|
232 |
+
$transaction->save();
|
233 |
+
|
234 |
+
return $reservedOrderId;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* add products in order
|
239 |
+
*
|
240 |
+
* @param $products
|
241 |
+
*/
|
242 |
+
protected function _addProducts($products)
|
243 |
+
{
|
244 |
+
$this->_subTotal = 0;
|
245 |
+
|
246 |
+
foreach ($products as $productRequest) {
|
247 |
+
if ($productRequest['product'] == 'rand') {
|
248 |
+
|
249 |
+
$productsCollection = Mage::getResourceModel('catalog/product_collection');
|
250 |
+
$productsCollection->addFieldToFilter('type_id', 'simple');
|
251 |
+
|
252 |
+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($productsCollection);
|
253 |
+
|
254 |
+
$productsCollection->getSelect()
|
255 |
+
->order('RAND()')
|
256 |
+
->limit(rand($productRequest['min'], $productRequest['max']));
|
257 |
+
|
258 |
+
foreach ($productsCollection as $product){
|
259 |
+
$this->_addProduct(array(
|
260 |
+
'product' => $product->getId(),
|
261 |
+
'qty' => rand(1, 2)
|
262 |
+
));
|
263 |
+
}
|
264 |
+
}
|
265 |
+
else {
|
266 |
+
$this->_addProduct($productRequest);
|
267 |
+
}
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* add product in order
|
273 |
+
*
|
274 |
+
* @param $requestData
|
275 |
+
* @return array
|
276 |
+
* @throws Exception
|
277 |
+
*/
|
278 |
+
protected function _addProduct($requestData)
|
279 |
+
{
|
280 |
+
$request = new Varien_Object();
|
281 |
+
$request->setData($requestData);
|
282 |
+
|
283 |
+
$product = Mage::getModel('catalog/product')->load($request['product']);
|
284 |
+
|
285 |
+
|
286 |
+
$cartCandidates = $product->getTypeInstance(true)
|
287 |
+
->prepareForCartAdvanced($request, $product);
|
288 |
+
|
289 |
+
if (is_string($cartCandidates)) {
|
290 |
+
throw new Exception($cartCandidates);
|
291 |
+
}
|
292 |
+
|
293 |
+
if (!is_array($cartCandidates)) {
|
294 |
+
$cartCandidates = array($cartCandidates);
|
295 |
+
}
|
296 |
+
|
297 |
+
$parentItem = null;
|
298 |
+
$errors = array();
|
299 |
+
$items = array();
|
300 |
+
foreach ($cartCandidates as $candidate) {
|
301 |
+
|
302 |
+
$item = $this->_productToOrderItem($candidate, $candidate->getCartQty(), $request['price']);
|
303 |
+
|
304 |
+
$items[] = $item;
|
305 |
+
|
306 |
+
/**
|
307 |
+
* As parent item we should always use the item of first added product
|
308 |
+
*/
|
309 |
+
if (!$parentItem) {
|
310 |
+
$parentItem = $item;
|
311 |
+
}
|
312 |
+
if ($parentItem && $candidate->getParentProductId()) {
|
313 |
+
$item->setParentItem($parentItem);
|
314 |
+
}
|
315 |
+
/**
|
316 |
+
* We specify qty after we know about parent (for stock)
|
317 |
+
*/
|
318 |
+
$item->setQty($item->getQty() + $candidate->getCartQty());
|
319 |
+
|
320 |
+
// collect errors instead of throwing first one
|
321 |
+
if ($item->getHasError()) {
|
322 |
+
$message = $item->getMessage();
|
323 |
+
if (!in_array($message, $errors)) { // filter duplicate messages
|
324 |
+
$errors[] = $message;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
if (!empty($errors)) {
|
329 |
+
Mage::throwException(implode("\n", $errors));
|
330 |
+
}
|
331 |
+
|
332 |
+
foreach ($items as $item){
|
333 |
+
$this->_order->addItem($item);
|
334 |
+
}
|
335 |
+
|
336 |
+
return $items;
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
/**
|
341 |
+
* add product in order
|
342 |
+
*
|
343 |
+
* @param Mage_Catalog_Model_Product $product
|
344 |
+
* @param int $qty
|
345 |
+
* @param $price
|
346 |
+
* @return Mage_Sales_Model_Order_Item
|
347 |
+
*/
|
348 |
+
function _productToOrderItem(Mage_Catalog_Model_Product $product, $qty = 1, $price)
|
349 |
+
{
|
350 |
+
|
351 |
+
if($price){
|
352 |
+
$finalPrice = $price;
|
353 |
+
}else{
|
354 |
+
$finalPrice = $product->getFinalPrice();
|
355 |
+
}
|
356 |
+
|
357 |
+
$rowTotal = $finalPrice * $qty;
|
358 |
+
|
359 |
+
$options = $product->getCustomOptions();
|
360 |
+
|
361 |
+
$optionsByCode = array();
|
362 |
+
|
363 |
+
foreach ($options as $option)
|
364 |
+
{
|
365 |
+
$quoteOption = Mage::getModel('sales/quote_item_option')->setData($option->getData())
|
366 |
+
->setProduct($option->getProduct());
|
367 |
+
|
368 |
+
$optionsByCode[$quoteOption->getCode()] = $quoteOption;
|
369 |
+
}
|
370 |
+
|
371 |
+
$product->setCustomOptions($optionsByCode);
|
372 |
+
|
373 |
+
// DECREMENTE O STOCK
|
374 |
+
$stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct( $product->getId() );
|
375 |
+
if( $stockItem->getManageStock() ){
|
376 |
+
$stockItem->setData('qty', $stockItem->getQty()-$product['qty']);
|
377 |
+
}
|
378 |
+
$stockItem->save();
|
379 |
+
|
380 |
+
$options = $product->getTypeInstance(true)->getOrderOptions($product);
|
381 |
+
|
382 |
+
$orderItem = Mage::getModel('sales/order_item')
|
383 |
+
->setStoreId($this->_storeId)
|
384 |
+
->setQuoteItemId(0)
|
385 |
+
->setQuoteParentItemId(NULL)
|
386 |
+
->setProductId($product->getId())
|
387 |
+
->setProductType($product->getTypeId())
|
388 |
+
->setQtyBackordered(NULL)
|
389 |
+
->setTotalQtyOrdered($product['rqty'])
|
390 |
+
->setQtyOrdered($product['qty'])
|
391 |
+
->setName($product->getName())
|
392 |
+
->setSku($product->getSku())
|
393 |
+
->setPrice( $finalPrice )
|
394 |
+
->setBasePrice( $finalPrice )
|
395 |
+
->setOriginalPrice( $finalPrice )
|
396 |
+
->setRowTotal($rowTotal)
|
397 |
+
->setBaseRowTotal($rowTotal)
|
398 |
+
|
399 |
+
->setWeeeTaxApplied(serialize(array()))
|
400 |
+
->setBaseWeeeTaxDisposition(0)
|
401 |
+
->setWeeeTaxDisposition(0)
|
402 |
+
->setBaseWeeeTaxRowDisposition(0)
|
403 |
+
->setWeeeTaxRowDisposition(0)
|
404 |
+
->setBaseWeeeTaxAppliedAmount(0)
|
405 |
+
->setBaseWeeeTaxAppliedRowAmount(0)
|
406 |
+
->setWeeeTaxAppliedAmount(0)
|
407 |
+
->setWeeeTaxAppliedRowAmount(0)
|
408 |
+
|
409 |
+
->setProductOptions($options);
|
410 |
+
|
411 |
+
$this->_subTotal += $rowTotal;
|
412 |
+
|
413 |
+
return $orderItem;
|
414 |
+
}
|
415 |
+
}
|
app/code/community/DB1/AnyMarket/Helper/Product.php
CHANGED
@@ -1,1311 +1,2173 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
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 |
-
|
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 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
$
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
)
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
}
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
$
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
$
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
"
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
$
|
718 |
-
$
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
}
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
$
|
746 |
-
$
|
747 |
-
|
748 |
-
$
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
);
|
753 |
-
|
754 |
-
|
755 |
-
$
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
$
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
$
|
769 |
-
$
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
$
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
$
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
$
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
)
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
)
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
$
|
934 |
-
|
935 |
-
$
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
$
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
$
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
$
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
$
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
)
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
$this->
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
$product->
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
$
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
$
|
1108 |
-
$
|
1109 |
-
|
1110 |
-
$
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
$
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
$
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
if(
|
1155 |
-
|
1156 |
-
$
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
);
|
1257 |
-
Mage::
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
$
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
$
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1311 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param $arrAttr
|
7 |
+
* @param $key
|
8 |
+
* @param $value
|
9 |
+
* @return bool
|
10 |
+
*/
|
11 |
+
private function checkArrayAttributes($arrAttr, $key, $value){
|
12 |
+
foreach ($arrAttr as $arrVal) {
|
13 |
+
if( $arrVal[$key] == $value ){
|
14 |
+
return true;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
return false;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param $UnitMeasurement
|
22 |
+
* @param $value
|
23 |
+
* @param $typeConvert
|
24 |
+
* @return float
|
25 |
+
*/
|
26 |
+
private function convertUnitMeasurement($UnitMeasurement, $value, $typeConvert){
|
27 |
+
/*
|
28 |
+
* $typeConvert = 0 receive from anymarket
|
29 |
+
* $typeConvert = 1 send to anymarket
|
30 |
+
|
31 |
+
* 'CentÃmetro', 'value' => '0'
|
32 |
+
* 'Metro', 'value' => '1'
|
33 |
+
* 'DecÃmetro', 'value' => '2'
|
34 |
+
* 'MilÃmetro', 'value' => '3'
|
35 |
+
*/
|
36 |
+
|
37 |
+
$valueRet = $value;
|
38 |
+
if( $typeConvert == 0 ){
|
39 |
+
switch ($UnitMeasurement) {
|
40 |
+
case 0:
|
41 |
+
$valueRet = $value*1;
|
42 |
+
break;
|
43 |
+
case 1:
|
44 |
+
$valueRet = $value/100;
|
45 |
+
break;
|
46 |
+
case 2:
|
47 |
+
$valueRet = $value/10;
|
48 |
+
break;
|
49 |
+
case 3:
|
50 |
+
$valueRet = $value*10;
|
51 |
+
break;
|
52 |
+
}
|
53 |
+
}else{
|
54 |
+
switch ($UnitMeasurement) {
|
55 |
+
case 0:
|
56 |
+
$valueRet = $value*1;
|
57 |
+
break;
|
58 |
+
case 1:
|
59 |
+
$valueRet = $value*100;
|
60 |
+
break;
|
61 |
+
case 2:
|
62 |
+
$valueRet = $value*10;
|
63 |
+
break;
|
64 |
+
case 3:
|
65 |
+
$valueRet = $value/10;
|
66 |
+
break;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $valueRet;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* get all fields configured in configuration for descriptions
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function getFieldsDescriptionConfig($storeID){
|
79 |
+
$ConfigDescProd = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_desc_field', $storeID);
|
80 |
+
$fieldDesc = array();
|
81 |
+
if ($ConfigDescProd && $ConfigDescProd != 'a:0:{}') {
|
82 |
+
$ConfigDescProd = unserialize($ConfigDescProd);
|
83 |
+
if (is_array($ConfigDescProd)) {
|
84 |
+
foreach($ConfigDescProd as $ConfigDescProdRow) {
|
85 |
+
|
86 |
+
$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','description');
|
87 |
+
$attributesData = Mage::getResourceModel('catalog/product_attribute_collection')
|
88 |
+
->addVisibleFilter()
|
89 |
+
->addFieldToSelect(array('frontend_input', 'backend_type'))
|
90 |
+
->addFieldToFilter('main_table.attribute_id', array('eq' => $attributeId));
|
91 |
+
|
92 |
+
$arrValuesAttrs = array_values( $attributesData->getData() );
|
93 |
+
$StoreIDAmProd = array_shift( $arrValuesAttrs );
|
94 |
+
if( ($StoreIDAmProd['frontend_input'] == "textarea") && ($StoreIDAmProd['backend_type'] == "text") ){
|
95 |
+
array_push($fieldDesc, $ConfigDescProdRow['descProduct']);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
if( empty($fieldDesc) ) {
|
102 |
+
array_push($fieldDesc, "description");
|
103 |
+
}
|
104 |
+
|
105 |
+
return $fieldDesc;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get decription by configuration
|
110 |
+
*
|
111 |
+
* @param $product
|
112 |
+
* @return string
|
113 |
+
*/
|
114 |
+
public function getFullDescription($storeID, $product){
|
115 |
+
$ConfigDescProd = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_desc_field', $storeID);
|
116 |
+
$descComplete = "";
|
117 |
+
if ($ConfigDescProd && $ConfigDescProd != 'a:0:{}') {
|
118 |
+
$ConfigDescProd = unserialize($ConfigDescProd);
|
119 |
+
if (is_array($ConfigDescProd)) {
|
120 |
+
foreach($ConfigDescProd as $ConfigDescProdRow) {
|
121 |
+
$descComplete .= $product->getData( $ConfigDescProdRow['descProduct'] ).' ';
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}else{
|
125 |
+
$descComplete = $product->getDescription();
|
126 |
+
}
|
127 |
+
$baseURLMedia = Mage::getBaseUrl('media');
|
128 |
+
|
129 |
+
$descComplete = str_replace('{{media url="', $baseURLMedia, $descComplete);
|
130 |
+
$descComplete = str_replace('"}}', '', $descComplete);
|
131 |
+
|
132 |
+
return trim($descComplete);
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* create logs of product
|
137 |
+
*
|
138 |
+
* @param $returnProd array
|
139 |
+
* @param $product Mage_Catalog_Model_Product
|
140 |
+
*/
|
141 |
+
public function saveLogsProds($storeID, $priority, $returnProd, $product){
|
142 |
+
$anymarketproductsUpdt = Mage::getModel('db1_anymarket/anymarketproducts')->setStoreId($storeID)->load($product->getId(), 'nmp_id');
|
143 |
+
|
144 |
+
if(is_array($anymarketproductsUpdt->getData('store_id'))){
|
145 |
+
$arrValuesProds = array_values($anymarketproductsUpdt->getData('store_id'));
|
146 |
+
$StoreIDAmProd = array_shift($arrValuesProds);
|
147 |
+
}else{
|
148 |
+
$StoreIDAmProd = $anymarketproductsUpdt->getData('store_id');
|
149 |
+
}
|
150 |
+
|
151 |
+
if($returnProd['error'] == '1'){ //RETORNOU ERRO
|
152 |
+
if( ($anymarketproductsUpdt->getData('nmp_sku') == null) || ($StoreIDAmProd != $storeID) ){
|
153 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts');
|
154 |
+
$anymarketproducts->setNmpId( $product->getId() );
|
155 |
+
$anymarketproducts->setNmpSku( $product->getSku() );
|
156 |
+
$anymarketproducts->setNmpName( $product->getName() );
|
157 |
+
$anymarketproducts->setNmpDescError( $returnProd['return'] );
|
158 |
+
$anymarketproducts->setNmpStatusInt("Erro");
|
159 |
+
$anymarketproducts->setStatus("1");
|
160 |
+
$anymarketproducts->setStores(array($storeID));
|
161 |
+
$anymarketproducts->save();
|
162 |
+
}else{
|
163 |
+
$anymarketproductsUpdt->setNmpId( $product->getId() );
|
164 |
+
$anymarketproductsUpdt->setNmpSku( $product->getSku() );
|
165 |
+
$anymarketproductsUpdt->setNmpName( $product->getName() );
|
166 |
+
$anymarketproductsUpdt->setNmpDescError( $returnProd['return'] );
|
167 |
+
$anymarketproductsUpdt->setNmpStatusInt("Erro");
|
168 |
+
$anymarketproductsUpdt->setStatus("1");
|
169 |
+
$anymarketproductsUpdt->setStores(array($storeID));
|
170 |
+
$anymarketproductsUpdt->save();
|
171 |
+
}
|
172 |
+
|
173 |
+
$URL = Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array('id' => $product->getId() ));
|
174 |
+
$this->addMessageInBox($storeID, 'Error synchronizing AnyMarket products.', 'Error on Sinc product SKU: '.$product->getSku(), $URL);
|
175 |
+
$returnMet = $returnProd['return'];
|
176 |
+
}else{ //FOI BEM SUCEDIDO
|
177 |
+
if( ($anymarketproductsUpdt->getData('nmp_sku') == null) || ($StoreIDAmProd != $storeID) ) {
|
178 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts');
|
179 |
+
$anymarketproducts->setNmpId($product->getId());
|
180 |
+
$anymarketproducts->setNmpSku($product->getSku());
|
181 |
+
$anymarketproducts->setNmpName($product->getName());
|
182 |
+
$anymarketproducts->setNmpDescError("");
|
183 |
+
$anymarketproducts->setNmpStatusInt("Integrado");
|
184 |
+
$anymarketproducts->setStatus("1");
|
185 |
+
$anymarketproducts->setStores(array($storeID));
|
186 |
+
$anymarketproducts->save();
|
187 |
+
}else{
|
188 |
+
$anymarketproductsUpdt->setNmpId($product->getId());
|
189 |
+
$anymarketproductsUpdt->setNmpSku($product->getSku());
|
190 |
+
$anymarketproductsUpdt->setNmpName($product->getName());
|
191 |
+
$anymarketproductsUpdt->setNmpDescError("");
|
192 |
+
$anymarketproductsUpdt->setNmpStatusInt("Integrado");
|
193 |
+
$anymarketproductsUpdt->setStatus("1");
|
194 |
+
$anymarketproductsUpdt->setStores(array($storeID));
|
195 |
+
$anymarketproductsUpdt->save();
|
196 |
+
}
|
197 |
+
|
198 |
+
$returnMet = $returnProd['return'];
|
199 |
+
}
|
200 |
+
|
201 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
202 |
+
if(is_string($returnMet)){
|
203 |
+
$anymarketlog->setLogDesc( $returnMet );
|
204 |
+
}else{
|
205 |
+
$anymarketlog->setLogDesc( json_encode($returnMet) );
|
206 |
+
}
|
207 |
+
|
208 |
+
$anymarketlog->setLogId( $product->getSku() );
|
209 |
+
if(is_string($returnProd['json'])){
|
210 |
+
$anymarketlog->setLogJson( $returnProd['json'] );
|
211 |
+
}else{
|
212 |
+
$anymarketlog->setLogJson( json_encode($returnProd['json']) );
|
213 |
+
}
|
214 |
+
|
215 |
+
$anymarketlog->setStatus($priority);
|
216 |
+
$anymarketlog->setStores(array($storeID));
|
217 |
+
$anymarketlog->save();
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* @param $var_1
|
222 |
+
* @param $var_2
|
223 |
+
* @return array
|
224 |
+
*/
|
225 |
+
private function compareArrayImage($var_1, $var_2){
|
226 |
+
$arrayReturn = array();
|
227 |
+
foreach ($var_1 as $value_1) {
|
228 |
+
$hSamVal = false;
|
229 |
+
foreach ($var_2 as $value_2) {
|
230 |
+
$ArrtratValue1 = explode("_", $value_1['ctrl']);
|
231 |
+
$ArrtratValue2 = explode("_", $value_2['ctrl']);
|
232 |
+
|
233 |
+
$tratval1 = array_values($ArrtratValue1);
|
234 |
+
$tratValue1 = array_shift($tratval1);
|
235 |
+
$tratval2 = array_values($ArrtratValue2);
|
236 |
+
$tratValue2 = array_shift($tratval2);
|
237 |
+
if( $tratValue1 == $tratValue2 ){
|
238 |
+
$hSamVal = true;
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
if(!$hSamVal){
|
243 |
+
$arrayReturn[] = $value_1;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
return $arrayReturn;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* create a Configurable Product
|
251 |
+
*
|
252 |
+
* @param $storeID
|
253 |
+
* @param $dataProdConfig
|
254 |
+
* @param $simpleProducts
|
255 |
+
* @param $AttributeIds
|
256 |
+
* @return Mage_Catalog_Model_Product
|
257 |
+
*/
|
258 |
+
private function create_configurable_product($storeID, $dataProdConfig, $simpleProducts, $AttributeIds){
|
259 |
+
$productGenerator = Mage::helper('db1_anymarket/productgenerator');
|
260 |
+
$product = $productGenerator->createConfigurableProduct($storeID, $dataProdConfig, $simpleProducts, $AttributeIds);
|
261 |
+
|
262 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Configurable product Created').' ('.$product->getId().')';
|
263 |
+
$returnProd['error'] = '0';
|
264 |
+
$returnProd['json'] = '';
|
265 |
+
|
266 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
267 |
+
|
268 |
+
return $product;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* update a Configurable Product
|
273 |
+
*
|
274 |
+
* @param $storeID
|
275 |
+
* @param $idProd
|
276 |
+
* @param $dataProdConfig
|
277 |
+
* @param $simpleProducts
|
278 |
+
* @param $AttributeIds
|
279 |
+
* @return Mage_Catalog_Model_Product
|
280 |
+
*/
|
281 |
+
private function update_configurable_product($storeID, $idProd, $dataProdConfig, $simpleProducts, $AttributeIds){
|
282 |
+
$productGenerator = Mage::helper('db1_anymarket/productgenerator');
|
283 |
+
$product = $productGenerator->updateConfigurableProduct($storeID, $idProd, $dataProdConfig, $simpleProducts, $AttributeIds);
|
284 |
+
|
285 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Configurable product Updated').' ('.$product->getSku().')';
|
286 |
+
$returnProd['error'] = '0';
|
287 |
+
$returnProd['json'] = '';
|
288 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
289 |
+
|
290 |
+
return $product;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* create simple prod in magento
|
295 |
+
*
|
296 |
+
* @param $storeID
|
297 |
+
* @param $data
|
298 |
+
* @return Mage_Catalog_Model_Product
|
299 |
+
*/
|
300 |
+
function create_simple_product($storeID, $data){
|
301 |
+
$productGenerator = Mage::helper('db1_anymarket/productgenerator');
|
302 |
+
$product = $productGenerator->createSimpleProduct($data);
|
303 |
+
|
304 |
+
if(!$product){
|
305 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Simple product Created').' ('.$product->getId().')';
|
306 |
+
$returnProd['error'] = '0';
|
307 |
+
$returnProd['json'] = '';
|
308 |
+
|
309 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
310 |
+
}
|
311 |
+
|
312 |
+
return $product;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* @param $attrCode
|
317 |
+
* @param $attrVal
|
318 |
+
* @param $typeProc
|
319 |
+
* @return mixed
|
320 |
+
*/
|
321 |
+
public function procAttrConfig($attrCode, $attrVal, $typeProc){
|
322 |
+
$_product = Mage::getModel('catalog/product');
|
323 |
+
$attr = $_product->getResource()->getAttribute($attrCode);
|
324 |
+
|
325 |
+
if($attr){
|
326 |
+
if ($attr->usesSource()) {
|
327 |
+
if($typeProc == 0){
|
328 |
+
$returnAttr = $attr->getSource()->getOptionId((string)$attrVal);
|
329 |
+
if($returnAttr){
|
330 |
+
return $returnAttr;
|
331 |
+
}else{
|
332 |
+
return $attrVal;
|
333 |
+
}
|
334 |
+
}else{
|
335 |
+
$returnAttr = $attr->getSource()->getOptionText($attrVal);
|
336 |
+
if($returnAttr){
|
337 |
+
return $returnAttr;
|
338 |
+
}else{
|
339 |
+
return $attrVal;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}else{
|
343 |
+
return $attrVal;
|
344 |
+
}
|
345 |
+
}else{
|
346 |
+
return $attrVal;
|
347 |
+
}
|
348 |
+
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* update image for specific product
|
353 |
+
*
|
354 |
+
* @param $Prod
|
355 |
+
* @param $ProdsJSON
|
356 |
+
* @param $idClient
|
357 |
+
*/
|
358 |
+
public function update_image_product($Prod, $ProdsJSON, $idClient){
|
359 |
+
$arrSku = $ProdsJSON->skus;
|
360 |
+
$variation = array();
|
361 |
+
foreach ($arrSku as $skuImg) {
|
362 |
+
if($skuImg->idInClient == $Prod->getSku() ){
|
363 |
+
foreach ($skuImg->variations as $variationSku) {
|
364 |
+
array_push($variation, $variationSku->description);
|
365 |
+
}
|
366 |
+
break;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
$mediaApi = Mage::getModel("catalog/product_attribute_media_api");
|
371 |
+
$items = $mediaApi->items($Prod->getId());
|
372 |
+
$imagesGalleryMG = array();
|
373 |
+
foreach($items as $item) {
|
374 |
+
$crltImg = basename($item['file']);
|
375 |
+
$crltImg = str_replace(strrchr($crltImg,"."), "", $crltImg);
|
376 |
+
$imagesGalleryMG[] = array('ctrl' => $crltImg, 'img' => $item['url'], 'file' => $item['file'] );
|
377 |
+
}
|
378 |
+
|
379 |
+
$imagesGalleryAM = array();
|
380 |
+
foreach ($ProdsJSON->photos as $image) {
|
381 |
+
$crltImgAM = basename($image->original);
|
382 |
+
$crltImgAM = str_replace(strrchr($crltImgAM,"."), "", $crltImgAM);
|
383 |
+
|
384 |
+
if( !empty($variation) ){
|
385 |
+
if (in_array( $image->variationValue, $variation)) {
|
386 |
+
$imagesGalleryAM[] = array('ctrl' => md5($crltImgAM . $idClient), 'img' => $image->standard_resolution, 'main' => $image->main);
|
387 |
+
}
|
388 |
+
}else{
|
389 |
+
$imagesGalleryAM[] = array('ctrl' => md5($crltImgAM . $idClient), 'img' => $image->standard_resolution, 'main' => $image->main);
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
//COMPARA IMG AM COM MG SE TIVER DIVERGENCIA ADD NO PRODUTO
|
394 |
+
$diffAM = $this->compareArrayImage($imagesGalleryAM, $imagesGalleryMG);
|
395 |
+
if ($diffAM) {
|
396 |
+
foreach ($diffAM as $diffAM_value) {
|
397 |
+
$imagesGallery[] = array('img' => $diffAM_value['img'], 'main' => $diffAM_value['main']);
|
398 |
+
}
|
399 |
+
|
400 |
+
$dataImgs = array('images' => $imagesGallery, 'sku' => $idClient);
|
401 |
+
$productGenerator = Mage::helper('db1_anymarket/productgenerator');
|
402 |
+
$productGenerator->updateImages($Prod, $dataImgs);
|
403 |
+
}
|
404 |
+
|
405 |
+
//COMPARA IMG AM COM MG SE TIVER DIVERCIA REMOVE DO PRODUTO
|
406 |
+
$diffMG = $this->compareArrayImage($imagesGalleryMG, $imagesGalleryAM);
|
407 |
+
if ($diffMG) {
|
408 |
+
foreach ($diffMG as $diffMG_value) {
|
409 |
+
$mediaApi->remove($Prod->getId(), $diffMG_value['file']);
|
410 |
+
//remover arquivo fisicamente
|
411 |
+
}
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
*
|
417 |
+
* Send Image to Anymarket
|
418 |
+
*
|
419 |
+
* @param $storeID
|
420 |
+
* @param $product
|
421 |
+
* @param $variation
|
422 |
+
*
|
423 |
+
*/
|
424 |
+
public function sendImageToAnyMarket($storeID, $product, $variation){
|
425 |
+
if($product){
|
426 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
427 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
428 |
+
$exportImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_export_image_field', $storeID);
|
429 |
+
|
430 |
+
$headers = array(
|
431 |
+
"Content-type: application/json",
|
432 |
+
"gumgaToken: ".$TOKEN
|
433 |
+
);
|
434 |
+
|
435 |
+
if($product->getData('id_anymarket') != ''){
|
436 |
+
$imgGetRet = $this->CallAPICurl("GET", $HOST."/v2/products/".$product->getData('id_anymarket')."/images", $headers, null);
|
437 |
+
if($imgGetRet['error'] == '0'){
|
438 |
+
$imgsProdAnymarket = $imgGetRet['return'];
|
439 |
+
$imgsProdMagento = $product->getMediaGalleryImages();
|
440 |
+
|
441 |
+
$arrAdd = array();
|
442 |
+
$ctrlAdd = false;
|
443 |
+
$arrRemove = array();
|
444 |
+
$ctrlRemove = false;
|
445 |
+
$arrImgs = array();
|
446 |
+
|
447 |
+
//verifica quais irao adicionar
|
448 |
+
foreach ($imgsProdMagento as $imgProdMagento) {
|
449 |
+
$ctrlAdd = false;
|
450 |
+
|
451 |
+
$urlImage = $imgProdMagento->getData('url');
|
452 |
+
$infoImg = getimagesize( $urlImage );
|
453 |
+
$imgSize = filesize( $imgProdMagento->getData('path') );
|
454 |
+
|
455 |
+
if( ($infoImg[0] != "") && ((float)$infoImg[0] < 350 || (float)$infoImg[1] < 350 || $imgSize > 4100000 )) {
|
456 |
+
if ($exportImage == 0) {
|
457 |
+
array_push($arrProd, 'Image_c (' . $urlImage . ' - Sku: ' . $product->getSku() . ' - Width: ' . $infoImg[0] . ' - Height: ' . $infoImg[1] . ' - Size: ' . $imgSize . ')');
|
458 |
+
} else {
|
459 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
460 |
+
$anymarketlog->setLogDesc('Error on export image - ' . $urlImage);
|
461 |
+
$anymarketlog->setLogId($product->getSku());
|
462 |
+
$anymarketlog->setStatus("1");
|
463 |
+
$anymarketlog->setStores(array($storeID));
|
464 |
+
$anymarketlog->save();
|
465 |
+
}
|
466 |
+
}else{
|
467 |
+
foreach ($imgsProdAnymarket as $imgProdAnymarket) {
|
468 |
+
if ($variation) {
|
469 |
+
if (($imgProdMagento->getData('url') == $imgProdAnymarket->url) && ($imgProdAnymarket->variation == $variation)) {
|
470 |
+
$ctrlAdd = true;
|
471 |
+
break;
|
472 |
+
}
|
473 |
+
} else {
|
474 |
+
if ($imgProdMagento->getData('url') == $imgProdAnymarket->url) {
|
475 |
+
$ctrlAdd = true;
|
476 |
+
break;
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
}
|
481 |
+
|
482 |
+
if (!$ctrlAdd) {
|
483 |
+
array_push($arrAdd, $imgProdMagento->getData('url'));
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
}
|
488 |
+
|
489 |
+
//verifica quais irao remover
|
490 |
+
foreach ($imgsProdAnymarket as $imgProdAnymarket) {
|
491 |
+
$ctrlRemove = false;
|
492 |
+
foreach ($imgsProdMagento as $imgProdMagento) {
|
493 |
+
if($variation){
|
494 |
+
if( ($imgProdAnymarket->url == $imgProdMagento->getData('url')) && ($imgProdAnymarket->variation == $variation) ){
|
495 |
+
$ctrlRemove = true;
|
496 |
+
break;
|
497 |
+
}
|
498 |
+
}else{
|
499 |
+
if($imgProdAnymarket->url == $imgProdMagento->getData('url') ){
|
500 |
+
$ctrlRemove = true;
|
501 |
+
break;
|
502 |
+
}
|
503 |
+
}
|
504 |
+
}
|
505 |
+
|
506 |
+
if(!$ctrlRemove){
|
507 |
+
if($variation){
|
508 |
+
if($imgProdAnymarket->variation == $variation){
|
509 |
+
array_push($arrRemove, $imgProdAnymarket->id);
|
510 |
+
}
|
511 |
+
}else{
|
512 |
+
array_push($arrRemove, $imgProdAnymarket->id);
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
// Add Image
|
518 |
+
if( !empty($arrImgs) ){
|
519 |
+
$returnProd['error'] = '1';
|
520 |
+
$returnProd['json'] = '';
|
521 |
+
|
522 |
+
$emptyFields = ' ';
|
523 |
+
foreach ($arrImgs as $field) {
|
524 |
+
$emptyFields .= $field.', ';
|
525 |
+
}
|
526 |
+
|
527 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Product with inconsistency:').' '.$emptyFields;
|
528 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
529 |
+
}else {
|
530 |
+
foreach ($arrAdd as $imgAdd) {
|
531 |
+
if ($variation) {
|
532 |
+
$JSONAdd = array(
|
533 |
+
"url" => $imgAdd,
|
534 |
+
"variation" => $variation,
|
535 |
+
);
|
536 |
+
} else {
|
537 |
+
$JSONAdd = array(
|
538 |
+
"url" => $imgAdd
|
539 |
+
);
|
540 |
+
}
|
541 |
+
|
542 |
+
$imgPostRet = $this->CallAPICurl("POST", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/images", $headers, $JSONAdd);
|
543 |
+
if ($imgPostRet['error'] == '1') {
|
544 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
545 |
+
$anymarketlog->setLogDesc('Error on export image (' . $product->getData('id_anymarket') . ') - ' . is_string($imgPostRet['return']) ? $imgPostRet['return'] : json_encode($imgPostRet['return']));
|
546 |
+
$anymarketlog->setLogJson($imgPostRet['json']);
|
547 |
+
$anymarketlog->setLogId($product->getSku());
|
548 |
+
$anymarketlog->setStatus("1");
|
549 |
+
$anymarketlog->setStores(array($storeID));
|
550 |
+
$anymarketlog->save();
|
551 |
+
} else {
|
552 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
553 |
+
$anymarketlog->setLogDesc('Exported image (' . $imgAdd . ')');
|
554 |
+
$anymarketlog->setLogJson($imgPostRet['json']);
|
555 |
+
$anymarketlog->setLogId($product->getSku());
|
556 |
+
$anymarketlog->setStatus("1");
|
557 |
+
$anymarketlog->setStores(array($storeID));
|
558 |
+
$anymarketlog->save();
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
// remove image
|
564 |
+
foreach ($arrRemove as $imgRemove) {
|
565 |
+
$imgDelRet = $this->CallAPICurl("DELETE", $HOST."/v2/products/".$product->getData('id_anymarket')."/images/".$imgRemove, $headers, null);
|
566 |
+
if($imgDelRet['error'] == '1'){
|
567 |
+
$anymarketlogDel = Mage::getModel('db1_anymarket/anymarketlog');
|
568 |
+
|
569 |
+
if( is_string($imgDelRet['return']) ){
|
570 |
+
$anymarketlogDel->setLogDesc( 'Error on delete image in Anymarket ('.$imgRemove.') - '.$imgDelRet['return']);
|
571 |
+
}else{
|
572 |
+
$anymarketlogDel->setLogDesc( 'Error on delete image in Anymarket ('.$imgRemove.') - '.json_encode($imgDelRet['return']));
|
573 |
+
}
|
574 |
+
|
575 |
+
$anymarketlogDel->setLogJson('');
|
576 |
+
$anymarketlogDel->setLogId($product->getSku());
|
577 |
+
$anymarketlogDel->setStatus("1");
|
578 |
+
$anymarketlogDel->setStores(array($storeID));
|
579 |
+
$anymarketlogDel->save();
|
580 |
+
}else{
|
581 |
+
$anymarketlogDel = Mage::getModel('db1_anymarket/anymarketlog');
|
582 |
+
$anymarketlogDel->setLogDesc( 'Deleted image from Anymarket ');
|
583 |
+
$anymarketlogDel->setLogJson('');
|
584 |
+
$anymarketlogDel->setLogId($product->getSku());
|
585 |
+
$anymarketlogDel->setStatus("1");
|
586 |
+
$anymarketlogDel->setStores(array($storeID));
|
587 |
+
$anymarketlogDel->save();
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
}else{
|
592 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
593 |
+
$anymarketlog->setLogDesc( 'Error on get images from Anymarket ('.$product->getData('id_anymarket').') - '.$imgGetRet['return'] );
|
594 |
+
$anymarketlog->setStatus("1");
|
595 |
+
$anymarketlog->setStores(array($storeID));
|
596 |
+
$anymarketlog->save();
|
597 |
+
}
|
598 |
+
}
|
599 |
+
}
|
600 |
+
}
|
601 |
+
|
602 |
+
/**
|
603 |
+
* @param $product
|
604 |
+
* @param $skusParam
|
605 |
+
* @param $storeID
|
606 |
+
*/
|
607 |
+
public function sendImageSkuToAnyMarket($storeID, $product, $skusParam) {
|
608 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
609 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
610 |
+
|
611 |
+
$headers = array(
|
612 |
+
"Content-type: application/json",
|
613 |
+
"Cache-Control: no-cache",
|
614 |
+
"gumgaToken: ".$TOKEN
|
615 |
+
);
|
616 |
+
|
617 |
+
// SINCRONIZA AS FOTOS E SKUS
|
618 |
+
$skusProd = $this->CallAPICurl("GET", $HOST."/v2/products/".$product->getData('id_anymarket')."/skus", $headers, null);
|
619 |
+
if($skusProd['error'] == '0') {
|
620 |
+
foreach ($skusParam as $skuPut) {
|
621 |
+
$prodSimple = Mage::getModel('catalog/product')->load($skuPut['internalIdProduct']);
|
622 |
+
|
623 |
+
if ($prodSimple->getData('id_anymarket') != '') {
|
624 |
+
$paramSku = array(
|
625 |
+
"title" => $skuPut['title'],
|
626 |
+
"partnerId" => $skuPut['partnerId'],
|
627 |
+
"ean" => $skuPut['ean'],
|
628 |
+
"amount" => $skuPut['amount'],
|
629 |
+
"price" => $skuPut['price'],
|
630 |
+
);
|
631 |
+
|
632 |
+
if (isset($skuPut['variations'])) {
|
633 |
+
foreach ($skuPut['variations'] as $variationPut) {
|
634 |
+
$this->sendImageToAnyMarket($storeID, $prodSimple, $variationPut);
|
635 |
+
}
|
636 |
+
$paramSku['variations'] = $skuPut['variations'];
|
637 |
+
} else {
|
638 |
+
$this->sendImageToAnyMarket($storeID, $product, null);
|
639 |
+
}
|
640 |
+
|
641 |
+
$flagHSku = '';
|
642 |
+
if (isset($skusProd['return'])) {
|
643 |
+
foreach ($skusProd['return'] as $skuAM) {
|
644 |
+
if ($skuAM->partnerId == $prodSimple->getSku()) {
|
645 |
+
$flagHSku = $skuAM->id;
|
646 |
+
break;
|
647 |
+
}
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
if ($flagHSku != '') {
|
652 |
+
$skuProdReturn = $this->CallAPICurl("PUT", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus/" . $flagHSku, $headers, $paramSku);
|
653 |
+
|
654 |
+
if ($skuProdReturn['error'] == '0') {
|
655 |
+
$skuProdReturn['return'] = Mage::helper('db1_anymarket')->__('SKU Updated') . ' (' . $skuPut['partnerId'] . ')';
|
656 |
+
}
|
657 |
+
} else {
|
658 |
+
$skuProdReturn = $this->CallAPICurl("POST", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus", $headers, $paramSku);
|
659 |
+
|
660 |
+
if ($skuProdReturn['error'] == '0') {
|
661 |
+
$skuProdReturn['return'] = Mage::helper('db1_anymarket')->__('SKU Created') . ' (' . $skuPut['partnerId'] . ')';
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
$this->saveLogsProds($storeID, "1", $skuProdReturn, $prodSimple);
|
666 |
+
$this->updatePriceStockAnyMarket($storeID, $skuPut['internalIdProduct'], $skuPut['amount'], $skuPut['price']);
|
667 |
+
}
|
668 |
+
}
|
669 |
+
}else{
|
670 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
671 |
+
$anymarketlog->setLogDesc('Error on get Images Anymarket: '. $skusProd['return']);
|
672 |
+
$anymarketlog->setLogJson($skusProd['json']);
|
673 |
+
$anymarketlog->setLogId($product->getSku());
|
674 |
+
$anymarketlog->setStatus("1");
|
675 |
+
$anymarketlog->setStores(array($storeID));
|
676 |
+
$anymarketlog->save();
|
677 |
+
}
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* @param $descBrand
|
682 |
+
* @param $storeID
|
683 |
+
* @return integer
|
684 |
+
*/
|
685 |
+
public function getBrandForProduct($storeID, $descBrand){
|
686 |
+
$brand = Mage::getModel('db1_anymarket/anymarketbrands')->load($descBrand, 'brd_name');
|
687 |
+
if( $brand->getData('brd_id') == null ){
|
688 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
689 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
690 |
+
|
691 |
+
$headers = array(
|
692 |
+
"Content-type: application/json",
|
693 |
+
"Accept: */*",
|
694 |
+
"gumgaToken: ".$TOKEN
|
695 |
+
);
|
696 |
+
|
697 |
+
$param = array(
|
698 |
+
"name" => $descBrand,
|
699 |
+
"partnerId" => $descBrand
|
700 |
+
);
|
701 |
+
|
702 |
+
$returnBrands = $this->CallAPICurl("POST", $HOST."/v2/brands", $headers, $param);
|
703 |
+
$brandsJSON = $returnBrands['return'];
|
704 |
+
$return = null;
|
705 |
+
if( $returnBrands['error'] == '0' ){
|
706 |
+
$return = $brandsJSON->id;
|
707 |
+
}else{
|
708 |
+
if( isset($brandsJSON->data->brandId) ){
|
709 |
+
$return = $brandsJSON->data->brandId;
|
710 |
+
}
|
711 |
+
}
|
712 |
+
|
713 |
+
if( $return ){
|
714 |
+
$mBrands = Mage::getModel('db1_anymarket/anymarketbrands');
|
715 |
+
$mBrands->setBrdId( $return );
|
716 |
+
$mBrands->setBrdName( $descBrand );
|
717 |
+
$mBrands->setStatus("1");
|
718 |
+
$mBrands->setStores(array($storeID));
|
719 |
+
$mBrands->save();
|
720 |
+
|
721 |
+
return $return;
|
722 |
+
}else{
|
723 |
+
return '';
|
724 |
+
}
|
725 |
+
|
726 |
+
}else{
|
727 |
+
return $brand->getData('brd_id');
|
728 |
+
}
|
729 |
+
}
|
730 |
+
|
731 |
+
/**
|
732 |
+
* send product to AnyMarket
|
733 |
+
*
|
734 |
+
* @param $idProduct
|
735 |
+
* @return bool
|
736 |
+
*/
|
737 |
+
public function sendProductToAnyMarket($storeID, $idProduct){
|
738 |
+
//obter configuracoes
|
739 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->load($idProduct);
|
740 |
+
|
741 |
+
//Obtem os parametros dos attr para subir para o AM
|
742 |
+
$model = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_model_field', $storeID);
|
743 |
+
$brand = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_brand_field', $storeID);
|
744 |
+
|
745 |
+
$volume_comprimento = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_vol_comp_field', $storeID);
|
746 |
+
$volume_altura = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_vol_alt_field', $storeID);
|
747 |
+
$volume_largura = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_vol_larg_field', $storeID);
|
748 |
+
$video_url = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_video_url_field', $storeID);
|
749 |
+
$nbm = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_nbm_field', $storeID);
|
750 |
+
$nbm_origin = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_nbm_origin_field', $storeID);
|
751 |
+
$ean = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_ean_field', $storeID);
|
752 |
+
$warranty_text = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_warranty_text_field', $storeID);
|
753 |
+
$warranty_time = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_warranty_time_field', $storeID);
|
754 |
+
|
755 |
+
$price_factor = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_price_factor_field', $storeID);
|
756 |
+
$calculated_price = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_calculated_price_field', $storeID);
|
757 |
+
|
758 |
+
$arrProd = array();
|
759 |
+
// verifica categoria null ou em branco
|
760 |
+
$categProd = $product->getData('categoria_anymarket');
|
761 |
+
if($categProd == null || $categProd == ''){
|
762 |
+
array_push($arrProd, 'AnyMarket_Category');
|
763 |
+
}
|
764 |
+
|
765 |
+
// verifica o Price Factor (Markup)
|
766 |
+
$varPriceFactor = $this->procAttrConfig($price_factor, $product->getData( $price_factor ), 1);
|
767 |
+
if((string)(float)$varPriceFactor == $varPriceFactor) {
|
768 |
+
$varPriceFactor = (float)$varPriceFactor;
|
769 |
+
if($varPriceFactor > 99){
|
770 |
+
array_push($arrProd, 'AnyMarket_Price_Factor(Limit 99)');
|
771 |
+
}
|
772 |
+
}else{
|
773 |
+
array_push($arrProd, 'AnyMarket_Price_Factor(Only Number)');
|
774 |
+
}
|
775 |
+
|
776 |
+
// verifica Origin null ou em branco
|
777 |
+
$originData = $this->procAttrConfig($nbm_origin, $product->getData( $nbm_origin ), 1);
|
778 |
+
if($originData == null || $originData == ''){
|
779 |
+
array_push($arrProd, 'AnyMarket_Origin');
|
780 |
+
}
|
781 |
+
|
782 |
+
//trata para nao enviar novamente solicitacao quando o erro for o mesmo
|
783 |
+
if( ($product->getData('id_anymarket') == '') || ($product->getData('id_anymarket') == '0') ){
|
784 |
+
$prodErrorCtrl = Mage::getModel('db1_anymarket/anymarketproducts')->setStoreId($storeID)
|
785 |
+
->load($product->getId(), 'nmp_id');
|
786 |
+
if( $prodErrorCtrl->getData('nmp_id') != null ){
|
787 |
+
$descError = $prodErrorCtrl->getData('nmp_desc_error');
|
788 |
+
|
789 |
+
// Trata para nao ficar disparando em cima da Duplicadade de SKU
|
790 |
+
$mesgDuplSku = strrpos($descError, "Duplicidade de SKU:");
|
791 |
+
if ($mesgDuplSku !== false) {
|
792 |
+
$oldSkuErr = $this->getBetweenCaract($descError, '"', '"');
|
793 |
+
|
794 |
+
if($oldSkuErr == $product->getSku()){
|
795 |
+
array_push($arrProd, 'Duplicidade de SKU: '.Mage::helper('db1_anymarket')->__('Already existing SKU in anymarket').' "'.$oldSkuErr.'".');
|
796 |
+
}
|
797 |
+
}
|
798 |
+
}
|
799 |
+
}
|
800 |
+
|
801 |
+
if( !empty($arrProd) ){
|
802 |
+
$returnProd['error'] = '1';
|
803 |
+
$returnProd['json'] = '';
|
804 |
+
|
805 |
+
$emptyFields = ' ';
|
806 |
+
foreach ($arrProd as $field) {
|
807 |
+
$emptyFields .= $field.', ';
|
808 |
+
}
|
809 |
+
|
810 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Product with inconsistency:').$emptyFields;
|
811 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
812 |
+
|
813 |
+
return false;
|
814 |
+
}else{
|
815 |
+
$arrProd = array();
|
816 |
+
|
817 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
818 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
819 |
+
|
820 |
+
$MassUnit = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_weight_field', $storeID);
|
821 |
+
$UnitMeasurement = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_size_field', $storeID);
|
822 |
+
|
823 |
+
//verifica se o produto e configurable
|
824 |
+
$confID = "";
|
825 |
+
$Weight = "";
|
826 |
+
if($product->getTypeID() == "configurable"){
|
827 |
+
$confID = $product->getId();
|
828 |
+
}else{
|
829 |
+
// verifica se é um simples pertecente a um Configurable
|
830 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild( $product->getId() );
|
831 |
+
$Weight = $product->getWeight();
|
832 |
+
if (isset($parentIds[0])) {
|
833 |
+
$confID = $parentIds[0];
|
834 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->load($confID);
|
835 |
+
}
|
836 |
+
}
|
837 |
+
|
838 |
+
//obtem as imagens do produto(Config ou Simples)
|
839 |
+
$itemsIMG = array();
|
840 |
+
$galleryData = $product->getMediaGalleryImages();
|
841 |
+
$exportImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_export_image_field', $storeID);
|
842 |
+
foreach($galleryData as $g_image) {
|
843 |
+
$infoImg = getimagesize($g_image['url']);
|
844 |
+
$imgSize = filesize($g_image['path']);
|
845 |
+
|
846 |
+
if( ($infoImg[0] != "") && ((float)$infoImg[0] < 350 || (float)$infoImg[1] < 350 || $imgSize > 4100000) ){
|
847 |
+
if($exportImage == 0) {
|
848 |
+
array_push($arrProd, 'Image_a (' . $g_image['url'] . ' - Sku: ' . $product->getSku() . ' - Width: ' . $infoImg[0] . ' - Height: ' . $infoImg[1] . ' - Size: ' . $imgSize . ')');
|
849 |
+
}else{
|
850 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
851 |
+
$anymarketlog->setLogDesc('Error on export image - ' . $g_image['url']);
|
852 |
+
$anymarketlog->setLogId($product->getSku());
|
853 |
+
$anymarketlog->setStatus("1");
|
854 |
+
$anymarketlog->setStores(array($storeID));
|
855 |
+
$anymarketlog->save();
|
856 |
+
}
|
857 |
+
}else{
|
858 |
+
$itemsIMG[] = array(
|
859 |
+
"main" => true,
|
860 |
+
"url" => $g_image['url']
|
861 |
+
);
|
862 |
+
}
|
863 |
+
}
|
864 |
+
|
865 |
+
//obtem os produtos configs - verifica se e configurable
|
866 |
+
$ArrSimpleConfigProd = array();
|
867 |
+
if($confID != ""){
|
868 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
869 |
+
$attributesConf = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
870 |
+
|
871 |
+
foreach($childProducts as $child) {
|
872 |
+
$SimpleConfigProd = Mage::getModel('catalog/product')->load($child->getId());
|
873 |
+
|
874 |
+
if ($Weight == "") {
|
875 |
+
$Weight = $SimpleConfigProd->getWeight();
|
876 |
+
}
|
877 |
+
|
878 |
+
//obtem os atributos do configuravel
|
879 |
+
$qtyStore = $this->getAllStores();
|
880 |
+
if (count($qtyStore) > 1) {
|
881 |
+
$storeIDAttrVar = $storeID;
|
882 |
+
} else {
|
883 |
+
$fArr = array_shift($qtyStore);
|
884 |
+
$storeIDAttrVar = $fArr['store_id'];
|
885 |
+
}
|
886 |
+
|
887 |
+
$ArrVariationValues = array();
|
888 |
+
foreach ($attributesConf as $attribute) {
|
889 |
+
$options = Mage::getResourceModel('eav/entity_attribute_option_collection');
|
890 |
+
$valuesAttr = $options->setAttributeFilter($attribute['attribute_id'])
|
891 |
+
->setStoreFilter($storeIDAttrVar)
|
892 |
+
->toOptionArray();
|
893 |
+
|
894 |
+
foreach ($valuesAttr as $value) {
|
895 |
+
$childValue = $child->getData($attribute['attribute_code']);
|
896 |
+
if ($value['value'] == $childValue) {
|
897 |
+
$ArrVariationValues[$attribute['store_label']] = $value['label'];
|
898 |
+
}
|
899 |
+
}
|
900 |
+
}
|
901 |
+
|
902 |
+
//obtem as imagens do produto (Obtem os simples e relaciona as variacoes)
|
903 |
+
$galleryDataSimp = $SimpleConfigProd->getMediaGalleryImages();
|
904 |
+
foreach ($galleryDataSimp as $g_imageSimp) {
|
905 |
+
$infoImg = getimagesize($g_imageSimp['url']);
|
906 |
+
$imgSize = filesize($g_imageSimp['path']);
|
907 |
+
|
908 |
+
if (($infoImg[0] != "") && ((float)$infoImg[0] < 350 || (float)$infoImg[1] < 350 || $imgSize > 4100000)) {
|
909 |
+
if ($exportImage == 0) {
|
910 |
+
array_push($arrProd, 'Image_b (' . $g_imageSimp['url'] . ' - Sku: ' . $SimpleConfigProd->getSku() . ' - Width: ' . $infoImg[0] . ' - Height: ' . $infoImg[1] . ' - Size: ' . $imgSize . ')');
|
911 |
+
} else {
|
912 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
913 |
+
$anymarketlog->setLogDesc('Error on export image - ' . $g_imageSimp['url']);
|
914 |
+
$anymarketlog->setLogId($SimpleConfigProd->getSku());
|
915 |
+
$anymarketlog->setStatus("1");
|
916 |
+
$anymarketlog->setStores(array($storeID));
|
917 |
+
$anymarketlog->save();
|
918 |
+
}
|
919 |
+
} else {
|
920 |
+
foreach ($ArrVariationValues as $value) {
|
921 |
+
$itemsIMG[] = array(
|
922 |
+
"main" => false,
|
923 |
+
"url" => $g_imageSimp['url'],
|
924 |
+
"variation" => $value,
|
925 |
+
);
|
926 |
+
}
|
927 |
+
}
|
928 |
+
}
|
929 |
+
|
930 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
931 |
+
|
932 |
+
if ($filter == 'final_price') {
|
933 |
+
$stkPrice = $SimpleConfigProd->getFinalPrice();
|
934 |
+
} else {
|
935 |
+
$stkPrice = $SimpleConfigProd->getData($filter);
|
936 |
+
}
|
937 |
+
|
938 |
+
$simpConfProdSku = $SimpleConfigProd->getSku();
|
939 |
+
// verificacao dos dados de price
|
940 |
+
if (($stkPrice == null) || ($stkPrice == '') || ((float)$stkPrice <= 0)) {
|
941 |
+
array_push($arrProd, 'Price (' . $simpConfProdSku . ')');
|
942 |
+
}
|
943 |
+
|
944 |
+
// verificacao dos dados de SKU
|
945 |
+
$cValid = array('.', '-', '_');
|
946 |
+
|
947 |
+
if (!ctype_alnum(str_replace($cValid, '', $simpConfProdSku))) {
|
948 |
+
array_push($arrProd, 'SKU (' . $simpConfProdSku . ')');
|
949 |
+
}
|
950 |
+
|
951 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($SimpleConfigProd);
|
952 |
+
if ($SimpleConfigProd->getData('integra_anymarket') == 1 && $SimpleConfigProd->getStatus() == 1){
|
953 |
+
$ArrSimpleConfigProd[] = array(
|
954 |
+
"variations" => $ArrVariationValues,
|
955 |
+
"price" => $stkPrice,
|
956 |
+
"amount" => $stock->getQty(),
|
957 |
+
"ean" => $SimpleConfigProd->getData($ean),
|
958 |
+
"partnerId" => $simpConfProdSku,
|
959 |
+
"title" => $SimpleConfigProd->getName(),
|
960 |
+
"idProduct" => $SimpleConfigProd->getData('id_anymarket'),
|
961 |
+
"internalIdProduct" => $SimpleConfigProd->getId(),
|
962 |
+
);
|
963 |
+
}
|
964 |
+
|
965 |
+
}
|
966 |
+
|
967 |
+
}
|
968 |
+
|
969 |
+
//ajusta o array de skus
|
970 |
+
if( count($ArrSimpleConfigProd) <= 0 ){
|
971 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
972 |
+
|
973 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
974 |
+
|
975 |
+
if($filter == 'final_price'){
|
976 |
+
$stkPrice = $product->getFinalPrice();
|
977 |
+
}else{
|
978 |
+
$stkPrice = $product->getData($filter);
|
979 |
+
}
|
980 |
+
|
981 |
+
$prodSkuJ = $product->getSku();
|
982 |
+
|
983 |
+
// verificacao dos dados de price
|
984 |
+
if(($stkPrice == null) || ($stkPrice == '') || ((float)$stkPrice <= 0)){
|
985 |
+
array_push($arrProd, 'Price ('.$prodSkuJ.')');
|
986 |
+
}
|
987 |
+
|
988 |
+
// verificacao dos dados de SKU
|
989 |
+
$cValid = array('.', '-', '_');
|
990 |
+
if(!ctype_alnum(str_replace($cValid, '', $prodSkuJ))) {
|
991 |
+
array_push($arrProd, 'SKU ('.$prodSkuJ.')');
|
992 |
+
}
|
993 |
+
|
994 |
+
if ($product->getData('integra_anymarket') == 1 && $product->getStatus() == 1) {
|
995 |
+
$ArrSimpleConfigProd[] = array(
|
996 |
+
"price" => $stkPrice,
|
997 |
+
"amount" => $stock->getQty(),
|
998 |
+
"ean" => $product->getData($ean),
|
999 |
+
"partnerId" => $prodSkuJ,
|
1000 |
+
"title" => $product->getName(),
|
1001 |
+
"idProduct" => $product->getData('id_anymarket'),
|
1002 |
+
"internalIdProduct" => $product->getId(),
|
1003 |
+
);
|
1004 |
+
}
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
|
1008 |
+
//cria os headers
|
1009 |
+
$headers = array(
|
1010 |
+
"Content-type: application/json",
|
1011 |
+
"Cache-Control: no-cache",
|
1012 |
+
"gumgaToken: ".$TOKEN
|
1013 |
+
);
|
1014 |
+
|
1015 |
+
$idProductAnyMarket = null;
|
1016 |
+
if($product->getData('id_anymarket') != ""){
|
1017 |
+
$idProductAnyMarket = $product->getData('id_anymarket');
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
|
1021 |
+
//cria os custom attributes
|
1022 |
+
$attributeSetModel = Mage::getModel("eav/entity_attribute_set");
|
1023 |
+
$attributeSetModel->load($product->getAttributeSetId());
|
1024 |
+
$attributeSetName = $attributeSetModel->getAttributeSetId();
|
1025 |
+
|
1026 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
1027 |
+
->setAttributeSetFilter($attributeSetName)
|
1028 |
+
->getItems();
|
1029 |
+
|
1030 |
+
$ArrAttributes = array();
|
1031 |
+
$contIndexAttr = 0;
|
1032 |
+
foreach ($attributes as $attribute){
|
1033 |
+
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($attribute->getAttributeId(), 'nma_id_attr');
|
1034 |
+
if($attrCheck->getData('nma_id_attr') != null){
|
1035 |
+
if($attrCheck->getData('status') == 1){
|
1036 |
+
if( $attribute->getAttributeCode() != $model ){
|
1037 |
+
if(!$this->checkArrayAttributes($ArrAttributes, "description", $attribute->getFrontendLabel())){
|
1038 |
+
if($confID == ""){
|
1039 |
+
$valAttr = $this->procAttrConfig($attribute->getAttributeCode(), $product->getData( $attribute->getAttributeCode() ), 1);
|
1040 |
+
if( $valAttr != null || $valAttr != '' ){
|
1041 |
+
$ArrAttributes[] = array("index" => $contIndexAttr, "name" => $attribute->getFrontendLabel(), "value" => $valAttr);
|
1042 |
+
$contIndexAttr = $contIndexAttr+1;
|
1043 |
+
}
|
1044 |
+
}else{
|
1045 |
+
foreach ($attributesConf as $attributeConf){
|
1046 |
+
if(!in_array($attribute->getAttributeCode(), $attributeConf)){
|
1047 |
+
if(!$this->checkArrayAttributes($ArrAttributes, "description", $attribute->getFrontendLabel())){
|
1048 |
+
$valAttr = $this->procAttrConfig($attribute->getAttributeCode(), $product->getData( $attribute->getAttributeCode() ), 1);
|
1049 |
+
if( $valAttr != null || $valAttr != '' ){
|
1050 |
+
$ArrAttributes[] = array("index" => $contIndexAttr, "name" => $attribute->getFrontendLabel(), "value" => $valAttr);
|
1051 |
+
$contIndexAttr = $contIndexAttr+1;
|
1052 |
+
}
|
1053 |
+
}
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
}
|
1057 |
+
}
|
1058 |
+
}
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
//trata as dimensoes
|
1064 |
+
$vHeight = $this->procAttrConfig($volume_altura, $product->getData( $volume_altura ), 1);
|
1065 |
+
$vWidth = $this->procAttrConfig($volume_largura, $product->getData( $volume_largura ), 1);
|
1066 |
+
$vLength = $this->procAttrConfig($volume_comprimento, $product->getData( $volume_comprimento ), 1);
|
1067 |
+
|
1068 |
+
//Cria os params
|
1069 |
+
$param = array(
|
1070 |
+
"id" => $idProductAnyMarket,
|
1071 |
+
"title" => $product->getName(),
|
1072 |
+
"description" => $this->getFullDescription($storeID, $product),
|
1073 |
+
"nbm" => array(
|
1074 |
+
"id" => $this->procAttrConfig($nbm, $product->getData( $nbm ), 1)
|
1075 |
+
),
|
1076 |
+
"brand" => array(
|
1077 |
+
"id" => $this->getBrandForProduct($storeID, $this->procAttrConfig($brand, $product->getData( $brand ), 1)),
|
1078 |
+
"name" => $this->procAttrConfig($brand, $product->getData( $brand ), 1)
|
1079 |
+
),
|
1080 |
+
"origin" => array(
|
1081 |
+
"id" => $this->procAttrConfig($nbm_origin, $product->getData( $nbm_origin ), 1)
|
1082 |
+
),
|
1083 |
+
"category" => array(
|
1084 |
+
"id" => $product->getData('categoria_anymarket')
|
1085 |
+
),
|
1086 |
+
"model" => $this->procAttrConfig($model, $product->getData( $model ), 1),
|
1087 |
+
"warrantyText" => $this->procAttrConfig($warranty_text, $product->getData( $warranty_text ), 1),
|
1088 |
+
"warrantyTime" => $this->procAttrConfig($warranty_time, $product->getData( $warranty_time ), 1),
|
1089 |
+
"weight" => $MassUnit == 0 ? $Weight/1 : $Weight/1000,
|
1090 |
+
"height" => $this->convertUnitMeasurement($UnitMeasurement, $vHeight, 1),
|
1091 |
+
"width" => $this->convertUnitMeasurement($UnitMeasurement, $vWidth, 1),
|
1092 |
+
"length" => $this->convertUnitMeasurement($UnitMeasurement, $vLength, 1),
|
1093 |
+
"images" => $itemsIMG,
|
1094 |
+
"priceFactor" => $varPriceFactor,
|
1095 |
+
"calculatedPrice" => $product->getData( $calculated_price ) == 0 ? false : true,
|
1096 |
+
// OBTER ATRIBUTOS CUSTOM
|
1097 |
+
"characteristics" => $ArrAttributes,
|
1098 |
+
"skus" => $ArrSimpleConfigProd,
|
1099 |
+
);
|
1100 |
+
|
1101 |
+
$varVideoURL = $this->procAttrConfig($video_url, $product->getData( $video_url ), 1);
|
1102 |
+
if($varVideoURL && $varVideoURL != ""){
|
1103 |
+
$param["videoUrl"] = $varVideoURL;
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
if( !empty($arrProd) ){
|
1107 |
+
$returnProd['error'] = '1';
|
1108 |
+
$returnProd['json'] = '';
|
1109 |
+
|
1110 |
+
$emptyFields = ' ';
|
1111 |
+
foreach ($arrProd as $field) {
|
1112 |
+
$emptyFields .= $field.', ';
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Product with inconsistency:').' '.$emptyFields;
|
1116 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
1117 |
+
|
1118 |
+
return false;
|
1119 |
+
}else{
|
1120 |
+
if( ($product->getData('id_anymarket') == '') || ($product->getData('id_anymarket') == '0') ){
|
1121 |
+
$returnProd = $this->CallAPICurl("POST", $HOST."/v2/products/", $headers, $param);
|
1122 |
+
|
1123 |
+
$IDinAnymarket = '0';
|
1124 |
+
if($returnProd['error'] != '1'){
|
1125 |
+
$SaveLog = $returnProd['return'];
|
1126 |
+
$IDinAnymarket = json_encode($SaveLog->id);
|
1127 |
+
|
1128 |
+
if($IDinAnymarket != '0'){
|
1129 |
+
$productForSave = Mage::getModel('catalog/product')->setStoreId($storeID)->load($product->getId());
|
1130 |
+
$productForSave->setIdAnymarket($IDinAnymarket);
|
1131 |
+
$productForSave->save();
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
if($product->getTypeID() == "configurable"){
|
1135 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
1136 |
+
|
1137 |
+
if(is_array($childProducts)) {
|
1138 |
+
foreach ($childProducts as $child) {
|
1139 |
+
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
|
1140 |
+
$productC = Mage::getModel('catalog/product')->setStoreId($storeID)->load($child->getId());
|
1141 |
+
|
1142 |
+
if ($productC->getIntegraAnymarket() != '1') {
|
1143 |
+
$productC->setIntegraAnymarket('1');
|
1144 |
+
}
|
1145 |
+
if ($IDinAnymarket != '0') {
|
1146 |
+
$productC->setIdAnymarket($IDinAnymarket);
|
1147 |
+
}
|
1148 |
+
$productC->save();
|
1149 |
+
Mage::app()->setCurrentStore( $this->getCurrentStoreView() );
|
1150 |
+
}
|
1151 |
+
}
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
if($IDinAnymarket != '0'){
|
1155 |
+
$returnProd['error'] = '0';
|
1156 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Successfully synchronized product.');
|
1157 |
+
$this->saveLogsProds($storeID, "1", $returnProd, $product);
|
1158 |
+
}else{
|
1159 |
+
$returnProd['error'] = '1';
|
1160 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Error synchronizing, code anymarket invalid.');
|
1161 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
}else{
|
1165 |
+
$this->saveLogsProds($storeID, "1", $returnProd, $product);
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
}else{
|
1169 |
+
$returnProd = $this->CallAPICurl("PUT", $HOST."/v2/products/".$product->getData('id_anymarket'), $headers, $param);
|
1170 |
+
if($returnProd['error'] == '0'){
|
1171 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Product Updated');
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
//ADICIONA UM NOVO SKU
|
1175 |
+
foreach ($ArrSimpleConfigProd as $skuPut) {
|
1176 |
+
$skuProdReturn = $this->CallAPICurl("POST", $HOST."/v2/products/".$product->getData('id_anymarket')."/skus", $headers, $skuPut);
|
1177 |
+
if($skuProdReturn['error'] == '0'){
|
1178 |
+
$skuProdReturn['return'] = Mage::helper('db1_anymarket')->__('SKU Created').' ('.$skuPut['partnerId'].')';
|
1179 |
+
$this->saveLogsProds($storeID, "1", $skuProdReturn, $product);
|
1180 |
+
}else{
|
1181 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
1182 |
+
$productSku = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $skuPut['partnerId'] );
|
1183 |
+
if( $productSku != null ) {
|
1184 |
+
if ($productSku->getData() != null) {
|
1185 |
+
if ($productSku->getId() != null) {
|
1186 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productSku);
|
1187 |
+
$this->updatePriceStockAnyMarket($storeID, $productSku->getId(), $stock->getQty(), $productSku->getData($filter));
|
1188 |
+
}
|
1189 |
+
}
|
1190 |
+
}
|
1191 |
+
}
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
$this->sendImageSkuToAnyMarket($storeID, $product, $param['skus']);
|
1195 |
+
|
1196 |
+
$this->saveLogsProds($storeID, "1", $returnProd, $product);
|
1197 |
+
}
|
1198 |
+
return true;
|
1199 |
+
}
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
/**
|
1205 |
+
* @param $HOST
|
1206 |
+
* @param $headers
|
1207 |
+
* @param $IDTransmission
|
1208 |
+
* @param $statusTransmission
|
1209 |
+
* @param $tokenTransmissions
|
1210 |
+
*/
|
1211 |
+
private function changeStatusTransmission($HOST, $headers, $IDTransmission, $statusTransmission, $tokenTransmissions){
|
1212 |
+
$params = array(
|
1213 |
+
"marketPlaceStatus" => $statusTransmission." Sincronizado"
|
1214 |
+
);
|
1215 |
+
|
1216 |
+
$returnChangeTrans = $this->CallAPICurl("PUT", $HOST."/v2/transmissions/".$IDTransmission, $headers, $params);
|
1217 |
+
if($returnChangeTrans['error'] == '1'){
|
1218 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1219 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('Error on change transmissions status: '). $returnChangeTrans['return'] );
|
1220 |
+
$anymarketlog->setStatus("0");
|
1221 |
+
$anymarketlog->save();
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
if($tokenTransmissions != 'notoken'){
|
1225 |
+
$paramsFeeds = array(
|
1226 |
+
"token" => $tokenTransmissions
|
1227 |
+
);
|
1228 |
+
|
1229 |
+
$returnChangeTrans = $this->CallAPICurl("PUT", $HOST."/v2/transmissions/feeds/".$IDTransmission, $headers, $paramsFeeds);
|
1230 |
+
if($returnChangeTrans['error'] == '1'){
|
1231 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1232 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('Error update feeds transmissions'));
|
1233 |
+
$anymarketlog->setStatus("1");
|
1234 |
+
$anymarketlog->save();
|
1235 |
+
}
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
/**
|
1241 |
+
* get only product in feed of AnyMarket
|
1242 |
+
*/
|
1243 |
+
public function getFeedProdsFromAnyMarket($storeID){
|
1244 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
1245 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
1246 |
+
|
1247 |
+
$headers = array(
|
1248 |
+
"Content-type: application/json",
|
1249 |
+
"Accept: */*",
|
1250 |
+
"gumgaToken: ".$TOKEN
|
1251 |
+
);
|
1252 |
+
|
1253 |
+
$returnFeedTrans = $this->CallAPICurl("GET", $HOST."/v2/transmissions/feeds?limit=100", $headers, null);
|
1254 |
+
|
1255 |
+
if($returnFeedTrans['error'] == '1'){
|
1256 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1257 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('Error on get transmissions feed '). $returnFeedTrans['return'] );
|
1258 |
+
$anymarketlog->setStatus("0");
|
1259 |
+
$anymarketlog->save();
|
1260 |
+
}else{
|
1261 |
+
$prodCreated = $this->getSpecificFeedProduct($storeID, $returnFeedTrans['return'], $headers, $HOST);
|
1262 |
+
|
1263 |
+
// TRATA STOCK
|
1264 |
+
if ( $prodCreated ) {
|
1265 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
1266 |
+
if ($typeSincOrder == 1) {
|
1267 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
1268 |
+
$ProdStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($prodCreated);
|
1269 |
+
$this->updatePriceStockAnyMarket($storeID, $prodCreated->getId(), $ProdStock->getQty(), $prodCreated->getData($filter));
|
1270 |
+
}
|
1271 |
+
}
|
1272 |
+
}
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
/**
|
1276 |
+
* @param $IDProd
|
1277 |
+
* @param $storeID
|
1278 |
+
*/
|
1279 |
+
public function getStockProductAnyMarket($storeID, $IDProd){
|
1280 |
+
$product = Mage::getModel('catalog/product')->load( $IDProd );
|
1281 |
+
if($product->getIdAnymarket() != ''){
|
1282 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
1283 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
1284 |
+
|
1285 |
+
$headers = array(
|
1286 |
+
"Content-type: application/json",
|
1287 |
+
"Accept: */*",
|
1288 |
+
"gumgaToken: " . $TOKEN
|
1289 |
+
);
|
1290 |
+
|
1291 |
+
$returnProdSpecific = $this->CallAPICurl("GET", $HOST . "/v2/products/" . $product->getIdAnymarket(), $headers, null);
|
1292 |
+
if ($returnProdSpecific['error'] == '0') {
|
1293 |
+
$ProdsJSON = $returnProdSpecific['return'];
|
1294 |
+
|
1295 |
+
foreach ($ProdsJSON->skus as $sku) {
|
1296 |
+
$IDSKUProd = $sku->partnerId != null ? $sku->partnerId : $ProdsJSON->idProduct;
|
1297 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $IDSKUProd);
|
1298 |
+
|
1299 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1300 |
+
$stockItem->setData('is_in_stock', $sku->amount > 0 ? '1' : '0');
|
1301 |
+
$stockItem->setData('qty', $sku->amount);
|
1302 |
+
$stockItem->save();
|
1303 |
+
|
1304 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1305 |
+
$anymarketlog->setLogDesc(Mage::helper('db1_anymarket')->__('Imported stock SKU: ') . $product->getData('sku'));
|
1306 |
+
$anymarketlog->setLogId($product->getId());
|
1307 |
+
$anymarketlog->setStatus("0");
|
1308 |
+
$anymarketlog->setStores(array($storeID));
|
1309 |
+
$anymarketlog->save();
|
1310 |
+
|
1311 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->load($product->getIdAnymarket(), 'nmp_id');
|
1312 |
+
if ($anymarketproducts->getNmpId() == null) {
|
1313 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->load($product->getId(), 'nmp_id');
|
1314 |
+
}
|
1315 |
+
|
1316 |
+
$anymarketproducts->setNmpId($product->getId());
|
1317 |
+
$anymarketproducts->setNmpSku($product->getData('sku'));
|
1318 |
+
$anymarketproducts->setNmpName($product->getData('name'));
|
1319 |
+
$anymarketproducts->setNmpDescError("");
|
1320 |
+
$anymarketproducts->setNmpStatusInt("Integrado");
|
1321 |
+
$anymarketproducts->setStatus("1");
|
1322 |
+
$anymarketproducts->setStores(array($storeID));
|
1323 |
+
$anymarketproducts->save();
|
1324 |
+
}
|
1325 |
+
} else {
|
1326 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1327 |
+
$anymarketlog->setLogDesc("Erro on get stock " . $returnProdSpecific['return']);
|
1328 |
+
$anymarketlog->setLogId($IDProd);
|
1329 |
+
$anymarketlog->setStatus("0");
|
1330 |
+
$anymarketlog->setStores(array($storeID));
|
1331 |
+
$anymarketlog->save();
|
1332 |
+
}
|
1333 |
+
}
|
1334 |
+
}
|
1335 |
+
|
1336 |
+
|
1337 |
+
/**
|
1338 |
+
* @param $listTransmissions
|
1339 |
+
* @param $headers
|
1340 |
+
* @param $HOST
|
1341 |
+
* @param $storeID
|
1342 |
+
*
|
1343 |
+
* @return string
|
1344 |
+
*/
|
1345 |
+
public function getSpecificFeedProduct($storeID, $listTransmissions, $headers, $HOST){
|
1346 |
+
$arrJSONProds = array();
|
1347 |
+
$arrControlProds = array();
|
1348 |
+
|
1349 |
+
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
|
1350 |
+
foreach ($listTransmissions as $transmissionIDs) {
|
1351 |
+
$transmissionID = $transmissionIDs->id;
|
1352 |
+
$transmissionToken = $transmissionIDs->token;
|
1353 |
+
|
1354 |
+
$transmissionReturn = $this->CallAPICurl("GET", $HOST."/v2/transmissions/".$transmissionID, $headers, null);
|
1355 |
+
|
1356 |
+
$prodRet = "";
|
1357 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
1358 |
+
if($typeSincProd == 1) {
|
1359 |
+
if ($transmissionReturn['error'] == '1') {
|
1360 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1361 |
+
$anymarketlog->setLogDesc(Mage::helper('db1_anymarket')->__('Error on get transmissions ') . $transmissionReturn['return']);
|
1362 |
+
$anymarketlog->setStatus("0");
|
1363 |
+
$anymarketlog->save();
|
1364 |
+
} else {
|
1365 |
+
$transmission = $transmissionReturn['return'];
|
1366 |
+
$statusTransmission = $transmission->publicationStatus;
|
1367 |
+
$IDProdTrans = $transmission->product->id;
|
1368 |
+
$NameProdTrans = $transmission->product->title;
|
1369 |
+
if ($statusTransmission == 'ACTIVE') {
|
1370 |
+
$arrVarSku = array();
|
1371 |
+
if (isset($transmission->sku->variations)) {
|
1372 |
+
foreach ($transmission->sku->variations as $variation) {
|
1373 |
+
array_push($arrVarSku, array(
|
1374 |
+
"id" => $variation->id,
|
1375 |
+
"description" => $variation->description,
|
1376 |
+
"variationTypeId" => $variation->type->id,
|
1377 |
+
"variationTypeName" => $variation->type->name
|
1378 |
+
));
|
1379 |
+
|
1380 |
+
}
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
$imagesGallery = array();
|
1384 |
+
foreach ($transmission->images as $image) {
|
1385 |
+
$imagesGallery[] = array(
|
1386 |
+
"standard_resolution" => $image->standardUrl,
|
1387 |
+
"original" => $image->standardUrl,
|
1388 |
+
"main" => $image->main,
|
1389 |
+
"variationValue" => isset($image->variation) ? $image->variation : null
|
1390 |
+
);
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
$arrVarGeral = array();
|
1394 |
+
if (isset($transmission->sku->variations)) {
|
1395 |
+
foreach ($transmission->sku->variations as $varSKU) {
|
1396 |
+
array_push($arrVarGeral, array(
|
1397 |
+
"name" => $varSKU->type->name,
|
1398 |
+
"id" => $varSKU->type->id
|
1399 |
+
));
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
if (!in_array($IDProdTrans, $arrControlProds)) {
|
1404 |
+
array_push($arrControlProds, $IDProdTrans);
|
1405 |
+
|
1406 |
+
$arrAttr = array();
|
1407 |
+
if (isset($transmission->characteristics)) {
|
1408 |
+
foreach ($transmission->characteristics as $carac) {
|
1409 |
+
array_push($arrAttr, array(
|
1410 |
+
"name" => $carac->name,
|
1411 |
+
"value" => $carac->value
|
1412 |
+
));
|
1413 |
+
}
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
$arrJSONProds[$IDProdTrans] = array(
|
1417 |
+
"id" => $IDProdTrans,
|
1418 |
+
"title" => $transmission->product->title,
|
1419 |
+
"idTransmission" => $transmissionIDs->id,
|
1420 |
+
"description" => isset($transmission->description) ? $transmission->description : null,
|
1421 |
+
"brand" => isset($transmission->brand->id) ? $transmission->brand->id : null,
|
1422 |
+
"model" => isset($transmission->model) ? $transmission->model : null,
|
1423 |
+
"videoURL" => isset($transmission->videoUrl) ? $transmission->videoUrl : null,
|
1424 |
+
"warrantyTime" => isset($transmission->warrantyTime) ? $transmission->warrantyTime : null,
|
1425 |
+
"warranty" => isset($transmission->warrantyText) ? $transmission->warrantyText : null,
|
1426 |
+
"height" => isset($transmission->height) ? $transmission->height : null,
|
1427 |
+
"width" => isset($transmission->width) ? $transmission->width : null,
|
1428 |
+
"weight" => isset($transmission->weight) ? $transmission->weight : null,
|
1429 |
+
"length" => isset($transmission->length) ? $transmission->length : null,
|
1430 |
+
"originCode" => isset($transmission->origin->id) ? $transmission->origin->id : null,
|
1431 |
+
"nbm" => isset($transmission->nbm) ? $transmission->nbm->id : null,
|
1432 |
+
"category" => isset($transmission->category->id) ? $transmission->category->id : null,
|
1433 |
+
"photos" => $imagesGallery,
|
1434 |
+
"variations" => $arrVarGeral,
|
1435 |
+
"attributes" => $arrAttr,
|
1436 |
+
"skus" => array(
|
1437 |
+
array(
|
1438 |
+
"id" => $transmission->sku->id,
|
1439 |
+
"title" => empty($arrVarGeral) ? $transmission->product->title : $transmission->sku->title,
|
1440 |
+
"idProduct" => $IDProdTrans,
|
1441 |
+
"idInClient" => isset($transmission->sku->idInClient) ? $transmission->sku->idInClient : $transmission->sku->partnerId,
|
1442 |
+
"price" => $transmission->sku->price,
|
1443 |
+
"stockAmount" => $transmission->sku->amount,
|
1444 |
+
"ean" => isset($transmission->sku->ean) ? $transmission->sku->ean : null,
|
1445 |
+
"variations" => $arrVarSku
|
1446 |
+
)
|
1447 |
+
),
|
1448 |
+
);
|
1449 |
+
} else {
|
1450 |
+
foreach ($arrVarGeral as $variationGeral) {
|
1451 |
+
if (!in_array($variationGeral, $arrJSONProds[$IDProdTrans]['variations'])) {
|
1452 |
+
array_push($arrJSONProds[$IDProdTrans]['variations'], $variationGeral);
|
1453 |
+
}
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
foreach ($imagesGallery as $imageG) {
|
1457 |
+
if (!in_array($imageG, $arrJSONProds[$IDProdTrans]['photos'])) {
|
1458 |
+
array_push($arrJSONProds[$IDProdTrans]['photos'], $imageG);
|
1459 |
+
}
|
1460 |
+
}
|
1461 |
+
array_push($arrJSONProds[$IDProdTrans]['skus'], array(
|
1462 |
+
"id" => $transmission->sku->id,
|
1463 |
+
"title" => $transmission->sku->title,
|
1464 |
+
"idProduct" => $IDProdTrans,
|
1465 |
+
"idInClient" => isset($transmission->sku->idInClient) ? $transmission->sku->idInClient : $transmission->sku->partnerId,
|
1466 |
+
"price" => $transmission->sku->price,
|
1467 |
+
"stockAmount" => $transmission->sku->amount,
|
1468 |
+
"ean" => isset($transmission->sku->ean) ? $transmission->sku->ean : null,
|
1469 |
+
"variations" => $arrVarSku
|
1470 |
+
));
|
1471 |
+
}
|
1472 |
+
} else if ($statusTransmission == 'PAUSED') {
|
1473 |
+
$prodLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', isset($transmission->sku->partnerId) ? $transmission->sku->partnerId : $IDProdTrans);
|
1474 |
+
if ($prodLoaded != null) {
|
1475 |
+
if ($prodLoaded->getData('integra_anymarket') == 1) {
|
1476 |
+
$prodLoaded->setStatus(2);
|
1477 |
+
$prodLoaded->save();
|
1478 |
+
|
1479 |
+
$this->changeStatusTransmission($HOST, $headers, $transmissionID, 'Pausado', $transmissionToken);
|
1480 |
+
$prodRet = 'Transmission Paused - '.$prodLoaded->getSku();
|
1481 |
+
}
|
1482 |
+
}
|
1483 |
+
} else if ($statusTransmission == 'CLOSED') {
|
1484 |
+
$prodLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', isset($transmission->sku->partnerId) ? $transmission->sku->partnerId : $IDProdTrans);
|
1485 |
+
if ($prodLoaded != null) {
|
1486 |
+
if ($prodLoaded->getData('integra_anymarket') == 1) {
|
1487 |
+
$prodLoaded->setStatus(2);
|
1488 |
+
$prodLoaded->save();
|
1489 |
+
|
1490 |
+
$this->changeStatusTransmission($HOST, $headers, $transmissionID, 'Finalizado', $transmissionToken);
|
1491 |
+
$prodRet = 'Transmission Closed - '.$prodLoaded->getSku();
|
1492 |
+
}
|
1493 |
+
}
|
1494 |
+
} elseif ($statusTransmission == 'WITHOUT_STOCK') {
|
1495 |
+
$prodLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', isset($transmission->sku->partnerId) ? $transmission->sku->partnerId : $IDProdTrans);
|
1496 |
+
if ($prodLoaded != null) {
|
1497 |
+
if ($prodLoaded->getData('integra_anymarket') == 1) {
|
1498 |
+
|
1499 |
+
// DECREMENTE O STOCK
|
1500 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($prodLoaded->getId());
|
1501 |
+
if ($stockItem->getManageStock()) {
|
1502 |
+
//$prodLoaded->setStatus(2);
|
1503 |
+
$stockItem->setData('qty', 0);
|
1504 |
+
$stockItem->setData('is_in_stock', 0);
|
1505 |
+
$stockItem->save();
|
1506 |
+
}
|
1507 |
+
$prodLoaded->save();
|
1508 |
+
|
1509 |
+
$prodRet = 'Product Without Stock - '.$prodLoaded->getSku();
|
1510 |
+
$this->changeStatusTransmission($HOST, $headers, $transmissionID, 'Sem Estoque', $transmissionToken);
|
1511 |
+
}
|
1512 |
+
}
|
1513 |
+
}
|
1514 |
+
}
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
1518 |
+
if( $typeSincOrder == 0 ){
|
1519 |
+
if( $transmissionReturn['error'] == '0' ) {
|
1520 |
+
$transmissionStock = $transmissionReturn['return'];
|
1521 |
+
|
1522 |
+
$skuToLoad = isset($transmissionStock->sku->partnerId) ? $transmissionStock->sku->partnerId : $transmissionStock->product->id;
|
1523 |
+
$prodLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $skuToLoad);
|
1524 |
+
if ($prodLoaded != null) {
|
1525 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($prodLoaded->getId());
|
1526 |
+
if ($stockItem->getManageStock()) {
|
1527 |
+
$stockItem->setData('qty', $transmissionStock->sku->amount);
|
1528 |
+
if ($transmissionStock->sku->amount > 0) {
|
1529 |
+
$stockItem->setData('is_in_stock', 1);
|
1530 |
+
} else {
|
1531 |
+
$stockItem->setData('is_in_stock', 0);
|
1532 |
+
}
|
1533 |
+
$stockItem->save();
|
1534 |
+
}
|
1535 |
+
$prodLoaded->save();
|
1536 |
+
|
1537 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1538 |
+
$anymarketlog->setLogDesc( "Stock Updated" );
|
1539 |
+
$anymarketlog->setLogId( $prodLoaded->getSku() );
|
1540 |
+
$anymarketlog->setStatus("0");
|
1541 |
+
$anymarketlog->setStores(array($storeID));
|
1542 |
+
$anymarketlog->save();
|
1543 |
+
|
1544 |
+
$prodRet = $prodLoaded->getSku()." - Stock Updated";
|
1545 |
+
}else{
|
1546 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1547 |
+
$anymarketlog->setLogDesc( "Product not found (".$skuToLoad.") - Stock Updated" );
|
1548 |
+
$anymarketlog->setStatus("0");
|
1549 |
+
$anymarketlog->setStores(array($storeID));
|
1550 |
+
$anymarketlog->save();
|
1551 |
+
|
1552 |
+
$prodRet = "Product not found (".$skuToLoad.") - Stock Updated";
|
1553 |
+
}
|
1554 |
+
}else{
|
1555 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1556 |
+
$anymarketlog->setLogDesc( $transmissionReturn['return'] . " - Update Stock" );
|
1557 |
+
$anymarketlog->setStatus("0");
|
1558 |
+
$anymarketlog->setStores(array($storeID));
|
1559 |
+
$anymarketlog->save();
|
1560 |
+
|
1561 |
+
$prodRet = $transmissionReturn['return'] . " - Update Stock";
|
1562 |
+
}
|
1563 |
+
}
|
1564 |
+
}
|
1565 |
+
|
1566 |
+
//CRIA OS PRODUTOS CASO ELES NAO EXISTAM
|
1567 |
+
foreach ($arrJSONProds as $ProdsJSON) {
|
1568 |
+
$feedReturn = $this->createProducts($storeID, json_encode($ProdsJSON));
|
1569 |
+
if($feedReturn){
|
1570 |
+
$this->changeStatusTransmission($HOST, $headers, $ProdsJSON["idTransmission"], 'Ativo', $transmissionToken);
|
1571 |
+
|
1572 |
+
$returnProd = array();
|
1573 |
+
$returnProd['return'] = 'Product Created or updated.';
|
1574 |
+
$returnProd['json'] = '';
|
1575 |
+
$returnProd['error'] = '0';
|
1576 |
+
$this->saveLogsProds($storeID, "1", $returnProd, $feedReturn);
|
1577 |
+
|
1578 |
+
$prodRet = 'Product Created or updated.';
|
1579 |
+
}
|
1580 |
+
}
|
1581 |
+
|
1582 |
+
return $prodRet;
|
1583 |
+
}
|
1584 |
+
|
1585 |
+
|
1586 |
+
/**
|
1587 |
+
* @param $ProdsJSON
|
1588 |
+
* @param $storeID
|
1589 |
+
* @return Mage_Catalog_Model_Product
|
1590 |
+
*/
|
1591 |
+
public function createProducts($storeID, $ProdsJSON){
|
1592 |
+
Mage::getSingleton('core/session')->setImportProdsVariable('false');
|
1593 |
+
$ProdsJSON = json_decode($ProdsJSON);
|
1594 |
+
|
1595 |
+
$ProdCrt = null;
|
1596 |
+
$websiteID = Mage::getModel('core/store')->load($storeID)->getWebsiteId();
|
1597 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1598 |
+
|
1599 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
1600 |
+
|
1601 |
+
$priceField = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
1602 |
+
if($priceField == 'final_price'){
|
1603 |
+
$priceField = 'price';
|
1604 |
+
|
1605 |
+
$config = new Mage_Core_Model_Config();
|
1606 |
+
$config->saveConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', 'price', 'default', $storeID);
|
1607 |
+
|
1608 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
$brand = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_brand_field', $storeID);
|
1612 |
+
$nbm = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_nbm_field', $storeID);
|
1613 |
+
$model = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_model_field', $storeID);
|
1614 |
+
$MassUnit = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_weight_field', $storeID);
|
1615 |
+
$UnitMeasurement = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_size_field', $storeID);
|
1616 |
+
$AttrSet = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_atribute_set_field', $storeID);
|
1617 |
+
|
1618 |
+
$volume_comprimento = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_vol_comp_field', $storeID);
|
1619 |
+
$volume_altura = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_vol_alt_field', $storeID);
|
1620 |
+
$volume_largura = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_vol_larg_field', $storeID);
|
1621 |
+
$video_url = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_video_url_field', $storeID);
|
1622 |
+
$nbm_origin = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_nbm_origin_field', $storeID);
|
1623 |
+
$ean = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_ean_field', $storeID);
|
1624 |
+
$warranty_text = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_warranty_text_field', $storeID);
|
1625 |
+
$warranty_time = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_warranty_time_field', $storeID);
|
1626 |
+
|
1627 |
+
$configureFieldsConfig = $this->getFieldsDescriptionConfig($storeID);
|
1628 |
+
|
1629 |
+
//PROD CONFIGURABLE
|
1630 |
+
if ( !empty( $ProdsJSON->variations ) ) {
|
1631 |
+
$prodSimpleFromConfig = array();
|
1632 |
+
$AttributeIds = array();
|
1633 |
+
$AttributeOptions = array();
|
1634 |
+
|
1635 |
+
$variationArray = array();
|
1636 |
+
$sinc = '';
|
1637 |
+
foreach ($ProdsJSON->variations as $variation) {
|
1638 |
+
$variationArray[$variation->id] = $variation->name;
|
1639 |
+
$AttrCtlr = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', $variation->name);
|
1640 |
+
if(!$AttrCtlr->getData()){
|
1641 |
+
$sinc = $variation->name;
|
1642 |
+
break;
|
1643 |
+
}
|
1644 |
+
}
|
1645 |
+
|
1646 |
+
if($sinc == ''){
|
1647 |
+
foreach ($ProdsJSON->skus as $sku) {
|
1648 |
+
$IDSKUProd = $sku->idInClient != null ? $sku->idInClient : $sku->id;
|
1649 |
+
$ProdCrt = '';
|
1650 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $IDSKUProd);
|
1651 |
+
|
1652 |
+
foreach ($sku->variations as $varValues) {
|
1653 |
+
$descVar = $varValues->description;
|
1654 |
+
$idVar = $varValues->variationTypeId;
|
1655 |
+
}
|
1656 |
+
|
1657 |
+
//trata as dimensoes
|
1658 |
+
$vHeight = $this->procAttrConfig($volume_altura, $ProdsJSON->height, 0);
|
1659 |
+
$vWidth = $this->procAttrConfig($volume_largura, $ProdsJSON->width, 0);
|
1660 |
+
$vLength = $this->procAttrConfig($volume_comprimento, $ProdsJSON->length, 0);
|
1661 |
+
|
1662 |
+
if(!$product){
|
1663 |
+
$AttributeId = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', $variationArray[ $idVar ]);
|
1664 |
+
if (!in_array($AttributeId, $AttributeIds)) {
|
1665 |
+
$AttributeIds[] = $AttributeId;
|
1666 |
+
$collectionAttr = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
1667 |
+
->setPositionOrder('asc')
|
1668 |
+
->setAttributeFilter($AttributeId)
|
1669 |
+
->setStoreFilter(0)
|
1670 |
+
->load();
|
1671 |
+
|
1672 |
+
$AttributeOptions[$idVar] = $collectionAttr->toOptionArray();
|
1673 |
+
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
$varAttr = '';
|
1677 |
+
$descVarAttr = '';
|
1678 |
+
foreach ( $AttributeOptions[$idVar] as $attrOpt) {
|
1679 |
+
if($attrOpt['label'] == $descVar ){
|
1680 |
+
$varAttr = $attrOpt['value'];
|
1681 |
+
$descVarAttr = $attrOpt['label'];
|
1682 |
+
break;
|
1683 |
+
}
|
1684 |
+
}
|
1685 |
+
|
1686 |
+
$imagesGallery = array();
|
1687 |
+
foreach ($ProdsJSON->photos as $image) {
|
1688 |
+
if( $image->variationValue != null ){
|
1689 |
+
if( $image->variationValue == $descVarAttr ){
|
1690 |
+
$imagesGallery[] = array('img' => $image->standard_resolution, 'main' => $image->main);
|
1691 |
+
}
|
1692 |
+
}
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
if($varAttr != ''){
|
1696 |
+
$dataPrd = array(
|
1697 |
+
'attribute_set_id' => $AttrSet == null ? Mage::getModel('catalog/product')->getDefaultAttributeSetId() : $AttrSet,
|
1698 |
+
'type_id' => 'simple',
|
1699 |
+
'sku' => $IDSKUProd,
|
1700 |
+
'name' => $sku->title,
|
1701 |
+
'description' => $sku->title,
|
1702 |
+
'short_description' => $sku->title,
|
1703 |
+
$priceField => $sku->price,
|
1704 |
+
'created_at' => strtotime('now'),
|
1705 |
+
'updated_at' => strtotime('now'),
|
1706 |
+
'id_anymarket' => $sku->idProduct,
|
1707 |
+
'weight' => $MassUnit == 1 ? $ProdsJSON->weight*1000 : $ProdsJSON->weight,
|
1708 |
+
'store_id' => $storeID,
|
1709 |
+
'website_ids' => array($websiteID),
|
1710 |
+
$brand => $this->procAttrConfig($brand, $ProdsJSON->brand, 0),
|
1711 |
+
$model => $this->procAttrConfig($model, $ProdsJSON->model, 0),
|
1712 |
+
$video_url => $this->procAttrConfig($video_url, $ProdsJSON->videoURL, 0),
|
1713 |
+
|
1714 |
+
$volume_comprimento => $this->convertUnitMeasurement($UnitMeasurement, $vLength, 0),
|
1715 |
+
$volume_altura => $this->convertUnitMeasurement($UnitMeasurement, $vHeight, 0),
|
1716 |
+
$volume_largura => $this->convertUnitMeasurement($UnitMeasurement, $vWidth, 0),
|
1717 |
+
|
1718 |
+
$warranty_time => $this->procAttrConfig($warranty_time, $ProdsJSON->warrantyTime, 0),
|
1719 |
+
$nbm => $this->procAttrConfig($nbm, $ProdsJSON->nbm, 0),
|
1720 |
+
$nbm_origin => $this->procAttrConfig($nbm_origin, $ProdsJSON->originCode, 0),
|
1721 |
+
$ean => $this->procAttrConfig($ean, $sku->ean, 0),
|
1722 |
+
$warranty_text => $this->procAttrConfig($warranty_text, $ProdsJSON->warranty, 0),
|
1723 |
+
'msrp_enabled' => '2',
|
1724 |
+
'categoria_anymarket' => $ProdsJSON->category,
|
1725 |
+
$variationArray[ $idVar ] => $varAttr,
|
1726 |
+
);
|
1727 |
+
|
1728 |
+
foreach ($ProdsJSON->attributes as $attrProd) {
|
1729 |
+
$dataPrd[ strtolower($attrProd->name) ] = $this->procAttrConfig(strtolower($attrProd->name), $attrProd->value, 0);
|
1730 |
+
}
|
1731 |
+
|
1732 |
+
$dataPrdSimple = array(
|
1733 |
+
'product' => $dataPrd,
|
1734 |
+
'stock_item' => array(
|
1735 |
+
'is_in_stock' => $sku->stockAmount > 0 ? '1' : '0',
|
1736 |
+
'qty' => $sku->stockAmount,
|
1737 |
+
),
|
1738 |
+
'images' => $imagesGallery,
|
1739 |
+
);
|
1740 |
+
|
1741 |
+
$ProdReturn = $this->create_simple_product($storeID, $dataPrdSimple);
|
1742 |
+
$ProdCrt = $ProdReturn->getEntityId();
|
1743 |
+
|
1744 |
+
$product = Mage::getModel('catalog/product')->load($ProdCrt);
|
1745 |
+
}else{
|
1746 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1747 |
+
$anymarketlog->setLogDesc( 'Opção de variação sem correspondente no magento ('.$variationArray[ $idVar ].') - '.$descVar );
|
1748 |
+
$anymarketlog->setStatus("0");
|
1749 |
+
$anymarketlog->setStores(array($storeID));
|
1750 |
+
$anymarketlog->save();
|
1751 |
+
}
|
1752 |
+
}else{
|
1753 |
+
//Atualiza Imagens
|
1754 |
+
$this->update_image_product($product, $ProdsJSON, $IDSKUProd);
|
1755 |
+
|
1756 |
+
$webSiteIds = $product->getWebsiteIds();
|
1757 |
+
if(!in_array($websiteID, $webSiteIds)){
|
1758 |
+
array_push($webSiteIds, $websiteID);
|
1759 |
+
$product->setWebsiteIds( $webSiteIds );
|
1760 |
+
}
|
1761 |
+
|
1762 |
+
$product->setStoreId($storeID);
|
1763 |
+
$product->setName( $sku->title );
|
1764 |
+
$product->setDescription( $sku->title );
|
1765 |
+
$product->setShortDescription( $sku->title );
|
1766 |
+
$product->setData('weight', $MassUnit == 1 ? $ProdsJSON->weight*1000 : $ProdsJSON->weight);
|
1767 |
+
|
1768 |
+
$product->setData($priceField, $sku->price);
|
1769 |
+
$product->setData('brand_anymarket', $ProdsJSON->brand);
|
1770 |
+
$product->setData($model, $this->procAttrConfig($model, $ProdsJSON->model, 0));
|
1771 |
+
$product->setData($video_url, $this->procAttrConfig($video_url, $ProdsJSON->videoURL, 0));
|
1772 |
+
|
1773 |
+
$product->setData($volume_comprimento, $this->convertUnitMeasurement($UnitMeasurement, $vLength, 0));
|
1774 |
+
$product->setData($volume_altura, $this->convertUnitMeasurement($UnitMeasurement, $vHeight, 0));
|
1775 |
+
$product->setData($volume_largura,$this->convertUnitMeasurement($UnitMeasurement, $vWidth, 0));
|
1776 |
+
|
1777 |
+
$product->setData($warranty_time, $this->procAttrConfig($warranty_time, $ProdsJSON->warrantyTime, 0));
|
1778 |
+
$product->setData($nbm, $this->procAttrConfig($nbm, $ProdsJSON->nbm, 0));
|
1779 |
+
$product->setData($nbm_origin, $this->procAttrConfig($nbm_origin, $ProdsJSON->originCode, 0));
|
1780 |
+
$product->setData($ean, $this->procAttrConfig($ean, $sku->ean, 0));
|
1781 |
+
$product->setData($warranty_text, $this->procAttrConfig($warranty_text, $ProdsJSON->warranty, 0));
|
1782 |
+
$product->setData('id_anymarket', $sku->idProduct);
|
1783 |
+
$product->setData('categoria_anymarket', $ProdsJSON->category);
|
1784 |
+
$product->setData('name', $ProdsJSON->title);
|
1785 |
+
$product->setStatus(1);
|
1786 |
+
$product->save();
|
1787 |
+
|
1788 |
+
foreach ($ProdsJSON->attributes as $attrProd) {
|
1789 |
+
$product->setData( strtolower($attrProd->name), $this->procAttrConfig(strtolower($attrProd->name), $attrProd->value, 0));
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
if( $typeSincOrder == 0 ) {
|
1793 |
+
$qtyStock = $sku->stockAmount;
|
1794 |
+
$inStock = $qtyStock > 0 ? '1' : '0';
|
1795 |
+
|
1796 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1797 |
+
$stockItem->setData('is_in_stock', $inStock);
|
1798 |
+
$stockItem->setData('qty', $qtyStock);
|
1799 |
+
$stockItem->save();
|
1800 |
+
}
|
1801 |
+
|
1802 |
+
$ProdCrt = $product->getId();
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Simple product Created').' ('.$ProdCrt.')';
|
1806 |
+
$returnProd['error'] = '0';
|
1807 |
+
$returnProd['json'] = '';
|
1808 |
+
|
1809 |
+
$this->saveLogsProds($storeID, "1", $returnProd, $product);
|
1810 |
+
|
1811 |
+
if($ProdCrt != ''){
|
1812 |
+
$prodSimpleFromConfig[] = array('AttributeText' => $variationArray[ $idVar ], 'Id' => $ProdCrt);
|
1813 |
+
$ProdCrt = '';
|
1814 |
+
}
|
1815 |
+
}
|
1816 |
+
|
1817 |
+
$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
|
1818 |
+
->addAttributeToFilter('type_id', array('eq' => 'configurable'));
|
1819 |
+
|
1820 |
+
$prod = null;
|
1821 |
+
foreach ($collectionConfigurable as $prodConfig) {
|
1822 |
+
$prod = Mage::getModel('catalog/product')->setStoreId(1)->load( $prodConfig->getId() );
|
1823 |
+
if( $prod->getData('id_anymarket') == $ProdsJSON->id ){
|
1824 |
+
break;
|
1825 |
+
}
|
1826 |
+
|
1827 |
+
}
|
1828 |
+
|
1829 |
+
$imagesGallery = array();
|
1830 |
+
foreach ($ProdsJSON->photos as $image) {
|
1831 |
+
$imagesGallery[] = array('img' => $image->standard_resolution, 'main' => $image->main);
|
1832 |
+
}
|
1833 |
+
|
1834 |
+
if( $prod == null ){
|
1835 |
+
if($prodSimpleFromConfig){
|
1836 |
+
$dataProdConfig = array(
|
1837 |
+
'stock' => '0',
|
1838 |
+
'price' => '0',
|
1839 |
+
'name' => $ProdsJSON->title,
|
1840 |
+
'brand' => '',
|
1841 |
+
'sku' => $ProdsJSON->id,
|
1842 |
+
'id_anymarket' => $ProdsJSON->id,
|
1843 |
+
'categoria_anymarket' => $ProdsJSON->category,
|
1844 |
+
'images' => $imagesGallery
|
1845 |
+
);
|
1846 |
+
|
1847 |
+
foreach ($configureFieldsConfig as $fieldConfig) {
|
1848 |
+
$dataProdConfig[$fieldConfig] = $ProdsJSON->description;
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
$ProdCrt = $this->create_configurable_product($storeID, $dataProdConfig, $prodSimpleFromConfig, $AttributeIds);
|
1852 |
+
}
|
1853 |
+
}else{
|
1854 |
+
$dataProdConfig = array(
|
1855 |
+
'stock' => '0',
|
1856 |
+
'price' => '0',
|
1857 |
+
'name' => $ProdsJSON->title,
|
1858 |
+
'brand' => '',
|
1859 |
+
'sku' => $ProdsJSON->id,
|
1860 |
+
'id_anymarket' => $ProdsJSON->id,
|
1861 |
+
'categoria_anymarket' => $ProdsJSON->category
|
1862 |
+
);
|
1863 |
+
|
1864 |
+
foreach ($configureFieldsConfig as $fieldConfig) {
|
1865 |
+
$dataProdConfig[$fieldConfig] = $ProdsJSON->description;
|
1866 |
+
}
|
1867 |
+
|
1868 |
+
$this->update_configurable_product($storeID, $prod->getId(), $dataProdConfig, $prodSimpleFromConfig, $AttributeIds);
|
1869 |
+
}
|
1870 |
+
}else{
|
1871 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
1872 |
+
$anymarketlog->setLogDesc( 'Variação sem correspondente no magento ('.utf8_decode($sinc).') - Produto: '.$ProdsJSON->id);
|
1873 |
+
$anymarketlog->setStatus("0");
|
1874 |
+
$anymarketlog->setStores(array($storeID));
|
1875 |
+
$anymarketlog->save();
|
1876 |
+
}
|
1877 |
+
// PROD SIMPLES
|
1878 |
+
}else{
|
1879 |
+
foreach ($ProdsJSON->skus as $ProdJSON) {
|
1880 |
+
$skuProd = $ProdJSON;
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
$imagesGallery = array();
|
1884 |
+
foreach ($ProdsJSON->photos as $image) {
|
1885 |
+
$imagesGallery[] = array('img' => $image->standard_resolution, 'main' => $image->main);
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
$IDSkuJsonProd = $skuProd->idInClient != null ? $skuProd->idInClient : $skuProd->idProduct;
|
1889 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $IDSkuJsonProd);
|
1890 |
+
foreach ($ProdsJSON->skus as $sku) {
|
1891 |
+
$skuEan = $sku->ean;
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
//trata as dimensoes
|
1895 |
+
$vHeight = $this->procAttrConfig($volume_altura, $ProdsJSON->height, 0);
|
1896 |
+
$vWidth = $this->procAttrConfig($volume_largura, $ProdsJSON->width, 0);
|
1897 |
+
$vLength = $this->procAttrConfig($volume_comprimento, $ProdsJSON->length, 0);
|
1898 |
+
|
1899 |
+
if(!$product){
|
1900 |
+
$dataPrd = array(
|
1901 |
+
'attribute_set_id' => $AttrSet == null ? Mage::getModel('catalog/product')->getDefaultAttributeSetId() : $AttrSet,
|
1902 |
+
'type_id' => 'simple',
|
1903 |
+
'sku' => $IDSkuJsonProd,
|
1904 |
+
'name' => $skuProd->title,
|
1905 |
+
$priceField => $skuProd->price,
|
1906 |
+
'created_at' => strtotime('now'),
|
1907 |
+
'updated_at' => strtotime('now'),
|
1908 |
+
'id_anymarket' => $ProdsJSON->id,
|
1909 |
+
'weight' => $MassUnit == 1 ? $ProdsJSON->weight*1000 : $ProdsJSON->weight,
|
1910 |
+
'store_id' => $storeID,
|
1911 |
+
'website_ids' => array($websiteID),
|
1912 |
+
'brand_anymarket' => $ProdsJSON->brand,
|
1913 |
+
$nbm => $this->procAttrConfig($nbm, $ProdsJSON->nbm, 0),
|
1914 |
+
$model => $this->procAttrConfig($model, $ProdsJSON->model, 0),
|
1915 |
+
$video_url => $this->procAttrConfig($video_url, $ProdsJSON->videoURL, 0),
|
1916 |
+
|
1917 |
+
$volume_comprimento => $this->convertUnitMeasurement($UnitMeasurement, $vLength, 0),
|
1918 |
+
$volume_altura => $this->convertUnitMeasurement($UnitMeasurement, $vHeight, 0),
|
1919 |
+
$volume_largura => $this->convertUnitMeasurement($UnitMeasurement, $vWidth, 0),
|
1920 |
+
|
1921 |
+
$warranty_time => $this->procAttrConfig($warranty_time, $ProdsJSON->warrantyTime, 0),
|
1922 |
+
$nbm_origin => $this->procAttrConfig($nbm_origin, $ProdsJSON->originCode, 0),
|
1923 |
+
$ean => $this->procAttrConfig($ean, $skuEan, 0),
|
1924 |
+
$warranty_text => $this->procAttrConfig($warranty_text, $ProdsJSON->warranty, 0),
|
1925 |
+
'msrp_enabled' => '2',
|
1926 |
+
'categoria_anymarket' => $ProdsJSON->category,
|
1927 |
+
);
|
1928 |
+
|
1929 |
+
foreach ($configureFieldsConfig as $fieldConfig) {
|
1930 |
+
$dataPrd[$fieldConfig] = $ProdsJSON->description;
|
1931 |
+
}
|
1932 |
+
|
1933 |
+
foreach ($ProdsJSON->attributes as $attrProd) {
|
1934 |
+
$dataPrd[ strtolower($attrProd->name) ] = $this->procAttrConfig(strtolower($attrProd->name), $attrProd->value, 0);
|
1935 |
+
}
|
1936 |
+
|
1937 |
+
$data = array(
|
1938 |
+
'product' => $dataPrd,
|
1939 |
+
'stock_item' => array(
|
1940 |
+
'is_in_stock' => $skuProd->stockAmount > 0 ? '1' : '0',
|
1941 |
+
'qty' => $skuProd->stockAmount,
|
1942 |
+
),
|
1943 |
+
'images' => $imagesGallery,
|
1944 |
+
|
1945 |
+
);
|
1946 |
+
|
1947 |
+
$ProdCrt = $this->create_simple_product($storeID, $data);
|
1948 |
+
}else{
|
1949 |
+
//Atualiza Imagens
|
1950 |
+
$this->update_image_product($product, $ProdsJSON, $IDSkuJsonProd);
|
1951 |
+
|
1952 |
+
$webSiteIds = $product->getWebsiteIds();
|
1953 |
+
if(!in_array($websiteID, $webSiteIds)){
|
1954 |
+
array_push($webSiteIds, $websiteID);
|
1955 |
+
$product->setWebsiteIds( $webSiteIds );
|
1956 |
+
}
|
1957 |
+
|
1958 |
+
$product->setStoreId($storeID);
|
1959 |
+
$product->setName( $skuProd->title );
|
1960 |
+
|
1961 |
+
// $product->setDescription( $ProdsJSON->description );
|
1962 |
+
// $product->setShortDescription( $ProdsJSON->description );
|
1963 |
+
|
1964 |
+
foreach ($configureFieldsConfig as $fieldConfig) {
|
1965 |
+
$product->setData($fieldConfig, $ProdsJSON->description);
|
1966 |
+
}
|
1967 |
+
|
1968 |
+
$product->setData('weight', $MassUnit == 1 ? $ProdsJSON->weight*1000 : $ProdsJSON->weight);
|
1969 |
+
|
1970 |
+
$product->setData('brand_anymarket', $ProdsJSON->brand);
|
1971 |
+
$product->setData($model, $this->procAttrConfig($model, $ProdsJSON->model, 0));
|
1972 |
+
$product->setData($video_url, $this->procAttrConfig($video_url, $ProdsJSON->videoURL, 0));
|
1973 |
+
|
1974 |
+
$product->setData($volume_comprimento, $this->convertUnitMeasurement($UnitMeasurement, $vLength, 0));
|
1975 |
+
$product->setData($volume_altura, $this->convertUnitMeasurement($UnitMeasurement, $vHeight, 0));
|
1976 |
+
$product->setData($volume_largura, $this->convertUnitMeasurement($UnitMeasurement, $vWidth, 0));
|
1977 |
+
|
1978 |
+
$product->setData($warranty_time, $this->procAttrConfig($warranty_time, $ProdsJSON->warrantyTime, 0));
|
1979 |
+
$product->setData($nbm, $this->procAttrConfig($nbm, $ProdsJSON->nbm, 0));
|
1980 |
+
$product->setData($nbm_origin, $this->procAttrConfig($nbm_origin, $ProdsJSON->originCode, 0));
|
1981 |
+
$product->setData($ean, $this->procAttrConfig($ean, $skuEan, 0));
|
1982 |
+
$product->setData($warranty_text, $this->procAttrConfig($warranty_text, $ProdsJSON->warranty, 0));
|
1983 |
+
$product->setData('id_anymarket', $ProdsJSON->id);
|
1984 |
+
$product->setData('categoria_anymarket', $ProdsJSON->category);
|
1985 |
+
$product->setData('name', $ProdsJSON->title);
|
1986 |
+
$product->setStatus(1);
|
1987 |
+
|
1988 |
+
foreach ($ProdsJSON->attributes as $attrProd) {
|
1989 |
+
$product->setData( strtolower($attrProd->name), $this->procAttrConfig(strtolower($attrProd->name), $attrProd->value, 0));
|
1990 |
+
}
|
1991 |
+
|
1992 |
+
$product->setData($priceField, $skuProd->price);
|
1993 |
+
|
1994 |
+
if( $typeSincOrder == 0 ) {
|
1995 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1996 |
+
$stockItem->setData('is_in_stock', $ProdsJSON->skus[0]->stockAmount > 0 ? '1' : '0');
|
1997 |
+
$stockItem->setData('qty', $ProdsJSON->skus[0]->stockAmount);
|
1998 |
+
$stockItem->save();
|
1999 |
+
}
|
2000 |
+
|
2001 |
+
$product->save();
|
2002 |
+
|
2003 |
+
$ProdCrt = $product;
|
2004 |
+
}
|
2005 |
+
|
2006 |
+
}
|
2007 |
+
Mage::getSingleton('core/session')->setImportProdsVariable('true');
|
2008 |
+
return $ProdCrt;
|
2009 |
+
}
|
2010 |
+
|
2011 |
+
public function massUpdtProds($storeID){
|
2012 |
+
try {
|
2013 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
2014 |
+
if($typeSincProd == 0){
|
2015 |
+
$products = $products = Mage::getModel('catalog/product')
|
2016 |
+
->getCollection()
|
2017 |
+
->addAttributeToSelect('name');
|
2018 |
+
$cont = 0;
|
2019 |
+
foreach($products as $product) {
|
2020 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild( $product->getId() );
|
2021 |
+
|
2022 |
+
if (!$parentIds) {
|
2023 |
+
$anymarketproductsUpdt = Mage::getModel('db1_anymarket/anymarketproducts')->setStoreId($storeID)->load($product->getId(), 'nmp_id');
|
2024 |
+
if(is_array($anymarketproductsUpdt->getData('store_id'))){
|
2025 |
+
$arrvar = array_values($anymarketproductsUpdt->getData('store_id'));
|
2026 |
+
$StoreIDAmProd = array_shift($arrvar);
|
2027 |
+
}else{
|
2028 |
+
$StoreIDAmProd = $anymarketproductsUpdt->getData('store_id');
|
2029 |
+
}
|
2030 |
+
if( ($anymarketproductsUpdt->getData('nmp_id') == null) || ($StoreIDAmProd != $storeID) ){
|
2031 |
+
|
2032 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild( $product->getId() );
|
2033 |
+
if (!isset($parentIds[0])) {
|
2034 |
+
$name = $product->getName();
|
2035 |
+
$sku = $product->getSku();
|
2036 |
+
$IDProd = $product->getId();
|
2037 |
+
|
2038 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->load($sku ,'nmp_sku');
|
2039 |
+
$anymarketproducts->setNmpId( $IDProd );
|
2040 |
+
$anymarketproducts->setNmpSku( $sku );
|
2041 |
+
$anymarketproducts->setNmpName( $name );
|
2042 |
+
$anymarketproducts->setNmpDescError("");
|
2043 |
+
$anymarketproducts->setNmpStatusInt("Não integrado (Magento)");
|
2044 |
+
$anymarketproducts->setStatus($product->getData('integra_anymarket'));
|
2045 |
+
$anymarketproducts->setStores(array($storeID));
|
2046 |
+
$anymarketproducts->save();
|
2047 |
+
|
2048 |
+
$cont = $cont+1;
|
2049 |
+
}
|
2050 |
+
}else{
|
2051 |
+
if( ($anymarketproductsUpdt->getData('nmp_sku') != $product->getSku() ) || ($anymarketproductsUpdt->getData('nmp_name') != $product->getName() ) ){
|
2052 |
+
$anymarketproductsUpdt->setNmpSku( $product->getSku() );
|
2053 |
+
$anymarketproductsUpdt->setNmpName( $product->getName() );
|
2054 |
+
$anymarketproductsUpdt->save();
|
2055 |
+
|
2056 |
+
$cont = $cont+1;
|
2057 |
+
}
|
2058 |
+
}
|
2059 |
+
}
|
2060 |
+
|
2061 |
+
}
|
2062 |
+
|
2063 |
+
if($cont > 0){
|
2064 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
2065 |
+
Mage::helper('db1_anymarket')->__('Total %d products successfully listed.', $cont)
|
2066 |
+
);
|
2067 |
+
}
|
2068 |
+
}
|
2069 |
+
} catch (Mage_Core_Exception $e) {
|
2070 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
2071 |
+
} catch (Exception $e) {
|
2072 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
2073 |
+
Mage::helper('db1_anymarket')->__('There was an error updating the products.')
|
2074 |
+
);
|
2075 |
+
Mage::logException($e);
|
2076 |
+
}
|
2077 |
+
}
|
2078 |
+
|
2079 |
+
/**
|
2080 |
+
* @param $IDProd
|
2081 |
+
* @param $QtdStock
|
2082 |
+
* @param $Price
|
2083 |
+
*/
|
2084 |
+
public function updatePriceStockAnyMarket($storeID, $IDProd, $QtdStock, $Price){
|
2085 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $IDProd );
|
2086 |
+
if($product->getTypeID() != "configurable"){
|
2087 |
+
if( ($product->getStatus() == 1) && ($product->getData('integra_anymarket') == 1) ){
|
2088 |
+
$anymarketproductsUpdt = Mage::getModel('db1_anymarket/anymarketproducts')->load($product->getId(), 'nmp_id');
|
2089 |
+
if( ($anymarketproductsUpdt->getData('nmp_status_int') != 'Não integrado (Magento)') ){
|
2090 |
+
$sincronize = true;
|
2091 |
+
if($product->getVisibility() == 1){ //nao exibido individualmente
|
2092 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild( $product->getId() );
|
2093 |
+
if ($parentIds) {
|
2094 |
+
$sincronize = true;
|
2095 |
+
}else{
|
2096 |
+
$sincronize = false;
|
2097 |
+
}
|
2098 |
+
}
|
2099 |
+
|
2100 |
+
if ($sincronize == true) {
|
2101 |
+
if($product->getData('id_anymarket') != ""){
|
2102 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
2103 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
2104 |
+
|
2105 |
+
$headers = array(
|
2106 |
+
"Content-type: application/json",
|
2107 |
+
"Accept: */*",
|
2108 |
+
"gumgaToken: ".$TOKEN
|
2109 |
+
);
|
2110 |
+
|
2111 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
2112 |
+
if( $typeSincProd == 0 ){
|
2113 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
2114 |
+
if($filter == 'final_price'){
|
2115 |
+
$Price = $product->getFinalPrice();
|
2116 |
+
}else{
|
2117 |
+
$Price = $product->getData($filter);
|
2118 |
+
}
|
2119 |
+
}else{
|
2120 |
+
$Price = null;
|
2121 |
+
}
|
2122 |
+
|
2123 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
2124 |
+
if( $typeSincOrder == 0 ){
|
2125 |
+
$QtdStock = null;
|
2126 |
+
}elseif( !is_numeric ( $QtdStock ) ){
|
2127 |
+
$QtdStock = null;
|
2128 |
+
}
|
2129 |
+
|
2130 |
+
if( ($QtdStock != null) || ($Price != null) ){
|
2131 |
+
$params = array(
|
2132 |
+
"partnerId" => $product->getSku(),
|
2133 |
+
"quantity" => $QtdStock,
|
2134 |
+
"cost" => $Price
|
2135 |
+
);
|
2136 |
+
|
2137 |
+
$returnProd = $this->CallAPICurl("PUT", $HOST."/v2/stocks", $headers, array($params));
|
2138 |
+
if($returnProd['return'] == ''){
|
2139 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Update Stock and Price');
|
2140 |
+
$returnProd['error'] = '0';
|
2141 |
+
$returnProd['json'] = json_encode($params);
|
2142 |
+
}
|
2143 |
+
|
2144 |
+
if( $returnProd['error'] == '1' ){
|
2145 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
2146 |
+
}else{
|
2147 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
2148 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('Update stock and price.') );
|
2149 |
+
$anymarketlog->setStatus("0");
|
2150 |
+
$anymarketlog->setLogId( $product->getId() );
|
2151 |
+
$anymarketlog->setLogJson( json_encode($params) );
|
2152 |
+
$anymarketlog->setStores(array($storeID));
|
2153 |
+
$anymarketlog->save();
|
2154 |
+
}
|
2155 |
+
}
|
2156 |
+
|
2157 |
+
}
|
2158 |
+
}
|
2159 |
+
}
|
2160 |
+
}
|
2161 |
+
}else{
|
2162 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
2163 |
+
|
2164 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
2165 |
+
foreach($childProducts as $child) {
|
2166 |
+
$this->updatePriceStockAnyMarket($storeID, $child->getId(), $child->getStockItem()->getQty(), $child->getData($filter));
|
2167 |
+
}
|
2168 |
+
}
|
2169 |
+
|
2170 |
+
|
2171 |
+
}
|
2172 |
+
|
2173 |
Â
}
|
app/code/community/DB1/AnyMarket/Helper/Productgenerator.php
CHANGED
@@ -1,289 +1,281 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
protected $_defaultData = array(
|
6 |
-
'product' => array(
|
7 |
-
'attribute_set_id' =>
|
8 |
-
'type_id' => 'simple',
|
9 |
-
'sku' => '0124ASF3',
|
10 |
-
'has_options' => '0',
|
11 |
-
'required_options' => '0',
|
12 |
-
'created_at' => '',
|
13 |
-
'updated_at' => '',
|
14 |
-
'status' => '1',
|
15 |
-
'visibility' => '4',
|
16 |
-
'volume_comprimento' => null,
|
17 |
-
'volume_altura' => null,
|
18 |
-
'volume_largura' => null,
|
19 |
-
'warranty_time' => null,
|
20 |
-
'id_anymarket' => null,
|
21 |
-
'tax_class_id' => '0',
|
22 |
-
'is_recurring' => '0',
|
23 |
-
'weight' => '1.0000',
|
24 |
-
'price' => '
|
25 |
-
'cost' => '
|
26 |
-
'special_price' => null,
|
27 |
-
'msrp' => null,
|
28 |
-
'name' => '
|
29 |
-
'url_key' => '',
|
30 |
-
'coun1_of_manufacture' => null,
|
31 |
-
'video_url' => null,
|
32 |
-
'nbm' => '1',
|
33 |
-
'nbm_origin' => '1',
|
34 |
-
'ean' => '1',
|
35 |
-
'warranty_text' => null,
|
36 |
-
'msrp_enabled' => '2',
|
37 |
-
'msrp_display_actual_price_type' => '4',
|
38 |
-
'meta_title' => null,
|
39 |
-
'meta_description' => null,
|
40 |
-
'image' => 'no_selection',
|
41 |
-
'small_image' => 'no_selection',
|
42 |
-
'thumbnail' => 'no_selection',
|
43 |
-
'custom_design' => null,
|
44 |
-
'page_layout' => null,
|
45 |
-
'options_container' => 'container1',
|
46 |
-
'gift_message_available' => null,
|
47 |
-
'url_path' => 'teste.html',
|
48 |
-
'news_from_date' => null,
|
49 |
-
'news_to_date' => null,
|
50 |
-
'special_from_date' => null,
|
51 |
-
'special_to_date' => null,
|
52 |
-
'custom_design_from' => null,
|
53 |
-
'custom_design_to' => null,
|
54 |
-
'description' => '
|
55 |
-
'short_description' => '
|
56 |
-
'meta_keyword' => null,
|
57 |
-
'custom_layout_update' => null,
|
58 |
-
'is_salable' => '1',
|
59 |
-
'integra_anymarket' => '1',
|
60 |
-
'categoria_anymarket' => '',
|
61 |
-
|
62 |
-
|
63 |
-
'
|
64 |
-
|
65 |
-
'
|
66 |
-
'
|
67 |
-
'
|
68 |
-
'
|
69 |
-
'
|
70 |
-
|
71 |
-
|
72 |
-
);
|
73 |
-
|
74 |
-
/**
|
75 |
-
* update images in MG
|
76 |
-
*
|
77 |
-
* @
|
78 |
-
* @param $
|
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 |
-
$imgName = basename($image_url);
|
134 |
-
$imgName = str_replace('.'.$image_type, "", $imgName);
|
135 |
-
$filename = md5($imgName . $sku).'.'.$image_type;
|
136 |
-
|
137 |
-
$dirPath = Mage::getBaseDir('media') . DS . 'import';
|
138 |
-
if (!file_exists($dirPath)) {
|
139 |
-
mkdir($dirPath, 0777, true);
|
140 |
-
}
|
141 |
-
|
142 |
-
$filepath = $dirPath . DS . $filename;
|
143 |
-
|
144 |
-
$curl_handle = curl_init();
|
145 |
-
curl_setopt($curl_handle, CURLOPT_URL,$image_url);
|
146 |
-
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
|
147 |
-
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
|
148 |
-
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Cirkel');
|
149 |
-
$query = curl_exec($curl_handle);
|
150 |
-
curl_close($curl_handle);
|
151 |
-
|
152 |
-
file_put_contents($filepath, $query);
|
153 |
-
|
154 |
-
if (file_exists($filepath)) {
|
155 |
-
$attrIMG = array();
|
156 |
-
|
157 |
-
if( array_key_exists('main', $image) ){
|
158 |
-
if($image['main'] == true){
|
159 |
-
$attrIMG = array('image', 'thumbnail', 'small_image');
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
|
164 |
-
$productMG->
|
165 |
-
$productMG->
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
*
|
175 |
-
* @
|
176 |
-
*
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
$confProduct->
|
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 |
-
$confProduct->
|
207 |
-
|
208 |
-
|
209 |
-
$confProduct->
|
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 |
-
* @param
|
238 |
-
* @return
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
$
|
243 |
-
|
244 |
-
$confProduct->
|
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 |
-
->setStatus(1)
|
282 |
-
->setTaxClassId(0)
|
283 |
-
->setIdAnymarket( $dataProdConfig['id_anymarket'] )
|
284 |
-
->save();
|
285 |
-
|
286 |
-
return $confProduct;
|
287 |
-
}
|
288 |
-
|
289 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
protected $_defaultData = array(
|
6 |
+
'product' => array(
|
7 |
+
'attribute_set_id' => '4',
|
8 |
+
'type_id' => 'simple',
|
9 |
+
'sku' => '0124ASF3',
|
10 |
+
'has_options' => '0',
|
11 |
+
'required_options' => '0',
|
12 |
+
'created_at' => '',
|
13 |
+
'updated_at' => '',
|
14 |
+
'status' => '1',
|
15 |
+
'visibility' => '4',
|
16 |
+
'volume_comprimento' => null,
|
17 |
+
'volume_altura' => null,
|
18 |
+
'volume_largura' => null,
|
19 |
+
'warranty_time' => null,
|
20 |
+
'id_anymarket' => null,
|
21 |
+
'tax_class_id' => '0',
|
22 |
+
'is_recurring' => '0',
|
23 |
+
'weight' => '1.0000',
|
24 |
+
'price' => '0',
|
25 |
+
'cost' => '0',
|
26 |
+
'special_price' => null,
|
27 |
+
'msrp' => null,
|
28 |
+
'name' => 'product no name' ,
|
29 |
+
'url_key' => '',
|
30 |
+
'coun1_of_manufacture' => null,
|
31 |
+
'video_url' => null,
|
32 |
+
'nbm' => '1',
|
33 |
+
'nbm_origin' => '1',
|
34 |
+
'ean' => '1',
|
35 |
+
'warranty_text' => null,
|
36 |
+
'msrp_enabled' => '2',
|
37 |
+
'msrp_display_actual_price_type' => '4',
|
38 |
+
'meta_title' => null,
|
39 |
+
'meta_description' => null,
|
40 |
+
'image' => 'no_selection',
|
41 |
+
'small_image' => 'no_selection',
|
42 |
+
'thumbnail' => 'no_selection',
|
43 |
+
'custom_design' => null,
|
44 |
+
'page_layout' => null,
|
45 |
+
'options_container' => 'container1',
|
46 |
+
'gift_message_available' => null,
|
47 |
+
'url_path' => 'teste.html',
|
48 |
+
'news_from_date' => null,
|
49 |
+
'news_to_date' => null,
|
50 |
+
'special_from_date' => null,
|
51 |
+
'special_to_date' => null,
|
52 |
+
'custom_design_from' => null,
|
53 |
+
'custom_design_to' => null,
|
54 |
+
'description' => '',
|
55 |
+
'short_description' => '.',
|
56 |
+
'meta_keyword' => null,
|
57 |
+
'custom_layout_update' => null,
|
58 |
+
'is_salable' => '1',
|
59 |
+
'integra_anymarket' => '1',
|
60 |
+
'categoria_anymarket' => '',
|
61 |
+
'category_ids' => array(2,3,4),
|
62 |
+
),
|
63 |
+
'images' => array(),
|
64 |
+
'stock_item' => array(
|
65 |
+
'use_config_manage_stock' => '0',
|
66 |
+
'manage_stock' => '1',
|
67 |
+
'min_sale_qty' => '1',
|
68 |
+
'max_sale_qty' => '',
|
69 |
+
'is_in_stock' => '1',
|
70 |
+
'qty' => '9999',
|
71 |
+
),
|
72 |
+
);
|
73 |
+
|
74 |
+
/**
|
75 |
+
* update images in MG
|
76 |
+
*
|
77 |
+
* @param $product
|
78 |
+
* @param $data
|
79 |
+
*/
|
80 |
+
public function updateImages($product, $data){
|
81 |
+
$sku = $data['sku'];
|
82 |
+
foreach ($data['images'] as $image) {
|
83 |
+
$this->importImages($product, $image, $sku);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
/**
|
89 |
+
* create simple prod in MG
|
90 |
+
*
|
91 |
+
* @param array $data
|
92 |
+
* @return Mage_Catalog_Model_Product
|
93 |
+
*/
|
94 |
+
public function createSimpleProduct($data = array()){
|
95 |
+
$data = array_replace_recursive($this->_defaultData, $data);
|
96 |
+
|
97 |
+
$product = Mage::getModel('catalog/product');
|
98 |
+
$product->setData($data['product']);
|
99 |
+
$product->setStockData($data['stock_item']);
|
100 |
+
$product->setForceConfirmed(true);
|
101 |
+
$prodSaved = $product->save();
|
102 |
+
|
103 |
+
$sku = $data['product']['sku'];
|
104 |
+
|
105 |
+
if( array_key_exists("images", $data) ){
|
106 |
+
foreach ($data['images'] as $image) {
|
107 |
+
$this->importImages($prodSaved, $image, $sku);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
return $prodSaved;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* import Images
|
116 |
+
*
|
117 |
+
* @param $product
|
118 |
+
* @param $image
|
119 |
+
* @param $sku
|
120 |
+
*/
|
121 |
+
private function importImages($product, $image, $sku){
|
122 |
+
|
123 |
+
$image_url = $image['img'];
|
124 |
+
$image_url = str_replace("https://", "http://", $image_url);
|
125 |
+
$image_type = substr(strrchr($image_url,"."),1);
|
126 |
+
$split = explode("?", $image_type);
|
127 |
+
$image_type = $split[0];
|
128 |
+
$split = explode("/", $image_type);
|
129 |
+
$image_type = $split[0];
|
130 |
+
|
131 |
+
$image_url = substr($image_url, 0,strpos($image_url, $image_type)+strlen($image_type));
|
132 |
+
|
133 |
+
$imgName = basename($image_url);
|
134 |
+
$imgName = str_replace('.'.$image_type, "", $imgName);
|
135 |
+
$filename = md5($imgName . $sku).'.'.$image_type;
|
136 |
+
|
137 |
+
$dirPath = Mage::getBaseDir('media') . DS . 'import';
|
138 |
+
if (!file_exists($dirPath)) {
|
139 |
+
mkdir($dirPath, 0777, true);
|
140 |
+
}
|
141 |
+
|
142 |
+
$filepath = $dirPath . DS . $filename;
|
143 |
+
|
144 |
+
$curl_handle = curl_init();
|
145 |
+
curl_setopt($curl_handle, CURLOPT_URL,$image_url);
|
146 |
+
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
|
147 |
+
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
|
148 |
+
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Cirkel');
|
149 |
+
$query = curl_exec($curl_handle);
|
150 |
+
curl_close($curl_handle);
|
151 |
+
|
152 |
+
file_put_contents($filepath, $query);
|
153 |
+
|
154 |
+
if (file_exists($filepath)) {
|
155 |
+
$attrIMG = array();
|
156 |
+
|
157 |
+
if( array_key_exists('main', $image) ){
|
158 |
+
if($image['main'] == true){
|
159 |
+
$attrIMG = array('image', 'thumbnail', 'small_image');
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
|
164 |
+
$productMG = Mage::getModel('catalog/product')->loadByAttribute('sku', $product->getSku());
|
165 |
+
$productMG->addImageToMediaGallery( $filepath, $attrIMG, false, false);
|
166 |
+
$productMG->save();
|
167 |
+
Mage::app()->setCurrentStore( $this->getCurrentStoreView() );
|
168 |
+
}
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* create configurable product in MG
|
174 |
+
*
|
175 |
+
* @param array $dataProdConfig
|
176 |
+
* @param array $simpleProducts
|
177 |
+
* @param array $AttributeIds
|
178 |
+
* @return Mage_Catalog_Model_Product
|
179 |
+
*/
|
180 |
+
public function createConfigurableProduct($storeID, $dataProdConfig = array() , $simpleProducts = array(), $AttributeIds = array()){
|
181 |
+
$confProduct = Mage::getModel('catalog/product')->setSku($dataProdConfig['sku']);
|
182 |
+
$confProduct->setTypeId('configurable');
|
183 |
+
|
184 |
+
$confProduct->getTypeInstance()->setUsedProductAttributeIds($AttributeIds);
|
185 |
+
|
186 |
+
$configurableProductsData = array();
|
187 |
+
$configurableAttributesData = $confProduct->getTypeInstance()->getConfigurableAttributesAsArray();
|
188 |
+
|
189 |
+
foreach ($simpleProducts as $simpleProduct) {
|
190 |
+
$sProd = Mage::getModel('catalog/product')->load( $simpleProduct['Id'] );
|
191 |
+
|
192 |
+
$AttributeId = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', $simpleProduct['AttributeText'] );
|
193 |
+
|
194 |
+
$simpleProductsData = array(
|
195 |
+
'label' => $sProd->getAttributeText( $simpleProduct['AttributeText'] ),
|
196 |
+
'attribute_id' => $AttributeId,
|
197 |
+
'value_index' => (int) $sProd->getData( $simpleProduct['AttributeText'] ),
|
198 |
+
'is_percent' => 0,
|
199 |
+
'pricing_value' => $sProd->getPrice(),
|
200 |
+
);
|
201 |
+
|
202 |
+
$configurableProductsData[ $sProd->getId() ] = $simpleProductsData;
|
203 |
+
$configurableAttributesData[0]['values'][] = $simpleProductsData;
|
204 |
+
}
|
205 |
+
|
206 |
+
$confProduct->setConfigurableProductsData($configurableProductsData);
|
207 |
+
$confProduct->setConfigurableAttributesData($configurableAttributesData);
|
208 |
+
|
209 |
+
$confProduct->setCanSaveConfigurableAttributes(true);
|
210 |
+
|
211 |
+
$confProduct->setStoreId($storeID)
|
212 |
+
->setAttributeSetId( Mage::getModel('catalog/product')->getDefaultAttributeSetId() )
|
213 |
+
->setCategoryIds(array(2,3,4))
|
214 |
+
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
|
215 |
+
->setStatus(1)
|
216 |
+
->setTaxClassId(0);
|
217 |
+
|
218 |
+
foreach ($dataProdConfig as $key => $value) {
|
219 |
+
$confProduct->setData($key, $value);
|
220 |
+
}
|
221 |
+
$confProduct->save();
|
222 |
+
|
223 |
+
$sku = $dataProdConfig['sku'];
|
224 |
+
foreach ($dataProdConfig['images'] as $image) {
|
225 |
+
$this->importImages($confProduct, $image, $sku);
|
226 |
+
}
|
227 |
+
|
228 |
+
return $confProduct;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* update configurable product in MG
|
233 |
+
*
|
234 |
+
* @param $idProd
|
235 |
+
* @param array $dataProdConfig
|
236 |
+
* @param array $simpleProducts
|
237 |
+
* @param array $AttributeIds
|
238 |
+
* @return Mage_Catalog_Model_Product
|
239 |
+
*/
|
240 |
+
public function updateConfigurableProduct($storeID, $idProd, $dataProdConfig = array() , $simpleProducts = array(), $AttributeIds = array()){
|
241 |
+
$confProduct = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $idProd );
|
242 |
+
$confProduct->setTypeId('configurable');
|
243 |
+
|
244 |
+
$confProduct->getTypeInstance()->setUsedProductAttributeIds($AttributeIds);
|
245 |
+
|
246 |
+
$configurableProductsData = array();
|
247 |
+
|
248 |
+
foreach ($simpleProducts as $simpleProduct) {
|
249 |
+
$sProd = Mage::getModel('catalog/product')->load( $simpleProduct['Id'] );
|
250 |
+
|
251 |
+
$AttributeId = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', $simpleProduct['AttributeText'] );
|
252 |
+
|
253 |
+
$simpleProductsData = array(
|
254 |
+
'label' => $sProd->getAttributeText( $simpleProduct['AttributeText'] ),
|
255 |
+
'attribute_id' => $AttributeId,
|
256 |
+
'value_index' => (int) $sProd->getData( $simpleProduct['AttributeText'] ),
|
257 |
+
'is_percent' => 0,
|
258 |
+
'pricing_value' => $sProd->getPrice(),
|
259 |
+
);
|
260 |
+
|
261 |
+
$configurableProductsData[ $sProd->getId() ] = $simpleProductsData;
|
262 |
+
}
|
263 |
+
|
264 |
+
$confProduct->setConfigurableProductsData($configurableProductsData);
|
265 |
+
$confProduct->setCanSaveConfigurableAttributes(true);
|
266 |
+
$confProduct->setStoreId($storeID)
|
267 |
+
->setAttributeSetId( Mage::getModel('catalog/product')->getDefaultAttributeSetId() )
|
268 |
+
->setCategoryIds(array(2,3,4))
|
269 |
+
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
|
270 |
+
->setStatus(1)
|
271 |
+
->setTaxClassId(0);
|
272 |
+
|
273 |
+
foreach ($dataProdConfig as $key => $value) {
|
274 |
+
$confProduct->setData($key, $value);
|
275 |
+
}
|
276 |
+
$confProduct->save();
|
277 |
+
|
278 |
+
return $confProduct;
|
279 |
+
}
|
280 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
281 |
Â
}
|
app/code/community/DB1/AnyMarket/Helper/Queue.php
CHANGED
@@ -1,148 +1,234 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Helper_Queue extends DB1_AnyMarket_Helper_Data
|
4 |
-
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
$queueItem
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
$
|
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 |
-
|
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 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Helper_Queue extends DB1_AnyMarket_Helper_Data
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* add item in current queue
|
8 |
+
*
|
9 |
+
* @param $IdItem
|
10 |
+
* @param $typeItem
|
11 |
+
* @param $tableItem
|
12 |
+
*/
|
13 |
+
public function addQueue($storeID, $IdItem, $typeItem, $tableItem){
|
14 |
+
$queueItem = Mage::getModel('db1_anymarket/anymarketqueue');
|
15 |
+
$queueItem->setNmqId($IdItem);
|
16 |
+
$queueItem->setNmqType($typeItem);
|
17 |
+
$queueItem->setNmqTable($tableItem);
|
18 |
+
$queueItem->setStores(array($storeID));
|
19 |
+
$queueItem->save();
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* remove item from queue
|
24 |
+
*
|
25 |
+
* @param $idItem
|
26 |
+
*/
|
27 |
+
public function removeQueue($idItem){
|
28 |
+
$anymarketQueueDel = Mage::getModel('db1_anymarket/anymarketqueue');
|
29 |
+
$anymarketQueueDel->setId($idItem)->delete();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* process queue
|
34 |
+
*/
|
35 |
+
public function processQueue(){
|
36 |
+
$qtyItensImport = (int)Mage::getConfig()->getNode('default/queue_qty/qty');
|
37 |
+
$itens = Mage::getModel('db1_anymarket/anymarketqueue')
|
38 |
+
->getCollection()
|
39 |
+
->setPageSize($qtyItensImport)
|
40 |
+
->setCurPage(1);
|
41 |
+
|
42 |
+
foreach($itens->getData() as $item) {
|
43 |
+
$IdItemQueue = $item['nmq_id'];
|
44 |
+
|
45 |
+
$anymarketQueue = Mage::getModel('db1_anymarket/anymarketqueue')->load($item['entity_id']);
|
46 |
+
$arrValueStore = array_values($anymarketQueue->getStoreId());
|
47 |
+
$storeID = array_shift($arrValueStore);
|
48 |
+
|
49 |
+
$cronEnabled = Mage::getStoreConfig('anymarket_section/anymarket_cron_group/anymarket_queue_field', $storeID);
|
50 |
+
if($cronEnabled == '1') {
|
51 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
52 |
+
|
53 |
+
$typImp = $item['nmq_type'];
|
54 |
+
if ($item['nmq_table'] == 'ORDER') {
|
55 |
+
try {
|
56 |
+
if ($typImp == 'IMP') {
|
57 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
58 |
+
$anymarketorders->load($IdItemQueue, 'nmo_id_anymarket');
|
59 |
+
//Import
|
60 |
+
if ($anymarketorders->getNmoStatusInt() != "Não integrado (Magento)") {
|
61 |
+
$idAnyMarket = $anymarketorders->getNmoIdSeqAnymarket();
|
62 |
+
if ($idAnyMarket) {
|
63 |
+
$idReg = $anymarketorders->getId();
|
64 |
+
Mage::helper('db1_anymarket/order')->getSpecificOrderFromAnyMarket($idAnyMarket, "notoken", $storeID);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
69 |
+
$anymarketorders->load($IdItemQueue, 'nmo_id_order');
|
70 |
+
//Export
|
71 |
+
if ($anymarketorders->getNmoStatusInt() != "Não integrado (AnyMarket)") {
|
72 |
+
$Order = Mage::getModel('sales/order')->loadByIncrementId($anymarketorders->getNmoIdOrder());
|
73 |
+
Mage::helper('db1_anymarket/order')->updateOrderAnyMarket($storeID, $Order);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
} catch (Exception $e) {
|
78 |
+
Mage::logException($e);
|
79 |
+
}
|
80 |
+
} else if ($item['nmq_table'] == 'PRODUCT') {
|
81 |
+
// EXPORT PRODUCT
|
82 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
83 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->setStoreId($storeID);
|
84 |
+
$anymarketproducts->load($IdItemQueue, 'nmp_id');
|
85 |
+
|
86 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $anymarketproducts->getNmpSku());
|
87 |
+
if (($typImp == 'EXP') && ($typeSincProd == 0)) {
|
88 |
+
try {
|
89 |
+
$anymarketproducts->setStatus('1')->setIsMassupdate(true)->save();
|
90 |
+
if ($product != null) {
|
91 |
+
Mage::helper('db1_anymarket/product')->sendProductToAnyMarket($storeID, $product->getId());
|
92 |
+
}
|
93 |
+
|
94 |
+
} catch (Exception $e) {
|
95 |
+
Mage::logException($e);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
// TRATA STOCK
|
100 |
+
if ($product) {
|
101 |
+
if ($typeSincOrder == 1) {
|
102 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
103 |
+
$ProdStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
104 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product->getId(), $ProdStock->getQty(), $product->getData($filter));
|
105 |
+
} else {
|
106 |
+
Mage::helper('db1_anymarket/product')->getStockProductAnyMarket($storeID, $product->getId());
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
111 |
+
$this->removeQueue($item['entity_id']);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* process Orders by CRON
|
119 |
+
*/
|
120 |
+
public function processOrders(){
|
121 |
+
Mage::getSingleton('core/session')->setImportOrdersVariable('false');
|
122 |
+
|
123 |
+
$allStores = Mage::helper('db1_anymarket')->getAllStores();
|
124 |
+
foreach ($allStores as $store) {
|
125 |
+
$storeID = $store['store_id'];
|
126 |
+
|
127 |
+
$cronEnabled = Mage::getStoreConfig('anymarket_section/anymarket_cron_group/anymarket_order_field', $storeID);
|
128 |
+
if( $cronEnabled == '1' ) {
|
129 |
+
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
130 |
+
if ($ConfigOrder == 1) {
|
131 |
+
Mage::helper('db1_anymarket/order')->getFeedOrdersFromAnyMarket($storeID);
|
132 |
+
}
|
133 |
+
|
134 |
+
$colAnyOrders = Mage::getResourceModel('db1_anymarket/anymarketorders_collection')
|
135 |
+
->addFieldToFilter('nmo_status_int', array('like' => 'ERROR%'))
|
136 |
+
->load();
|
137 |
+
|
138 |
+
foreach ($colAnyOrders->getItems() as $anymarketorders) {
|
139 |
+
$anymarketorder = Mage::getModel('db1_anymarket/anymarketorders')->load($anymarketorders->getId());
|
140 |
+
if (is_array($anymarketorder->getData('store_id')) && in_array($storeID, $anymarketorder->getData('store_id'))) {
|
141 |
+
if ($anymarketorders->getData('nmo_status_int') == 'ERROR 01') {
|
142 |
+
$this->addQueue($storeID, $anymarketorder->getNmoIdAnymarket(), 'IMP', 'ORDER');
|
143 |
+
} else if ($anymarketorders->getData('nmo_status_int') == 'ERROR 02') {
|
144 |
+
$this->addQueue($storeID, $anymarketorder->getNmoIdOrder(), 'EXP', 'ORDER');
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
}
|
151 |
+
Mage::getSingleton('core/session')->setImportOrdersVariable('true');
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* process Products By CRON
|
157 |
+
*/
|
158 |
+
public function processProducts(){
|
159 |
+
$allStores = Mage::helper('db1_anymarket')->getAllStores();
|
160 |
+
foreach ($allStores as $store) {
|
161 |
+
$storeID = $store['store_id'];
|
162 |
+
$cronEnabled = Mage::getStoreConfig('anymarket_section/anymarket_cron_group/anymarket_product_field', $storeID);
|
163 |
+
if( $cronEnabled == '1' ) {
|
164 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
165 |
+
if ($typeSincProd == 1) {
|
166 |
+
Mage::helper('db1_anymarket/product')->getFeedProdsFromAnyMarket($storeID);
|
167 |
+
} else {
|
168 |
+
$colAnyProds = Mage::getResourceModel('db1_anymarket/anymarketproducts_collection')
|
169 |
+
->addFieldToFilter('nmp_status_int', array('neq' => 'Integrado'))
|
170 |
+
->load();
|
171 |
+
|
172 |
+
foreach ($colAnyProds->getItems() as $anymarketproducts) {
|
173 |
+
if ($anymarketproducts->getData('nmp_sku') != null) {
|
174 |
+
$anymarketprod = Mage::getModel('db1_anymarket/anymarketproducts')->load($anymarketproducts->getData('nmp_id'), 'nmp_id');
|
175 |
+
if (is_array($anymarketprod->getData('store_id')) && in_array($storeID, $anymarketprod->getData('store_id'))) {
|
176 |
+
|
177 |
+
if($anymarketprod->getData('nmp_status_int') == "Erro" ) {
|
178 |
+
$ProdLoaded = Mage::getModel('catalog/product')->loadByAttribute('sku', $anymarketproducts->getData('nmp_sku'));
|
179 |
+
if ($ProdLoaded) {
|
180 |
+
if (($ProdLoaded->getStatus() == 1) && ($ProdLoaded->getData('integra_anymarket') == 1)) {
|
181 |
+
$this->addQueue($storeID, $anymarketproducts->getData('nmp_id'), 'EXP', 'PRODUCT');
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
}
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* process Clean Logs By CRON
|
197 |
+
*/
|
198 |
+
public function processCleanLogs(){
|
199 |
+
$from = date("Y-m-d H:m:s", strtotime("-3 months"));
|
200 |
+
$to = date("Y-m-d H:m:s", strtotime("-73 years"));
|
201 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketlog_collection')
|
202 |
+
->addFieldToFilter('updated_at', array('from'=> $to, 'to'=> $from ))
|
203 |
+
->load();
|
204 |
+
|
205 |
+
$contLogs = 0;
|
206 |
+
foreach ($collection->getItems() as $anymarketlog) {
|
207 |
+
$anymarketlog->delete();
|
208 |
+
$contLogs += 1;
|
209 |
+
}
|
210 |
+
|
211 |
+
return $contLogs;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* process Reindex by CRON
|
216 |
+
*/
|
217 |
+
public function processReindex()
|
218 |
+
{
|
219 |
+
$allStores = Mage::helper('db1_anymarket')->getAllStores();
|
220 |
+
foreach ($allStores as $store) {
|
221 |
+
$storeID = $store['store_id'];
|
222 |
+
$cronEnabled = Mage::getStoreConfig('anymarket_section/anymarket_cron_group/anymarket_reindex_field', $storeID);
|
223 |
+
if( $cronEnabled == '1' ) {
|
224 |
+
$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
|
225 |
+
foreach ($processes as $process) {
|
226 |
+
if( $process->getData("mode") == "manual" ) {
|
227 |
+
$process->reindexEverything();
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketattributes.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Admin search model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketattributes extends Varien_Object
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Load search results
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketattributes
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function load()
|
34 |
-
{
|
35 |
-
$arr = array();
|
36 |
-
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
-
$this->setResults($arr);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
$collection = Mage::getResourceModel('db1_anymarket/anymarketattributes_collection')
|
41 |
-
->addFieldToFilter('nma_desc', array('like' => $this->getQuery().'%'))
|
42 |
-
->setCurPage($this->getStart())
|
43 |
-
->setPageSize($this->getLimit())
|
44 |
-
->load();
|
45 |
-
foreach ($collection->getItems() as $anymarketattributes) {
|
46 |
-
$arr[] = array(
|
47 |
-
'id' => 'anymarketattributes/1/'.$anymarketattributes->getId(),
|
48 |
-
'type' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'),
|
49 |
-
'name' => $anymarketattributes->getNmaDesc(),
|
50 |
-
'description' => $anymarketattributes->getNmaDesc(),
|
51 |
-
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
-
'*/anymarket_anymarketattributes/edit',
|
53 |
-
array('id'=>$anymarketattributes->getId())
|
54 |
-
),
|
55 |
-
);
|
56 |
-
}
|
57 |
-
$this->setResults($arr);
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Admin search model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketattributes extends Varien_Object
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Load search results
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketattributes
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function load()
|
34 |
+
{
|
35 |
+
$arr = array();
|
36 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
+
$this->setResults($arr);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketattributes_collection')
|
41 |
+
->addFieldToFilter('nma_desc', array('like' => $this->getQuery().'%'))
|
42 |
+
->setCurPage($this->getStart())
|
43 |
+
->setPageSize($this->getLimit())
|
44 |
+
->load();
|
45 |
+
foreach ($collection->getItems() as $anymarketattributes) {
|
46 |
+
$arr[] = array(
|
47 |
+
'id' => 'anymarketattributes/1/'.$anymarketattributes->getId(),
|
48 |
+
'type' => Mage::helper('db1_anymarket')->__('Anymarket Attributes'),
|
49 |
+
'name' => $anymarketattributes->getNmaDesc(),
|
50 |
+
'description' => $anymarketattributes->getNmaDesc(),
|
51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
+
'*/anymarket_anymarketattributes/edit',
|
53 |
+
array('id'=>$anymarketattributes->getId())
|
54 |
+
),
|
55 |
+
);
|
56 |
+
}
|
57 |
+
$this->setResults($arr);
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketbrands.php
ADDED
@@ -0,0 +1,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Admin search model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketbrands extends Varien_Object
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Load search results
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketbrands
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function load()
|
34 |
+
{
|
35 |
+
$arr = array();
|
36 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
+
$this->setResults($arr);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketbrands_collection')
|
41 |
+
->addFieldToFilter('brd_id', array('like' => $this->getQuery().'%'))
|
42 |
+
->setCurPage($this->getStart())
|
43 |
+
->setPageSize($this->getLimit())
|
44 |
+
->load();
|
45 |
+
foreach ($collection->getItems() as $anymarketbrands) {
|
46 |
+
$arr[] = array(
|
47 |
+
'id' => 'anymarketbrands/1/'.$anymarketbrands->getId(),
|
48 |
+
'type' => Mage::helper('db1_anymarket')->__('Anymarketbrands'),
|
49 |
+
'name' => $anymarketbrands->getBrdId(),
|
50 |
+
'description' => $anymarketbrands->getBrdId(),
|
51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
+
'*/anymarket_anymarketbrands/edit',
|
53 |
+
array('id'=>$anymarketbrands->getId())
|
54 |
+
),
|
55 |
+
);
|
56 |
+
}
|
57 |
+
$this->setResults($arr);
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketlog.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Admin search model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketlog extends Varien_Object
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Load search results
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketlog
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
public function load()
|
34 |
-
{
|
35 |
-
$arr = array();
|
36 |
-
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
-
$this->setResults($arr);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
$collection = Mage::getResourceModel('db1_anymarket/anymarketlog_collection')
|
41 |
-
->addFieldToFilter('log_desc', array('like' => $this->getQuery().'%'))
|
42 |
-
->setCurPage($this->getStart())
|
43 |
-
->setPageSize($this->getLimit())
|
44 |
-
->load();
|
45 |
-
foreach ($collection->getItems() as $anymarketlog) {
|
46 |
-
$arr[] = array(
|
47 |
-
'id' => 'anymarketlog/1/'.$anymarketlog->getId(),
|
48 |
-
'type' => Mage::helper('db1_anymarket')->__('AnyMarket Log'),
|
49 |
-
'name' => $anymarketlog->getLogDesc(),
|
50 |
-
'description' => $anymarketlog->getLogDesc(),
|
51 |
-
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
-
'*/anymarket_anymarketlog/edit',
|
53 |
-
array('id'=>$anymarketlog->getId())
|
54 |
-
),
|
55 |
-
);
|
56 |
-
}
|
57 |
-
$this->setResults($arr);
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Admin search model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketlog extends Varien_Object
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Load search results
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketlog
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function load()
|
34 |
+
{
|
35 |
+
$arr = array();
|
36 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
+
$this->setResults($arr);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketlog_collection')
|
41 |
+
->addFieldToFilter('log_desc', array('like' => $this->getQuery().'%'))
|
42 |
+
->setCurPage($this->getStart())
|
43 |
+
->setPageSize($this->getLimit())
|
44 |
+
->load();
|
45 |
+
foreach ($collection->getItems() as $anymarketlog) {
|
46 |
+
$arr[] = array(
|
47 |
+
'id' => 'anymarketlog/1/'.$anymarketlog->getId(),
|
48 |
+
'type' => Mage::helper('db1_anymarket')->__('AnyMarket Log'),
|
49 |
+
'name' => $anymarketlog->getLogDesc(),
|
50 |
+
'description' => $anymarketlog->getLogDesc(),
|
51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
+
'*/anymarket_anymarketlog/edit',
|
53 |
+
array('id'=>$anymarketlog->getId())
|
54 |
+
),
|
55 |
+
);
|
56 |
+
}
|
57 |
+
$this->setResults($arr);
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketorders.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Admin search model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketorders extends Varien_Object
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Load search results
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketorders
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function load()
|
34 |
-
{
|
35 |
-
$arr = array();
|
36 |
-
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
-
$this->setResults($arr);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
$collection = Mage::getResourceModel('db1_anymarket/anymarketorders_collection')
|
41 |
-
->addFieldToFilter('nmo_id_order', array('like' => $this->getQuery().'%'))
|
42 |
-
->setCurPage($this->getStart())
|
43 |
-
->setPageSize($this->getLimit())
|
44 |
-
->load();
|
45 |
-
foreach ($collection->getItems() as $anymarketorders) {
|
46 |
-
$arr[] = array(
|
47 |
-
'id' => 'anymarketorders/1/'.$anymarketorders->getId(),
|
48 |
-
'type' => Mage::helper('db1_anymarket')->__('Anymarket Orders'),
|
49 |
-
'name' => $anymarketorders->getNmoIdOrder(),
|
50 |
-
'description' => $anymarketorders->getNmoIdOrder(),
|
51 |
-
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
-
'*/anymarket_anymarketorders/edit',
|
53 |
-
array('id'=>$anymarketorders->getId())
|
54 |
-
),
|
55 |
-
);
|
56 |
-
}
|
57 |
-
$this->setResults($arr);
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Admin search model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketorders extends Varien_Object
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Load search results
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketorders
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function load()
|
34 |
+
{
|
35 |
+
$arr = array();
|
36 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
+
$this->setResults($arr);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketorders_collection')
|
41 |
+
->addFieldToFilter('nmo_id_order', array('like' => $this->getQuery().'%'))
|
42 |
+
->setCurPage($this->getStart())
|
43 |
+
->setPageSize($this->getLimit())
|
44 |
+
->load();
|
45 |
+
foreach ($collection->getItems() as $anymarketorders) {
|
46 |
+
$arr[] = array(
|
47 |
+
'id' => 'anymarketorders/1/'.$anymarketorders->getId(),
|
48 |
+
'type' => Mage::helper('db1_anymarket')->__('Anymarket Orders'),
|
49 |
+
'name' => $anymarketorders->getNmoIdOrder(),
|
50 |
+
'description' => $anymarketorders->getNmoIdOrder(),
|
51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
+
'*/anymarket_anymarketorders/edit',
|
53 |
+
array('id'=>$anymarketorders->getId())
|
54 |
+
),
|
55 |
+
);
|
56 |
+
}
|
57 |
+
$this->setResults($arr);
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketproducts.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Admin search model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketproducts extends Varien_Object
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Load search results
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketproducts
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
public function load()
|
34 |
-
{
|
35 |
-
$arr = array();
|
36 |
-
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
-
$this->setResults($arr);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
$collection = Mage::getResourceModel('db1_anymarket/anymarketproducts_collection')
|
41 |
-
->addFieldToFilter('nmp_status_int', array('like' => $this->getQuery().'%'))
|
42 |
-
->setCurPage($this->getStart())
|
43 |
-
->setPageSize($this->getLimit())
|
44 |
-
->load();
|
45 |
-
foreach ($collection->getItems() as $anymarketproducts) {
|
46 |
-
$arr[] = array(
|
47 |
-
'id' => 'anymarketproducts/1/'.$anymarketproducts->getId(),
|
48 |
-
'type' => Mage::helper('db1_anymarket')->__('Anymarket Products'),
|
49 |
-
'name' => $anymarketproducts->getNmpStatusInt(),
|
50 |
-
'description' => $anymarketproducts->getNmpStatusInt(),
|
51 |
-
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
-
'*/anymarket_anymarketproducts/edit',
|
53 |
-
array('id'=>$anymarketproducts->getId())
|
54 |
-
),
|
55 |
-
);
|
56 |
-
}
|
57 |
-
$this->setResults($arr);
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Admin search model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketproducts extends Varien_Object
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Load search results
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketproducts
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function load()
|
34 |
+
{
|
35 |
+
$arr = array();
|
36 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
+
$this->setResults($arr);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketproducts_collection')
|
41 |
+
->addFieldToFilter('nmp_status_int', array('like' => $this->getQuery().'%'))
|
42 |
+
->setCurPage($this->getStart())
|
43 |
+
->setPageSize($this->getLimit())
|
44 |
+
->load();
|
45 |
+
foreach ($collection->getItems() as $anymarketproducts) {
|
46 |
+
$arr[] = array(
|
47 |
+
'id' => 'anymarketproducts/1/'.$anymarketproducts->getId(),
|
48 |
+
'type' => Mage::helper('db1_anymarket')->__('Anymarket Products'),
|
49 |
+
'name' => $anymarketproducts->getNmpStatusInt(),
|
50 |
+
'description' => $anymarketproducts->getNmpStatusInt(),
|
51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
+
'*/anymarket_anymarketproducts/edit',
|
53 |
+
array('id'=>$anymarketproducts->getId())
|
54 |
+
),
|
55 |
+
);
|
56 |
+
}
|
57 |
+
$this->setResults($arr);
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketqueue.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Admin search model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
"
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketqueue extends Varien_Object
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Load search results
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketqueue
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function load()
|
34 |
-
{
|
35 |
-
$arr = array();
|
36 |
-
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
-
$this->setResults($arr);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
$collection = Mage::getResourceModel('db1_anymarket/anymarketqueue_collection')
|
41 |
-
->addFieldToFilter('nmq_id', array('like' => $this->getQuery().'%'))
|
42 |
-
->setCurPage($this->getStart())
|
43 |
-
->setPageSize($this->getLimit())
|
44 |
-
->load();
|
45 |
-
foreach ($collection->getItems() as $anymarketqueue) {
|
46 |
-
$arr[] = array(
|
47 |
-
'id' => 'anymarketqueue/1/'.$anymarketqueue->getId(),
|
48 |
-
'type' => Mage::helper('db1_anymarket')->__('Anymarket Queue'),
|
49 |
-
'name' => $anymarketqueue->getNmqId(),
|
50 |
-
'description' => $anymarketqueue->getNmqId(),
|
51 |
-
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
-
'*/anymarket_anymarketqueue/edit',
|
53 |
-
array('id'=>$anymarketqueue->getId())
|
54 |
-
),
|
55 |
-
);
|
56 |
-
}
|
57 |
-
$this->setResults($arr);
|
58 |
-
return $this;
|
59 |
-
}
|
60 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Admin search model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
"
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Adminhtml_Search_Anymarketqueue extends Varien_Object
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Load search results
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketqueue
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function load()
|
34 |
+
{
|
35 |
+
$arr = array();
|
36 |
+
if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
|
37 |
+
$this->setResults($arr);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
$collection = Mage::getResourceModel('db1_anymarket/anymarketqueue_collection')
|
41 |
+
->addFieldToFilter('nmq_id', array('like' => $this->getQuery().'%'))
|
42 |
+
->setCurPage($this->getStart())
|
43 |
+
->setPageSize($this->getLimit())
|
44 |
+
->load();
|
45 |
+
foreach ($collection->getItems() as $anymarketqueue) {
|
46 |
+
$arr[] = array(
|
47 |
+
'id' => 'anymarketqueue/1/'.$anymarketqueue->getId(),
|
48 |
+
'type' => Mage::helper('db1_anymarket')->__('Anymarket Queue'),
|
49 |
+
'name' => $anymarketqueue->getNmqId(),
|
50 |
+
'description' => $anymarketqueue->getNmqId(),
|
51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
52 |
+
'*/anymarket_anymarketqueue/edit',
|
53 |
+
array('id'=>$anymarketqueue->getId())
|
54 |
+
),
|
55 |
+
);
|
56 |
+
}
|
57 |
+
$this->setResults($arr);
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketattributes.php
CHANGED
@@ -1,104 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Anymarketattributes extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Entity code.
|
28 |
-
* Can be used as part of method name for entity processing
|
29 |
-
*/
|
30 |
-
const ENTITY = 'db1_anymarket_anymarketattributes';
|
31 |
-
const CACHE_TAG = 'db1_anymarket_anymarketattributes';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Prefix of model events names
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $_eventPrefix = 'db1_anymarket_anymarketattributes';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Parameter name in event
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_eventObject = 'anymarketattributes';
|
46 |
-
|
47 |
-
/**
|
48 |
-
* constructor
|
49 |
-
*
|
50 |
-
* @access public
|
51 |
-
* @return void
|
52 |
-
|
53 |
-
*/
|
54 |
-
public function _construct()
|
55 |
-
{
|
56 |
-
parent::_construct();
|
57 |
-
$this->_init('db1_anymarket/anymarketattributes');
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* before save anymarket attributes
|
62 |
-
*
|
63 |
-
* @access protected
|
64 |
-
* @return DB1_AnyMarket_Model_Anymarketattributes
|
65 |
-
|
66 |
-
*/
|
67 |
-
protected function _beforeSave()
|
68 |
-
{
|
69 |
-
parent::_beforeSave();
|
70 |
-
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
-
if ($this->isObjectNew()) {
|
72 |
-
$this->setCreatedAt($now);
|
73 |
-
}
|
74 |
-
$this->setUpdatedAt($now);
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* save anymarket attributes relation
|
80 |
-
*
|
81 |
-
* @access public
|
82 |
-
* @return DB1_AnyMarket_Model_Anymarketattributes
|
83 |
-
|
84 |
-
*/
|
85 |
-
protected function _afterSave()
|
86 |
-
{
|
87 |
-
return parent::_afterSave();
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* get default values
|
92 |
-
*
|
93 |
-
* @access public
|
94 |
-
* @return array
|
95 |
-
|
96 |
-
*/
|
97 |
-
public function getDefaultValues()
|
98 |
-
{
|
99 |
-
$values = array();
|
100 |
-
$values['status'] = 1;
|
101 |
-
return $values;
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Anymarketattributes extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entity code.
|
28 |
+
* Can be used as part of method name for entity processing
|
29 |
+
*/
|
30 |
+
const ENTITY = 'db1_anymarket_anymarketattributes';
|
31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketattributes';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Prefix of model events names
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketattributes';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Parameter name in event
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventObject = 'anymarketattributes';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* constructor
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return void
|
52 |
+
|
53 |
+
*/
|
54 |
+
public function _construct()
|
55 |
+
{
|
56 |
+
parent::_construct();
|
57 |
+
$this->_init('db1_anymarket/anymarketattributes');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* before save anymarket attributes
|
62 |
+
*
|
63 |
+
* @access protected
|
64 |
+
* @return DB1_AnyMarket_Model_Anymarketattributes
|
65 |
+
|
66 |
+
*/
|
67 |
+
protected function _beforeSave()
|
68 |
+
{
|
69 |
+
parent::_beforeSave();
|
70 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
+
if ($this->isObjectNew()) {
|
72 |
+
$this->setCreatedAt($now);
|
73 |
+
}
|
74 |
+
$this->setUpdatedAt($now);
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* save anymarket attributes relation
|
80 |
+
*
|
81 |
+
* @access public
|
82 |
+
* @return DB1_AnyMarket_Model_Anymarketattributes
|
83 |
+
|
84 |
+
*/
|
85 |
+
protected function _afterSave()
|
86 |
+
{
|
87 |
+
return parent::_afterSave();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get default values
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @return array
|
95 |
+
|
96 |
+
*/
|
97 |
+
public function getDefaultValues()
|
98 |
+
{
|
99 |
+
$values = array();
|
100 |
+
$values['status'] = 1;
|
101 |
+
return $values;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketattributes_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
-
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* init anymarket attributes
|
23 |
-
*
|
24 |
-
* @access protected
|
25 |
-
* @param $anymarketattributesId
|
26 |
-
* @return DB1_AnyMarket_Model_Anymarketattributes
|
27 |
-
|
28 |
-
*/
|
29 |
-
protected function _initAnymarketattributes($anymarketattributesId)
|
30 |
-
{
|
31 |
-
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes')->load($anymarketattributesId);
|
32 |
-
if (!$anymarketattributes->getId()) {
|
33 |
-
$this->_fault('anymarketattributes_not_exists');
|
34 |
-
}
|
35 |
-
return $anymarketattributes;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* get anymarket attributes
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param mixed $filters
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function items($filters = null)
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketattributes')->getCollection();
|
49 |
-
$apiHelper = Mage::helper('api');
|
50 |
-
$filters = $apiHelper->parseFilters($filters);
|
51 |
-
try {
|
52 |
-
foreach ($filters as $field => $value) {
|
53 |
-
$collection->addFieldToFilter($field, $value);
|
54 |
-
}
|
55 |
-
} catch (Mage_Core_Exception $e) {
|
56 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
-
}
|
58 |
-
$result = array();
|
59 |
-
foreach ($collection as $anymarketattributes) {
|
60 |
-
$result[] = $this->_getApiData($anymarketattributes);
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Add anymarket attributes
|
67 |
-
*
|
68 |
-
* @access public
|
69 |
-
* @param array $data
|
70 |
-
* @return array
|
71 |
-
|
72 |
-
*/
|
73 |
-
public function add($data)
|
74 |
-
{
|
75 |
-
try {
|
76 |
-
if (is_null($data)) {
|
77 |
-
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
-
}
|
79 |
-
$data = (array)$data;
|
80 |
-
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes')
|
81 |
-
->setData((array)$data)
|
82 |
-
->save();
|
83 |
-
} catch (Mage_Core_Exception $e) {
|
84 |
-
$this->_fault('data_invalid', $e->getMessage());
|
85 |
-
} catch (Exception $e) {
|
86 |
-
$this->_fault('data_invalid', $e->getMessage());
|
87 |
-
}
|
88 |
-
return $anymarketattributes->getId();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Change existing anymarket attributes information
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param int $anymarketattributesId
|
96 |
-
* @param array $data
|
97 |
-
* @return bool
|
98 |
-
|
99 |
-
*/
|
100 |
-
public function update($anymarketattributesId, $data)
|
101 |
-
{
|
102 |
-
$anymarketattributes = $this->_initAnymarketattributes($anymarketattributesId);
|
103 |
-
try {
|
104 |
-
$data = (array)$data;
|
105 |
-
$anymarketattributes->addData($data);
|
106 |
-
$anymarketattributes->save();
|
107 |
-
}
|
108 |
-
catch (Mage_Core_Exception $e) {
|
109 |
-
$this->_fault('save_error', $e->getMessage());
|
110 |
-
}
|
111 |
-
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* remove anymarket attributes
|
117 |
-
*
|
118 |
-
* @access public
|
119 |
-
* @param int $anymarketattributesId
|
120 |
-
* @return bool
|
121 |
-
|
122 |
-
*/
|
123 |
-
public function remove($anymarketattributesId)
|
124 |
-
{
|
125 |
-
$anymarketattributes = $this->_initAnymarketattributes($anymarketattributesId);
|
126 |
-
try {
|
127 |
-
$anymarketattributes->delete();
|
128 |
-
} catch (Mage_Core_Exception $e) {
|
129 |
-
$this->_fault('remove_error', $e->getMessage());
|
130 |
-
}
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* get info
|
136 |
-
*
|
137 |
-
* @access public
|
138 |
-
* @param int $anymarketattributesId
|
139 |
-
* @return array
|
140 |
-
|
141 |
-
*/
|
142 |
-
public function info($anymarketattributesId)
|
143 |
-
{
|
144 |
-
$result = array();
|
145 |
-
$anymarketattributes = $this->_initAnymarketattributes($anymarketattributesId);
|
146 |
-
$result = $this->_getApiData($anymarketattributes);
|
147 |
-
return $result;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* get data for api
|
152 |
-
*
|
153 |
-
* @access protected
|
154 |
-
* @param DB1_AnyMarket_Model_Anymarketattributes $anymarketattributes
|
155 |
-
* @return array()
|
156 |
-
|
157 |
-
*/
|
158 |
-
protected function _getApiData(DB1_AnyMarket_Model_Anymarketattributes $anymarketattributes)
|
159 |
-
{
|
160 |
-
return $anymarketattributes->getData();
|
161 |
-
}
|
162 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketattributes_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarket attributes
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketattributesId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketattributes
|
27 |
+
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketattributes($anymarketattributesId)
|
30 |
+
{
|
31 |
+
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes')->load($anymarketattributesId);
|
32 |
+
if (!$anymarketattributes->getId()) {
|
33 |
+
$this->_fault('anymarketattributes_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketattributes;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarket attributes
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketattributes')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketattributes) {
|
60 |
+
$result[] = $this->_getApiData($anymarketattributes);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarket attributes
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketattributes->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarket attributes information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketattributesId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
|
99 |
+
*/
|
100 |
+
public function update($anymarketattributesId, $data)
|
101 |
+
{
|
102 |
+
$anymarketattributes = $this->_initAnymarketattributes($anymarketattributesId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketattributes->addData($data);
|
106 |
+
$anymarketattributes->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarket attributes
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketattributesId
|
120 |
+
* @return bool
|
121 |
+
|
122 |
+
*/
|
123 |
+
public function remove($anymarketattributesId)
|
124 |
+
{
|
125 |
+
$anymarketattributes = $this->_initAnymarketattributes($anymarketattributesId);
|
126 |
+
try {
|
127 |
+
$anymarketattributes->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketattributesId
|
139 |
+
* @return array
|
140 |
+
|
141 |
+
*/
|
142 |
+
public function info($anymarketattributesId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketattributes = $this->_initAnymarketattributes($anymarketattributesId);
|
146 |
+
$result = $this->_getApiData($anymarketattributes);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketattributes $anymarketattributes
|
155 |
+
* @return array()
|
156 |
+
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketattributes $anymarketattributes)
|
159 |
+
{
|
160 |
+
return $anymarketattributes->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api/V2.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketattributes_Api_V2 extends DB1_AnyMarket_Model_Anymarketattributes_Api
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Anymarket Attributes info
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @param int $anymarketattributesId
|
24 |
-
* @return object
|
25 |
-
|
26 |
-
*/
|
27 |
-
public function info($anymarketattributesId)
|
28 |
-
{
|
29 |
-
$result = parent::info($anymarketattributesId);
|
30 |
-
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
-
return $result;
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketattributes_Api_V2 extends DB1_AnyMarket_Model_Anymarketattributes_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Anymarket Attributes info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketattributesId
|
24 |
+
* @return object
|
25 |
+
|
26 |
+
*/
|
27 |
+
public function info($anymarketattributesId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketattributesId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketbrands.php
ADDED
@@ -0,0 +1,104 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Anymarketbrands extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entity code.
|
28 |
+
* Can be used as part of method name for entity processing
|
29 |
+
*/
|
30 |
+
const ENTITY = 'db1_anymarket_anymarketbrands';
|
31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketbrands';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Prefix of model events names
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketbrands';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Parameter name in event
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventObject = 'anymarketbrands';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* constructor
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return void
|
52 |
+
|
53 |
+
*/
|
54 |
+
public function _construct()
|
55 |
+
{
|
56 |
+
parent::_construct();
|
57 |
+
$this->_init('db1_anymarket/anymarketbrands');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* before save anymarketbrands
|
62 |
+
*
|
63 |
+
* @access protected
|
64 |
+
* @return DB1_AnyMarket_Model_Anymarketbrands
|
65 |
+
|
66 |
+
*/
|
67 |
+
protected function _beforeSave()
|
68 |
+
{
|
69 |
+
parent::_beforeSave();
|
70 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
+
if ($this->isObjectNew()) {
|
72 |
+
$this->setCreatedAt($now);
|
73 |
+
}
|
74 |
+
$this->setUpdatedAt($now);
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* save anymarketbrands relation
|
80 |
+
*
|
81 |
+
* @access public
|
82 |
+
* @return DB1_AnyMarket_Model_Anymarketbrands
|
83 |
+
|
84 |
+
*/
|
85 |
+
protected function _afterSave()
|
86 |
+
{
|
87 |
+
return parent::_afterSave();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get default values
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @return array
|
95 |
+
|
96 |
+
*/
|
97 |
+
public function getDefaultValues()
|
98 |
+
{
|
99 |
+
$values = array();
|
100 |
+
$values['status'] = 1;
|
101 |
+
return $values;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api.php
ADDED
@@ -0,0 +1,162 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketbrands_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarketbrands
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketbrandsId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketbrands
|
27 |
+
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketbrands($anymarketbrandsId)
|
30 |
+
{
|
31 |
+
$anymarketbrands = Mage::getModel('db1_anymarket/anymarketbrands')->load($anymarketbrandsId);
|
32 |
+
if (!$anymarketbrands->getId()) {
|
33 |
+
$this->_fault('anymarketbrands_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketbrands;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarketbrand
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketbrands')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketbrands) {
|
60 |
+
$result[] = $this->_getApiData($anymarketbrands);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarketbrands
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketbrands = Mage::getModel('db1_anymarket/anymarketbrands')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketbrands->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarketbrands information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketbrandsId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
|
99 |
+
*/
|
100 |
+
public function update($anymarketbrandsId, $data)
|
101 |
+
{
|
102 |
+
$anymarketbrands = $this->_initAnymarketbrands($anymarketbrandsId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketbrands->addData($data);
|
106 |
+
$anymarketbrands->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarketbrands
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketbrandsId
|
120 |
+
* @return bool
|
121 |
+
|
122 |
+
*/
|
123 |
+
public function remove($anymarketbrandsId)
|
124 |
+
{
|
125 |
+
$anymarketbrands = $this->_initAnymarketbrands($anymarketbrandsId);
|
126 |
+
try {
|
127 |
+
$anymarketbrands->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketbrandsId
|
139 |
+
* @return array
|
140 |
+
|
141 |
+
*/
|
142 |
+
public function info($anymarketbrandsId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketbrands = $this->_initAnymarketbrands($anymarketbrandsId);
|
146 |
+
$result = $this->_getApiData($anymarketbrands);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketbrands $anymarketbrands
|
155 |
+
* @return array()
|
156 |
+
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketbrands $anymarketbrands)
|
159 |
+
{
|
160 |
+
return $anymarketbrands->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api/V2.php
ADDED
@@ -0,0 +1,33 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketbrands_Api_V2 extends DB1_AnyMarket_Model_Anymarketbrands_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Anymarketbrands info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketbrandsId
|
24 |
+
* @return object
|
25 |
+
|
26 |
+
*/
|
27 |
+
public function info($anymarketbrandsId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketbrandsId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketcategories.php
CHANGED
@@ -1,104 +1,115 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Anymarketcategories extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Entity code.
|
28 |
-
* Can be used as part of method name for entity processing
|
29 |
-
*/
|
30 |
-
const ENTITY = 'db1_anymarket_anymarketcategories';
|
31 |
-
const CACHE_TAG = 'db1_anymarket_anymarketcategories';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Prefix of model events names
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $_eventPrefix = 'db1_anymarket_anymarketcategories';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Parameter name in event
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_eventObject = 'anymarketcategories';
|
46 |
-
|
47 |
-
/**
|
48 |
-
* constructor
|
49 |
-
*
|
50 |
-
* @access public
|
51 |
-
* @return void
|
52 |
-
|
53 |
-
*/
|
54 |
-
public function _construct()
|
55 |
-
{
|
56 |
-
parent::_construct();
|
57 |
-
$this->_init('db1_anymarket/anymarketcategories');
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* before save anymarket categories
|
62 |
-
*
|
63 |
-
* @access protected
|
64 |
-
* @return DB1_AnyMarket_Model_Anymarketcategories
|
65 |
-
|
66 |
-
*/
|
67 |
-
protected function _beforeSave()
|
68 |
-
{
|
69 |
-
parent::_beforeSave();
|
70 |
-
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
-
if ($this->isObjectNew()) {
|
72 |
-
$this->setCreatedAt($now);
|
73 |
-
}
|
74 |
-
$this->setUpdatedAt($now);
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* save anymarket categories relation
|
80 |
-
*
|
81 |
-
* @access public
|
82 |
-
* @return DB1_AnyMarket_Model_Anymarketcategories
|
83 |
-
|
84 |
-
*/
|
85 |
-
protected function _afterSave()
|
86 |
-
{
|
87 |
-
return parent::_afterSave();
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* get default values
|
92 |
-
*
|
93 |
-
* @access public
|
94 |
-
* @return array
|
95 |
-
|
96 |
-
*/
|
97 |
-
public function getDefaultValues()
|
98 |
-
{
|
99 |
-
$values = array();
|
100 |
-
$values['status'] = 1;
|
101 |
-
return $values;
|
102 |
-
}
|
103 |
-
|
104 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Anymarketcategories extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entity code.
|
28 |
+
* Can be used as part of method name for entity processing
|
29 |
+
*/
|
30 |
+
const ENTITY = 'db1_anymarket_anymarketcategories';
|
31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketcategories';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Prefix of model events names
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketcategories';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Parameter name in event
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventObject = 'anymarketcategories';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* constructor
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return void
|
52 |
+
|
53 |
+
*/
|
54 |
+
public function _construct()
|
55 |
+
{
|
56 |
+
parent::_construct();
|
57 |
+
$this->_init('db1_anymarket/anymarketcategories');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* before save anymarket categories
|
62 |
+
*
|
63 |
+
* @access protected
|
64 |
+
* @return DB1_AnyMarket_Model_Anymarketcategories
|
65 |
+
|
66 |
+
*/
|
67 |
+
protected function _beforeSave()
|
68 |
+
{
|
69 |
+
parent::_beforeSave();
|
70 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
+
if ($this->isObjectNew()) {
|
72 |
+
$this->setCreatedAt($now);
|
73 |
+
}
|
74 |
+
$this->setUpdatedAt($now);
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* save anymarket categories relation
|
80 |
+
*
|
81 |
+
* @access public
|
82 |
+
* @return DB1_AnyMarket_Model_Anymarketcategories
|
83 |
+
|
84 |
+
*/
|
85 |
+
protected function _afterSave()
|
86 |
+
{
|
87 |
+
return parent::_afterSave();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get default values
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @return array
|
95 |
+
|
96 |
+
*/
|
97 |
+
public function getDefaultValues()
|
98 |
+
{
|
99 |
+
$values = array();
|
100 |
+
$values['status'] = 1;
|
101 |
+
return $values;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Load Specific By IDMagento
|
106 |
+
*
|
107 |
+
* @access public
|
108 |
+
* @return Object
|
109 |
+
*
|
110 |
+
*/
|
111 |
+
public function loadByNmcIdMagento($idMG){
|
112 |
+
return $this->getCollection()->addFieldToFilter('nmc_id_magento', $idMG);
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketcategories_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
-
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* init anymarket categories
|
23 |
-
*
|
24 |
-
* @access protected
|
25 |
-
* @param $anymarketcategoriesId
|
26 |
-
* @return DB1_AnyMarket_Model_Anymarketcategories
|
27 |
-
|
28 |
-
*/
|
29 |
-
protected function _initAnymarketcategories($anymarketcategoriesId)
|
30 |
-
{
|
31 |
-
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories')->load($anymarketcategoriesId);
|
32 |
-
if (!$anymarketcategories->getId()) {
|
33 |
-
$this->_fault('anymarketcategories_not_exists');
|
34 |
-
}
|
35 |
-
return $anymarketcategories;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* get anymarket categories
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param mixed $filters
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function items($filters = null)
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection();
|
49 |
-
$apiHelper = Mage::helper('api');
|
50 |
-
$filters = $apiHelper->parseFilters($filters);
|
51 |
-
try {
|
52 |
-
foreach ($filters as $field => $value) {
|
53 |
-
$collection->addFieldToFilter($field, $value);
|
54 |
-
}
|
55 |
-
} catch (Mage_Core_Exception $e) {
|
56 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
-
}
|
58 |
-
$result = array();
|
59 |
-
foreach ($collection as $anymarketcategories) {
|
60 |
-
$result[] = $this->_getApiData($anymarketcategories);
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Add anymarket categories
|
67 |
-
*
|
68 |
-
* @access public
|
69 |
-
* @param array $data
|
70 |
-
* @return array
|
71 |
-
|
72 |
-
*/
|
73 |
-
public function add($data)
|
74 |
-
{
|
75 |
-
try {
|
76 |
-
if (is_null($data)) {
|
77 |
-
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
-
}
|
79 |
-
$data = (array)$data;
|
80 |
-
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories')
|
81 |
-
->setData((array)$data)
|
82 |
-
->save();
|
83 |
-
} catch (Mage_Core_Exception $e) {
|
84 |
-
$this->_fault('data_invalid', $e->getMessage());
|
85 |
-
} catch (Exception $e) {
|
86 |
-
$this->_fault('data_invalid', $e->getMessage());
|
87 |
-
}
|
88 |
-
return $anymarketcategories->getId();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Change existing anymarket categories information
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param int $anymarketcategoriesId
|
96 |
-
* @param array $data
|
97 |
-
* @return bool
|
98 |
-
|
99 |
-
*/
|
100 |
-
public function update($anymarketcategoriesId, $data)
|
101 |
-
{
|
102 |
-
$anymarketcategories = $this->_initAnymarketcategories($anymarketcategoriesId);
|
103 |
-
try {
|
104 |
-
$data = (array)$data;
|
105 |
-
$anymarketcategories->addData($data);
|
106 |
-
$anymarketcategories->save();
|
107 |
-
}
|
108 |
-
catch (Mage_Core_Exception $e) {
|
109 |
-
$this->_fault('save_error', $e->getMessage());
|
110 |
-
}
|
111 |
-
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* remove anymarket categories
|
117 |
-
*
|
118 |
-
* @access public
|
119 |
-
* @param int $anymarketcategoriesId
|
120 |
-
* @return bool
|
121 |
-
|
122 |
-
*/
|
123 |
-
public function remove($anymarketcategoriesId)
|
124 |
-
{
|
125 |
-
$anymarketcategories = $this->_initAnymarketcategories($anymarketcategoriesId);
|
126 |
-
try {
|
127 |
-
$anymarketcategories->delete();
|
128 |
-
} catch (Mage_Core_Exception $e) {
|
129 |
-
$this->_fault('remove_error', $e->getMessage());
|
130 |
-
}
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* get info
|
136 |
-
*
|
137 |
-
* @access public
|
138 |
-
* @param int $anymarketcategoriesId
|
139 |
-
* @return array
|
140 |
-
|
141 |
-
*/
|
142 |
-
public function info($anymarketcategoriesId)
|
143 |
-
{
|
144 |
-
$result = array();
|
145 |
-
$anymarketcategories = $this->_initAnymarketcategories($anymarketcategoriesId);
|
146 |
-
$result = $this->_getApiData($anymarketcategories);
|
147 |
-
return $result;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* get data for api
|
152 |
-
*
|
153 |
-
* @access protected
|
154 |
-
* @param DB1_AnyMarket_Model_Anymarketcategories $anymarketcategories
|
155 |
-
* @return array()
|
156 |
-
|
157 |
-
*/
|
158 |
-
protected function _getApiData(DB1_AnyMarket_Model_Anymarketcategories $anymarketcategories)
|
159 |
-
{
|
160 |
-
return $anymarketcategories->getData();
|
161 |
-
}
|
162 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketcategories_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarket categories
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketcategoriesId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketcategories
|
27 |
+
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketcategories($anymarketcategoriesId)
|
30 |
+
{
|
31 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories')->load($anymarketcategoriesId);
|
32 |
+
if (!$anymarketcategories->getId()) {
|
33 |
+
$this->_fault('anymarketcategories_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketcategories;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarket categories
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketcategories) {
|
60 |
+
$result[] = $this->_getApiData($anymarketcategories);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarket categories
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketcategories = Mage::getModel('db1_anymarket/anymarketcategories')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketcategories->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarket categories information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketcategoriesId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
|
99 |
+
*/
|
100 |
+
public function update($anymarketcategoriesId, $data)
|
101 |
+
{
|
102 |
+
$anymarketcategories = $this->_initAnymarketcategories($anymarketcategoriesId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketcategories->addData($data);
|
106 |
+
$anymarketcategories->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarket categories
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketcategoriesId
|
120 |
+
* @return bool
|
121 |
+
|
122 |
+
*/
|
123 |
+
public function remove($anymarketcategoriesId)
|
124 |
+
{
|
125 |
+
$anymarketcategories = $this->_initAnymarketcategories($anymarketcategoriesId);
|
126 |
+
try {
|
127 |
+
$anymarketcategories->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketcategoriesId
|
139 |
+
* @return array
|
140 |
+
|
141 |
+
*/
|
142 |
+
public function info($anymarketcategoriesId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketcategories = $this->_initAnymarketcategories($anymarketcategoriesId);
|
146 |
+
$result = $this->_getApiData($anymarketcategories);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketcategories $anymarketcategories
|
155 |
+
* @return array()
|
156 |
+
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketcategories $anymarketcategories)
|
159 |
+
{
|
160 |
+
return $anymarketcategories->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api/V2.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketcategories_Api_V2 extends DB1_AnyMarket_Model_Anymarketcategories_Api
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Anymarket Categories info
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @param int $anymarketcategoriesId
|
24 |
-
* @return object
|
25 |
-
|
26 |
-
*/
|
27 |
-
public function info($anymarketcategoriesId)
|
28 |
-
{
|
29 |
-
$result = parent::info($anymarketcategoriesId);
|
30 |
-
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
-
return $result;
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketcategories_Api_V2 extends DB1_AnyMarket_Model_Anymarketcategories_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Anymarket Categories info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketcategoriesId
|
24 |
+
* @return object
|
25 |
+
|
26 |
+
*/
|
27 |
+
public function info($anymarketcategoriesId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketcategoriesId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketlog.php
CHANGED
@@ -1,104 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Anymarketlog extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Entity code.
|
28 |
-
* Can be used as part of method name for entity processing
|
29 |
-
*/
|
30 |
-
const ENTITY = 'db1_anymarket_anymarketlog';
|
31 |
-
const CACHE_TAG = 'db1_anymarket_anymarketlog';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Prefix of model events names
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $_eventPrefix = 'db1_anymarket_anymarketlog';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Parameter name in event
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_eventObject = 'anymarketlog';
|
46 |
-
|
47 |
-
/**
|
48 |
-
* constructor
|
49 |
-
*
|
50 |
-
* @access public
|
51 |
-
* @return void
|
52 |
-
*
|
53 |
-
*/
|
54 |
-
public function _construct()
|
55 |
-
{
|
56 |
-
parent::_construct();
|
57 |
-
$this->_init('db1_anymarket/anymarketlog');
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* before save anymarket log
|
62 |
-
*
|
63 |
-
* @access protected
|
64 |
-
* @return DB1_AnyMarket_Model_Anymarketlog
|
65 |
-
*
|
66 |
-
*/
|
67 |
-
protected function _beforeSave()
|
68 |
-
{
|
69 |
-
parent::_beforeSave();
|
70 |
-
|
71 |
-
if ($this->
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Anymarketlog extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entity code.
|
28 |
+
* Can be used as part of method name for entity processing
|
29 |
+
*/
|
30 |
+
const ENTITY = 'db1_anymarket_anymarketlog';
|
31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketlog';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Prefix of model events names
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketlog';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Parameter name in event
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventObject = 'anymarketlog';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* constructor
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return void
|
52 |
+
*
|
53 |
+
*/
|
54 |
+
public function _construct()
|
55 |
+
{
|
56 |
+
parent::_construct();
|
57 |
+
$this->_init('db1_anymarket/anymarketlog');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* before save anymarket log
|
62 |
+
*
|
63 |
+
* @access protected
|
64 |
+
* @return DB1_AnyMarket_Model_Anymarketlog
|
65 |
+
*
|
66 |
+
*/
|
67 |
+
protected function _beforeSave()
|
68 |
+
{
|
69 |
+
parent::_beforeSave();
|
70 |
+
|
71 |
+
if( strpos($this->getLogDesc(), "Error Curl: <url> malformed") === false ) {
|
72 |
+
|
73 |
+
$stores = $this->getStores();
|
74 |
+
if( $stores != null) {
|
75 |
+
if (is_array($stores)) {
|
76 |
+
$storeID = reset($stores);
|
77 |
+
}
|
78 |
+
|
79 |
+
$nivelLogs = Mage::getStoreConfig('anymarket_section/anymarket_logs_group/anymarket_log_nivel_field', $storeID);
|
80 |
+
if ((int)$nivelLogs == 0) {
|
81 |
+
$this->_dataSaveAllowed = false;
|
82 |
+
} elseif ((int)$nivelLogs == 1) {
|
83 |
+
if ((int)$this->getStatus() == 1) {
|
84 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
85 |
+
if ($this->isObjectNew()) {
|
86 |
+
$this->setCreatedAt($now);
|
87 |
+
}
|
88 |
+
$this->setUpdatedAt($now);
|
89 |
+
} else {
|
90 |
+
$this->_dataSaveAllowed = false;
|
91 |
+
}
|
92 |
+
} else {
|
93 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
94 |
+
if ($this->isObjectNew()) {
|
95 |
+
$this->setCreatedAt($now);
|
96 |
+
}
|
97 |
+
$this->setUpdatedAt($now);
|
98 |
+
}
|
99 |
+
}else{
|
100 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
101 |
+
if ($this->isObjectNew()) {
|
102 |
+
$this->setCreatedAt($now);
|
103 |
+
}
|
104 |
+
$this->setUpdatedAt($now);
|
105 |
+
}
|
106 |
+
}else {
|
107 |
+
$this->_dataSaveAllowed = false;
|
108 |
+
}
|
109 |
+
return $this;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* save anymarket log relation
|
114 |
+
*
|
115 |
+
* @access public
|
116 |
+
* @return DB1_AnyMarket_Model_Anymarketlog
|
117 |
+
*
|
118 |
+
*/
|
119 |
+
protected function _afterSave()
|
120 |
+
{
|
121 |
+
return parent::_afterSave();
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* get default values
|
126 |
+
*
|
127 |
+
* @access public
|
128 |
+
* @return array
|
129 |
+
*
|
130 |
+
*/
|
131 |
+
public function getDefaultValues()
|
132 |
+
{
|
133 |
+
$values = array();
|
134 |
+
$values['status'] = 1;
|
135 |
+
return $values;
|
136 |
+
}
|
137 |
+
|
138 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketlog_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
-
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* init anymarket log
|
23 |
-
*
|
24 |
-
* @access protected
|
25 |
-
* @param $anymarketlogId
|
26 |
-
* @return DB1_AnyMarket_Model_Anymarketlog
|
27 |
-
|
28 |
-
*/
|
29 |
-
protected function _initAnymarketlog($anymarketlogId)
|
30 |
-
{
|
31 |
-
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog')->load($anymarketlogId);
|
32 |
-
if (!$anymarketlog->getId()) {
|
33 |
-
$this->_fault('anymarketlog_not_exists');
|
34 |
-
}
|
35 |
-
return $anymarketlog;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* get anymarket log
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param mixed $filters
|
43 |
-
* @return array
|
44 |
-
*
|
45 |
-
*/
|
46 |
-
public function items($filters = null)
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketlog')->getCollection();
|
49 |
-
$apiHelper = Mage::helper('api');
|
50 |
-
$filters = $apiHelper->parseFilters($filters);
|
51 |
-
try {
|
52 |
-
foreach ($filters as $field => $value) {
|
53 |
-
$collection->addFieldToFilter($field, $value);
|
54 |
-
}
|
55 |
-
} catch (Mage_Core_Exception $e) {
|
56 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
-
}
|
58 |
-
$result = array();
|
59 |
-
foreach ($collection as $anymarketlog) {
|
60 |
-
$result[] = $this->_getApiData($anymarketlog);
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Add anymarket log
|
67 |
-
*
|
68 |
-
* @access public
|
69 |
-
* @param array $data
|
70 |
-
* @return array
|
71 |
-
*
|
72 |
-
*/
|
73 |
-
public function add($data)
|
74 |
-
{
|
75 |
-
try {
|
76 |
-
if (is_null($data)) {
|
77 |
-
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
-
}
|
79 |
-
$data = (array)$data;
|
80 |
-
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog')
|
81 |
-
->setData((array)$data)
|
82 |
-
->save();
|
83 |
-
} catch (Mage_Core_Exception $e) {
|
84 |
-
$this->_fault('data_invalid', $e->getMessage());
|
85 |
-
} catch (Exception $e) {
|
86 |
-
$this->_fault('data_invalid', $e->getMessage());
|
87 |
-
}
|
88 |
-
return $anymarketlog->getId();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Change existing anymarket log information
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param int $anymarketlogId
|
96 |
-
* @param array $data
|
97 |
-
* @return bool
|
98 |
-
*
|
99 |
-
*/
|
100 |
-
public function update($anymarketlogId, $data)
|
101 |
-
{
|
102 |
-
$anymarketlog = $this->_initAnymarketlog($anymarketlogId);
|
103 |
-
try {
|
104 |
-
$data = (array)$data;
|
105 |
-
$anymarketlog->addData($data);
|
106 |
-
$anymarketlog->save();
|
107 |
-
}
|
108 |
-
catch (Mage_Core_Exception $e) {
|
109 |
-
$this->_fault('save_error', $e->getMessage());
|
110 |
-
}
|
111 |
-
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* remove anymarket log
|
117 |
-
*
|
118 |
-
* @access public
|
119 |
-
* @param int $anymarketlogId
|
120 |
-
* @return bool
|
121 |
-
*
|
122 |
-
*/
|
123 |
-
public function remove($anymarketlogId)
|
124 |
-
{
|
125 |
-
$anymarketlog = $this->_initAnymarketlog($anymarketlogId);
|
126 |
-
try {
|
127 |
-
$anymarketlog->delete();
|
128 |
-
} catch (Mage_Core_Exception $e) {
|
129 |
-
$this->_fault('remove_error', $e->getMessage());
|
130 |
-
}
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* get info
|
136 |
-
*
|
137 |
-
* @access public
|
138 |
-
* @param int $anymarketlogId
|
139 |
-
* @return array
|
140 |
-
*
|
141 |
-
*/
|
142 |
-
public function info($anymarketlogId)
|
143 |
-
{
|
144 |
-
$result = array();
|
145 |
-
$anymarketlog = $this->_initAnymarketlog($anymarketlogId);
|
146 |
-
$result = $this->_getApiData($anymarketlog);
|
147 |
-
return $result;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* get data for api
|
152 |
-
*
|
153 |
-
* @access protected
|
154 |
-
* @param DB1_AnyMarket_Model_Anymarketlog $anymarketlog
|
155 |
-
* @return array()
|
156 |
-
*
|
157 |
-
*/
|
158 |
-
protected function _getApiData(DB1_AnyMarket_Model_Anymarketlog $anymarketlog)
|
159 |
-
{
|
160 |
-
return $anymarketlog->getData();
|
161 |
-
}
|
162 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketlog_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarket log
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketlogId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketlog
|
27 |
+
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketlog($anymarketlogId)
|
30 |
+
{
|
31 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog')->load($anymarketlogId);
|
32 |
+
if (!$anymarketlog->getId()) {
|
33 |
+
$this->_fault('anymarketlog_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketlog;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarket log
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketlog')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketlog) {
|
60 |
+
$result[] = $this->_getApiData($anymarketlog);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarket log
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
*
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketlog->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarket log information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketlogId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
*
|
99 |
+
*/
|
100 |
+
public function update($anymarketlogId, $data)
|
101 |
+
{
|
102 |
+
$anymarketlog = $this->_initAnymarketlog($anymarketlogId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketlog->addData($data);
|
106 |
+
$anymarketlog->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarket log
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketlogId
|
120 |
+
* @return bool
|
121 |
+
*
|
122 |
+
*/
|
123 |
+
public function remove($anymarketlogId)
|
124 |
+
{
|
125 |
+
$anymarketlog = $this->_initAnymarketlog($anymarketlogId);
|
126 |
+
try {
|
127 |
+
$anymarketlog->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketlogId
|
139 |
+
* @return array
|
140 |
+
*
|
141 |
+
*/
|
142 |
+
public function info($anymarketlogId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketlog = $this->_initAnymarketlog($anymarketlogId);
|
146 |
+
$result = $this->_getApiData($anymarketlog);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketlog $anymarketlog
|
155 |
+
* @return array()
|
156 |
+
*
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketlog $anymarketlog)
|
159 |
+
{
|
160 |
+
return $anymarketlog->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api/V2.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketlog_Api_V2 extends DB1_AnyMarket_Model_Anymarketlog_Api
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* AnyMarket Log info
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @param int $anymarketlogId
|
24 |
-
* @return object
|
25 |
-
*
|
26 |
-
*/
|
27 |
-
public function info($anymarketlogId)
|
28 |
-
{
|
29 |
-
$result = parent::info($anymarketlogId);
|
30 |
-
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
-
return $result;
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketlog_Api_V2 extends DB1_AnyMarket_Model_Anymarketlog_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* AnyMarket Log info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketlogId
|
24 |
+
* @return object
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
public function info($anymarketlogId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketlogId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketorders.php
CHANGED
@@ -1,104 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Anymarketorders extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Entity code.
|
28 |
-
* Can be used as part of method name for entity processing
|
29 |
-
*/
|
30 |
-
const ENTITY = 'db1_anymarket_anymarketorders';
|
31 |
-
const CACHE_TAG = 'db1_anymarket_anymarketorders';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Prefix of model events names
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $_eventPrefix = 'db1_anymarket_anymarketorders';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Parameter name in event
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_eventObject = 'anymarketorders';
|
46 |
-
|
47 |
-
/**
|
48 |
-
* constructor
|
49 |
-
*
|
50 |
-
* @access public
|
51 |
-
* @return void
|
52 |
-
|
53 |
-
*/
|
54 |
-
public function _construct()
|
55 |
-
{
|
56 |
-
parent::_construct();
|
57 |
-
$this->_init('db1_anymarket/anymarketorders');
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* before save anymarket orders
|
62 |
-
*
|
63 |
-
* @access protected
|
64 |
-
* @return DB1_AnyMarket_Model_Anymarketorders
|
65 |
-
|
66 |
-
*/
|
67 |
-
protected function _beforeSave()
|
68 |
-
{
|
69 |
-
parent::_beforeSave();
|
70 |
-
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
-
if ($this->isObjectNew()) {
|
72 |
-
$this->setCreatedAt($now);
|
73 |
-
}
|
74 |
-
$this->setUpdatedAt($now);
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* save anymarket orders relation
|
80 |
-
*
|
81 |
-
* @access public
|
82 |
-
* @return DB1_AnyMarket_Model_Anymarketorders
|
83 |
-
|
84 |
-
*/
|
85 |
-
protected function _afterSave()
|
86 |
-
{
|
87 |
-
return parent::_afterSave();
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* get default values
|
92 |
-
*
|
93 |
-
* @access public
|
94 |
-
* @return array
|
95 |
-
|
96 |
-
*/
|
97 |
-
public function getDefaultValues()
|
98 |
-
{
|
99 |
-
$values = array();
|
100 |
-
$values['status'] = 1;
|
101 |
-
return $values;
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Anymarketorders extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entity code.
|
28 |
+
* Can be used as part of method name for entity processing
|
29 |
+
*/
|
30 |
+
const ENTITY = 'db1_anymarket_anymarketorders';
|
31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketorders';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Prefix of model events names
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketorders';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Parameter name in event
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventObject = 'anymarketorders';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* constructor
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return void
|
52 |
+
|
53 |
+
*/
|
54 |
+
public function _construct()
|
55 |
+
{
|
56 |
+
parent::_construct();
|
57 |
+
$this->_init('db1_anymarket/anymarketorders');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* before save anymarket orders
|
62 |
+
*
|
63 |
+
* @access protected
|
64 |
+
* @return DB1_AnyMarket_Model_Anymarketorders
|
65 |
+
|
66 |
+
*/
|
67 |
+
protected function _beforeSave()
|
68 |
+
{
|
69 |
+
parent::_beforeSave();
|
70 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
+
if ($this->isObjectNew()) {
|
72 |
+
$this->setCreatedAt($now);
|
73 |
+
}
|
74 |
+
$this->setUpdatedAt($now);
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* save anymarket orders relation
|
80 |
+
*
|
81 |
+
* @access public
|
82 |
+
* @return DB1_AnyMarket_Model_Anymarketorders
|
83 |
+
|
84 |
+
*/
|
85 |
+
protected function _afterSave()
|
86 |
+
{
|
87 |
+
return parent::_afterSave();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get default values
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @return array
|
95 |
+
|
96 |
+
*/
|
97 |
+
public function getDefaultValues()
|
98 |
+
{
|
99 |
+
$values = array();
|
100 |
+
$values['status'] = 1;
|
101 |
+
return $values;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketorders_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
-
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* init anymarket orders
|
23 |
-
*
|
24 |
-
* @access protected
|
25 |
-
* @param $anymarketordersId
|
26 |
-
* @return DB1_AnyMarket_Model_Anymarketorders
|
27 |
-
|
28 |
-
*/
|
29 |
-
protected function _initAnymarketorders($anymarketordersId)
|
30 |
-
{
|
31 |
-
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($anymarketordersId);
|
32 |
-
if (!$anymarketorders->getId()) {
|
33 |
-
$this->_fault('anymarketorders_not_exists');
|
34 |
-
}
|
35 |
-
return $anymarketorders;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* get anymarket orders
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param mixed $filters
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function items($filters = null)
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketorders')->getCollection();
|
49 |
-
$apiHelper = Mage::helper('api');
|
50 |
-
$filters = $apiHelper->parseFilters($filters);
|
51 |
-
try {
|
52 |
-
foreach ($filters as $field => $value) {
|
53 |
-
$collection->addFieldToFilter($field, $value);
|
54 |
-
}
|
55 |
-
} catch (Mage_Core_Exception $e) {
|
56 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
-
}
|
58 |
-
$result = array();
|
59 |
-
foreach ($collection as $anymarketorders) {
|
60 |
-
$result[] = $this->_getApiData($anymarketorders);
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Add anymarket orders
|
67 |
-
*
|
68 |
-
* @access public
|
69 |
-
* @param array $data
|
70 |
-
* @return array
|
71 |
-
|
72 |
-
*/
|
73 |
-
public function add($data)
|
74 |
-
{
|
75 |
-
try {
|
76 |
-
if (is_null($data)) {
|
77 |
-
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
-
}
|
79 |
-
$data = (array)$data;
|
80 |
-
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')
|
81 |
-
->setData((array)$data)
|
82 |
-
->save();
|
83 |
-
} catch (Mage_Core_Exception $e) {
|
84 |
-
$this->_fault('data_invalid', $e->getMessage());
|
85 |
-
} catch (Exception $e) {
|
86 |
-
$this->_fault('data_invalid', $e->getMessage());
|
87 |
-
}
|
88 |
-
return $anymarketorders->getId();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Change existing anymarket orders information
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param int $anymarketordersId
|
96 |
-
* @param array $data
|
97 |
-
* @return bool
|
98 |
-
|
99 |
-
*/
|
100 |
-
public function update($anymarketordersId, $data)
|
101 |
-
{
|
102 |
-
$anymarketorders = $this->_initAnymarketorders($anymarketordersId);
|
103 |
-
try {
|
104 |
-
$data = (array)$data;
|
105 |
-
$anymarketorders->addData($data);
|
106 |
-
$anymarketorders->save();
|
107 |
-
}
|
108 |
-
catch (Mage_Core_Exception $e) {
|
109 |
-
$this->_fault('save_error', $e->getMessage());
|
110 |
-
}
|
111 |
-
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* remove anymarket orders
|
117 |
-
*
|
118 |
-
* @access public
|
119 |
-
* @param int $anymarketordersId
|
120 |
-
* @return bool
|
121 |
-
|
122 |
-
*/
|
123 |
-
public function remove($anymarketordersId)
|
124 |
-
{
|
125 |
-
$anymarketorders = $this->_initAnymarketorders($anymarketordersId);
|
126 |
-
try {
|
127 |
-
$anymarketorders->delete();
|
128 |
-
} catch (Mage_Core_Exception $e) {
|
129 |
-
$this->_fault('remove_error', $e->getMessage());
|
130 |
-
}
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* get info
|
136 |
-
*
|
137 |
-
* @access public
|
138 |
-
* @param int $anymarketordersId
|
139 |
-
* @return array
|
140 |
-
|
141 |
-
*/
|
142 |
-
public function info($anymarketordersId)
|
143 |
-
{
|
144 |
-
$result = array();
|
145 |
-
$anymarketorders = $this->_initAnymarketorders($anymarketordersId);
|
146 |
-
$result = $this->_getApiData($anymarketorders);
|
147 |
-
return $result;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* get data for api
|
152 |
-
*
|
153 |
-
* @access protected
|
154 |
-
* @param DB1_AnyMarket_Model_Anymarketorders $anymarketorders
|
155 |
-
* @return array()
|
156 |
-
|
157 |
-
*/
|
158 |
-
protected function _getApiData(DB1_AnyMarket_Model_Anymarketorders $anymarketorders)
|
159 |
-
{
|
160 |
-
return $anymarketorders->getData();
|
161 |
-
}
|
162 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketorders_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarket orders
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketordersId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketorders
|
27 |
+
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketorders($anymarketordersId)
|
30 |
+
{
|
31 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($anymarketordersId);
|
32 |
+
if (!$anymarketorders->getId()) {
|
33 |
+
$this->_fault('anymarketorders_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketorders;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarket orders
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketorders')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketorders) {
|
60 |
+
$result[] = $this->_getApiData($anymarketorders);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarket orders
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketorders->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarket orders information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketordersId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
|
99 |
+
*/
|
100 |
+
public function update($anymarketordersId, $data)
|
101 |
+
{
|
102 |
+
$anymarketorders = $this->_initAnymarketorders($anymarketordersId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketorders->addData($data);
|
106 |
+
$anymarketorders->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarket orders
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketordersId
|
120 |
+
* @return bool
|
121 |
+
|
122 |
+
*/
|
123 |
+
public function remove($anymarketordersId)
|
124 |
+
{
|
125 |
+
$anymarketorders = $this->_initAnymarketorders($anymarketordersId);
|
126 |
+
try {
|
127 |
+
$anymarketorders->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketordersId
|
139 |
+
* @return array
|
140 |
+
|
141 |
+
*/
|
142 |
+
public function info($anymarketordersId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketorders = $this->_initAnymarketorders($anymarketordersId);
|
146 |
+
$result = $this->_getApiData($anymarketorders);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketorders $anymarketorders
|
155 |
+
* @return array()
|
156 |
+
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketorders $anymarketorders)
|
159 |
+
{
|
160 |
+
return $anymarketorders->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api/V2.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketorders_Api_V2 extends DB1_AnyMarket_Model_Anymarketorders_Api
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Anymarket Orders info
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @param int $anymarketordersId
|
24 |
-
* @return object
|
25 |
-
|
26 |
-
*/
|
27 |
-
public function info($anymarketordersId)
|
28 |
-
{
|
29 |
-
$result = parent::info($anymarketordersId);
|
30 |
-
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
-
return $result;
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketorders_Api_V2 extends DB1_AnyMarket_Model_Anymarketorders_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Anymarket Orders info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketordersId
|
24 |
+
* @return object
|
25 |
+
|
26 |
+
*/
|
27 |
+
public function info($anymarketordersId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketordersId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketproducts.php
CHANGED
@@ -1,104 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Anymarketproducts extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Entity code.
|
28 |
-
* Can be used as part of method name for entity processing
|
29 |
-
*/
|
30 |
-
const ENTITY = 'db1_anymarket_anymarketproducts';
|
31 |
-
const CACHE_TAG = 'db1_anymarket_anymarketproducts';
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Prefix of model events names
|
35 |
-
*
|
36 |
-
* @var string
|
37 |
-
*/
|
38 |
-
protected $_eventPrefix = 'db1_anymarket_anymarketproducts';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Parameter name in event
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_eventObject = 'anymarketproducts';
|
46 |
-
|
47 |
-
/**
|
48 |
-
* constructor
|
49 |
-
*
|
50 |
-
* @access public
|
51 |
-
* @return void
|
52 |
-
*
|
53 |
-
*/
|
54 |
-
public function _construct()
|
55 |
-
{
|
56 |
-
parent::_construct();
|
57 |
-
$this->_init('db1_anymarket/anymarketproducts');
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* before save anymarket products
|
62 |
-
*
|
63 |
-
* @access protected
|
64 |
-
* @return DB1_AnyMarket_Model_Anymarketproducts
|
65 |
-
*
|
66 |
-
*/
|
67 |
-
protected function _beforeSave()
|
68 |
-
{
|
69 |
-
parent::_beforeSave();
|
70 |
-
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
-
if ($this->isObjectNew()) {
|
72 |
-
$this->setCreatedAt($now);
|
73 |
-
}
|
74 |
-
$this->setUpdatedAt($now);
|
75 |
-
return $this;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* save anymarket products relation
|
80 |
-
*
|
81 |
-
* @access public
|
82 |
-
* @return DB1_AnyMarket_Model_Anymarketproducts
|
83 |
-
*
|
84 |
-
*/
|
85 |
-
protected function _afterSave()
|
86 |
-
{
|
87 |
-
return parent::_afterSave();
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* get default values
|
92 |
-
*
|
93 |
-
* @access public
|
94 |
-
* @return array
|
95 |
-
*
|
96 |
-
*/
|
97 |
-
public function getDefaultValues()
|
98 |
-
{
|
99 |
-
$values = array();
|
100 |
-
$values['status'] = 1;
|
101 |
-
return $values;
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Anymarketproducts extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entity code.
|
28 |
+
* Can be used as part of method name for entity processing
|
29 |
+
*/
|
30 |
+
const ENTITY = 'db1_anymarket_anymarketproducts';
|
31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketproducts';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Prefix of model events names
|
35 |
+
*
|
36 |
+
* @var string
|
37 |
+
*/
|
38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketproducts';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Parameter name in event
|
42 |
+
*
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventObject = 'anymarketproducts';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* constructor
|
49 |
+
*
|
50 |
+
* @access public
|
51 |
+
* @return void
|
52 |
+
*
|
53 |
+
*/
|
54 |
+
public function _construct()
|
55 |
+
{
|
56 |
+
parent::_construct();
|
57 |
+
$this->_init('db1_anymarket/anymarketproducts');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* before save anymarket products
|
62 |
+
*
|
63 |
+
* @access protected
|
64 |
+
* @return DB1_AnyMarket_Model_Anymarketproducts
|
65 |
+
*
|
66 |
+
*/
|
67 |
+
protected function _beforeSave()
|
68 |
+
{
|
69 |
+
parent::_beforeSave();
|
70 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
71 |
+
if ($this->isObjectNew()) {
|
72 |
+
$this->setCreatedAt($now);
|
73 |
+
}
|
74 |
+
$this->setUpdatedAt($now);
|
75 |
+
return $this;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* save anymarket products relation
|
80 |
+
*
|
81 |
+
* @access public
|
82 |
+
* @return DB1_AnyMarket_Model_Anymarketproducts
|
83 |
+
*
|
84 |
+
*/
|
85 |
+
protected function _afterSave()
|
86 |
+
{
|
87 |
+
return parent::_afterSave();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* get default values
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @return array
|
95 |
+
*
|
96 |
+
*/
|
97 |
+
public function getDefaultValues()
|
98 |
+
{
|
99 |
+
$values = array();
|
100 |
+
$values['status'] = 1;
|
101 |
+
return $values;
|
102 |
+
}
|
103 |
+
|
104 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketproducts_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
-
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* init anymarket products
|
23 |
-
*
|
24 |
-
* @access protected
|
25 |
-
* @param $anymarketproductsId
|
26 |
-
* @return DB1_AnyMarket_Model_Anymarketproducts
|
27 |
-
|
28 |
-
*/
|
29 |
-
protected function _initAnymarketproducts($anymarketproductsId)
|
30 |
-
{
|
31 |
-
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->load($anymarketproductsId);
|
32 |
-
if (!$anymarketproducts->getId()) {
|
33 |
-
$this->_fault('anymarketproducts_not_exists');
|
34 |
-
}
|
35 |
-
return $anymarketproducts;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* get anymarket products
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param mixed $filters
|
43 |
-
* @return array
|
44 |
-
*
|
45 |
-
*/
|
46 |
-
public function items($filters = null)
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketproducts')->getCollection();
|
49 |
-
$apiHelper = Mage::helper('api');
|
50 |
-
$filters = $apiHelper->parseFilters($filters);
|
51 |
-
try {
|
52 |
-
foreach ($filters as $field => $value) {
|
53 |
-
$collection->addFieldToFilter($field, $value);
|
54 |
-
}
|
55 |
-
} catch (Mage_Core_Exception $e) {
|
56 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
-
}
|
58 |
-
$result = array();
|
59 |
-
foreach ($collection as $anymarketproducts) {
|
60 |
-
$result[] = $this->_getApiData($anymarketproducts);
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Add anymarket products
|
67 |
-
*
|
68 |
-
* @access public
|
69 |
-
* @param array $data
|
70 |
-
* @return array
|
71 |
-
*
|
72 |
-
*/
|
73 |
-
public function add($data)
|
74 |
-
{
|
75 |
-
try {
|
76 |
-
if (is_null($data)) {
|
77 |
-
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
-
}
|
79 |
-
$data = (array)$data;
|
80 |
-
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')
|
81 |
-
->setData((array)$data)
|
82 |
-
->save();
|
83 |
-
} catch (Mage_Core_Exception $e) {
|
84 |
-
$this->_fault('data_invalid', $e->getMessage());
|
85 |
-
} catch (Exception $e) {
|
86 |
-
$this->_fault('data_invalid', $e->getMessage());
|
87 |
-
}
|
88 |
-
return $anymarketproducts->getId();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Change existing anymarket products information
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param int $anymarketproductsId
|
96 |
-
* @param array $data
|
97 |
-
* @return bool
|
98 |
-
*
|
99 |
-
*/
|
100 |
-
public function update($anymarketproductsId, $data)
|
101 |
-
{
|
102 |
-
$anymarketproducts = $this->_initAnymarketproducts($anymarketproductsId);
|
103 |
-
try {
|
104 |
-
$data = (array)$data;
|
105 |
-
$anymarketproducts->addData($data);
|
106 |
-
$anymarketproducts->save();
|
107 |
-
}
|
108 |
-
catch (Mage_Core_Exception $e) {
|
109 |
-
$this->_fault('save_error', $e->getMessage());
|
110 |
-
}
|
111 |
-
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* remove anymarket products
|
117 |
-
*
|
118 |
-
* @access public
|
119 |
-
* @param int $anymarketproductsId
|
120 |
-
* @return bool
|
121 |
-
*
|
122 |
-
*/
|
123 |
-
public function remove($anymarketproductsId)
|
124 |
-
{
|
125 |
-
$anymarketproducts = $this->_initAnymarketproducts($anymarketproductsId);
|
126 |
-
try {
|
127 |
-
$anymarketproducts->delete();
|
128 |
-
} catch (Mage_Core_Exception $e) {
|
129 |
-
$this->_fault('remove_error', $e->getMessage());
|
130 |
-
}
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* get info
|
136 |
-
*
|
137 |
-
* @access public
|
138 |
-
* @param int $anymarketproductsId
|
139 |
-
* @return array
|
140 |
-
*
|
141 |
-
*/
|
142 |
-
public function info($anymarketproductsId)
|
143 |
-
{
|
144 |
-
$result = array();
|
145 |
-
$anymarketproducts = $this->_initAnymarketproducts($anymarketproductsId);
|
146 |
-
$result = $this->_getApiData($anymarketproducts);
|
147 |
-
return $result;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* get data for api
|
152 |
-
*
|
153 |
-
* @access protected
|
154 |
-
* @param DB1_AnyMarket_Model_Anymarketproducts $anymarketproducts
|
155 |
-
* @return array()
|
156 |
-
*
|
157 |
-
*/
|
158 |
-
protected function _getApiData(DB1_AnyMarket_Model_Anymarketproducts $anymarketproducts)
|
159 |
-
{
|
160 |
-
return $anymarketproducts->getData();
|
161 |
-
}
|
162 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketproducts_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarket products
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketproductsId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketproducts
|
27 |
+
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketproducts($anymarketproductsId)
|
30 |
+
{
|
31 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->load($anymarketproductsId);
|
32 |
+
if (!$anymarketproducts->getId()) {
|
33 |
+
$this->_fault('anymarketproducts_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketproducts;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarket products
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketproducts')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketproducts) {
|
60 |
+
$result[] = $this->_getApiData($anymarketproducts);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarket products
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
*
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketproducts->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarket products information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketproductsId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
*
|
99 |
+
*/
|
100 |
+
public function update($anymarketproductsId, $data)
|
101 |
+
{
|
102 |
+
$anymarketproducts = $this->_initAnymarketproducts($anymarketproductsId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketproducts->addData($data);
|
106 |
+
$anymarketproducts->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarket products
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketproductsId
|
120 |
+
* @return bool
|
121 |
+
*
|
122 |
+
*/
|
123 |
+
public function remove($anymarketproductsId)
|
124 |
+
{
|
125 |
+
$anymarketproducts = $this->_initAnymarketproducts($anymarketproductsId);
|
126 |
+
try {
|
127 |
+
$anymarketproducts->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketproductsId
|
139 |
+
* @return array
|
140 |
+
*
|
141 |
+
*/
|
142 |
+
public function info($anymarketproductsId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketproducts = $this->_initAnymarketproducts($anymarketproductsId);
|
146 |
+
$result = $this->_getApiData($anymarketproducts);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketproducts $anymarketproducts
|
155 |
+
* @return array()
|
156 |
+
*
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketproducts $anymarketproducts)
|
159 |
+
{
|
160 |
+
return $anymarketproducts->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api/V2.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketproducts_Api_V2 extends DB1_AnyMarket_Model_Anymarketproducts_Api
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Anymarket Products info
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @param int $anymarketproductsId
|
24 |
-
* @return object
|
25 |
-
*
|
26 |
-
*/
|
27 |
-
public function info($anymarketproductsId)
|
28 |
-
{
|
29 |
-
$result = parent::info($anymarketproductsId);
|
30 |
-
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
-
return $result;
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketproducts_Api_V2 extends DB1_AnyMarket_Model_Anymarketproducts_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Anymarket Products info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketproductsId
|
24 |
+
* @return object
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
public function info($anymarketproductsId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketproductsId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketqueue.php
CHANGED
@@ -1,103 +1,103 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Model_Anymarketqueue extends Mage_Core_Model_Abstract
|
24 |
-
{
|
25 |
-
/**
|
26 |
-
* Entity code.
|
27 |
-
* Can be used as part of method name for entity processing
|
28 |
-
*/
|
29 |
-
const ENTITY = 'db1_anymarket_anymarketqueue';
|
30 |
-
const CACHE_TAG = 'db1_anymarket_anymarketqueue';
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Prefix of model events names
|
34 |
-
*
|
35 |
-
* @var string
|
36 |
-
*/
|
37 |
-
protected $_eventPrefix = 'db1_anymarket_anymarketqueue';
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Parameter name in event
|
41 |
-
*
|
42 |
-
* @var string
|
43 |
-
*/
|
44 |
-
protected $_eventObject = 'anymarketqueue';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* constructor
|
48 |
-
*
|
49 |
-
* @access public
|
50 |
-
* @return void
|
51 |
-
|
52 |
-
*/
|
53 |
-
public function _construct()
|
54 |
-
{
|
55 |
-
parent::_construct();
|
56 |
-
$this->_init('db1_anymarket/anymarketqueue');
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* before save anymarket queue
|
61 |
-
*
|
62 |
-
* @access protected
|
63 |
-
* @return DB1_AnyMarket_Model_Anymarketqueue
|
64 |
-
|
65 |
-
*/
|
66 |
-
protected function _beforeSave()
|
67 |
-
{
|
68 |
-
parent::_beforeSave();
|
69 |
-
$now = Mage::getSingleton('core/date')->gmtDate();
|
70 |
-
if ($this->isObjectNew()) {
|
71 |
-
$this->setCreatedAt($now);
|
72 |
-
}
|
73 |
-
$this->setUpdatedAt($now);
|
74 |
-
return $this;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* save anymarket queue relation
|
79 |
-
*
|
80 |
-
* @access public
|
81 |
-
* @return DB1_AnyMarket_Model_Anymarketqueue
|
82 |
-
|
83 |
-
*/
|
84 |
-
protected function _afterSave()
|
85 |
-
{
|
86 |
-
return parent::_afterSave();
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* get default values
|
91 |
-
*
|
92 |
-
* @access public
|
93 |
-
* @return array
|
94 |
-
|
95 |
-
*/
|
96 |
-
public function getDefaultValues()
|
97 |
-
{
|
98 |
-
$values = array();
|
99 |
-
$values['status'] = 1;
|
100 |
-
return $values;
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Model_Anymarketqueue extends Mage_Core_Model_Abstract
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* Entity code.
|
27 |
+
* Can be used as part of method name for entity processing
|
28 |
+
*/
|
29 |
+
const ENTITY = 'db1_anymarket_anymarketqueue';
|
30 |
+
const CACHE_TAG = 'db1_anymarket_anymarketqueue';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Prefix of model events names
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketqueue';
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Parameter name in event
|
41 |
+
*
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventObject = 'anymarketqueue';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* constructor
|
48 |
+
*
|
49 |
+
* @access public
|
50 |
+
* @return void
|
51 |
+
|
52 |
+
*/
|
53 |
+
public function _construct()
|
54 |
+
{
|
55 |
+
parent::_construct();
|
56 |
+
$this->_init('db1_anymarket/anymarketqueue');
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* before save anymarket queue
|
61 |
+
*
|
62 |
+
* @access protected
|
63 |
+
* @return DB1_AnyMarket_Model_Anymarketqueue
|
64 |
+
|
65 |
+
*/
|
66 |
+
protected function _beforeSave()
|
67 |
+
{
|
68 |
+
parent::_beforeSave();
|
69 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
70 |
+
if ($this->isObjectNew()) {
|
71 |
+
$this->setCreatedAt($now);
|
72 |
+
}
|
73 |
+
$this->setUpdatedAt($now);
|
74 |
+
return $this;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* save anymarket queue relation
|
79 |
+
*
|
80 |
+
* @access public
|
81 |
+
* @return DB1_AnyMarket_Model_Anymarketqueue
|
82 |
+
|
83 |
+
*/
|
84 |
+
protected function _afterSave()
|
85 |
+
{
|
86 |
+
return parent::_afterSave();
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* get default values
|
91 |
+
*
|
92 |
+
* @access public
|
93 |
+
* @return array
|
94 |
+
|
95 |
+
*/
|
96 |
+
public function getDefaultValues()
|
97 |
+
{
|
98 |
+
$values = array();
|
99 |
+
$values['status'] = 1;
|
100 |
+
return $values;
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketqueue_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
-
{
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* init anymarket queue
|
23 |
-
*
|
24 |
-
* @access protected
|
25 |
-
* @param $anymarketqueueId
|
26 |
-
* @return DB1_AnyMarket_Model_Anymarketqueue
|
27 |
-
"
|
28 |
-
*/
|
29 |
-
protected function _initAnymarketqueue($anymarketqueueId)
|
30 |
-
{
|
31 |
-
$anymarketqueue = Mage::getModel('db1_anymarket/anymarketqueue')->load($anymarketqueueId);
|
32 |
-
if (!$anymarketqueue->getId()) {
|
33 |
-
$this->_fault('anymarketqueue_not_exists');
|
34 |
-
}
|
35 |
-
return $anymarketqueue;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* get anymarket queues
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param mixed $filters
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function items($filters = null)
|
47 |
-
{
|
48 |
-
$collection = Mage::getModel('db1_anymarket/anymarketqueue')->getCollection();
|
49 |
-
$apiHelper = Mage::helper('api');
|
50 |
-
$filters = $apiHelper->parseFilters($filters);
|
51 |
-
try {
|
52 |
-
foreach ($filters as $field => $value) {
|
53 |
-
$collection->addFieldToFilter($field, $value);
|
54 |
-
}
|
55 |
-
} catch (Mage_Core_Exception $e) {
|
56 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
-
}
|
58 |
-
$result = array();
|
59 |
-
foreach ($collection as $anymarketqueue) {
|
60 |
-
$result[] = $this->_getApiData($anymarketqueue);
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Add anymarket queue
|
67 |
-
*
|
68 |
-
* @access public
|
69 |
-
* @param array $data
|
70 |
-
* @return array
|
71 |
-
|
72 |
-
*/
|
73 |
-
public function add($data)
|
74 |
-
{
|
75 |
-
try {
|
76 |
-
if (is_null($data)) {
|
77 |
-
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
-
}
|
79 |
-
$data = (array)$data;
|
80 |
-
$anymarketqueue = Mage::getModel('db1_anymarket/anymarketqueue')
|
81 |
-
->setData((array)$data)
|
82 |
-
->save();
|
83 |
-
} catch (Mage_Core_Exception $e) {
|
84 |
-
$this->_fault('data_invalid', $e->getMessage());
|
85 |
-
} catch (Exception $e) {
|
86 |
-
$this->_fault('data_invalid', $e->getMessage());
|
87 |
-
}
|
88 |
-
return $anymarketqueue->getId();
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Change existing anymarket queue information
|
93 |
-
*
|
94 |
-
* @access public
|
95 |
-
* @param int $anymarketqueueId
|
96 |
-
* @param array $data
|
97 |
-
* @return bool
|
98 |
-
|
99 |
-
*/
|
100 |
-
public function update($anymarketqueueId, $data)
|
101 |
-
{
|
102 |
-
$anymarketqueue = $this->_initAnymarketqueue($anymarketqueueId);
|
103 |
-
try {
|
104 |
-
$data = (array)$data;
|
105 |
-
$anymarketqueue->addData($data);
|
106 |
-
$anymarketqueue->save();
|
107 |
-
}
|
108 |
-
catch (Mage_Core_Exception $e) {
|
109 |
-
$this->_fault('save_error', $e->getMessage());
|
110 |
-
}
|
111 |
-
|
112 |
-
return true;
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* remove anymarket queue
|
117 |
-
*
|
118 |
-
* @access public
|
119 |
-
* @param int $anymarketqueueId
|
120 |
-
* @return bool
|
121 |
-
|
122 |
-
*/
|
123 |
-
public function remove($anymarketqueueId)
|
124 |
-
{
|
125 |
-
$anymarketqueue = $this->_initAnymarketqueue($anymarketqueueId);
|
126 |
-
try {
|
127 |
-
$anymarketqueue->delete();
|
128 |
-
} catch (Mage_Core_Exception $e) {
|
129 |
-
$this->_fault('remove_error', $e->getMessage());
|
130 |
-
}
|
131 |
-
return true;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* get info
|
136 |
-
*
|
137 |
-
* @access public
|
138 |
-
* @param int $anymarketqueueId
|
139 |
-
* @return array
|
140 |
-
|
141 |
-
*/
|
142 |
-
public function info($anymarketqueueId)
|
143 |
-
{
|
144 |
-
$result = array();
|
145 |
-
$anymarketqueue = $this->_initAnymarketqueue($anymarketqueueId);
|
146 |
-
$result = $this->_getApiData($anymarketqueue);
|
147 |
-
return $result;
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* get data for api
|
152 |
-
*
|
153 |
-
* @access protected
|
154 |
-
* @param DB1_AnyMarket_Model_Anymarketqueue $anymarketqueue
|
155 |
-
* @return array()
|
156 |
-
|
157 |
-
*/
|
158 |
-
protected function _getApiData(DB1_AnyMarket_Model_Anymarketqueue $anymarketqueue)
|
159 |
-
{
|
160 |
-
return $anymarketqueue->getData();
|
161 |
-
}
|
162 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketqueue_Api extends Mage_Api_Model_Resource_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* init anymarket queue
|
23 |
+
*
|
24 |
+
* @access protected
|
25 |
+
* @param $anymarketqueueId
|
26 |
+
* @return DB1_AnyMarket_Model_Anymarketqueue
|
27 |
+
"
|
28 |
+
*/
|
29 |
+
protected function _initAnymarketqueue($anymarketqueueId)
|
30 |
+
{
|
31 |
+
$anymarketqueue = Mage::getModel('db1_anymarket/anymarketqueue')->load($anymarketqueueId);
|
32 |
+
if (!$anymarketqueue->getId()) {
|
33 |
+
$this->_fault('anymarketqueue_not_exists');
|
34 |
+
}
|
35 |
+
return $anymarketqueue;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* get anymarket queues
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param mixed $filters
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function items($filters = null)
|
47 |
+
{
|
48 |
+
$collection = Mage::getModel('db1_anymarket/anymarketqueue')->getCollection();
|
49 |
+
$apiHelper = Mage::helper('api');
|
50 |
+
$filters = $apiHelper->parseFilters($filters);
|
51 |
+
try {
|
52 |
+
foreach ($filters as $field => $value) {
|
53 |
+
$collection->addFieldToFilter($field, $value);
|
54 |
+
}
|
55 |
+
} catch (Mage_Core_Exception $e) {
|
56 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
57 |
+
}
|
58 |
+
$result = array();
|
59 |
+
foreach ($collection as $anymarketqueue) {
|
60 |
+
$result[] = $this->_getApiData($anymarketqueue);
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Add anymarket queue
|
67 |
+
*
|
68 |
+
* @access public
|
69 |
+
* @param array $data
|
70 |
+
* @return array
|
71 |
+
|
72 |
+
*/
|
73 |
+
public function add($data)
|
74 |
+
{
|
75 |
+
try {
|
76 |
+
if (is_null($data)) {
|
77 |
+
throw new Exception(Mage::helper('db1_anymarket')->__("Data cannot be null"));
|
78 |
+
}
|
79 |
+
$data = (array)$data;
|
80 |
+
$anymarketqueue = Mage::getModel('db1_anymarket/anymarketqueue')
|
81 |
+
->setData((array)$data)
|
82 |
+
->save();
|
83 |
+
} catch (Mage_Core_Exception $e) {
|
84 |
+
$this->_fault('data_invalid', $e->getMessage());
|
85 |
+
} catch (Exception $e) {
|
86 |
+
$this->_fault('data_invalid', $e->getMessage());
|
87 |
+
}
|
88 |
+
return $anymarketqueue->getId();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Change existing anymarket queue information
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @param int $anymarketqueueId
|
96 |
+
* @param array $data
|
97 |
+
* @return bool
|
98 |
+
|
99 |
+
*/
|
100 |
+
public function update($anymarketqueueId, $data)
|
101 |
+
{
|
102 |
+
$anymarketqueue = $this->_initAnymarketqueue($anymarketqueueId);
|
103 |
+
try {
|
104 |
+
$data = (array)$data;
|
105 |
+
$anymarketqueue->addData($data);
|
106 |
+
$anymarketqueue->save();
|
107 |
+
}
|
108 |
+
catch (Mage_Core_Exception $e) {
|
109 |
+
$this->_fault('save_error', $e->getMessage());
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* remove anymarket queue
|
117 |
+
*
|
118 |
+
* @access public
|
119 |
+
* @param int $anymarketqueueId
|
120 |
+
* @return bool
|
121 |
+
|
122 |
+
*/
|
123 |
+
public function remove($anymarketqueueId)
|
124 |
+
{
|
125 |
+
$anymarketqueue = $this->_initAnymarketqueue($anymarketqueueId);
|
126 |
+
try {
|
127 |
+
$anymarketqueue->delete();
|
128 |
+
} catch (Mage_Core_Exception $e) {
|
129 |
+
$this->_fault('remove_error', $e->getMessage());
|
130 |
+
}
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* get info
|
136 |
+
*
|
137 |
+
* @access public
|
138 |
+
* @param int $anymarketqueueId
|
139 |
+
* @return array
|
140 |
+
|
141 |
+
*/
|
142 |
+
public function info($anymarketqueueId)
|
143 |
+
{
|
144 |
+
$result = array();
|
145 |
+
$anymarketqueue = $this->_initAnymarketqueue($anymarketqueueId);
|
146 |
+
$result = $this->_getApiData($anymarketqueue);
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* get data for api
|
152 |
+
*
|
153 |
+
* @access protected
|
154 |
+
* @param DB1_AnyMarket_Model_Anymarketqueue $anymarketqueue
|
155 |
+
* @return array()
|
156 |
+
|
157 |
+
*/
|
158 |
+
protected function _getApiData(DB1_AnyMarket_Model_Anymarketqueue $anymarketqueue)
|
159 |
+
{
|
160 |
+
return $anymarketqueue->getData();
|
161 |
+
}
|
162 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api/V2.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
class DB1_AnyMarket_Model_Anymarketqueue_Api_V2 extends DB1_AnyMarket_Model_Anymarketqueue_Api
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* Anymarket Queue info
|
21 |
-
*
|
22 |
-
* @access public
|
23 |
-
* @param int $anymarketqueueId
|
24 |
-
* @return object
|
25 |
-
|
26 |
-
*/
|
27 |
-
public function info($anymarketqueueId)
|
28 |
-
{
|
29 |
-
$result = parent::info($anymarketqueueId);
|
30 |
-
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
-
return $result;
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
class DB1_AnyMarket_Model_Anymarketqueue_Api_V2 extends DB1_AnyMarket_Model_Anymarketqueue_Api
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Anymarket Queue info
|
21 |
+
*
|
22 |
+
* @access public
|
23 |
+
* @param int $anymarketqueueId
|
24 |
+
* @return object
|
25 |
+
|
26 |
+
*/
|
27 |
+
public function info($anymarketqueueId)
|
28 |
+
{
|
29 |
+
$result = parent::info($anymarketqueueId);
|
30 |
+
$result = Mage::helper('api')->wsiArrayPacker($result);
|
31 |
+
return $result;
|
32 |
+
}
|
33 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Cron.php
CHANGED
@@ -1,66 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
class DB1_AnyMarket_Model_Cron{
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
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 |
-
$ProdLoaded = Mage::getModel('catalog/product')->load( $product->getId() );
|
46 |
-
if( ($ProdLoaded->getStatus() == 1) && ($ProdLoaded->getData('integra_anymarket') == 1) ){
|
47 |
-
Mage::helper('db1_anymarket/product')->sendProductToAnyMarket( $product->getId() );
|
48 |
-
|
49 |
-
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', Mage::app()->getStore()->getId()));
|
50 |
-
$ProdStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
51 |
-
|
52 |
-
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($product->getId(), $ProdStock->getQty(), $ProdLoaded->getData($filter));
|
53 |
-
}
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
}
|
58 |
-
}
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
public function executeQueue(){
|
63 |
-
Mage::helper('db1_anymarket/queue')->processQueue();
|
64 |
-
}
|
65 |
-
|
66 |
Â
}
|
1 |
+
<?php
|
2 |
+
class DB1_AnyMarket_Model_Cron{
|
3 |
+
|
4 |
+
/**
|
5 |
+
* sinc all orders in feed and orders with errors
|
6 |
+
*/
|
7 |
+
public function sincOrders(){
|
8 |
+
Mage::helper('db1_anymarket/queue')->processOrders();
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* sinc all products in feed and products with errors
|
13 |
+
*/
|
14 |
+
public function sincProducts(){
|
15 |
+
Mage::helper('db1_anymarket/queue')->processProducts();
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* execute the queue
|
20 |
+
*/
|
21 |
+
public function executeReindex(){
|
22 |
+
Mage::helper('db1_anymarket/queue')->processReindex();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* execute the queue
|
27 |
+
*/
|
28 |
+
public function executeQueue(){
|
29 |
+
Mage::helper('db1_anymarket/queue')->processQueue();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* execute the clean logs
|
34 |
+
*/
|
35 |
+
public function executeCleanLogs(){
|
36 |
+
$contLogs = Mage::helper('db1_anymarket/queue')->processCleanLogs();
|
37 |
+
|
38 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
39 |
+
$anymarketlog->setLogDesc('Clean Logs by System, '.$contLogs.' cleaned');
|
40 |
+
$anymarketlog->setStatus("0");
|
41 |
+
$anymarketlog->save();
|
42 |
+
}
|
43 |
+
|
44 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
45 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/Observer.php
CHANGED
@@ -1,178 +1,330 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_Observer {
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
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 |
-
|
48 |
-
|
49 |
-
$
|
50 |
-
$
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
if(
|
59 |
-
Mage::helper('db1_anymarket/product')->
|
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 |
-
Mage::helper('db1_anymarket/
|
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 |
-
if(
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
178 |
Â
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_Observer {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @param $observer
|
7 |
+
*/
|
8 |
+
public function setQuickCreateFlag($observer) {
|
9 |
+
$request = $observer->getControllerAction()->getRequest();
|
10 |
+
$simpleProductRequest = $request->getParam('simple_product');
|
11 |
+
|
12 |
+
if( isset($simpleProductRequest['sku_autogenerate']) ){
|
13 |
+
$configurableProduct = Mage::getModel('catalog/product')
|
14 |
+
->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)
|
15 |
+
->load($request->getParam('product'));
|
16 |
+
|
17 |
+
$product = Mage::getModel('catalog/product')
|
18 |
+
->setStoreId(0)
|
19 |
+
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
|
20 |
+
->setAttributeSetId($configurableProduct->getAttributeSetId());
|
21 |
+
$product->addData( $request->getParam('simple_product', array()) );
|
22 |
+
|
23 |
+
foreach ($configurableProduct->getTypeInstance()->getConfigurableAttributes() as $attribute) {
|
24 |
+
$value = $product->getAttributeText($attribute->getProductAttribute()->getAttributeCode());
|
25 |
+
$autogenerateOptions[] = $value;
|
26 |
+
}
|
27 |
+
|
28 |
+
$sku = $configurableProduct->getSku() . '-' . implode('-', $autogenerateOptions);
|
29 |
+
|
30 |
+
Mage::getSingleton('core/session')->setQuickCreateProdVariable($sku);
|
31 |
+
}else{
|
32 |
+
Mage::getSingleton('core/session')->setQuickCreateProdVariable($simpleProductRequest['sku']);
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param $observer
|
38 |
+
*/
|
39 |
+
public function sendProdAnyMarket($observer) {
|
40 |
+
$ExportProdSession = Mage::getSingleton('core/session')->getImportProdsVariable();
|
41 |
+
if( $ExportProdSession != 'false' ) {
|
42 |
+
$productOld = $observer->getEvent()->getProduct();
|
43 |
+
$QuickCreate = Mage::getSingleton('core/session')->getQuickCreateProdVariable();
|
44 |
+
if($QuickCreate == null || $QuickCreate == "" || $QuickCreate != $productOld->getSku() ){
|
45 |
+
$storeID = ($productOld->getStoreId() != null && $productOld->getStoreId() != "0") ? $productOld->getStoreId() : 1;
|
46 |
+
|
47 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
48 |
+
if($typeSincProd == 0){
|
49 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->load($productOld->getId());
|
50 |
+
if( $product->getData('integra_anymarket') == 1 && $product->getStatus() == 1 ){
|
51 |
+
|
52 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
53 |
+
$stockQty = $stock->getQty();
|
54 |
+
if($product->getTypeID() == "configurable"){
|
55 |
+
//PRODUTO CONFIGURAVEL
|
56 |
+
Mage::getModel('catalog/product_type_configurable')->getProduct($product)->unsetData('_cache_instance_products');
|
57 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
58 |
+
if(count($childProducts) > 0){
|
59 |
+
Mage::helper('db1_anymarket/product')->sendProductToAnyMarket($storeID, $product->getId());
|
60 |
+
}
|
61 |
+
}else{
|
62 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild( $product->getId() );
|
63 |
+
if($parentIds){
|
64 |
+
//PRODUTO SIMPLES FILHO DE UM CONFIG
|
65 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
66 |
+
$ean = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_ean_field', $storeID);
|
67 |
+
|
68 |
+
if($filter == 'final_price'){
|
69 |
+
$stkPrice = $product->getFinalPrice();
|
70 |
+
}else{
|
71 |
+
$stkPrice = $product->getData($filter);
|
72 |
+
}
|
73 |
+
|
74 |
+
$attributeOptions = array();
|
75 |
+
foreach ($parentIds as $parentId) {
|
76 |
+
$productConfig = Mage::getModel('catalog/product')->load($parentId);
|
77 |
+
|
78 |
+
if( $productConfig->getId() ) {
|
79 |
+
foreach ($productConfig->getTypeInstance()->getConfigurableAttributes() as $attribute) {
|
80 |
+
$value = $product->getAttributeText($attribute->getProductAttribute()->getAttributeCode());
|
81 |
+
$attributeOptions[$attribute->getLabel()] = $value;
|
82 |
+
}
|
83 |
+
|
84 |
+
foreach ($parentIds as $parentId) {
|
85 |
+
$arrSku = array(
|
86 |
+
"variations" => $attributeOptions,
|
87 |
+
"price" => $stkPrice,
|
88 |
+
"amount" => $stockQty,
|
89 |
+
"ean" => $product->getData($ean),
|
90 |
+
"partnerId" => $product->getSku(),
|
91 |
+
"title" => $product->getName(),
|
92 |
+
"idProduct" => $product->getData('id_anymarket'),
|
93 |
+
"internalIdProduct" => $product->getId(),
|
94 |
+
);
|
95 |
+
|
96 |
+
Mage::helper('db1_anymarket/product')->sendImageSkuToAnyMarket($storeID, $product, array($arrSku));
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}else{
|
101 |
+
//PRODUTO SIMPLES E OUTROS
|
102 |
+
Mage::helper('db1_anymarket/product')->sendProductToAnyMarket($storeID, $product->getId());
|
103 |
+
|
104 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
105 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product->getId(), $stockQty, $product->getData($filter));
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}else{
|
113 |
+
Mage::getSingleton('core/session')->setQuickCreateProdVariable('');
|
114 |
+
}
|
115 |
+
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @param $observer
|
121 |
+
*/
|
122 |
+
public function updateCategory($observer){
|
123 |
+
$category = $observer->getEvent()->getCategory();
|
124 |
+
if( !$category->getName() ) {
|
125 |
+
$category = Mage::getModel('catalog/category')->load($category->getId());
|
126 |
+
}
|
127 |
+
$storeID = Mage::helper('db1_anymarket')->getCurrentStoreView();
|
128 |
+
if( $category->getData('categ_integra_anymarket') == 1 ){
|
129 |
+
$amCategParent = Mage::getModel('db1_anymarket/anymarketcategories')->load($category->getParentId(), 'nmc_id_magento');
|
130 |
+
if( $amCategParent->getData('nmc_cat_id') ){
|
131 |
+
Mage::helper('db1_anymarket/category')->exportSpecificCategory($category, $amCategParent->getData('nmc_cat_id'), $storeID);
|
132 |
+
}else{
|
133 |
+
Mage::helper('db1_anymarket/category')->exportSpecificCategory($category, null, $storeID);
|
134 |
+
}
|
135 |
+
|
136 |
+
if($category->getChildren() != ''){
|
137 |
+
Mage::helper('db1_anymarket/category')->exportCategRecursively($category, $storeID);
|
138 |
+
}
|
139 |
+
}elseif( $category->getData('categ_integra_anymarket') == 0 ){
|
140 |
+
//Mage::helper('db1_anymarket/category')->deleteCategs($category, $storeID);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @param $observer
|
146 |
+
*/
|
147 |
+
public function deleteCategory($observer){
|
148 |
+
/*
|
149 |
+
$category = $observer->getEvent()->getCategory();
|
150 |
+
$storeID = Mage::helper('db1_anymarket')->getCurrentStoreView();
|
151 |
+
|
152 |
+
if( $category->getData('categ_integra_anymarket') == 1 ){
|
153 |
+
Mage::helper('db1_anymarket/category')->deleteCategs($category, $storeID);
|
154 |
+
}
|
155 |
+
*/
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* @param $observer
|
160 |
+
* @return $this
|
161 |
+
*/
|
162 |
+
public function updateOrderAnyMarketObs($observer){
|
163 |
+
$storeID = $observer->getEvent()->getOrder()->getStoreId();
|
164 |
+
$OrderID = $observer->getEvent()->getOrder()->getIncrementId();
|
165 |
+
if(Mage::registry('order_save_observer_executed_'.$OrderID )){
|
166 |
+
return $this;
|
167 |
+
}
|
168 |
+
|
169 |
+
Mage::register('order_save_observer_executed_'.$OrderID, true);
|
170 |
+
$order = $observer->getEvent()->getOrder();
|
171 |
+
Mage::helper('db1_anymarket/order')->updateOrderAnyMarket($storeID, $order );
|
172 |
+
|
173 |
+
//DECREMENTA STOCK ANYMARKET
|
174 |
+
$orderItems = $order->getItemsCollection();
|
175 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
176 |
+
foreach ($orderItems as $item){
|
177 |
+
$product_id = $item->product_id;
|
178 |
+
$_product = Mage::getModel('catalog/product')->load($product_id);
|
179 |
+
|
180 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product);
|
181 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product_id, $stock->getQty(), $_product->getData($filter));
|
182 |
+
}
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* @param $observer
|
188 |
+
*/
|
189 |
+
public function removeProdAnyMarketControl($observer){
|
190 |
+
$product = $observer->getEvent()->getProduct();
|
191 |
+
|
192 |
+
$anymarketproducts = Mage::getModel('db1_anymarket/anymarketproducts')->getCollection()
|
193 |
+
->addFieldToFilter('nmp_sku', $product->getSku());
|
194 |
+
|
195 |
+
foreach( $anymarketproducts as $item ){
|
196 |
+
$item->delete();
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @param $observer
|
202 |
+
*/
|
203 |
+
public function catalogInventorySave($observer){
|
204 |
+
$ImportOrderSession = Mage::getSingleton('core/session')->getImportOrdersVariable();
|
205 |
+
if( $ImportOrderSession != 'false' ) {
|
206 |
+
$event = $observer->getEvent();
|
207 |
+
$_item = $event->getItem();
|
208 |
+
|
209 |
+
$storeID = ($_item->getData('store_id') != null && $_item->getData('store_id') != "0") ? $_item->getData('store_id') : 1;
|
210 |
+
$product = Mage::getModel('catalog/product')->load( $_item->getProductId() );
|
211 |
+
if ( $product->getId() ) {
|
212 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
213 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $_item->getProductId(), $_item->getQty(), $product->getData($filter));
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* @param $observer
|
220 |
+
*/
|
221 |
+
public function subtractQuoteInventory($observer){
|
222 |
+
$quote = $observer->getEvent()->getQuote();
|
223 |
+
foreach ($quote->getAllItems() as $item) {
|
224 |
+
$product = Mage::getModel('catalog/product')->load( $item->getProductId() );
|
225 |
+
if ( $product->getId() ) {
|
226 |
+
$itemSold = $item->getTotalQty();
|
227 |
+
$qty = $item->getProduct()->getStockItem()->getQty();
|
228 |
+
$qtyNow = $qty - $itemSold;
|
229 |
+
|
230 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket('1', $item->getProductId(), $qtyNow, null);
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* @param $observer
|
238 |
+
*/
|
239 |
+
public function revertQuoteInventory($observer){
|
240 |
+
$quote = $observer->getEvent()->getQuote();
|
241 |
+
foreach ($quote->getAllItems() as $item) {
|
242 |
+
$product = Mage::getModel('catalog/product')->load( $item->getProductId() );
|
243 |
+
if ( $product->getId() ) {
|
244 |
+
$qty = $item->getProduct()->getStockItem()->getQty();
|
245 |
+
$itemRevert = ($item->getTotalQty());
|
246 |
+
$qtyNow = $qty + $itemRevert;
|
247 |
+
|
248 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket('1', $item->getProductId(), $qtyNow, null);
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* @param $observer
|
255 |
+
*/
|
256 |
+
public function cancelOrderItem($observer){
|
257 |
+
$item = $observer->getEvent()->getItem();
|
258 |
+
$product = Mage::getModel('catalog/product')->load( $item->getProductId() );
|
259 |
+
if ( $product->getId() ) {
|
260 |
+
$storeID = ($item->getStoreId() != null && $item->getStoreId() != "0") ? $item->getStoreId() : 1;
|
261 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product->getId(), $product->getStockItem()->getQty(), null);
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* @param $observer
|
267 |
+
*/
|
268 |
+
public function refundOrderInventory($observer){
|
269 |
+
$creditmemo = $observer->getEvent()->getCreditmemo();
|
270 |
+
$storeID = ($creditmemo->getStoreId() != null && $creditmemo->getStoreId() != "0") ? $creditmemo->getStoreId() : 1;
|
271 |
+
|
272 |
+
foreach ($creditmemo->getAllItems() as $item) {
|
273 |
+
$product = Mage::getModel('catalog/product')->load( $item->getProductId() );
|
274 |
+
if ( $product->getId() ) {
|
275 |
+
if ($item->getData('back_to_stock') == 1){
|
276 |
+
$ProdLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->load($item->getProductId());
|
277 |
+
$stockQty = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($ProdLoaded)->getQty();
|
278 |
+
|
279 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $item->getProductId(), $stockQty + (int)$item->getQty(), null);
|
280 |
+
}
|
281 |
+
}
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Save Admin Configurations
|
288 |
+
*/
|
289 |
+
public function saveConfigurations(Varien_Event_Observer $observer){
|
290 |
+
$postData = $observer->getEvent()->getData();
|
291 |
+
|
292 |
+
if (is_null($postData['store']) && $postData['website']) {
|
293 |
+
$scopeId = Mage::getModel('core/website')->load($postData['website'])->getId();
|
294 |
+
$OI = Mage::app()->getWebsite($scopeId)->getConfig('anymarket_section/anymarket_acesso_group/anymarket_oi_field');
|
295 |
+
} elseif($postData['store']) {
|
296 |
+
$scopeId = Mage::getModel('core/store')->load($postData['store'])->getId();
|
297 |
+
$OI = Mage::app()->getStore($scopeId)->getConfig('anymarket_section/anymarket_acesso_group/anymarket_oi_field');
|
298 |
+
} else {
|
299 |
+
$scopeId = 0;
|
300 |
+
$OI = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_oi_field');
|
301 |
+
}
|
302 |
+
|
303 |
+
if($OI != '') {
|
304 |
+
$configs = Mage::getModel('core/config_data')->getCollection()
|
305 |
+
->addFieldToFilter('path', 'anymarket_section/anymarket_acesso_group/anymarket_oi_field');
|
306 |
+
|
307 |
+
foreach ($configs as $config) {
|
308 |
+
if (($config->getValue() == $OI) && ($config->getScopeId() != $scopeId)) {
|
309 |
+
|
310 |
+
Mage::getModel('core/config')->saveConfig('anymarket_section/anymarket_acesso_group/anymarket_oi_field',
|
311 |
+
'',
|
312 |
+
'stores',
|
313 |
+
$scopeId);
|
314 |
+
|
315 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
316 |
+
Mage::helper('db1_anymarket')->__('This token ' . $OI . ' it is already being used.')
|
317 |
+
);
|
318 |
+
break;
|
319 |
+
}
|
320 |
+
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
|
329 |
+
}
|
330 |
Â
?>
|
app/code/community/DB1/AnyMarket/Model/PaymentMethod.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
class DB1_AnyMarket_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract {
|
3 |
-
protected $_code = 'db1_anymarket';
|
4 |
-
protected $_isInitializeNeeded = true;
|
5 |
-
protected $_canUseInternal = true;
|
6 |
-
protected $_canUseForMultishipping = false;
|
7 |
-
protected $_apiToken = null;
|
8 |
-
|
9 |
-
public function assignData($data)
|
10 |
-
{
|
11 |
-
$info = $this->getInfoInstance();
|
12 |
-
|
13 |
-
if ($data->getCustomFieldOne())
|
14 |
-
{
|
15 |
-
$info->setCustomFieldOne($data->getCustomFieldOne());
|
16 |
-
}
|
17 |
-
|
18 |
-
if ($data->getCustomFieldTwo())
|
19 |
-
{
|
20 |
-
$info->setCustomFieldTwo($data->getCustomFieldTwo());
|
21 |
-
}
|
22 |
-
|
23 |
-
return $this;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function validate()
|
27 |
-
{
|
28 |
-
parent::validate();
|
29 |
-
$info = $this->getInfoInstance();
|
30 |
-
|
31 |
-
return $this;
|
32 |
-
}
|
33 |
-
|
34 |
-
public function getOrderPlaceRedirectUrl()
|
35 |
-
{
|
36 |
-
return Mage::getUrl('db1_anymarket/payment/redirect', array('_secure' => false));
|
37 |
-
}
|
38 |
Â
}
|
1 |
+
<?php
|
2 |
+
class DB1_AnyMarket_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract {
|
3 |
+
protected $_code = 'db1_anymarket';
|
4 |
+
protected $_isInitializeNeeded = true;
|
5 |
+
protected $_canUseInternal = true;
|
6 |
+
protected $_canUseForMultishipping = false;
|
7 |
+
protected $_apiToken = null;
|
8 |
+
|
9 |
+
public function assignData($data)
|
10 |
+
{
|
11 |
+
$info = $this->getInfoInstance();
|
12 |
+
|
13 |
+
if ($data->getCustomFieldOne())
|
14 |
+
{
|
15 |
+
$info->setCustomFieldOne($data->getCustomFieldOne());
|
16 |
+
}
|
17 |
+
|
18 |
+
if ($data->getCustomFieldTwo())
|
19 |
+
{
|
20 |
+
$info->setCustomFieldTwo($data->getCustomFieldTwo());
|
21 |
+
}
|
22 |
+
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function validate()
|
27 |
+
{
|
28 |
+
parent::validate();
|
29 |
+
$info = $this->getInfoInstance();
|
30 |
+
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getOrderPlaceRedirectUrl()
|
35 |
+
{
|
36 |
+
return Mage::getUrl('db1_anymarket/payment/redirect', array('_secure' => false));
|
37 |
+
}
|
38 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketattributes extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* constructor
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function _construct()
|
34 |
-
{
|
35 |
-
$this->_init('db1_anymarket/anymarketattributes', 'entity_id');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Get store ids to which specified item is assigned
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param int $anymarketattributesId
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function lookupStoreIds($anymarketattributesId)
|
47 |
-
{
|
48 |
-
$adapter = $this->_getReadAdapter();
|
49 |
-
$select = $adapter->select()
|
50 |
-
->from($this->getTable('db1_anymarket/anymarketattributes_store'), 'store_id')
|
51 |
-
->where('anymarketattributes_id = ?', (int)$anymarketattributesId);
|
52 |
-
return $adapter->fetchCol($select);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Perform operations after object load
|
57 |
-
*
|
58 |
-
* @access public
|
59 |
-
* @param Mage_Core_Model_Abstract $object
|
60 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes
|
61 |
-
|
62 |
-
*/
|
63 |
-
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
-
{
|
65 |
-
if ($object->getId()) {
|
66 |
-
$stores = $this->lookupStoreIds($object->getId());
|
67 |
-
$object->setData('store_id', $stores);
|
68 |
-
}
|
69 |
-
return parent::_afterLoad($object);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve select object for load object data
|
74 |
-
*
|
75 |
-
* @param string $field
|
76 |
-
* @param mixed $value
|
77 |
-
* @param DB1_AnyMarket_Model_Anymarketattributes $object
|
78 |
-
* @return Zend_Db_Select
|
79 |
-
*/
|
80 |
-
protected function _getLoadSelect($field, $value, $object)
|
81 |
-
{
|
82 |
-
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
-
if ($object->getStoreId()) {
|
84 |
-
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
-
$select->join(
|
86 |
-
array('anymarket_anymarketattributes_store' => $this->getTable('db1_anymarket/anymarketattributes_store')),
|
87 |
-
$this->getMainTable() . '.entity_id = anymarket_anymarketattributes_store.anymarketattributes_id',
|
88 |
-
array()
|
89 |
-
)
|
90 |
-
->where('anymarket_anymarketattributes_store.store_id IN (?)', $storeIds)
|
91 |
-
->order('anymarket_anymarketattributes_store.store_id DESC')
|
92 |
-
->limit(1);
|
93 |
-
}
|
94 |
-
return $select;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Assign anymarket attributes to store views
|
99 |
-
*
|
100 |
-
* @access protected
|
101 |
-
* @param Mage_Core_Model_Abstract $object
|
102 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes
|
103 |
-
|
104 |
-
*/
|
105 |
-
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
-
{
|
107 |
-
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
-
$newStores = (array)$object->getStores();
|
109 |
-
if (empty($newStores)) {
|
110 |
-
$newStores = (array)$object->getStoreId();
|
111 |
-
}
|
112 |
-
$table = $this->getTable('db1_anymarket/anymarketattributes_store');
|
113 |
-
$insert = array_diff($newStores, $oldStores);
|
114 |
-
$delete = array_diff($oldStores, $newStores);
|
115 |
-
if ($delete) {
|
116 |
-
$where = array(
|
117 |
-
'anymarketattributes_id = ?' => (int) $object->getId(),
|
118 |
-
'store_id IN (?)' => $delete
|
119 |
-
);
|
120 |
-
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
-
}
|
122 |
-
if ($insert) {
|
123 |
-
$data = array();
|
124 |
-
foreach ($insert as $storeId) {
|
125 |
-
$data[] = array(
|
126 |
-
'anymarketattributes_id' => (int) $object->getId(),
|
127 |
-
'store_id' => (int) $storeId
|
128 |
-
);
|
129 |
-
}
|
130 |
-
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
-
}
|
132 |
-
return parent::_afterSave($object);
|
133 |
-
}}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketattributes extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function _construct()
|
34 |
+
{
|
35 |
+
$this->_init('db1_anymarket/anymarketattributes', 'entity_id');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get store ids to which specified item is assigned
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param int $anymarketattributesId
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function lookupStoreIds($anymarketattributesId)
|
47 |
+
{
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('db1_anymarket/anymarketattributes_store'), 'store_id')
|
51 |
+
->where('anymarketattributes_id = ?', (int)$anymarketattributesId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Perform operations after object load
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @param Mage_Core_Model_Abstract $object
|
60 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes
|
61 |
+
|
62 |
+
*/
|
63 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
+
{
|
65 |
+
if ($object->getId()) {
|
66 |
+
$stores = $this->lookupStoreIds($object->getId());
|
67 |
+
$object->setData('store_id', $stores);
|
68 |
+
}
|
69 |
+
return parent::_afterLoad($object);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve select object for load object data
|
74 |
+
*
|
75 |
+
* @param string $field
|
76 |
+
* @param mixed $value
|
77 |
+
* @param DB1_AnyMarket_Model_Anymarketattributes $object
|
78 |
+
* @return Zend_Db_Select
|
79 |
+
*/
|
80 |
+
protected function _getLoadSelect($field, $value, $object)
|
81 |
+
{
|
82 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
+
if ($object->getStoreId()) {
|
84 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
+
$select->join(
|
86 |
+
array('anymarket_anymarketattributes_store' => $this->getTable('db1_anymarket/anymarketattributes_store')),
|
87 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketattributes_store.anymarketattributes_id',
|
88 |
+
array()
|
89 |
+
)
|
90 |
+
->where('anymarket_anymarketattributes_store.store_id IN (?)', $storeIds)
|
91 |
+
->order('anymarket_anymarketattributes_store.store_id DESC')
|
92 |
+
->limit(1);
|
93 |
+
}
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Assign anymarket attributes to store views
|
99 |
+
*
|
100 |
+
* @access protected
|
101 |
+
* @param Mage_Core_Model_Abstract $object
|
102 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes
|
103 |
+
|
104 |
+
*/
|
105 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
+
{
|
107 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
+
$newStores = (array)$object->getStores();
|
109 |
+
if (empty($newStores)) {
|
110 |
+
$newStores = (array)$object->getStoreId();
|
111 |
+
}
|
112 |
+
$table = $this->getTable('db1_anymarket/anymarketattributes_store');
|
113 |
+
$insert = array_diff($newStores, $oldStores);
|
114 |
+
$delete = array_diff($oldStores, $newStores);
|
115 |
+
if ($delete) {
|
116 |
+
$where = array(
|
117 |
+
'anymarketattributes_id = ?' => (int) $object->getId(),
|
118 |
+
'store_id IN (?)' => $delete
|
119 |
+
);
|
120 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
+
}
|
122 |
+
if ($insert) {
|
123 |
+
$data = array();
|
124 |
+
foreach ($insert as $storeId) {
|
125 |
+
$data[] = array(
|
126 |
+
'anymarketattributes_id' => (int) $object->getId(),
|
127 |
+
'store_id' => (int) $storeId
|
128 |
+
);
|
129 |
+
}
|
130 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
+
}
|
132 |
+
return parent::_afterSave($object);
|
133 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes/Collection.php
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 25
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes collection resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
-
{
|
26 |
-
protected $_joinedFields = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* constructor
|
30 |
-
*
|
31 |
-
* @access public
|
32 |
-
* @return void
|
33 |
-
|
34 |
-
*/
|
35 |
-
protected function _construct()
|
36 |
-
{
|
37 |
-
parent::_construct();
|
38 |
-
$this->_init('db1_anymarket/anymarketattributes');
|
39 |
-
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Add filter by store
|
44 |
-
*
|
45 |
-
* @access public
|
46 |
-
* @param int|Mage_Core_Model_Store $store
|
47 |
-
* @param bool $withAdmin
|
48 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection
|
49 |
-
|
50 |
-
*/
|
51 |
-
public function addStoreFilter($store, $withAdmin = true)
|
52 |
-
{
|
53 |
-
if (!isset($this->_joinedFields['store'])) {
|
54 |
-
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
-
$store = array($store->getId());
|
56 |
-
}
|
57 |
-
if (!is_array($store)) {
|
58 |
-
$store = array($store);
|
59 |
-
}
|
60 |
-
if ($withAdmin) {
|
61 |
-
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
-
}
|
63 |
-
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
-
$this->_joinedFields['store'] = true;
|
65 |
-
}
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Join store relation table if there is store filter
|
71 |
-
*
|
72 |
-
* @access protected
|
73 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection
|
74 |
-
|
75 |
-
*/
|
76 |
-
protected function _renderFiltersBefore()
|
77 |
-
{
|
78 |
-
if ($this->getFilter('store')) {
|
79 |
-
$this->getSelect()->join(
|
80 |
-
array('store_table' => $this->getTable('db1_anymarket/anymarketattributes_store')),
|
81 |
-
'main_table.entity_id = store_table.anymarketattributes_id',
|
82 |
-
array()
|
83 |
-
)
|
84 |
-
->group('main_table.entity_id');
|
85 |
-
/*
|
86 |
-
* Allow analytic functions usage because of one field grouping
|
87 |
-
*/
|
88 |
-
$this->_useAnalyticFunction = true;
|
89 |
-
}
|
90 |
-
return parent::_renderFiltersBefore();
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* get anymarket attributes as array
|
95 |
-
*
|
96 |
-
* @access protected
|
97 |
-
* @param string $valueField
|
98 |
-
* @param string $labelField
|
99 |
-
* @param array $additional
|
100 |
-
* @return array
|
101 |
-
|
102 |
-
*/
|
103 |
-
protected function _toOptionArray($valueField='entity_id', $labelField='nma_desc', $additional=array())
|
104 |
-
{
|
105 |
-
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* get options hash
|
110 |
-
*
|
111 |
-
* @access protected
|
112 |
-
* @param string $valueField
|
113 |
-
* @param string $labelField
|
114 |
-
* @return array
|
115 |
-
|
116 |
-
*/
|
117 |
-
protected function _toOptionHash($valueField='entity_id', $labelField='nma_desc')
|
118 |
-
{
|
119 |
-
return parent::_toOptionHash($valueField, $labelField);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get SQL for get record count.
|
124 |
-
* Extra GROUP BY strip added.
|
125 |
-
*
|
126 |
-
* @access public
|
127 |
-
* @return Varien_Db_Select
|
128 |
-
|
129 |
-
*/
|
130 |
-
public function getSelectCountSql()
|
131 |
-
{
|
132 |
-
$countSelect = parent::getSelectCountSql();
|
133 |
-
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
-
return $countSelect;
|
135 |
-
}
|
136 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 25
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
+
{
|
26 |
+
protected $_joinedFields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->_init('db1_anymarket/anymarketattributes');
|
39 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add filter by store
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @param int|Mage_Core_Model_Store $store
|
47 |
+
* @param bool $withAdmin
|
48 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection
|
49 |
+
|
50 |
+
*/
|
51 |
+
public function addStoreFilter($store, $withAdmin = true)
|
52 |
+
{
|
53 |
+
if (!isset($this->_joinedFields['store'])) {
|
54 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
+
$store = array($store->getId());
|
56 |
+
}
|
57 |
+
if (!is_array($store)) {
|
58 |
+
$store = array($store);
|
59 |
+
}
|
60 |
+
if ($withAdmin) {
|
61 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
+
}
|
63 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
+
$this->_joinedFields['store'] = true;
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Join store relation table if there is store filter
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketattributes_Collection
|
74 |
+
|
75 |
+
*/
|
76 |
+
protected function _renderFiltersBefore()
|
77 |
+
{
|
78 |
+
if ($this->getFilter('store')) {
|
79 |
+
$this->getSelect()->join(
|
80 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketattributes_store')),
|
81 |
+
'main_table.entity_id = store_table.anymarketattributes_id',
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('main_table.entity_id');
|
85 |
+
/*
|
86 |
+
* Allow analytic functions usage because of one field grouping
|
87 |
+
*/
|
88 |
+
$this->_useAnalyticFunction = true;
|
89 |
+
}
|
90 |
+
return parent::_renderFiltersBefore();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* get anymarket attributes as array
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @param string $valueField
|
98 |
+
* @param string $labelField
|
99 |
+
* @param array $additional
|
100 |
+
* @return array
|
101 |
+
|
102 |
+
*/
|
103 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='nma_desc', $additional=array())
|
104 |
+
{
|
105 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get options hash
|
110 |
+
*
|
111 |
+
* @access protected
|
112 |
+
* @param string $valueField
|
113 |
+
* @param string $labelField
|
114 |
+
* @return array
|
115 |
+
|
116 |
+
*/
|
117 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='nma_desc')
|
118 |
+
{
|
119 |
+
return parent::_toOptionHash($valueField, $labelField);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get SQL for get record count.
|
124 |
+
* Extra GROUP BY strip added.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @return Varien_Db_Select
|
128 |
+
|
129 |
+
*/
|
130 |
+
public function getSelectCountSql()
|
131 |
+
{
|
132 |
+
$countSelect = parent::getSelectCountSql();
|
133 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
+
return $countSelect;
|
135 |
+
}
|
136 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands.php
ADDED
@@ -0,0 +1,133 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketbrands extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function _construct()
|
34 |
+
{
|
35 |
+
$this->_init('db1_anymarket/anymarketbrands', 'entity_id');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get store ids to which specified item is assigned
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param int $anymarketbrandsId
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function lookupStoreIds($anymarketbrandsId)
|
47 |
+
{
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('db1_anymarket/anymarketbrands_store'), 'store_id')
|
51 |
+
->where('anymarketbrands_id = ?', (int)$anymarketbrandsId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Perform operations after object load
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @param Mage_Core_Model_Abstract $object
|
60 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketbrands
|
61 |
+
|
62 |
+
*/
|
63 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
+
{
|
65 |
+
if ($object->getId()) {
|
66 |
+
$stores = $this->lookupStoreIds($object->getId());
|
67 |
+
$object->setData('store_id', $stores);
|
68 |
+
}
|
69 |
+
return parent::_afterLoad($object);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve select object for load object data
|
74 |
+
*
|
75 |
+
* @param string $field
|
76 |
+
* @param mixed $value
|
77 |
+
* @param DB1_AnyMarket_Model_Anymarketbrands $object
|
78 |
+
* @return Zend_Db_Select
|
79 |
+
*/
|
80 |
+
protected function _getLoadSelect($field, $value, $object)
|
81 |
+
{
|
82 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
+
if ($object->getStoreId()) {
|
84 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
+
$select->join(
|
86 |
+
array('anymarket_anymarketbrands_store' => $this->getTable('db1_anymarket/anymarketbrands_store')),
|
87 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketbrands_store.anymarketbrands_id',
|
88 |
+
array()
|
89 |
+
)
|
90 |
+
->where('anymarket_anymarketbrands_store.store_id IN (?)', $storeIds)
|
91 |
+
->order('anymarket_anymarketbrands_store.store_id DESC')
|
92 |
+
->limit(1);
|
93 |
+
}
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Assign anymarketbrands to store views
|
99 |
+
*
|
100 |
+
* @access protected
|
101 |
+
* @param Mage_Core_Model_Abstract $object
|
102 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketbrands
|
103 |
+
|
104 |
+
*/
|
105 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
+
{
|
107 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
+
$newStores = (array)$object->getStores();
|
109 |
+
if (empty($newStores)) {
|
110 |
+
$newStores = (array)$object->getStoreId();
|
111 |
+
}
|
112 |
+
$table = $this->getTable('db1_anymarket/anymarketbrands_store');
|
113 |
+
$insert = array_diff($newStores, $oldStores);
|
114 |
+
$delete = array_diff($oldStores, $newStores);
|
115 |
+
if ($delete) {
|
116 |
+
$where = array(
|
117 |
+
'anymarketbrands_id = ?' => (int) $object->getId(),
|
118 |
+
'store_id IN (?)' => $delete
|
119 |
+
);
|
120 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
+
}
|
122 |
+
if ($insert) {
|
123 |
+
$data = array();
|
124 |
+
foreach ($insert as $storeId) {
|
125 |
+
$data[] = array(
|
126 |
+
'anymarketbrands_id' => (int) $object->getId(),
|
127 |
+
'store_id' => (int) $storeId
|
128 |
+
);
|
129 |
+
}
|
130 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
+
}
|
132 |
+
return parent::_afterSave($object);
|
133 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands/Collection.php
ADDED
@@ -0,0 +1,136 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketbrands_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
+
{
|
26 |
+
protected $_joinedFields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->_init('db1_anymarket/anymarketbrands');
|
39 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add filter by store
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @param int|Mage_Core_Model_Store $store
|
47 |
+
* @param bool $withAdmin
|
48 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketbrands_Collection
|
49 |
+
|
50 |
+
*/
|
51 |
+
public function addStoreFilter($store, $withAdmin = true)
|
52 |
+
{
|
53 |
+
if (!isset($this->_joinedFields['store'])) {
|
54 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
+
$store = array($store->getId());
|
56 |
+
}
|
57 |
+
if (!is_array($store)) {
|
58 |
+
$store = array($store);
|
59 |
+
}
|
60 |
+
if ($withAdmin) {
|
61 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
+
}
|
63 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
+
$this->_joinedFields['store'] = true;
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Join store relation table if there is store filter
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketbrands_Collection
|
74 |
+
|
75 |
+
*/
|
76 |
+
protected function _renderFiltersBefore()
|
77 |
+
{
|
78 |
+
if ($this->getFilter('store')) {
|
79 |
+
$this->getSelect()->join(
|
80 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketbrands_store')),
|
81 |
+
'main_table.entity_id = store_table.anymarketbrands_id',
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('main_table.entity_id');
|
85 |
+
/*
|
86 |
+
* Allow analytic functions usage because of one field grouping
|
87 |
+
*/
|
88 |
+
$this->_useAnalyticFunction = true;
|
89 |
+
}
|
90 |
+
return parent::_renderFiltersBefore();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* get anymarketbrand as array
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @param string $valueField
|
98 |
+
* @param string $labelField
|
99 |
+
* @param array $additional
|
100 |
+
* @return array
|
101 |
+
|
102 |
+
*/
|
103 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='brd_id', $additional=array())
|
104 |
+
{
|
105 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get options hash
|
110 |
+
*
|
111 |
+
* @access protected
|
112 |
+
* @param string $valueField
|
113 |
+
* @param string $labelField
|
114 |
+
* @return array
|
115 |
+
|
116 |
+
*/
|
117 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='brd_id')
|
118 |
+
{
|
119 |
+
return parent::_toOptionHash($valueField, $labelField);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get SQL for get record count.
|
124 |
+
* Extra GROUP BY strip added.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @return Varien_Db_Select
|
128 |
+
|
129 |
+
*/
|
130 |
+
public function getSelectCountSql()
|
131 |
+
{
|
132 |
+
$countSelect = parent::getSelectCountSql();
|
133 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
+
return $countSelect;
|
135 |
+
}
|
136 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketcategories extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* constructor
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function _construct()
|
34 |
-
{
|
35 |
-
$this->_init('db1_anymarket/anymarketcategories', 'entity_id');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Get store ids to which specified item is assigned
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param int $anymarketcategoriesId
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function lookupStoreIds($anymarketcategoriesId)
|
47 |
-
{
|
48 |
-
$adapter = $this->_getReadAdapter();
|
49 |
-
$select = $adapter->select()
|
50 |
-
->from($this->getTable('db1_anymarket/anymarketcategories_store'), 'store_id')
|
51 |
-
->where('anymarketcategories_id = ?', (int)$anymarketcategoriesId);
|
52 |
-
return $adapter->fetchCol($select);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Perform operations after object load
|
57 |
-
*
|
58 |
-
* @access public
|
59 |
-
* @param Mage_Core_Model_Abstract $object
|
60 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories
|
61 |
-
|
62 |
-
*/
|
63 |
-
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
-
{
|
65 |
-
if ($object->getId()) {
|
66 |
-
$stores = $this->lookupStoreIds($object->getId());
|
67 |
-
$object->setData('store_id', $stores);
|
68 |
-
}
|
69 |
-
return parent::_afterLoad($object);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve select object for load object data
|
74 |
-
*
|
75 |
-
* @param string $field
|
76 |
-
* @param mixed $value
|
77 |
-
* @param DB1_AnyMarket_Model_Anymarketcategories $object
|
78 |
-
* @return Zend_Db_Select
|
79 |
-
*/
|
80 |
-
protected function _getLoadSelect($field, $value, $object)
|
81 |
-
{
|
82 |
-
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
-
if ($object->getStoreId()) {
|
84 |
-
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
-
$select->join(
|
86 |
-
array('anymarket_anymarketcategories_store' => $this->getTable('db1_anymarket/anymarketcategories_store')),
|
87 |
-
$this->getMainTable() . '.entity_id = anymarket_anymarketcategories_store.anymarketcategories_id',
|
88 |
-
array()
|
89 |
-
)
|
90 |
-
->where('anymarket_anymarketcategories_store.store_id IN (?)', $storeIds)
|
91 |
-
->order('anymarket_anymarketcategories_store.store_id DESC')
|
92 |
-
->limit(1);
|
93 |
-
}
|
94 |
-
return $select;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Assign anymarket categories to store views
|
99 |
-
*
|
100 |
-
* @access protected
|
101 |
-
* @param Mage_Core_Model_Abstract $object
|
102 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories
|
103 |
-
|
104 |
-
*/
|
105 |
-
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
-
{
|
107 |
-
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
-
$newStores = (array)$object->getStores();
|
109 |
-
if (empty($newStores)) {
|
110 |
-
$newStores = (array)$object->getStoreId();
|
111 |
-
}
|
112 |
-
$table = $this->getTable('db1_anymarket/anymarketcategories_store');
|
113 |
-
$insert = array_diff($newStores, $oldStores);
|
114 |
-
$delete = array_diff($oldStores, $newStores);
|
115 |
-
if ($delete) {
|
116 |
-
$where = array(
|
117 |
-
'anymarketcategories_id = ?' => (int) $object->getId(),
|
118 |
-
'store_id IN (?)' => $delete
|
119 |
-
);
|
120 |
-
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
-
}
|
122 |
-
if ($insert) {
|
123 |
-
$data = array();
|
124 |
-
foreach ($insert as $storeId) {
|
125 |
-
$data[] = array(
|
126 |
-
'anymarketcategories_id' => (int) $object->getId(),
|
127 |
-
'store_id' => (int) $storeId
|
128 |
-
);
|
129 |
-
}
|
130 |
-
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
-
}
|
132 |
-
return parent::_afterSave($object);
|
133 |
-
}}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketcategories extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function _construct()
|
34 |
+
{
|
35 |
+
$this->_init('db1_anymarket/anymarketcategories', 'entity_id');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get store ids to which specified item is assigned
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param int $anymarketcategoriesId
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function lookupStoreIds($anymarketcategoriesId)
|
47 |
+
{
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('db1_anymarket/anymarketcategories_store'), 'store_id')
|
51 |
+
->where('anymarketcategories_id = ?', (int)$anymarketcategoriesId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Perform operations after object load
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @param Mage_Core_Model_Abstract $object
|
60 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories
|
61 |
+
|
62 |
+
*/
|
63 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
+
{
|
65 |
+
if ($object->getId()) {
|
66 |
+
$stores = $this->lookupStoreIds($object->getId());
|
67 |
+
$object->setData('store_id', $stores);
|
68 |
+
}
|
69 |
+
return parent::_afterLoad($object);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve select object for load object data
|
74 |
+
*
|
75 |
+
* @param string $field
|
76 |
+
* @param mixed $value
|
77 |
+
* @param DB1_AnyMarket_Model_Anymarketcategories $object
|
78 |
+
* @return Zend_Db_Select
|
79 |
+
*/
|
80 |
+
protected function _getLoadSelect($field, $value, $object)
|
81 |
+
{
|
82 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
+
if ($object->getStoreId()) {
|
84 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
+
$select->join(
|
86 |
+
array('anymarket_anymarketcategories_store' => $this->getTable('db1_anymarket/anymarketcategories_store')),
|
87 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketcategories_store.anymarketcategories_id',
|
88 |
+
array()
|
89 |
+
)
|
90 |
+
->where('anymarket_anymarketcategories_store.store_id IN (?)', $storeIds)
|
91 |
+
->order('anymarket_anymarketcategories_store.store_id DESC')
|
92 |
+
->limit(1);
|
93 |
+
}
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Assign anymarket categories to store views
|
99 |
+
*
|
100 |
+
* @access protected
|
101 |
+
* @param Mage_Core_Model_Abstract $object
|
102 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories
|
103 |
+
|
104 |
+
*/
|
105 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
+
{
|
107 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
+
$newStores = (array)$object->getStores();
|
109 |
+
if (empty($newStores)) {
|
110 |
+
$newStores = (array)$object->getStoreId();
|
111 |
+
}
|
112 |
+
$table = $this->getTable('db1_anymarket/anymarketcategories_store');
|
113 |
+
$insert = array_diff($newStores, $oldStores);
|
114 |
+
$delete = array_diff($oldStores, $newStores);
|
115 |
+
if ($delete) {
|
116 |
+
$where = array(
|
117 |
+
'anymarketcategories_id = ?' => (int) $object->getId(),
|
118 |
+
'store_id IN (?)' => $delete
|
119 |
+
);
|
120 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
+
}
|
122 |
+
if ($insert) {
|
123 |
+
$data = array();
|
124 |
+
foreach ($insert as $storeId) {
|
125 |
+
$data[] = array(
|
126 |
+
'anymarketcategories_id' => (int) $object->getId(),
|
127 |
+
'store_id' => (int) $storeId
|
128 |
+
);
|
129 |
+
}
|
130 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
+
}
|
132 |
+
return parent::_afterSave($object);
|
133 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories/Collection.php
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Categories collection resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
-
{
|
26 |
-
protected $_joinedFields = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* constructor
|
30 |
-
*
|
31 |
-
* @access public
|
32 |
-
* @return void
|
33 |
-
|
34 |
-
*/
|
35 |
-
protected function _construct()
|
36 |
-
{
|
37 |
-
parent::_construct();
|
38 |
-
$this->_init('db1_anymarket/anymarketcategories');
|
39 |
-
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Add filter by store
|
44 |
-
*
|
45 |
-
* @access public
|
46 |
-
* @param int|Mage_Core_Model_Store $store
|
47 |
-
* @param bool $withAdmin
|
48 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection
|
49 |
-
|
50 |
-
*/
|
51 |
-
public function addStoreFilter($store, $withAdmin = true)
|
52 |
-
{
|
53 |
-
if (!isset($this->_joinedFields['store'])) {
|
54 |
-
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
-
$store = array($store->getId());
|
56 |
-
}
|
57 |
-
if (!is_array($store)) {
|
58 |
-
$store = array($store);
|
59 |
-
}
|
60 |
-
if ($withAdmin) {
|
61 |
-
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
-
}
|
63 |
-
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
-
$this->_joinedFields['store'] = true;
|
65 |
-
}
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Join store relation table if there is store filter
|
71 |
-
*
|
72 |
-
* @access protected
|
73 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection
|
74 |
-
|
75 |
-
*/
|
76 |
-
protected function _renderFiltersBefore()
|
77 |
-
{
|
78 |
-
if ($this->getFilter('store')) {
|
79 |
-
$this->getSelect()->join(
|
80 |
-
array('store_table' => $this->getTable('db1_anymarket/anymarketcategories_store')),
|
81 |
-
'main_table.entity_id = store_table.anymarketcategories_id',
|
82 |
-
array()
|
83 |
-
)
|
84 |
-
->group('main_table.entity_id');
|
85 |
-
/*
|
86 |
-
* Allow analytic functions usage because of one field grouping
|
87 |
-
*/
|
88 |
-
$this->_useAnalyticFunction = true;
|
89 |
-
}
|
90 |
-
return parent::_renderFiltersBefore();
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* get anymarket categories as array
|
95 |
-
*
|
96 |
-
* @access protected
|
97 |
-
* @param string $valueField
|
98 |
-
* @param string $labelField
|
99 |
-
* @param array $additional
|
100 |
-
* @return array
|
101 |
-
|
102 |
-
*/
|
103 |
-
protected function _toOptionArray($valueField='entity_id', $labelField='nmc_cat_desc', $additional=array())
|
104 |
-
{
|
105 |
-
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* get options hash
|
110 |
-
*
|
111 |
-
* @access protected
|
112 |
-
* @param string $valueField
|
113 |
-
* @param string $labelField
|
114 |
-
* @return array
|
115 |
-
|
116 |
-
*/
|
117 |
-
protected function _toOptionHash($valueField='entity_id', $labelField='nmc_cat_desc')
|
118 |
-
{
|
119 |
-
return parent::_toOptionHash($valueField, $labelField);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get SQL for get record count.
|
124 |
-
* Extra GROUP BY strip added.
|
125 |
-
*
|
126 |
-
* @access public
|
127 |
-
* @return Varien_Db_Select
|
128 |
-
|
129 |
-
*/
|
130 |
-
public function getSelectCountSql()
|
131 |
-
{
|
132 |
-
$countSelect = parent::getSelectCountSql();
|
133 |
-
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
-
return $countSelect;
|
135 |
-
}
|
136 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Categories collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
+
{
|
26 |
+
protected $_joinedFields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->_init('db1_anymarket/anymarketcategories');
|
39 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add filter by store
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @param int|Mage_Core_Model_Store $store
|
47 |
+
* @param bool $withAdmin
|
48 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection
|
49 |
+
|
50 |
+
*/
|
51 |
+
public function addStoreFilter($store, $withAdmin = true)
|
52 |
+
{
|
53 |
+
if (!isset($this->_joinedFields['store'])) {
|
54 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
+
$store = array($store->getId());
|
56 |
+
}
|
57 |
+
if (!is_array($store)) {
|
58 |
+
$store = array($store);
|
59 |
+
}
|
60 |
+
if ($withAdmin) {
|
61 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
+
}
|
63 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
+
$this->_joinedFields['store'] = true;
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Join store relation table if there is store filter
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketcategories_Collection
|
74 |
+
|
75 |
+
*/
|
76 |
+
protected function _renderFiltersBefore()
|
77 |
+
{
|
78 |
+
if ($this->getFilter('store')) {
|
79 |
+
$this->getSelect()->join(
|
80 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketcategories_store')),
|
81 |
+
'main_table.entity_id = store_table.anymarketcategories_id',
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('main_table.entity_id');
|
85 |
+
/*
|
86 |
+
* Allow analytic functions usage because of one field grouping
|
87 |
+
*/
|
88 |
+
$this->_useAnalyticFunction = true;
|
89 |
+
}
|
90 |
+
return parent::_renderFiltersBefore();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* get anymarket categories as array
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @param string $valueField
|
98 |
+
* @param string $labelField
|
99 |
+
* @param array $additional
|
100 |
+
* @return array
|
101 |
+
|
102 |
+
*/
|
103 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='nmc_cat_desc', $additional=array())
|
104 |
+
{
|
105 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get options hash
|
110 |
+
*
|
111 |
+
* @access protected
|
112 |
+
* @param string $valueField
|
113 |
+
* @param string $labelField
|
114 |
+
* @return array
|
115 |
+
|
116 |
+
*/
|
117 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='nmc_cat_desc')
|
118 |
+
{
|
119 |
+
return parent::_toOptionHash($valueField, $labelField);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get SQL for get record count.
|
124 |
+
* Extra GROUP BY strip added.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @return Varien_Db_Select
|
128 |
+
|
129 |
+
*/
|
130 |
+
public function getSelectCountSql()
|
131 |
+
{
|
132 |
+
$countSelect = parent::getSelectCountSql();
|
133 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
+
return $countSelect;
|
135 |
+
}
|
136 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketlog extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* constructor
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
public function _construct()
|
34 |
-
{
|
35 |
-
$this->_init('db1_anymarket/anymarketlog', 'entity_id');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Get store ids to which specified item is assigned
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param int $anymarketlogId
|
43 |
-
* @return array
|
44 |
-
*
|
45 |
-
*/
|
46 |
-
public function lookupStoreIds($anymarketlogId)
|
47 |
-
{
|
48 |
-
$adapter = $this->_getReadAdapter();
|
49 |
-
$select = $adapter->select()
|
50 |
-
->from($this->getTable('db1_anymarket/anymarketlog_store'), 'store_id')
|
51 |
-
->where('anymarketlog_id = ?', (int)$anymarketlogId);
|
52 |
-
return $adapter->fetchCol($select);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Perform operations after object load
|
57 |
-
*
|
58 |
-
* @access public
|
59 |
-
* @param Mage_Core_Model_Abstract $object
|
60 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketlog
|
61 |
-
*
|
62 |
-
*/
|
63 |
-
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
-
{
|
65 |
-
if ($object->getId()) {
|
66 |
-
$stores = $this->lookupStoreIds($object->getId());
|
67 |
-
$object->setData('store_id', $stores);
|
68 |
-
}
|
69 |
-
return parent::_afterLoad($object);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve select object for load object data
|
74 |
-
*
|
75 |
-
* @param string $field
|
76 |
-
* @param mixed $value
|
77 |
-
* @param DB1_AnyMarket_Model_Anymarketlog $object
|
78 |
-
* @return Zend_Db_Select
|
79 |
-
*/
|
80 |
-
protected function _getLoadSelect($field, $value, $object)
|
81 |
-
{
|
82 |
-
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
-
if ($object->getStoreId()) {
|
84 |
-
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
-
$select->join(
|
86 |
-
array('anymarket_anymarketlog_store' => $this->getTable('db1_anymarket/anymarketlog_store')),
|
87 |
-
$this->getMainTable() . '.entity_id = anymarket_anymarketlog_store.anymarketlog_id',
|
88 |
-
array()
|
89 |
-
)
|
90 |
-
->where('anymarket_anymarketlog_store.store_id IN (?)', $storeIds)
|
91 |
-
->order('anymarket_anymarketlog_store.store_id DESC')
|
92 |
-
->limit(1);
|
93 |
-
}
|
94 |
-
return $select;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Assign anymarket log to store views
|
99 |
-
*
|
100 |
-
* @access protected
|
101 |
-
* @param Mage_Core_Model_Abstract $object
|
102 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketlog
|
103 |
-
*
|
104 |
-
*/
|
105 |
-
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
-
{
|
107 |
-
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
-
$newStores = (array)$object->getStores();
|
109 |
-
if (empty($newStores)) {
|
110 |
-
$newStores = (array)$object->getStoreId();
|
111 |
-
}
|
112 |
-
$table = $this->getTable('db1_anymarket/anymarketlog_store');
|
113 |
-
$insert = array_diff($newStores, $oldStores);
|
114 |
-
$delete = array_diff($oldStores, $newStores);
|
115 |
-
if ($delete) {
|
116 |
-
$where = array(
|
117 |
-
'anymarketlog_id = ?' => (int) $object->getId(),
|
118 |
-
'store_id IN (?)' => $delete
|
119 |
-
);
|
120 |
-
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
-
}
|
122 |
-
if ($insert) {
|
123 |
-
$data = array();
|
124 |
-
foreach ($insert as $storeId) {
|
125 |
-
$data[] = array(
|
126 |
-
'anymarketlog_id' => (int) $object->getId(),
|
127 |
-
'store_id' => (int) $storeId
|
128 |
-
);
|
129 |
-
}
|
130 |
-
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
-
}
|
132 |
-
return parent::_afterSave($object);
|
133 |
-
}}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketlog extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function _construct()
|
34 |
+
{
|
35 |
+
$this->_init('db1_anymarket/anymarketlog', 'entity_id');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get store ids to which specified item is assigned
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param int $anymarketlogId
|
43 |
+
* @return array
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
public function lookupStoreIds($anymarketlogId)
|
47 |
+
{
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('db1_anymarket/anymarketlog_store'), 'store_id')
|
51 |
+
->where('anymarketlog_id = ?', (int)$anymarketlogId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Perform operations after object load
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @param Mage_Core_Model_Abstract $object
|
60 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketlog
|
61 |
+
*
|
62 |
+
*/
|
63 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
+
{
|
65 |
+
if ($object->getId()) {
|
66 |
+
$stores = $this->lookupStoreIds($object->getId());
|
67 |
+
$object->setData('store_id', $stores);
|
68 |
+
}
|
69 |
+
return parent::_afterLoad($object);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve select object for load object data
|
74 |
+
*
|
75 |
+
* @param string $field
|
76 |
+
* @param mixed $value
|
77 |
+
* @param DB1_AnyMarket_Model_Anymarketlog $object
|
78 |
+
* @return Zend_Db_Select
|
79 |
+
*/
|
80 |
+
protected function _getLoadSelect($field, $value, $object)
|
81 |
+
{
|
82 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
+
if ($object->getStoreId()) {
|
84 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
+
$select->join(
|
86 |
+
array('anymarket_anymarketlog_store' => $this->getTable('db1_anymarket/anymarketlog_store')),
|
87 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketlog_store.anymarketlog_id',
|
88 |
+
array()
|
89 |
+
)
|
90 |
+
->where('anymarket_anymarketlog_store.store_id IN (?)', $storeIds)
|
91 |
+
->order('anymarket_anymarketlog_store.store_id DESC')
|
92 |
+
->limit(1);
|
93 |
+
}
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Assign anymarket log to store views
|
99 |
+
*
|
100 |
+
* @access protected
|
101 |
+
* @param Mage_Core_Model_Abstract $object
|
102 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketlog
|
103 |
+
*
|
104 |
+
*/
|
105 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
+
{
|
107 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
+
$newStores = (array)$object->getStores();
|
109 |
+
if (empty($newStores)) {
|
110 |
+
$newStores = (array)$object->getStoreId();
|
111 |
+
}
|
112 |
+
$table = $this->getTable('db1_anymarket/anymarketlog_store');
|
113 |
+
$insert = array_diff($newStores, $oldStores);
|
114 |
+
$delete = array_diff($oldStores, $newStores);
|
115 |
+
if ($delete) {
|
116 |
+
$where = array(
|
117 |
+
'anymarketlog_id = ?' => (int) $object->getId(),
|
118 |
+
'store_id IN (?)' => $delete
|
119 |
+
);
|
120 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
+
}
|
122 |
+
if ($insert) {
|
123 |
+
$data = array();
|
124 |
+
foreach ($insert as $storeId) {
|
125 |
+
$data[] = array(
|
126 |
+
'anymarketlog_id' => (int) $object->getId(),
|
127 |
+
'store_id' => (int) $storeId
|
128 |
+
);
|
129 |
+
}
|
130 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
+
}
|
132 |
+
return parent::_afterSave($object);
|
133 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog/Collection.php
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket Log collection resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketlog_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
-
{
|
26 |
-
protected $_joinedFields = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* constructor
|
30 |
-
*
|
31 |
-
* @access public
|
32 |
-
* @return void
|
33 |
-
*
|
34 |
-
*/
|
35 |
-
protected function _construct()
|
36 |
-
{
|
37 |
-
parent::_construct();
|
38 |
-
$this->_init('db1_anymarket/anymarketlog');
|
39 |
-
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Add filter by store
|
44 |
-
*
|
45 |
-
* @access public
|
46 |
-
* @param int|Mage_Core_Model_Store $store
|
47 |
-
* @param bool $withAdmin
|
48 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketlog_Collection
|
49 |
-
*
|
50 |
-
*/
|
51 |
-
public function addStoreFilter($store, $withAdmin = true)
|
52 |
-
{
|
53 |
-
if (!isset($this->_joinedFields['store'])) {
|
54 |
-
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
-
$store = array($store->getId());
|
56 |
-
}
|
57 |
-
if (!is_array($store)) {
|
58 |
-
$store = array($store);
|
59 |
-
}
|
60 |
-
if ($withAdmin) {
|
61 |
-
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
-
}
|
63 |
-
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
-
$this->_joinedFields['store'] = true;
|
65 |
-
}
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Join store relation table if there is store filter
|
71 |
-
*
|
72 |
-
* @access protected
|
73 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketlog_Collection
|
74 |
-
*
|
75 |
-
*/
|
76 |
-
protected function _renderFiltersBefore()
|
77 |
-
{
|
78 |
-
if ($this->getFilter('store')) {
|
79 |
-
$this->getSelect()->join(
|
80 |
-
array('store_table' => $this->getTable('db1_anymarket/anymarketlog_store')),
|
81 |
-
'main_table.entity_id = store_table.anymarketlog_id',
|
82 |
-
array()
|
83 |
-
)
|
84 |
-
->group('main_table.entity_id');
|
85 |
-
/*
|
86 |
-
* Allow analytic functions usage because of one field grouping
|
87 |
-
*/
|
88 |
-
$this->_useAnalyticFunction = true;
|
89 |
-
}
|
90 |
-
return parent::_renderFiltersBefore();
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* get anymarket log as array
|
95 |
-
*
|
96 |
-
* @access protected
|
97 |
-
* @param string $valueField
|
98 |
-
* @param string $labelField
|
99 |
-
* @param array $additional
|
100 |
-
* @return array
|
101 |
-
*
|
102 |
-
*/
|
103 |
-
protected function _toOptionArray($valueField='entity_id', $labelField='log_desc', $additional=array())
|
104 |
-
{
|
105 |
-
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* get options hash
|
110 |
-
*
|
111 |
-
* @access protected
|
112 |
-
* @param string $valueField
|
113 |
-
* @param string $labelField
|
114 |
-
* @return array
|
115 |
-
*
|
116 |
-
*/
|
117 |
-
protected function _toOptionHash($valueField='entity_id', $labelField='log_desc')
|
118 |
-
{
|
119 |
-
return parent::_toOptionHash($valueField, $labelField);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get SQL for get record count.
|
124 |
-
* Extra GROUP BY strip added.
|
125 |
-
*
|
126 |
-
* @access public
|
127 |
-
* @return Varien_Db_Select
|
128 |
-
*
|
129 |
-
*/
|
130 |
-
public function getSelectCountSql()
|
131 |
-
{
|
132 |
-
$countSelect = parent::getSelectCountSql();
|
133 |
-
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
-
return $countSelect;
|
135 |
-
}
|
136 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket Log collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketlog_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
+
{
|
26 |
+
protected $_joinedFields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
*
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->_init('db1_anymarket/anymarketlog');
|
39 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add filter by store
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @param int|Mage_Core_Model_Store $store
|
47 |
+
* @param bool $withAdmin
|
48 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketlog_Collection
|
49 |
+
*
|
50 |
+
*/
|
51 |
+
public function addStoreFilter($store, $withAdmin = true)
|
52 |
+
{
|
53 |
+
if (!isset($this->_joinedFields['store'])) {
|
54 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
+
$store = array($store->getId());
|
56 |
+
}
|
57 |
+
if (!is_array($store)) {
|
58 |
+
$store = array($store);
|
59 |
+
}
|
60 |
+
if ($withAdmin) {
|
61 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
+
}
|
63 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
+
$this->_joinedFields['store'] = true;
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Join store relation table if there is store filter
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketlog_Collection
|
74 |
+
*
|
75 |
+
*/
|
76 |
+
protected function _renderFiltersBefore()
|
77 |
+
{
|
78 |
+
if ($this->getFilter('store')) {
|
79 |
+
$this->getSelect()->join(
|
80 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketlog_store')),
|
81 |
+
'main_table.entity_id = store_table.anymarketlog_id',
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('main_table.entity_id');
|
85 |
+
/*
|
86 |
+
* Allow analytic functions usage because of one field grouping
|
87 |
+
*/
|
88 |
+
$this->_useAnalyticFunction = true;
|
89 |
+
}
|
90 |
+
return parent::_renderFiltersBefore();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* get anymarket log as array
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @param string $valueField
|
98 |
+
* @param string $labelField
|
99 |
+
* @param array $additional
|
100 |
+
* @return array
|
101 |
+
*
|
102 |
+
*/
|
103 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='log_desc', $additional=array())
|
104 |
+
{
|
105 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get options hash
|
110 |
+
*
|
111 |
+
* @access protected
|
112 |
+
* @param string $valueField
|
113 |
+
* @param string $labelField
|
114 |
+
* @return array
|
115 |
+
*
|
116 |
+
*/
|
117 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='log_desc')
|
118 |
+
{
|
119 |
+
return parent::_toOptionHash($valueField, $labelField);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get SQL for get record count.
|
124 |
+
* Extra GROUP BY strip added.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @return Varien_Db_Select
|
128 |
+
*
|
129 |
+
*/
|
130 |
+
public function getSelectCountSql()
|
131 |
+
{
|
132 |
+
$countSelect = parent::getSelectCountSql();
|
133 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
+
return $countSelect;
|
135 |
+
}
|
136 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketorders extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* constructor
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
|
32 |
-
*/
|
33 |
-
public function _construct()
|
34 |
-
{
|
35 |
-
$this->_init('db1_anymarket/anymarketorders', 'entity_id');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Get store ids to which specified item is assigned
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param int $anymarketordersId
|
43 |
-
* @return array
|
44 |
-
|
45 |
-
*/
|
46 |
-
public function lookupStoreIds($anymarketordersId)
|
47 |
-
{
|
48 |
-
$adapter = $this->_getReadAdapter();
|
49 |
-
$select = $adapter->select()
|
50 |
-
->from($this->getTable('db1_anymarket/anymarketorders_store'), 'store_id')
|
51 |
-
->where('anymarketorders_id = ?', (int)$anymarketordersId);
|
52 |
-
return $adapter->fetchCol($select);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Perform operations after object load
|
57 |
-
*
|
58 |
-
* @access public
|
59 |
-
* @param Mage_Core_Model_Abstract $object
|
60 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketorders
|
61 |
-
|
62 |
-
*/
|
63 |
-
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
-
{
|
65 |
-
if ($object->getId()) {
|
66 |
-
$stores = $this->lookupStoreIds($object->getId());
|
67 |
-
$object->setData('store_id', $stores);
|
68 |
-
}
|
69 |
-
return parent::_afterLoad($object);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve select object for load object data
|
74 |
-
*
|
75 |
-
* @param string $field
|
76 |
-
* @param mixed $value
|
77 |
-
* @param DB1_AnyMarket_Model_Anymarketorders $object
|
78 |
-
* @return Zend_Db_Select
|
79 |
-
*/
|
80 |
-
protected function _getLoadSelect($field, $value, $object)
|
81 |
-
{
|
82 |
-
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
-
if ($object->getStoreId()) {
|
84 |
-
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
-
$select->join(
|
86 |
-
array('anymarket_anymarketorders_store' => $this->getTable('db1_anymarket/anymarketorders_store')),
|
87 |
-
$this->getMainTable() . '.entity_id = anymarket_anymarketorders_store.anymarketorders_id',
|
88 |
-
array()
|
89 |
-
)
|
90 |
-
->where('anymarket_anymarketorders_store.store_id IN (?)', $storeIds)
|
91 |
-
->order('anymarket_anymarketorders_store.store_id DESC')
|
92 |
-
->limit(1);
|
93 |
-
}
|
94 |
-
return $select;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Assign anymarket orders to store views
|
99 |
-
*
|
100 |
-
* @access protected
|
101 |
-
* @param Mage_Core_Model_Abstract $object
|
102 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketorders
|
103 |
-
|
104 |
-
*/
|
105 |
-
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
-
{
|
107 |
-
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
-
$newStores = (array)$object->getStores();
|
109 |
-
if (empty($newStores)) {
|
110 |
-
$newStores = (array)$object->getStoreId();
|
111 |
-
}
|
112 |
-
$table = $this->getTable('db1_anymarket/anymarketorders_store');
|
113 |
-
$insert = array_diff($newStores, $oldStores);
|
114 |
-
$delete = array_diff($oldStores, $newStores);
|
115 |
-
if ($delete) {
|
116 |
-
$where = array(
|
117 |
-
'anymarketorders_id = ?' => (int) $object->getId(),
|
118 |
-
'store_id IN (?)' => $delete
|
119 |
-
);
|
120 |
-
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
-
}
|
122 |
-
if ($insert) {
|
123 |
-
$data = array();
|
124 |
-
foreach ($insert as $storeId) {
|
125 |
-
$data[] = array(
|
126 |
-
'anymarketorders_id' => (int) $object->getId(),
|
127 |
-
'store_id' => (int) $storeId
|
128 |
-
);
|
129 |
-
}
|
130 |
-
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
-
}
|
132 |
-
return parent::_afterSave($object);
|
133 |
-
}}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketorders extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
|
32 |
+
*/
|
33 |
+
public function _construct()
|
34 |
+
{
|
35 |
+
$this->_init('db1_anymarket/anymarketorders', 'entity_id');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get store ids to which specified item is assigned
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param int $anymarketordersId
|
43 |
+
* @return array
|
44 |
+
|
45 |
+
*/
|
46 |
+
public function lookupStoreIds($anymarketordersId)
|
47 |
+
{
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('db1_anymarket/anymarketorders_store'), 'store_id')
|
51 |
+
->where('anymarketorders_id = ?', (int)$anymarketordersId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Perform operations after object load
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @param Mage_Core_Model_Abstract $object
|
60 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketorders
|
61 |
+
|
62 |
+
*/
|
63 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
+
{
|
65 |
+
if ($object->getId()) {
|
66 |
+
$stores = $this->lookupStoreIds($object->getId());
|
67 |
+
$object->setData('store_id', $stores);
|
68 |
+
}
|
69 |
+
return parent::_afterLoad($object);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve select object for load object data
|
74 |
+
*
|
75 |
+
* @param string $field
|
76 |
+
* @param mixed $value
|
77 |
+
* @param DB1_AnyMarket_Model_Anymarketorders $object
|
78 |
+
* @return Zend_Db_Select
|
79 |
+
*/
|
80 |
+
protected function _getLoadSelect($field, $value, $object)
|
81 |
+
{
|
82 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
+
if ($object->getStoreId()) {
|
84 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
+
$select->join(
|
86 |
+
array('anymarket_anymarketorders_store' => $this->getTable('db1_anymarket/anymarketorders_store')),
|
87 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketorders_store.anymarketorders_id',
|
88 |
+
array()
|
89 |
+
)
|
90 |
+
->where('anymarket_anymarketorders_store.store_id IN (?)', $storeIds)
|
91 |
+
->order('anymarket_anymarketorders_store.store_id DESC')
|
92 |
+
->limit(1);
|
93 |
+
}
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Assign anymarket orders to store views
|
99 |
+
*
|
100 |
+
* @access protected
|
101 |
+
* @param Mage_Core_Model_Abstract $object
|
102 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketorders
|
103 |
+
|
104 |
+
*/
|
105 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
+
{
|
107 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
+
$newStores = (array)$object->getStores();
|
109 |
+
if (empty($newStores)) {
|
110 |
+
$newStores = (array)$object->getStoreId();
|
111 |
+
}
|
112 |
+
$table = $this->getTable('db1_anymarket/anymarketorders_store');
|
113 |
+
$insert = array_diff($newStores, $oldStores);
|
114 |
+
$delete = array_diff($oldStores, $newStores);
|
115 |
+
if ($delete) {
|
116 |
+
$where = array(
|
117 |
+
'anymarketorders_id = ?' => (int) $object->getId(),
|
118 |
+
'store_id IN (?)' => $delete
|
119 |
+
);
|
120 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
+
}
|
122 |
+
if ($insert) {
|
123 |
+
$data = array();
|
124 |
+
foreach ($insert as $storeId) {
|
125 |
+
$data[] = array(
|
126 |
+
'anymarketorders_id' => (int) $object->getId(),
|
127 |
+
'store_id' => (int) $storeId
|
128 |
+
);
|
129 |
+
}
|
130 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
+
}
|
132 |
+
return parent::_afterSave($object);
|
133 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders/Collection.php
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Orders collection resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketorders_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
-
{
|
26 |
-
protected $_joinedFields = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* constructor
|
30 |
-
*
|
31 |
-
* @access public
|
32 |
-
* @return void
|
33 |
-
|
34 |
-
*/
|
35 |
-
protected function _construct()
|
36 |
-
{
|
37 |
-
parent::_construct();
|
38 |
-
$this->_init('db1_anymarket/anymarketorders');
|
39 |
-
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Add filter by store
|
44 |
-
*
|
45 |
-
* @access public
|
46 |
-
* @param int|Mage_Core_Model_Store $store
|
47 |
-
* @param bool $withAdmin
|
48 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketorders_Collection
|
49 |
-
|
50 |
-
*/
|
51 |
-
public function addStoreFilter($store, $withAdmin = true)
|
52 |
-
{
|
53 |
-
if (!isset($this->_joinedFields['store'])) {
|
54 |
-
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
-
$store = array($store->getId());
|
56 |
-
}
|
57 |
-
if (!is_array($store)) {
|
58 |
-
$store = array($store);
|
59 |
-
}
|
60 |
-
if ($withAdmin) {
|
61 |
-
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
-
}
|
63 |
-
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
-
$this->_joinedFields['store'] = true;
|
65 |
-
}
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Join store relation table if there is store filter
|
71 |
-
*
|
72 |
-
* @access protected
|
73 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketorders_Collection
|
74 |
-
|
75 |
-
*/
|
76 |
-
protected function _renderFiltersBefore()
|
77 |
-
{
|
78 |
-
if ($this->getFilter('store')) {
|
79 |
-
$this->getSelect()->join(
|
80 |
-
array('store_table' => $this->getTable('db1_anymarket/anymarketorders_store')),
|
81 |
-
'main_table.entity_id = store_table.anymarketorders_id',
|
82 |
-
array()
|
83 |
-
)
|
84 |
-
->group('main_table.entity_id');
|
85 |
-
/*
|
86 |
-
* Allow analytic functions usage because of one field grouping
|
87 |
-
*/
|
88 |
-
$this->_useAnalyticFunction = true;
|
89 |
-
}
|
90 |
-
return parent::_renderFiltersBefore();
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* get anymarket orders as array
|
95 |
-
*
|
96 |
-
* @access protected
|
97 |
-
* @param string $valueField
|
98 |
-
* @param string $labelField
|
99 |
-
* @param array $additional
|
100 |
-
* @return array
|
101 |
-
|
102 |
-
*/
|
103 |
-
protected function _toOptionArray($valueField='entity_id', $labelField='nmo_id_order', $additional=array())
|
104 |
-
{
|
105 |
-
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* get options hash
|
110 |
-
*
|
111 |
-
* @access protected
|
112 |
-
* @param string $valueField
|
113 |
-
* @param string $labelField
|
114 |
-
* @return array
|
115 |
-
|
116 |
-
*/
|
117 |
-
protected function _toOptionHash($valueField='entity_id', $labelField='nmo_id_order')
|
118 |
-
{
|
119 |
-
return parent::_toOptionHash($valueField, $labelField);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get SQL for get record count.
|
124 |
-
* Extra GROUP BY strip added.
|
125 |
-
*
|
126 |
-
* @access public
|
127 |
-
* @return Varien_Db_Select
|
128 |
-
|
129 |
-
*/
|
130 |
-
public function getSelectCountSql()
|
131 |
-
{
|
132 |
-
$countSelect = parent::getSelectCountSql();
|
133 |
-
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
-
return $countSelect;
|
135 |
-
}
|
136 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Orders collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketorders_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
+
{
|
26 |
+
protected $_joinedFields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->_init('db1_anymarket/anymarketorders');
|
39 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add filter by store
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @param int|Mage_Core_Model_Store $store
|
47 |
+
* @param bool $withAdmin
|
48 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketorders_Collection
|
49 |
+
|
50 |
+
*/
|
51 |
+
public function addStoreFilter($store, $withAdmin = true)
|
52 |
+
{
|
53 |
+
if (!isset($this->_joinedFields['store'])) {
|
54 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
+
$store = array($store->getId());
|
56 |
+
}
|
57 |
+
if (!is_array($store)) {
|
58 |
+
$store = array($store);
|
59 |
+
}
|
60 |
+
if ($withAdmin) {
|
61 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
+
}
|
63 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
+
$this->_joinedFields['store'] = true;
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Join store relation table if there is store filter
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketorders_Collection
|
74 |
+
|
75 |
+
*/
|
76 |
+
protected function _renderFiltersBefore()
|
77 |
+
{
|
78 |
+
if ($this->getFilter('store')) {
|
79 |
+
$this->getSelect()->join(
|
80 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketorders_store')),
|
81 |
+
'main_table.entity_id = store_table.anymarketorders_id',
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('main_table.entity_id');
|
85 |
+
/*
|
86 |
+
* Allow analytic functions usage because of one field grouping
|
87 |
+
*/
|
88 |
+
$this->_useAnalyticFunction = true;
|
89 |
+
}
|
90 |
+
return parent::_renderFiltersBefore();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* get anymarket orders as array
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @param string $valueField
|
98 |
+
* @param string $labelField
|
99 |
+
* @param array $additional
|
100 |
+
* @return array
|
101 |
+
|
102 |
+
*/
|
103 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='nmo_id_order', $additional=array())
|
104 |
+
{
|
105 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get options hash
|
110 |
+
*
|
111 |
+
* @access protected
|
112 |
+
* @param string $valueField
|
113 |
+
* @param string $labelField
|
114 |
+
* @return array
|
115 |
+
|
116 |
+
*/
|
117 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='nmo_id_order')
|
118 |
+
{
|
119 |
+
return parent::_toOptionHash($valueField, $labelField);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get SQL for get record count.
|
124 |
+
* Extra GROUP BY strip added.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @return Varien_Db_Select
|
128 |
+
|
129 |
+
*/
|
130 |
+
public function getSelectCountSql()
|
131 |
+
{
|
132 |
+
$countSelect = parent::getSelectCountSql();
|
133 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
+
return $countSelect;
|
135 |
+
}
|
136 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts.php
CHANGED
@@ -1,133 +1,133 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketproducts extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
-
{
|
26 |
-
|
27 |
-
/**
|
28 |
-
* constructor
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
*
|
32 |
-
*/
|
33 |
-
public function _construct()
|
34 |
-
{
|
35 |
-
$this->_init('db1_anymarket/anymarketproducts', 'entity_id');
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Get store ids to which specified item is assigned
|
40 |
-
*
|
41 |
-
* @access public
|
42 |
-
* @param int $anymarketproductsId
|
43 |
-
* @return array
|
44 |
-
*
|
45 |
-
*/
|
46 |
-
public function lookupStoreIds($anymarketproductsId)
|
47 |
-
{
|
48 |
-
$adapter = $this->_getReadAdapter();
|
49 |
-
$select = $adapter->select()
|
50 |
-
->from($this->getTable('db1_anymarket/anymarketproducts_store'), 'store_id')
|
51 |
-
->where('anymarketproducts_id = ?', (int)$anymarketproductsId);
|
52 |
-
return $adapter->fetchCol($select);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Perform operations after object load
|
57 |
-
*
|
58 |
-
* @access public
|
59 |
-
* @param Mage_Core_Model_Abstract $object
|
60 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts
|
61 |
-
*
|
62 |
-
*/
|
63 |
-
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
-
{
|
65 |
-
if ($object->getId()) {
|
66 |
-
$stores = $this->lookupStoreIds($object->getId());
|
67 |
-
$object->setData('store_id', $stores);
|
68 |
-
}
|
69 |
-
return parent::_afterLoad($object);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve select object for load object data
|
74 |
-
*
|
75 |
-
* @param string $field
|
76 |
-
* @param mixed $value
|
77 |
-
* @param DB1_AnyMarket_Model_Anymarketproducts $object
|
78 |
-
* @return Zend_Db_Select
|
79 |
-
*/
|
80 |
-
protected function _getLoadSelect($field, $value, $object)
|
81 |
-
{
|
82 |
-
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
-
if ($object->getStoreId()) {
|
84 |
-
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
-
$select->join(
|
86 |
-
array('anymarket_anymarketproducts_store' => $this->getTable('db1_anymarket/anymarketproducts_store')),
|
87 |
-
$this->getMainTable() . '.entity_id = anymarket_anymarketproducts_store.anymarketproducts_id',
|
88 |
-
array()
|
89 |
-
)
|
90 |
-
->where('anymarket_anymarketproducts_store.store_id IN (?)', $storeIds)
|
91 |
-
->order('anymarket_anymarketproducts_store.store_id DESC')
|
92 |
-
->limit(1);
|
93 |
-
}
|
94 |
-
return $select;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Assign anymarket products to store views
|
99 |
-
*
|
100 |
-
* @access protected
|
101 |
-
* @param Mage_Core_Model_Abstract $object
|
102 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts
|
103 |
-
*
|
104 |
-
*/
|
105 |
-
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
-
{
|
107 |
-
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
-
$newStores = (array)$object->getStores();
|
109 |
-
if (empty($newStores)) {
|
110 |
-
$newStores = (array)$object->getStoreId();
|
111 |
-
}
|
112 |
-
$table = $this->getTable('db1_anymarket/anymarketproducts_store');
|
113 |
-
$insert = array_diff($newStores, $oldStores);
|
114 |
-
$delete = array_diff($oldStores, $newStores);
|
115 |
-
if ($delete) {
|
116 |
-
$where = array(
|
117 |
-
'anymarketproducts_id = ?' => (int) $object->getId(),
|
118 |
-
'store_id IN (?)' => $delete
|
119 |
-
);
|
120 |
-
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
-
}
|
122 |
-
if ($insert) {
|
123 |
-
$data = array();
|
124 |
-
foreach ($insert as $storeId) {
|
125 |
-
$data[] = array(
|
126 |
-
'anymarketproducts_id' => (int) $object->getId(),
|
127 |
-
'store_id' => (int) $storeId
|
128 |
-
);
|
129 |
-
}
|
130 |
-
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
-
}
|
132 |
-
return parent::_afterSave($object);
|
133 |
-
}}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketproducts extends Mage_Core_Model_Resource_Db_Abstract
|
25 |
+
{
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
*
|
32 |
+
*/
|
33 |
+
public function _construct()
|
34 |
+
{
|
35 |
+
$this->_init('db1_anymarket/anymarketproducts', 'entity_id');
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get store ids to which specified item is assigned
|
40 |
+
*
|
41 |
+
* @access public
|
42 |
+
* @param int $anymarketproductsId
|
43 |
+
* @return array
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
public function lookupStoreIds($anymarketproductsId)
|
47 |
+
{
|
48 |
+
$adapter = $this->_getReadAdapter();
|
49 |
+
$select = $adapter->select()
|
50 |
+
->from($this->getTable('db1_anymarket/anymarketproducts_store'), 'store_id')
|
51 |
+
->where('anymarketproducts_id = ?', (int)$anymarketproductsId);
|
52 |
+
return $adapter->fetchCol($select);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Perform operations after object load
|
57 |
+
*
|
58 |
+
* @access public
|
59 |
+
* @param Mage_Core_Model_Abstract $object
|
60 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts
|
61 |
+
*
|
62 |
+
*/
|
63 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
64 |
+
{
|
65 |
+
if ($object->getId()) {
|
66 |
+
$stores = $this->lookupStoreIds($object->getId());
|
67 |
+
$object->setData('store_id', $stores);
|
68 |
+
}
|
69 |
+
return parent::_afterLoad($object);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Retrieve select object for load object data
|
74 |
+
*
|
75 |
+
* @param string $field
|
76 |
+
* @param mixed $value
|
77 |
+
* @param DB1_AnyMarket_Model_Anymarketproducts $object
|
78 |
+
* @return Zend_Db_Select
|
79 |
+
*/
|
80 |
+
protected function _getLoadSelect($field, $value, $object)
|
81 |
+
{
|
82 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
83 |
+
if ($object->getStoreId()) {
|
84 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
85 |
+
$select->join(
|
86 |
+
array('anymarket_anymarketproducts_store' => $this->getTable('db1_anymarket/anymarketproducts_store')),
|
87 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketproducts_store.anymarketproducts_id',
|
88 |
+
array()
|
89 |
+
)
|
90 |
+
->where('anymarket_anymarketproducts_store.store_id IN (?)', $storeIds)
|
91 |
+
->order('anymarket_anymarketproducts_store.store_id DESC')
|
92 |
+
->limit(1);
|
93 |
+
}
|
94 |
+
return $select;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Assign anymarket products to store views
|
99 |
+
*
|
100 |
+
* @access protected
|
101 |
+
* @param Mage_Core_Model_Abstract $object
|
102 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts
|
103 |
+
*
|
104 |
+
*/
|
105 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
106 |
+
{
|
107 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
108 |
+
$newStores = (array)$object->getStores();
|
109 |
+
if (empty($newStores)) {
|
110 |
+
$newStores = (array)$object->getStoreId();
|
111 |
+
}
|
112 |
+
$table = $this->getTable('db1_anymarket/anymarketproducts_store');
|
113 |
+
$insert = array_diff($newStores, $oldStores);
|
114 |
+
$delete = array_diff($oldStores, $newStores);
|
115 |
+
if ($delete) {
|
116 |
+
$where = array(
|
117 |
+
'anymarketproducts_id = ?' => (int) $object->getId(),
|
118 |
+
'store_id IN (?)' => $delete
|
119 |
+
);
|
120 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
121 |
+
}
|
122 |
+
if ($insert) {
|
123 |
+
$data = array();
|
124 |
+
foreach ($insert as $storeId) {
|
125 |
+
$data[] = array(
|
126 |
+
'anymarketproducts_id' => (int) $object->getId(),
|
127 |
+
'store_id' => (int) $storeId
|
128 |
+
);
|
129 |
+
}
|
130 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
131 |
+
}
|
132 |
+
return parent::_afterSave($object);
|
133 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts/Collection.php
CHANGED
@@ -1,136 +1,136 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Products collection resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
-
{
|
26 |
-
protected $_joinedFields = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* constructor
|
30 |
-
*
|
31 |
-
* @access public
|
32 |
-
* @return void
|
33 |
-
*
|
34 |
-
*/
|
35 |
-
protected function _construct()
|
36 |
-
{
|
37 |
-
parent::_construct();
|
38 |
-
$this->_init('db1_anymarket/anymarketproducts');
|
39 |
-
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Add filter by store
|
44 |
-
*
|
45 |
-
* @access public
|
46 |
-
* @param int|Mage_Core_Model_Store $store
|
47 |
-
* @param bool $withAdmin
|
48 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection
|
49 |
-
*
|
50 |
-
*/
|
51 |
-
public function addStoreFilter($store, $withAdmin = true)
|
52 |
-
{
|
53 |
-
if (!isset($this->_joinedFields['store'])) {
|
54 |
-
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
-
$store = array($store->getId());
|
56 |
-
}
|
57 |
-
if (!is_array($store)) {
|
58 |
-
$store = array($store);
|
59 |
-
}
|
60 |
-
if ($withAdmin) {
|
61 |
-
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
-
}
|
63 |
-
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
-
$this->_joinedFields['store'] = true;
|
65 |
-
}
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Join store relation table if there is store filter
|
71 |
-
*
|
72 |
-
* @access protected
|
73 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection
|
74 |
-
*
|
75 |
-
*/
|
76 |
-
protected function _renderFiltersBefore()
|
77 |
-
{
|
78 |
-
if ($this->getFilter('store')) {
|
79 |
-
$this->getSelect()->join(
|
80 |
-
array('store_table' => $this->getTable('db1_anymarket/anymarketproducts_store')),
|
81 |
-
'main_table.entity_id = store_table.anymarketproducts_id',
|
82 |
-
array()
|
83 |
-
)
|
84 |
-
->group('main_table.entity_id');
|
85 |
-
/*
|
86 |
-
* Allow analytic functions usage because of one field grouping
|
87 |
-
*/
|
88 |
-
$this->_useAnalyticFunction = true;
|
89 |
-
}
|
90 |
-
return parent::_renderFiltersBefore();
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* get anymarket products as array
|
95 |
-
*
|
96 |
-
* @access protected
|
97 |
-
* @param string $valueField
|
98 |
-
* @param string $labelField
|
99 |
-
* @param array $additional
|
100 |
-
* @return array
|
101 |
-
*
|
102 |
-
*/
|
103 |
-
protected function _toOptionArray($valueField='entity_id', $labelField='nmp_status_int', $additional=array())
|
104 |
-
{
|
105 |
-
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* get options hash
|
110 |
-
*
|
111 |
-
* @access protected
|
112 |
-
* @param string $valueField
|
113 |
-
* @param string $labelField
|
114 |
-
* @return array
|
115 |
-
*
|
116 |
-
*/
|
117 |
-
protected function _toOptionHash($valueField='entity_id', $labelField='nmp_status_int')
|
118 |
-
{
|
119 |
-
return parent::_toOptionHash($valueField, $labelField);
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Get SQL for get record count.
|
124 |
-
* Extra GROUP BY strip added.
|
125 |
-
*
|
126 |
-
* @access public
|
127 |
-
* @return Varien_Db_Select
|
128 |
-
*
|
129 |
-
*/
|
130 |
-
public function getSelectCountSql()
|
131 |
-
{
|
132 |
-
$countSelect = parent::getSelectCountSql();
|
133 |
-
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
-
return $countSelect;
|
135 |
-
}
|
136 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Products collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
25 |
+
{
|
26 |
+
protected $_joinedFields = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* constructor
|
30 |
+
*
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
*
|
34 |
+
*/
|
35 |
+
protected function _construct()
|
36 |
+
{
|
37 |
+
parent::_construct();
|
38 |
+
$this->_init('db1_anymarket/anymarketproducts');
|
39 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Add filter by store
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @param int|Mage_Core_Model_Store $store
|
47 |
+
* @param bool $withAdmin
|
48 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection
|
49 |
+
*
|
50 |
+
*/
|
51 |
+
public function addStoreFilter($store, $withAdmin = true)
|
52 |
+
{
|
53 |
+
if (!isset($this->_joinedFields['store'])) {
|
54 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
55 |
+
$store = array($store->getId());
|
56 |
+
}
|
57 |
+
if (!is_array($store)) {
|
58 |
+
$store = array($store);
|
59 |
+
}
|
60 |
+
if ($withAdmin) {
|
61 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
62 |
+
}
|
63 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
64 |
+
$this->_joinedFields['store'] = true;
|
65 |
+
}
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Join store relation table if there is store filter
|
71 |
+
*
|
72 |
+
* @access protected
|
73 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketproducts_Collection
|
74 |
+
*
|
75 |
+
*/
|
76 |
+
protected function _renderFiltersBefore()
|
77 |
+
{
|
78 |
+
if ($this->getFilter('store')) {
|
79 |
+
$this->getSelect()->join(
|
80 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketproducts_store')),
|
81 |
+
'main_table.entity_id = store_table.anymarketproducts_id',
|
82 |
+
array()
|
83 |
+
)
|
84 |
+
->group('main_table.entity_id');
|
85 |
+
/*
|
86 |
+
* Allow analytic functions usage because of one field grouping
|
87 |
+
*/
|
88 |
+
$this->_useAnalyticFunction = true;
|
89 |
+
}
|
90 |
+
return parent::_renderFiltersBefore();
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* get anymarket products as array
|
95 |
+
*
|
96 |
+
* @access protected
|
97 |
+
* @param string $valueField
|
98 |
+
* @param string $labelField
|
99 |
+
* @param array $additional
|
100 |
+
* @return array
|
101 |
+
*
|
102 |
+
*/
|
103 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='nmp_status_int', $additional=array())
|
104 |
+
{
|
105 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* get options hash
|
110 |
+
*
|
111 |
+
* @access protected
|
112 |
+
* @param string $valueField
|
113 |
+
* @param string $labelField
|
114 |
+
* @return array
|
115 |
+
*
|
116 |
+
*/
|
117 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='nmp_status_int')
|
118 |
+
{
|
119 |
+
return parent::_toOptionHash($valueField, $labelField);
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Get SQL for get record count.
|
124 |
+
* Extra GROUP BY strip added.
|
125 |
+
*
|
126 |
+
* @access public
|
127 |
+
* @return Varien_Db_Select
|
128 |
+
*
|
129 |
+
*/
|
130 |
+
public function getSelectCountSql()
|
131 |
+
{
|
132 |
+
$countSelect = parent::getSelectCountSql();
|
133 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
134 |
+
return $countSelect;
|
135 |
+
}
|
136 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue.php
CHANGED
@@ -1,132 +1,132 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Model_Resource_Anymarketqueue extends Mage_Core_Model_Resource_Db_Abstract
|
24 |
-
{
|
25 |
-
|
26 |
-
/**
|
27 |
-
* constructor
|
28 |
-
*
|
29 |
-
* @access public
|
30 |
-
|
31 |
-
*/
|
32 |
-
public function _construct()
|
33 |
-
{
|
34 |
-
$this->_init('db1_anymarket/anymarketqueue', 'entity_id');
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Get store ids to which specified item is assigned
|
39 |
-
*
|
40 |
-
* @access public
|
41 |
-
* @param int $anymarketqueueId
|
42 |
-
* @return array
|
43 |
-
|
44 |
-
*/
|
45 |
-
public function lookupStoreIds($anymarketqueueId)
|
46 |
-
{
|
47 |
-
$adapter = $this->_getReadAdapter();
|
48 |
-
$select = $adapter->select()
|
49 |
-
->from($this->getTable('db1_anymarket/anymarketqueue_store'), 'store_id')
|
50 |
-
->where('anymarketqueue_id = ?', (int)$anymarketqueueId);
|
51 |
-
return $adapter->fetchCol($select);
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Perform operations after object load
|
56 |
-
*
|
57 |
-
* @access public
|
58 |
-
* @param Mage_Core_Model_Abstract $object
|
59 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue
|
60 |
-
|
61 |
-
*/
|
62 |
-
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
63 |
-
{
|
64 |
-
if ($object->getId()) {
|
65 |
-
$stores = $this->lookupStoreIds($object->getId());
|
66 |
-
$object->setData('store_id', $stores);
|
67 |
-
}
|
68 |
-
return parent::_afterLoad($object);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Retrieve select object for load object data
|
73 |
-
*
|
74 |
-
* @param string $field
|
75 |
-
* @param mixed $value
|
76 |
-
* @param DB1_AnyMarket_Model_Anymarketqueue $object
|
77 |
-
* @return Zend_Db_Select
|
78 |
-
*/
|
79 |
-
protected function _getLoadSelect($field, $value, $object)
|
80 |
-
{
|
81 |
-
$select = parent::_getLoadSelect($field, $value, $object);
|
82 |
-
if ($object->getStoreId()) {
|
83 |
-
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
84 |
-
$select->join(
|
85 |
-
array('anymarket_anymarketqueue_store' => $this->getTable('db1_anymarket/anymarketqueue_store')),
|
86 |
-
$this->getMainTable() . '.entity_id = anymarket_anymarketqueue_store.anymarketqueue_id',
|
87 |
-
array()
|
88 |
-
)
|
89 |
-
->where('anymarket_anymarketqueue_store.store_id IN (?)', $storeIds)
|
90 |
-
->order('anymarket_anymarketqueue_store.store_id DESC')
|
91 |
-
->limit(1);
|
92 |
-
}
|
93 |
-
return $select;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Assign anymarket queue to store views
|
98 |
-
*
|
99 |
-
* @access protected
|
100 |
-
* @param Mage_Core_Model_Abstract $object
|
101 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue
|
102 |
-
|
103 |
-
*/
|
104 |
-
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
105 |
-
{
|
106 |
-
$oldStores = $this->lookupStoreIds($object->getId());
|
107 |
-
$newStores = (array)$object->getStores();
|
108 |
-
if (empty($newStores)) {
|
109 |
-
$newStores = (array)$object->getStoreId();
|
110 |
-
}
|
111 |
-
$table = $this->getTable('db1_anymarket/anymarketqueue_store');
|
112 |
-
$insert = array_diff($newStores, $oldStores);
|
113 |
-
$delete = array_diff($oldStores, $newStores);
|
114 |
-
if ($delete) {
|
115 |
-
$where = array(
|
116 |
-
'anymarketqueue_id = ?' => (int) $object->getId(),
|
117 |
-
'store_id IN (?)' => $delete
|
118 |
-
);
|
119 |
-
$this->_getWriteAdapter()->delete($table, $where);
|
120 |
-
}
|
121 |
-
if ($insert) {
|
122 |
-
$data = array();
|
123 |
-
foreach ($insert as $storeId) {
|
124 |
-
$data[] = array(
|
125 |
-
'anymarketqueue_id' => (int) $object->getId(),
|
126 |
-
'store_id' => (int) $storeId
|
127 |
-
);
|
128 |
-
}
|
129 |
-
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
130 |
-
}
|
131 |
-
return parent::_afterSave($object);
|
132 |
-
}}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Model_Resource_Anymarketqueue extends Mage_Core_Model_Resource_Db_Abstract
|
24 |
+
{
|
25 |
+
|
26 |
+
/**
|
27 |
+
* constructor
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
|
31 |
+
*/
|
32 |
+
public function _construct()
|
33 |
+
{
|
34 |
+
$this->_init('db1_anymarket/anymarketqueue', 'entity_id');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Get store ids to which specified item is assigned
|
39 |
+
*
|
40 |
+
* @access public
|
41 |
+
* @param int $anymarketqueueId
|
42 |
+
* @return array
|
43 |
+
|
44 |
+
*/
|
45 |
+
public function lookupStoreIds($anymarketqueueId)
|
46 |
+
{
|
47 |
+
$adapter = $this->_getReadAdapter();
|
48 |
+
$select = $adapter->select()
|
49 |
+
->from($this->getTable('db1_anymarket/anymarketqueue_store'), 'store_id')
|
50 |
+
->where('anymarketqueue_id = ?', (int)$anymarketqueueId);
|
51 |
+
return $adapter->fetchCol($select);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Perform operations after object load
|
56 |
+
*
|
57 |
+
* @access public
|
58 |
+
* @param Mage_Core_Model_Abstract $object
|
59 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue
|
60 |
+
|
61 |
+
*/
|
62 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
63 |
+
{
|
64 |
+
if ($object->getId()) {
|
65 |
+
$stores = $this->lookupStoreIds($object->getId());
|
66 |
+
$object->setData('store_id', $stores);
|
67 |
+
}
|
68 |
+
return parent::_afterLoad($object);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Retrieve select object for load object data
|
73 |
+
*
|
74 |
+
* @param string $field
|
75 |
+
* @param mixed $value
|
76 |
+
* @param DB1_AnyMarket_Model_Anymarketqueue $object
|
77 |
+
* @return Zend_Db_Select
|
78 |
+
*/
|
79 |
+
protected function _getLoadSelect($field, $value, $object)
|
80 |
+
{
|
81 |
+
$select = parent::_getLoadSelect($field, $value, $object);
|
82 |
+
if ($object->getStoreId()) {
|
83 |
+
$storeIds = array(Mage_Core_Model_App::ADMIN_STORE_ID, (int)$object->getStoreId());
|
84 |
+
$select->join(
|
85 |
+
array('anymarket_anymarketqueue_store' => $this->getTable('db1_anymarket/anymarketqueue_store')),
|
86 |
+
$this->getMainTable() . '.entity_id = anymarket_anymarketqueue_store.anymarketqueue_id',
|
87 |
+
array()
|
88 |
+
)
|
89 |
+
->where('anymarket_anymarketqueue_store.store_id IN (?)', $storeIds)
|
90 |
+
->order('anymarket_anymarketqueue_store.store_id DESC')
|
91 |
+
->limit(1);
|
92 |
+
}
|
93 |
+
return $select;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Assign anymarket queue to store views
|
98 |
+
*
|
99 |
+
* @access protected
|
100 |
+
* @param Mage_Core_Model_Abstract $object
|
101 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue
|
102 |
+
|
103 |
+
*/
|
104 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
105 |
+
{
|
106 |
+
$oldStores = $this->lookupStoreIds($object->getId());
|
107 |
+
$newStores = (array)$object->getStores();
|
108 |
+
if (empty($newStores)) {
|
109 |
+
$newStores = (array)$object->getStoreId();
|
110 |
+
}
|
111 |
+
$table = $this->getTable('db1_anymarket/anymarketqueue_store');
|
112 |
+
$insert = array_diff($newStores, $oldStores);
|
113 |
+
$delete = array_diff($oldStores, $newStores);
|
114 |
+
if ($delete) {
|
115 |
+
$where = array(
|
116 |
+
'anymarketqueue_id = ?' => (int) $object->getId(),
|
117 |
+
'store_id IN (?)' => $delete
|
118 |
+
);
|
119 |
+
$this->_getWriteAdapter()->delete($table, $where);
|
120 |
+
}
|
121 |
+
if ($insert) {
|
122 |
+
$data = array();
|
123 |
+
foreach ($insert as $storeId) {
|
124 |
+
$data[] = array(
|
125 |
+
'anymarketqueue_id' => (int) $object->getId(),
|
126 |
+
'store_id' => (int) $storeId
|
127 |
+
);
|
128 |
+
}
|
129 |
+
$this->_getWriteAdapter()->insertMultiple($table, $data);
|
130 |
+
}
|
131 |
+
return parent::_afterSave($object);
|
132 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue/Collection.php
CHANGED
@@ -1,135 +1,135 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Queue collection resource model
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
*/
|
23 |
-
class DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
24 |
-
{
|
25 |
-
protected $_joinedFields = array();
|
26 |
-
|
27 |
-
/**
|
28 |
-
* constructor
|
29 |
-
*
|
30 |
-
* @access public
|
31 |
-
* @return void
|
32 |
-
|
33 |
-
*/
|
34 |
-
protected function _construct()
|
35 |
-
{
|
36 |
-
parent::_construct();
|
37 |
-
$this->_init('db1_anymarket/anymarketqueue');
|
38 |
-
$this->_map['fields']['store'] = 'store_table.store_id';
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Add filter by store
|
43 |
-
*
|
44 |
-
* @access public
|
45 |
-
* @param int|Mage_Core_Model_Store $store
|
46 |
-
* @param bool $withAdmin
|
47 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection
|
48 |
-
|
49 |
-
*/
|
50 |
-
public function addStoreFilter($store, $withAdmin = true)
|
51 |
-
{
|
52 |
-
if (!isset($this->_joinedFields['store'])) {
|
53 |
-
if ($store instanceof Mage_Core_Model_Store) {
|
54 |
-
$store = array($store->getId());
|
55 |
-
}
|
56 |
-
if (!is_array($store)) {
|
57 |
-
$store = array($store);
|
58 |
-
}
|
59 |
-
if ($withAdmin) {
|
60 |
-
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
61 |
-
}
|
62 |
-
$this->addFilter('store', array('in' => $store), 'public');
|
63 |
-
$this->_joinedFields['store'] = true;
|
64 |
-
}
|
65 |
-
return $this;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Join store relation table if there is store filter
|
70 |
-
*
|
71 |
-
* @access protected
|
72 |
-
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection
|
73 |
-
|
74 |
-
*/
|
75 |
-
protected function _renderFiltersBefore()
|
76 |
-
{
|
77 |
-
if ($this->getFilter('store')) {
|
78 |
-
$this->getSelect()->join(
|
79 |
-
array('store_table' => $this->getTable('db1_anymarket/anymarketqueue_store')),
|
80 |
-
'main_table.entity_id = store_table.anymarketqueue_id',
|
81 |
-
array()
|
82 |
-
)
|
83 |
-
->group('main_table.entity_id');
|
84 |
-
/*
|
85 |
-
* Allow analytic functions usage because of one field grouping
|
86 |
-
*/
|
87 |
-
$this->_useAnalyticFunction = true;
|
88 |
-
}
|
89 |
-
return parent::_renderFiltersBefore();
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* get anymarket queues as array
|
94 |
-
*
|
95 |
-
* @access protected
|
96 |
-
* @param string $valueField
|
97 |
-
* @param string $labelField
|
98 |
-
* @param array $additional
|
99 |
-
* @return array
|
100 |
-
|
101 |
-
*/
|
102 |
-
protected function _toOptionArray($valueField='entity_id', $labelField='nmq_id', $additional=array())
|
103 |
-
{
|
104 |
-
return parent::_toOptionArray($valueField, $labelField, $additional);
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* get options hash
|
109 |
-
*
|
110 |
-
* @access protected
|
111 |
-
* @param string $valueField
|
112 |
-
* @param string $labelField
|
113 |
-
* @return array
|
114 |
-
|
115 |
-
*/
|
116 |
-
protected function _toOptionHash($valueField='entity_id', $labelField='nmq_id')
|
117 |
-
{
|
118 |
-
return parent::_toOptionHash($valueField, $labelField);
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Get SQL for get record count.
|
123 |
-
* Extra GROUP BY strip added.
|
124 |
-
*
|
125 |
-
* @access public
|
126 |
-
* @return Varien_Db_Select
|
127 |
-
|
128 |
-
*/
|
129 |
-
public function getSelectCountSql()
|
130 |
-
{
|
131 |
-
$countSelect = parent::getSelectCountSql();
|
132 |
-
$countSelect->reset(Zend_Db_Select::GROUP);
|
133 |
-
return $countSelect;
|
134 |
-
}
|
135 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Queue collection resource model
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
*/
|
23 |
+
class DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
24 |
+
{
|
25 |
+
protected $_joinedFields = array();
|
26 |
+
|
27 |
+
/**
|
28 |
+
* constructor
|
29 |
+
*
|
30 |
+
* @access public
|
31 |
+
* @return void
|
32 |
+
|
33 |
+
*/
|
34 |
+
protected function _construct()
|
35 |
+
{
|
36 |
+
parent::_construct();
|
37 |
+
$this->_init('db1_anymarket/anymarketqueue');
|
38 |
+
$this->_map['fields']['store'] = 'store_table.store_id';
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Add filter by store
|
43 |
+
*
|
44 |
+
* @access public
|
45 |
+
* @param int|Mage_Core_Model_Store $store
|
46 |
+
* @param bool $withAdmin
|
47 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection
|
48 |
+
|
49 |
+
*/
|
50 |
+
public function addStoreFilter($store, $withAdmin = true)
|
51 |
+
{
|
52 |
+
if (!isset($this->_joinedFields['store'])) {
|
53 |
+
if ($store instanceof Mage_Core_Model_Store) {
|
54 |
+
$store = array($store->getId());
|
55 |
+
}
|
56 |
+
if (!is_array($store)) {
|
57 |
+
$store = array($store);
|
58 |
+
}
|
59 |
+
if ($withAdmin) {
|
60 |
+
$store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
|
61 |
+
}
|
62 |
+
$this->addFilter('store', array('in' => $store), 'public');
|
63 |
+
$this->_joinedFields['store'] = true;
|
64 |
+
}
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Join store relation table if there is store filter
|
70 |
+
*
|
71 |
+
* @access protected
|
72 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketqueue_Collection
|
73 |
+
|
74 |
+
*/
|
75 |
+
protected function _renderFiltersBefore()
|
76 |
+
{
|
77 |
+
if ($this->getFilter('store')) {
|
78 |
+
$this->getSelect()->join(
|
79 |
+
array('store_table' => $this->getTable('db1_anymarket/anymarketqueue_store')),
|
80 |
+
'main_table.entity_id = store_table.anymarketqueue_id',
|
81 |
+
array()
|
82 |
+
)
|
83 |
+
->group('main_table.entity_id');
|
84 |
+
/*
|
85 |
+
* Allow analytic functions usage because of one field grouping
|
86 |
+
*/
|
87 |
+
$this->_useAnalyticFunction = true;
|
88 |
+
}
|
89 |
+
return parent::_renderFiltersBefore();
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* get anymarket queues as array
|
94 |
+
*
|
95 |
+
* @access protected
|
96 |
+
* @param string $valueField
|
97 |
+
* @param string $labelField
|
98 |
+
* @param array $additional
|
99 |
+
* @return array
|
100 |
+
|
101 |
+
*/
|
102 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='nmq_id', $additional=array())
|
103 |
+
{
|
104 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* get options hash
|
109 |
+
*
|
110 |
+
* @access protected
|
111 |
+
* @param string $valueField
|
112 |
+
* @param string $labelField
|
113 |
+
* @return array
|
114 |
+
|
115 |
+
*/
|
116 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='nmq_id')
|
117 |
+
{
|
118 |
+
return parent::_toOptionHash($valueField, $labelField);
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get SQL for get record count.
|
123 |
+
* Extra GROUP BY strip added.
|
124 |
+
*
|
125 |
+
* @access public
|
126 |
+
* @return Varien_Db_Select
|
127 |
+
|
128 |
+
*/
|
129 |
+
public function getSelectCountSql()
|
130 |
+
{
|
131 |
+
$countSelect = parent::getSelectCountSql();
|
132 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
133 |
+
return $countSelect;
|
134 |
+
}
|
135 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Setup.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* AnyMarket setup
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
25 |
-
{
|
26 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* AnyMarket setup
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
25 |
+
{
|
26 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Group/Values.php
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Customer_Group_Values
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
$customerGroup = Mage::getModel('customer/group')->getCollection();
|
8 |
-
$retornArray = array();
|
9 |
-
foreach ($customerGroup as $group) {
|
10 |
-
$retornArray[] = array( 'value' => $group->getData('customer_group_id'), 'label' => $group->getData('customer_group_code') );
|
11 |
-
}
|
12 |
-
|
13 |
-
return $retornArray;
|
14 |
-
}
|
15 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Customer_Group_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$customerGroup = Mage::getModel('customer/group')->getCollection();
|
8 |
+
$retornArray = array();
|
9 |
+
foreach ($customerGroup as $group) {
|
10 |
+
$retornArray[] = array( 'value' => $group->getData('customer_group_id'), 'label' => $group->getData('customer_group_code') );
|
11 |
+
}
|
12 |
+
|
13 |
+
return $retornArray;
|
14 |
+
}
|
15 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Street/Values.php
ADDED
@@ -0,0 +1,15 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Customer_Street_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$retornArray = array();
|
8 |
+
$retornArray[] = array( 'label' => 'Rua', 'value' => 'street' );
|
9 |
+
$retornArray[] = array( 'label' => 'Número', 'value' => 'number' );
|
10 |
+
$retornArray[] = array( 'label' => 'Bairro', 'value' => 'neighborhood' );
|
11 |
+
$retornArray[] = array( 'label' => 'Complemento', 'value' => 'comment' );
|
12 |
+
|
13 |
+
return $retornArray;
|
14 |
+
}
|
15 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Values.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Customer_Values
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
$attributes = Mage::getModel('customer/customer')->getAttributes();
|
8 |
-
$retornArray = array();
|
9 |
-
foreach ($attributes as $attribute) {
|
10 |
-
if($attribute->getStoreLabel() != ''){
|
11 |
-
$retornArray[] = array( 'value' => $attribute->getData('attribute_code'), 'label' => $attribute->getStoreLabel() );
|
12 |
-
}
|
13 |
-
}
|
14 |
-
|
15 |
-
return $retornArray;
|
16 |
-
}
|
17 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Customer_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$attributes = Mage::getModel('customer/customer')->getAttributes();
|
8 |
+
$retornArray = array();
|
9 |
+
foreach ($attributes as $attribute) {
|
10 |
+
if($attribute->getStoreLabel() != ''){
|
11 |
+
$retornArray[] = array( 'value' => $attribute->getData('attribute_code'), 'label' => $attribute->getStoreLabel() );
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
return $retornArray;
|
16 |
+
}
|
17 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Booleantp/Values.php
ADDED
@@ -0,0 +1,23 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Product_Booleantp_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
8 |
+
$retornArray = array();
|
9 |
+
foreach ($productAttrs as $productAttr) {
|
10 |
+
if($productAttr->getFrontendLabel() != null){
|
11 |
+
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeCode(), 'nma_id_attr');
|
12 |
+
|
13 |
+
if($attrCheck->getData('nma_id_attr') == null){
|
14 |
+
if($productAttr->getData('frontend_input') == 'boolean'){
|
15 |
+
$retornArray[] = array( 'value' => $productAttr->getAttributeCode(), 'label' => $productAttr->getFrontendLabel() );
|
16 |
+
}
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
return $retornArray;
|
22 |
+
}
|
23 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Price/Values.php
ADDED
@@ -0,0 +1,25 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Product_Price_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
8 |
+
$retornArray = array();
|
9 |
+
foreach ($productAttrs as $productAttr) {
|
10 |
+
if($productAttr->getFrontendLabel() != null){
|
11 |
+
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeCode(), 'nma_id_attr');
|
12 |
+
|
13 |
+
if($attrCheck->getData('nma_id_attr') == null){
|
14 |
+
$retornArray[] = array( 'value' => $productAttr->getAttributeCode(), 'label' => $productAttr->getFrontendLabel() );
|
15 |
+
}
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', Mage::app()->getStore()->getId());
|
20 |
+
if($typeSincProd == 0){
|
21 |
+
$retornArray[] = array( 'value' => 'final_price', 'label' => 'Final Price' );
|
22 |
+
}
|
23 |
+
return $retornArray;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Values.php
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Product_Values
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
8 |
-
$retornArray = array();
|
9 |
-
foreach ($productAttrs as $productAttr) {
|
10 |
-
if($productAttr->getFrontendLabel() != null){
|
11 |
-
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeCode(), 'nma_id_attr');
|
12 |
-
|
13 |
-
if($attrCheck->getData('nma_id_attr') == null){
|
14 |
-
$retornArray[] = array( 'value' => $productAttr->getAttributeCode(), 'label' => $productAttr->getFrontendLabel() );
|
15 |
-
}
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
return $retornArray;
|
20 |
-
}
|
21 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Product_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$productAttrs = Mage::getResourceModel('catalog/product_attribute_collection');
|
8 |
+
$retornArray = array();
|
9 |
+
foreach ($productAttrs as $productAttr) {
|
10 |
+
if($productAttr->getFrontendLabel() != null){
|
11 |
+
$attrCheck = Mage::getModel('db1_anymarket/anymarketattributes')->load($productAttr->getAttributeCode(), 'nma_id_attr');
|
12 |
+
|
13 |
+
if($attrCheck->getData('nma_id_attr') == null){
|
14 |
+
$retornArray[] = array( 'value' => $productAttr->getAttributeCode(), 'label' => $productAttr->getFrontendLabel() );
|
15 |
+
}
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
return $retornArray;
|
20 |
+
}
|
21 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Set/Values.php
ADDED
@@ -0,0 +1,14 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Attributes_Set_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$attributeSetCollection = Mage::getModel('catalog/product_attribute_set_api')->items();
|
8 |
+
foreach ($attributeSetCollection as $attributeSet) {
|
9 |
+
$retornArray[] = array( 'value' => $attributeSet['set_id'], 'label' => $attributeSet['name'] );
|
10 |
+
}
|
11 |
+
|
12 |
+
return $retornArray;
|
13 |
+
}
|
14 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Categories/Values.php
CHANGED
@@ -1,67 +1,70 @@
|
|
1 |
-
<?php
|
2 |
-
class DB1_AnyMarket_Model_System_Config_Source_Categories_Values extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
3 |
-
{
|
4 |
-
protected $retornArray = array();
|
5 |
-
protected $descComp;
|
6 |
-
|
7 |
-
private function getChildCat($IDRoot, $DescCateg){
|
8 |
-
$categCh = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection()
|
9 |
-
->addFilter('nmc_cat_root_id', $IDRoot);
|
10 |
-
|
11 |
-
$ctrlCat = '';
|
12 |
-
if(sizeof($categCh) >1){
|
13 |
-
$ctrlCat = $DescCateg;
|
14 |
-
}
|
15 |
-
|
16 |
-
foreach ($categCh as $catCh) {
|
17 |
-
if($ctrlCat == ''){
|
18 |
-
$DescCateg = $DescCateg.'\\'.$catCh->getData('nmc_cat_desc');
|
19 |
-
}else{
|
20 |
-
$DescCateg = $ctrlCat.'\\'.$catCh->getData('nmc_cat_desc');
|
21 |
-
}
|
22 |
-
$IDRoot = $catCh->getData('nmc_cat_id');
|
23 |
-
|
24 |
-
$returnCateg = $this->getChildCat($IDRoot, $DescCateg);
|
25 |
-
$hChild = $returnCateg["return"];
|
26 |
-
$IDRoot = $returnCateg["root"];
|
27 |
-
}
|
28 |
-
|
29 |
-
if($IDRoot != ''){
|
30 |
-
array_push($this->retornArray, array( 'value' => $IDRoot, 'label' => $DescCateg ) );
|
31 |
-
}
|
32 |
-
|
33 |
-
return array("return" => false, "root" => "", "desc" => "");
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getAllOptions()
|
37 |
-
{
|
38 |
-
if (!Mage::app()->isSingleStoreMode()){
|
39 |
-
$store = Mage::app()->getRequest()->getParam('store');
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
class DB1_AnyMarket_Model_System_Config_Source_Categories_Values extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
|
3 |
+
{
|
4 |
+
protected $retornArray = array();
|
5 |
+
protected $descComp;
|
6 |
+
|
7 |
+
private function getChildCat($IDRoot, $DescCateg){
|
8 |
+
$categCh = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection()
|
9 |
+
->addFilter('nmc_cat_root_id', $IDRoot);
|
10 |
+
|
11 |
+
$ctrlCat = '';
|
12 |
+
if(sizeof($categCh) >1){
|
13 |
+
$ctrlCat = $DescCateg;
|
14 |
+
}
|
15 |
+
|
16 |
+
foreach ($categCh as $catCh) {
|
17 |
+
if($ctrlCat == ''){
|
18 |
+
$DescCateg = $DescCateg.'\\'.$catCh->getData('nmc_cat_desc');
|
19 |
+
}else{
|
20 |
+
$DescCateg = $ctrlCat.'\\'.$catCh->getData('nmc_cat_desc');
|
21 |
+
}
|
22 |
+
$IDRoot = $catCh->getData('nmc_cat_id');
|
23 |
+
|
24 |
+
$returnCateg = $this->getChildCat($IDRoot, $DescCateg);
|
25 |
+
$hChild = $returnCateg["return"];
|
26 |
+
$IDRoot = $returnCateg["root"];
|
27 |
+
}
|
28 |
+
|
29 |
+
if($IDRoot != ''){
|
30 |
+
array_push($this->retornArray, array( 'value' => $IDRoot, 'label' => $DescCateg ) );
|
31 |
+
}
|
32 |
+
|
33 |
+
return array("return" => false, "root" => "", "desc" => "");
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getAllOptions()
|
37 |
+
{
|
38 |
+
if (!Mage::app()->isSingleStoreMode()){
|
39 |
+
$store = Mage::app()->getRequest()->getParam('store');
|
40 |
+
if( $store == null || $store == 0 ){
|
41 |
+
$store = 1;
|
42 |
+
}
|
43 |
+
$categories = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection()
|
44 |
+
->addFilter('nmc_cat_root_id','000')
|
45 |
+
->addStoreFilter($store)
|
46 |
+
->setOrder('nmc_cat_desc', 'ASC');
|
47 |
+
}else{
|
48 |
+
$categories = Mage::getModel('db1_anymarket/anymarketcategories')->getCollection()
|
49 |
+
->addFilter('nmc_cat_root_id','000')
|
50 |
+
->setOrder('nmc_cat_desc', 'ASC');
|
51 |
+
}
|
52 |
+
|
53 |
+
array_push($this->retornArray, array( 'value' => null, 'label' => ' ' ) );
|
54 |
+
foreach($categories as $category) {
|
55 |
+
$hChild = true;
|
56 |
+
$IDRoot = $category->getData('nmc_cat_id');
|
57 |
+
$DescCateg = $category->getData('nmc_cat_desc');
|
58 |
+
$this->descComp = $DescCateg;
|
59 |
+
while ( $hChild ) {
|
60 |
+
$returnCateg = $this->getChildCat($IDRoot, $DescCateg);
|
61 |
+
$hChild = $returnCateg["return"];
|
62 |
+
$IDRoot = $returnCateg["root"];
|
63 |
+
$DescCateg = $returnCateg["desc"];
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
return $this->retornArray;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Logs/Values.php
ADDED
@@ -0,0 +1,14 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Logs_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$retornArray = array();
|
8 |
+
$retornArray[] = array( 'label' => 'Não Logar', 'value' => '0' );
|
9 |
+
$retornArray[] = array( 'label' => 'Baixo', 'value' => '1' );
|
10 |
+
$retornArray[] = array( 'label' => 'Alto', 'value' => '2' );
|
11 |
+
|
12 |
+
return $retornArray;
|
13 |
+
}
|
14 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Massunit/Values.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_System_Config_Source_Massunit_Values
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
$retornArray = array();
|
8 |
-
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('Quilogramas'), 'value' => '0' );
|
9 |
-
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('Gramas'), 'value' => '1' );
|
10 |
-
|
11 |
-
return $retornArray;
|
12 |
-
}
|
13 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Massunit_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$retornArray = array();
|
8 |
+
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('Quilogramas'), 'value' => '0' );
|
9 |
+
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('Gramas'), 'value' => '1' );
|
10 |
+
|
11 |
+
return $retornArray;
|
12 |
+
}
|
13 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Measurementunit/Values.php
ADDED
@@ -0,0 +1,15 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Measurementunit_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$retornArray = array();
|
8 |
+
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('CentÃmetro'), 'value' => '0' );
|
9 |
+
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('Metro'), 'value' => '1' );
|
10 |
+
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('DecÃmetro'), 'value' => '2' );
|
11 |
+
$retornArray[] = array( 'label' => Mage::helper('db1_anymarket')->__('MilÃmetro'), 'value' => '3' );
|
12 |
+
|
13 |
+
return $retornArray;
|
14 |
+
}
|
15 |
+
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Orders/Values.php
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_System_Config_Source_Orders_Values
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
$retornArray = array();
|
8 |
-
// $retornArray[] = array( 'label' => 'Qualquer Status', 'value' => 'ANY' );
|
9 |
-
$retornArray[] = array( 'label' => 'Concluido (CONCLUDED)', 'value' => 'CONCLUDED' );
|
10 |
-
$retornArray[] = array( 'label' => 'Pendente (PENDING)', 'value' => 'PENDING' );
|
11 |
-
$retornArray[] = array( 'label' => 'Faturado (INVOICED)', 'value' => 'INVOICED' );
|
12 |
-
$retornArray[] = array( 'label' => 'Enviado (PAID_WAITING_DELIVERY)', 'value' => 'PAID_WAITING_DELIVERY' );
|
13 |
-
$retornArray[] = array( 'label' => 'Pago (PAID_WAITING_SHIP)', 'value' => 'PAID_WAITING_SHIP' );
|
14 |
-
$retornArray[] = array( 'label' => 'Cancelado (CANCELED)', 'value' => 'CANCELED' );
|
15 |
-
|
16 |
-
return $retornArray;
|
17 |
-
}
|
18 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_Orders_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$retornArray = array();
|
8 |
+
// $retornArray[] = array( 'label' => 'Qualquer Status', 'value' => 'ANY' );
|
9 |
+
$retornArray[] = array( 'label' => 'Concluido (CONCLUDED)', 'value' => 'CONCLUDED' );
|
10 |
+
$retornArray[] = array( 'label' => 'Pendente (PENDING)', 'value' => 'PENDING' );
|
11 |
+
$retornArray[] = array( 'label' => 'Faturado (INVOICED)', 'value' => 'INVOICED' );
|
12 |
+
$retornArray[] = array( 'label' => 'Enviado (PAID_WAITING_DELIVERY)', 'value' => 'PAID_WAITING_DELIVERY' );
|
13 |
+
$retornArray[] = array( 'label' => 'Pago (PAID_WAITING_SHIP)', 'value' => 'PAID_WAITING_SHIP' );
|
14 |
+
$retornArray[] = array( 'label' => 'Cancelado (CANCELED)', 'value' => 'CANCELED' );
|
15 |
+
|
16 |
+
return $retornArray;
|
17 |
+
}
|
18 |
Â
}
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Typesync/Order/Values.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DB1_AnyMarket_Model_System_Config_Source_TypeSync_Order_Values
|
4 |
-
{
|
5 |
-
public function toOptionArray()
|
6 |
-
{
|
7 |
-
$retornArray[] = array( 'value' => 0, 'label' => 'Magento to AnyMarket');
|
8 |
-
$retornArray[] = array( 'value' => 1, 'label' => 'AnyMarket to Magento');
|
9 |
-
|
10 |
-
return $retornArray;
|
11 |
-
}
|
12 |
Â
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DB1_AnyMarket_Model_System_Config_Source_TypeSync_Order_Values
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
$retornArray[] = array( 'value' => 0, 'label' => 'Magento to AnyMarket');
|
8 |
+
$retornArray[] = array( 'value' => 1, 'label' => 'AnyMarket to Magento');
|
9 |
+
|
10 |
+
return $retornArray;
|
11 |
+
}
|
12 |
Â
}
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketattributesController.php
CHANGED
@@ -1,328 +1,328 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB1_AnyMarket extension
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the MIT License
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/mit-license.php
|
11 |
-
*
|
12 |
-
* @category DB1
|
13 |
-
* @package DB1_AnyMarket
|
14 |
-
* @copyright Copyright (c) 2015
|
15 |
-
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
-
*/
|
17 |
-
/**
|
18 |
-
* Anymarket Attributes admin controller
|
19 |
-
*
|
20 |
-
* @category DB1
|
21 |
-
* @package DB1_AnyMarket
|
22 |
-
|
23 |
-
*/
|
24 |
-
class DB1_AnyMarket_Adminhtml_Anymarket_AnymarketattributesController extends DB1_AnyMarket_Controller_Adminhtml_AnyMarket
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* init the anymarket attributes
|
28 |
-
*
|
29 |
-
* @access protected
|
30 |
-
* @return DB1_AnyMarket_Model_Anymarketattributes
|
31 |
-
*/
|
32 |
-
protected function _initAnymarketattributes()
|
33 |
-
{
|
34 |
-
$anymarketattributesId = (int) $this->getRequest()->getParam('id');
|
35 |
-
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes');
|
36 |
-
if ($anymarketattributesId) {
|
37 |
-
$anymarketattributes->load($anymarketattributesId);
|
38 |
-
}
|
39 |
-
Mage::register('current_anymarketattributes', $anymarketattributes);
|
40 |
-
return $anymarketattributes;
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* default action
|
45 |
-
*
|
46 |
-
* @access public
|
47 |
-
* @return void
|
48 |
-
|
49 |
-
*/
|
50 |
-
public function indexAction()
|
51 |
-
{
|
52 |
-
$this->loadLayout();
|
53 |
-
$this->_title(Mage::helper('db1_anymarket')->__('AnyMarket'))
|
54 |
-
->_title(Mage::helper('db1_anymarket')->__('Anymarket Attributes'));
|
55 |
-
$this->renderLayout();
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* grid action
|
60 |
-
*
|
61 |
-
* @access public
|
62 |
-
* @return void
|
63 |
-
|
64 |
-
*/
|
65 |
-
public function gridAction()
|
66 |
-
{
|
67 |
-
$this->loadLayout()->renderLayout();
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* edit anymarket attributes - action
|
72 |
-
*
|
73 |
-
* @access public
|
74 |
-
* @return void
|
75 |
-
|
76 |
-
*/
|
77 |
-
public function editAction()
|
78 |
-
{
|
79 |
-
$anymarketattributesId = $this->getRequest()->getParam('id');
|
80 |
-
$anymarketattributes = $this->_initAnymarketattributes();
|
81 |
-
if ($anymarketattributesId && !$anymarketattributes->getId()) {
|
82 |
-
$this->_getSession()->addError(
|
83 |
-
Mage::helper('db1_anymarket')->__('This anymarket attributes no longer exists.')
|
84 |
-
);
|
85 |
-
$this->_redirect('*/*/');
|
86 |
-
return;
|
87 |
-
}
|
88 |
-
$data = Mage::getSingleton('adminhtml/session')->getAnymarketattributesData(true);
|
89 |
-
if (!empty($data)) {
|
90 |
-
$anymarketattributes->setData($data);
|
91 |
-
}
|
92 |
-
Mage::register('anymarketattributes_data', $anymarketattributes);
|
93 |
-
$this->loadLayout();
|
94 |
-
$this->_title(Mage::helper('db1_anymarket')->__('AnyMarket'))
|
95 |
-
->_title(Mage::helper('db1_anymarket')->__('Anymarket Attributes'));
|
96 |
-
if ($anymarketattributes->getId()) {
|
97 |
-
$this->_title($anymarketattributes->getNmaDesc());
|
98 |
-
} else {
|
99 |
-
$this->_title(Mage::helper('db1_anymarket')->__('Add anymarket attributes'));
|
100 |
-
}
|
101 |
-
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
102 |
-
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
103 |
-
}
|
104 |
-
$this->renderLayout();
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* new anymarket attributes action
|
109 |
-
*
|
110 |
-
* @access public
|
111 |
-
* @return void
|
112 |
-
|
113 |
-
*/
|
114 |
-
public function newAction()
|
115 |
-
{
|
116 |
-
$this->_forward('edit');
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* save anymarket attributes - action
|
121 |
-
*
|
122 |
-
* @access public
|
123 |
-
* @return void
|
124 |
-
|
125 |
-
*/
|
126 |
-
public function saveAction()
|
127 |
-
{
|
128 |
-
if ($data = $this->getRequest()->getPost('anymarketattributes')) {
|
129 |
-
try {
|
130 |
-
$anymarketattributes = $this->_initAnymarketattributes();
|
131 |
-
$anymarketattributes->addData($data);
|
132 |
-
$anymarketattributes->save();
|
133 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(
|
134 |
-
Mage::helper('db1_anymarket')->__('Anymarket Attributes was successfully saved')
|
135 |
-
);
|
136 |
-
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
137 |
-
if ($this->getRequest()->getParam('back')) {
|
138 |
-
$this->_redirect('*/*/edit', array('id' => $anymarketattributes->getId()));
|
139 |
-
return;
|
140 |
-
}
|
141 |
-
$this->_redirect('*/*/');
|
142 |
-
return;
|
143 |
-
} catch (Mage_Core_Exception $e) {
|
144 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
145 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketattributesData($data);
|
146 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
147 |
-
return;
|
148 |
-
} catch (Exception $e) {
|
149 |
-
Mage::logException($e);
|
150 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
151 |
-
Mage::helper('db1_anymarket')->__('There was a problem saving the anymarket attributes.')
|
152 |
-
);
|
153 |
-
Mage::getSingleton('adminhtml/session')->setAnymarketattributesData($data);
|
154 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
155 |
-
return;
|
156 |
-
}
|
157 |
-
}
|
158 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
159 |
-
Mage::helper('db1_anymarket')->__('Unable to find anymarket attributes to save.')
|
160 |
-
);
|
161 |
-
$this->_redirect('*/*/');
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* delete anymarket attributes - action
|
166 |
-
*
|
167 |
-
* @access public
|
168 |
-
* @return void
|
169 |
-
|
170 |
-
*/
|
171 |
-
public function deleteAction()
|
172 |
-
{
|
173 |
-
if ( $this->getRequest()->getParam('id') > 0) {
|
174 |
-
try {
|
175 |
-
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes');
|
176 |
-
$anymarketattributes->setId($this->getRequest()->getParam('id'))->delete();
|
177 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(
|
178 |
-
Mage::helper('db1_anymarket')->__('Anymarket Attributes was successfully deleted.')
|
179 |
-
);
|
180 |
-
$this->_redirect('*/*/');
|
181 |
-
return;
|
182 |
-
} catch (Mage_Core_Exception $e) {
|
183 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
184 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
185 |
-
} catch (Exception $e) {
|
186 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
187 |
-
Mage::helper('db1_anymarket')->__('There was an error deleting anymarket attributes.')
|
188 |
-
);
|
189 |
-
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
190 |
-
Mage::logException($e);
|
191 |
-
return;
|
192 |
-
}
|
193 |
-
}
|
194 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
195 |
-
Mage::helper('db1_anymarket')->__('Could not find anymarket attributes to delete.')
|
196 |
-
);
|
197 |
-
$this->_redirect('*/*/');
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* mass delete anymarket attributes - action
|
202 |
-
*
|
203 |
-
* @access public
|
204 |
-
* @return void
|
205 |
-
|
206 |
-
*/
|
207 |
-
public function massDeleteAction()
|
208 |
-
{
|
209 |
-
$anymarketattributesIds = $this->getRequest()->getParam('anymarketattributes');
|
210 |
-
if (!is_array($anymarketattributesIds)) {
|
211 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
212 |
-
Mage::helper('db1_anymarket')->__('Please select anymarket attributes to delete.')
|
213 |
-
);
|
214 |
-
} else {
|
215 |
-
try {
|
216 |
-
foreach ($anymarketattributesIds as $anymarketattributesId) {
|
217 |
-
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes');
|
218 |
-
$anymarketattributes->setId($anymarketattributesId)->delete();
|
219 |
-
}
|
220 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(
|
221 |
-
Mage::helper('db1_anymarket')->__('Total of %d anymarket attributes were successfully deleted.', count($anymarketattributesIds))
|
222 |
-
);
|
223 |
-
} catch (Mage_Core_Exception $e) {
|
224 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
225 |
-
} catch (Exception $e) {
|
226 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
227 |
-
Mage::helper('db1_anymarket')->__('There was an error deleting anymarket attributes.')
|
228 |
-
);
|
229 |
-
Mage::logException($e);
|
230 |
-
}
|
231 |
-
}
|
232 |
-
$this->_redirect('*/*/index');
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* mass status change - action
|
237 |
-
*
|
238 |
-
* @access public
|
239 |
-
* @return void
|
240 |
-
|
241 |
-
*/
|
242 |
-
public function massStatusAction()
|
243 |
-
{
|
244 |
-
$anymarketattributesIds = $this->getRequest()->getParam('anymarketattributes');
|
245 |
-
if (!is_array($anymarketattributesIds)) {
|
246 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
247 |
-
Mage::helper('db1_anymarket')->__('Please select anymarket attributes.')
|
248 |
-
);
|
249 |
-
} else {
|
250 |
-
try {
|
251 |
-
foreach ($anymarketattributesIds as $anymarketattributesId) {
|
252 |
-
$anymarketattributes = Mage::getSingleton('db1_anymarket/anymarketattributes')->load($anymarketattributesId)
|
253 |
-
->setStatus($this->getRequest()->getParam('status'))
|
254 |
-
->setIsMassupdate(true)
|
255 |
-
->save();
|
256 |
-
}
|
257 |
-
$this->_getSession()->addSuccess(
|
258 |
-
$this->__('Total of %d anymarket attributes were successfully updated.', count($anymarketattributesIds))
|
259 |
-
);
|
260 |
-
} catch (Mage_Core_Exception $e) {
|
261 |
-
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
262 |
-
} catch (Exception $e) {
|
263 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
264 |
-
Mage::helper('db1_anymarket')->__('There was an error updating anymarket attributes.')
|
265 |
-
);
|
266 |
-
Mage::logException($e);
|
267 |
-
}
|
268 |
-
}
|
269 |
-
$this->_redirect('*/*/index');
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* export as csv - action
|
274 |
-
*
|
275 |
-
* @access public
|
276 |
-
* @return void
|
277 |
-
|
278 |
-
*/
|
279 |
-
public function exportCsvAction()
|
280 |
-
{
|
281 |
-
$fileName = 'anymarketattributes.csv';
|
282 |
-
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketattributes_grid')
|
283 |
-
->getCsv();
|
284 |
-
$this->_prepareDownloadResponse($fileName, $content);
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* export as MsExcel - action
|
289 |
-
*
|
290 |
-
* @access public
|
291 |
-
* @return void
|
292 |
-
|
293 |
-
*/
|
294 |
-
public function exportExcelAction()
|
295 |
-
{
|
296 |
-
$fileName = 'anymarketattributes.xls';
|
297 |
-
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketattributes_grid')
|
298 |
-
->getExcelFile();
|
299 |
-
$this->_prepareDownloadResponse($fileName, $content);
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* export as xml - action
|
304 |
-
*
|
305 |
-
* @access public
|
306 |
-
* @return void
|
307 |
-
|
308 |
-
*/
|
309 |
-
public function exportXmlAction()
|
310 |
-
{
|
311 |
-
$fileName = 'anymarketattributes.xml';
|
312 |
-
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketattributes_grid')
|
313 |
-
->getXml();
|
314 |
-
$this->_prepareDownloadResponse($fileName, $content);
|
315 |
-
}
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Check if admin has permissions to visit related pages
|
319 |
-
*
|
320 |
-
* @access protected
|
321 |
-
* @return boolean
|
322 |
-
|
323 |
-
*/
|
324 |
-
protected function _isAllowed()
|
325 |
-
{
|
326 |
-
return Mage::getSingleton('admin/session')->isAllowed('system/db1_anymarket/anymarketattributes');
|
327 |
-
}
|
328 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2015
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarket Attributes admin controller
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Adminhtml_Anymarket_AnymarketattributesController extends DB1_AnyMarket_Controller_Adminhtml_AnyMarket
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* init the anymarket attributes
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Model_Anymarketattributes
|
31 |
+
*/
|
32 |
+
protected function _initAnymarketattributes()
|
33 |
+
{
|
34 |
+
$anymarketattributesId = (int) $this->getRequest()->getParam('id');
|
35 |
+
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes');
|
36 |
+
if ($anymarketattributesId) {
|
37 |
+
$anymarketattributes->load($anymarketattributesId);
|
38 |
+
}
|
39 |
+
Mage::register('current_anymarketattributes', $anymarketattributes);
|
40 |
+
return $anymarketattributes;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* default action
|
45 |
+
*
|
46 |
+
* @access public
|
47 |
+
* @return void
|
48 |
+
|
49 |
+
*/
|
50 |
+
public function indexAction()
|
51 |
+
{
|
52 |
+
$this->loadLayout();
|
53 |
+
$this->_title(Mage::helper('db1_anymarket')->__('AnyMarket'))
|
54 |
+
->_title(Mage::helper('db1_anymarket')->__('Anymarket Attributes'));
|
55 |
+
$this->renderLayout();
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* grid action
|
60 |
+
*
|
61 |
+
* @access public
|
62 |
+
* @return void
|
63 |
+
|
64 |
+
*/
|
65 |
+
public function gridAction()
|
66 |
+
{
|
67 |
+
$this->loadLayout()->renderLayout();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* edit anymarket attributes - action
|
72 |
+
*
|
73 |
+
* @access public
|
74 |
+
* @return void
|
75 |
+
|
76 |
+
*/
|
77 |
+
public function editAction()
|
78 |
+
{
|
79 |
+
$anymarketattributesId = $this->getRequest()->getParam('id');
|
80 |
+
$anymarketattributes = $this->_initAnymarketattributes();
|
81 |
+
if ($anymarketattributesId && !$anymarketattributes->getId()) {
|
82 |
+
$this->_getSession()->addError(
|
83 |
+
Mage::helper('db1_anymarket')->__('This anymarket attributes no longer exists.')
|
84 |
+
);
|
85 |
+
$this->_redirect('*/*/');
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
$data = Mage::getSingleton('adminhtml/session')->getAnymarketattributesData(true);
|
89 |
+
if (!empty($data)) {
|
90 |
+
$anymarketattributes->setData($data);
|
91 |
+
}
|
92 |
+
Mage::register('anymarketattributes_data', $anymarketattributes);
|
93 |
+
$this->loadLayout();
|
94 |
+
$this->_title(Mage::helper('db1_anymarket')->__('AnyMarket'))
|
95 |
+
->_title(Mage::helper('db1_anymarket')->__('Anymarket Attributes'));
|
96 |
+
if ($anymarketattributes->getId()) {
|
97 |
+
$this->_title($anymarketattributes->getNmaDesc());
|
98 |
+
} else {
|
99 |
+
$this->_title(Mage::helper('db1_anymarket')->__('Add anymarket attributes'));
|
100 |
+
}
|
101 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
102 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
103 |
+
}
|
104 |
+
$this->renderLayout();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* new anymarket attributes action
|
109 |
+
*
|
110 |
+
* @access public
|
111 |
+
* @return void
|
112 |
+
|
113 |
+
*/
|
114 |
+
public function newAction()
|
115 |
+
{
|
116 |
+
$this->_forward('edit');
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* save anymarket attributes - action
|
121 |
+
*
|
122 |
+
* @access public
|
123 |
+
* @return void
|
124 |
+
|
125 |
+
*/
|
126 |
+
public function saveAction()
|
127 |
+
{
|
128 |
+
if ($data = $this->getRequest()->getPost('anymarketattributes')) {
|
129 |
+
try {
|
130 |
+
$anymarketattributes = $this->_initAnymarketattributes();
|
131 |
+
$anymarketattributes->addData($data);
|
132 |
+
$anymarketattributes->save();
|
133 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
134 |
+
Mage::helper('db1_anymarket')->__('Anymarket Attributes was successfully saved')
|
135 |
+
);
|
136 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
137 |
+
if ($this->getRequest()->getParam('back')) {
|
138 |
+
$this->_redirect('*/*/edit', array('id' => $anymarketattributes->getId()));
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
$this->_redirect('*/*/');
|
142 |
+
return;
|
143 |
+
} catch (Mage_Core_Exception $e) {
|
144 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
145 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketattributesData($data);
|
146 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
147 |
+
return;
|
148 |
+
} catch (Exception $e) {
|
149 |
+
Mage::logException($e);
|
150 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
151 |
+
Mage::helper('db1_anymarket')->__('There was a problem saving the anymarket attributes.')
|
152 |
+
);
|
153 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketattributesData($data);
|
154 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
159 |
+
Mage::helper('db1_anymarket')->__('Unable to find anymarket attributes to save.')
|
160 |
+
);
|
161 |
+
$this->_redirect('*/*/');
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* delete anymarket attributes - action
|
166 |
+
*
|
167 |
+
* @access public
|
168 |
+
* @return void
|
169 |
+
|
170 |
+
*/
|
171 |
+
public function deleteAction()
|
172 |
+
{
|
173 |
+
if ( $this->getRequest()->getParam('id') > 0) {
|
174 |
+
try {
|
175 |
+
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes');
|
176 |
+
$anymarketattributes->setId($this->getRequest()->getParam('id'))->delete();
|
177 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
178 |
+
Mage::helper('db1_anymarket')->__('Anymarket Attributes was successfully deleted.')
|
179 |
+
);
|
180 |
+
$this->_redirect('*/*/');
|
181 |
+
return;
|
182 |
+
} catch (Mage_Core_Exception $e) {
|
183 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
184 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
185 |
+
} catch (Exception $e) {
|
186 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
187 |
+
Mage::helper('db1_anymarket')->__('There was an error deleting anymarket attributes.')
|
188 |
+
);
|
189 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
190 |
+
Mage::logException($e);
|
191 |
+
return;
|
192 |
+
}
|
193 |
+
}
|
194 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
195 |
+
Mage::helper('db1_anymarket')->__('Could not find anymarket attributes to delete.')
|
196 |
+
);
|
197 |
+
$this->_redirect('*/*/');
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* mass delete anymarket attributes - action
|
202 |
+
*
|
203 |
+
* @access public
|
204 |
+
* @return void
|
205 |
+
|
206 |
+
*/
|
207 |
+
public function massDeleteAction()
|
208 |
+
{
|
209 |
+
$anymarketattributesIds = $this->getRequest()->getParam('anymarketattributes');
|
210 |
+
if (!is_array($anymarketattributesIds)) {
|
211 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
212 |
+
Mage::helper('db1_anymarket')->__('Please select anymarket attributes to delete.')
|
213 |
+
);
|
214 |
+
} else {
|
215 |
+
try {
|
216 |
+
foreach ($anymarketattributesIds as $anymarketattributesId) {
|
217 |
+
$anymarketattributes = Mage::getModel('db1_anymarket/anymarketattributes');
|
218 |
+
$anymarketattributes->setId($anymarketattributesId)->delete();
|
219 |
+
}
|
220 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
221 |
+
Mage::helper('db1_anymarket')->__('Total of %d anymarket attributes were successfully deleted.', count($anymarketattributesIds))
|
222 |
+
);
|
223 |
+
} catch (Mage_Core_Exception $e) {
|
224 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
225 |
+
} catch (Exception $e) {
|
226 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
227 |
+
Mage::helper('db1_anymarket')->__('There was an error deleting anymarket attributes.')
|
228 |
+
);
|
229 |
+
Mage::logException($e);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
$this->_redirect('*/*/index');
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* mass status change - action
|
237 |
+
*
|
238 |
+
* @access public
|
239 |
+
* @return void
|
240 |
+
|
241 |
+
*/
|
242 |
+
public function massStatusAction()
|
243 |
+
{
|
244 |
+
$anymarketattributesIds = $this->getRequest()->getParam('anymarketattributes');
|
245 |
+
if (!is_array($anymarketattributesIds)) {
|
246 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
247 |
+
Mage::helper('db1_anymarket')->__('Please select anymarket attributes.')
|
248 |
+
);
|
249 |
+
} else {
|
250 |
+
try {
|
251 |
+
foreach ($anymarketattributesIds as $anymarketattributesId) {
|
252 |
+
$anymarketattributes = Mage::getSingleton('db1_anymarket/anymarketattributes')->load($anymarketattributesId)
|
253 |
+
->setStatus($this->getRequest()->getParam('status'))
|
254 |
+
->setIsMassupdate(true)
|
255 |
+
->save();
|
256 |
+
}
|
257 |
+
$this->_getSession()->addSuccess(
|
258 |
+
$this->__('Total of %d anymarket attributes were successfully updated.', count($anymarketattributesIds))
|
259 |
+
);
|
260 |
+
} catch (Mage_Core_Exception $e) {
|
261 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
262 |
+
} catch (Exception $e) {
|
263 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
264 |
+
Mage::helper('db1_anymarket')->__('There was an error updating anymarket attributes.')
|
265 |
+
);
|
266 |
+
Mage::logException($e);
|
267 |
+
}
|
268 |
+
}
|
269 |
+
$this->_redirect('*/*/index');
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* export as csv - action
|
274 |
+
*
|
275 |
+
* @access public
|
276 |
+
* @return void
|
277 |
+
|
278 |
+
*/
|
279 |
+
public function exportCsvAction()
|
280 |
+
{
|
281 |
+
$fileName = 'anymarketattributes.csv';
|
282 |
+
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketattributes_grid')
|
283 |
+
->getCsv();
|
284 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* export as MsExcel - action
|
289 |
+
*
|
290 |
+
* @access public
|
291 |
+
* @return void
|
292 |
+
|
293 |
+
*/
|
294 |
+
public function exportExcelAction()
|
295 |
+
{
|
296 |
+
$fileName = 'anymarketattributes.xls';
|
297 |
+
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketattributes_grid')
|
298 |
+
->getExcelFile();
|
299 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* export as xml - action
|
304 |
+
*
|
305 |
+
* @access public
|
306 |
+
* @return void
|
307 |
+
|
308 |
+
*/
|
309 |
+
public function exportXmlAction()
|
310 |
+
{
|
311 |
+
$fileName = 'anymarketattributes.xml';
|
312 |
+
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketattributes_grid')
|
313 |
+
->getXml();
|
314 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Check if admin has permissions to visit related pages
|
319 |
+
*
|
320 |
+
* @access protected
|
321 |
+
* @return boolean
|
322 |
+
|
323 |
+
*/
|
324 |
+
protected function _isAllowed()
|
325 |
+
{
|
326 |
+
return Mage::getSingleton('admin/session')->isAllowed('system/db1_anymarket/anymarketattributes');
|
327 |
+
}
|
328 |
+
}
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketbrandsController.php
ADDED
@@ -0,0 +1,349 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB1_AnyMarket extension
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the MIT License
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/mit-license.php
|
11 |
+
*
|
12 |
+
* @category DB1
|
13 |
+
* @package DB1_AnyMarket
|
14 |
+
* @copyright Copyright (c) 2016
|
15 |
+
* @license http://opensource.org/licenses/mit-license.php MIT License
|
16 |
+
*/
|
17 |
+
/**
|
18 |
+
* Anymarketbrands admin controller
|
19 |
+
*
|
20 |
+
* @category DB1
|
21 |
+
* @package DB1_AnyMarket
|
22 |
+
|
23 |
+
*/
|
24 |
+
class DB1_AnyMarket_Adminhtml_Anymarket_AnymarketbrandsController extends DB1_AnyMarket_Controller_Adminhtml_AnyMarket
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* init the anymarketbrands
|
28 |
+
*
|
29 |
+
* @access protected
|
30 |
+
* @return DB1_AnyMarket_Model_Anymarketbrands
|
31 |
+
*/
|
32 |
+
protected function _initAnymarketbrands()
|
33 |
+
{
|
34 |
+
$anymarketbrandsId = (int) $this->getRequest()->getParam('id');
|
35 |
+
$anymarketbrands = Mage::getModel('db1_anymarket/anymarketbrands');
|
36 |
+
if ($anymarketbrandsId) {
|
37 |
+
$anymarketbrands->load($anymarketbrandsId);
|
38 |
+
}
|
39 |
+
Mage::register('current_anymarketbrands', $anymarketbrands);
|
40 |
+
return $anymarketbrands;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* default action
|
45 |
+
*
|
46 |
+
* @access public
|
47 |
+
* @return void
|
48 |
+
|
49 |
+
*/
|
50 |
+
public function indexAction()
|
51 |
+
{
|
52 |
+
$this->loadLayout();
|
53 |
+
$this->_title(Mage::helper('db1_anymarket')->__('Anymarket'))
|
54 |
+
->_title(Mage::helper('db1_anymarket')->__('Anymarketbrand'));
|
55 |
+
$this->renderLayout();
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* import Brands action
|
60 |
+
*
|
61 |
+
* @access public
|
62 |
+
* @return void
|
63 |
+
*/
|
64 |
+
public function sincBrandsAction()
|
65 |
+
{
|
66 |
+
$storeID = Mage::getSingleton('core/session')->getStoreBrandVariable();
|
67 |
+
$brandCount = Mage::helper('db1_anymarket/brand')->getBrands($storeID);
|
68 |
+
|
69 |
+
if( $brandCount > 0 ) {
|
70 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
71 |
+
Mage::helper('db1_anymarket')->__('Successfully synchronized ').$brandCount. Mage::helper('db1_anymarket')->__(' brands.')
|
72 |
+
);
|
73 |
+
}else{
|
74 |
+
Mage::getSingleton('adminhtml/session')->addError( Mage::helper('db1_anymarket')->__('No brand was synchronized.') );
|
75 |
+
}
|
76 |
+
$this->_redirect('*/*/');
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* grid action
|
81 |
+
*
|
82 |
+
* @access public
|
83 |
+
* @return void
|
84 |
+
|
85 |
+
*/
|
86 |
+
public function gridAction()
|
87 |
+
{
|
88 |
+
$this->loadLayout()->renderLayout();
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* edit anymarketbrands - action
|
93 |
+
*
|
94 |
+
* @access public
|
95 |
+
* @return void
|
96 |
+
|
97 |
+
*/
|
98 |
+
public function editAction()
|
99 |
+
{
|
100 |
+
$anymarketbrandsId = $this->getRequest()->getParam('id');
|
101 |
+
$anymarketbrands = $this->_initAnymarketbrands();
|
102 |
+
if ($anymarketbrandsId && !$anymarketbrands->getId()) {
|
103 |
+
$this->_getSession()->addError(
|
104 |
+
Mage::helper('db1_anymarket')->__('This brand no longer exists.')
|
105 |
+
);
|
106 |
+
$this->_redirect('*/*/');
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
$data = Mage::getSingleton('adminhtml/session')->getAnymarketbrandsData(true);
|
110 |
+
if (!empty($data)) {
|
111 |
+
$anymarketbrands->setData($data);
|
112 |
+
}
|
113 |
+
Mage::register('anymarketbrands_data', $anymarketbrands);
|
114 |
+
$this->loadLayout();
|
115 |
+
$this->_title(Mage::helper('db1_anymarket')->__('Anymarket'))
|
116 |
+
->_title(Mage::helper('db1_anymarket')->__('Anymarketbrand'));
|
117 |
+
if ($anymarketbrands->getId()) {
|
118 |
+
$this->_title($anymarketbrands->getBrdId());
|
119 |
+
} else {
|
120 |
+
$this->_title(Mage::helper('db1_anymarket')->__('Add Brands'));
|
121 |
+
}
|
122 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
123 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
124 |
+
}
|
125 |
+
$this->renderLayout();
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* new anymarketbrands action
|
130 |
+
*
|
131 |
+
* @access public
|
132 |
+
* @return void
|
133 |
+
|
134 |
+
*/
|
135 |
+
public function newAction()
|
136 |
+
{
|
137 |
+
$this->_forward('edit');
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* save anymarketbrands - action
|
142 |
+
*
|
143 |
+
* @access public
|
144 |
+
* @return void
|
145 |
+
|
146 |
+
*/
|
147 |
+
public function saveAction()
|
148 |
+
{
|
149 |
+
if ($data = $this->getRequest()->getPost('anymarketbrands')) {
|
150 |
+
try {
|
151 |
+
$anymarketbrands = $this->_initAnymarketbrands();
|
152 |
+
$anymarketbrands->addData($data);
|
153 |
+
$anymarketbrands->save();
|
154 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
155 |
+
Mage::helper('db1_anymarket')->__('Brand was successfully saved')
|
156 |
+
);
|
157 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
158 |
+
if ($this->getRequest()->getParam('back')) {
|
159 |
+
$this->_redirect('*/*/edit', array('id' => $anymarketbrands->getId()));
|
160 |
+
return;
|
161 |
+
}
|
162 |
+
$this->_redirect('*/*/');
|
163 |
+
return;
|
164 |
+
} catch (Mage_Core_Exception $e) {
|
165 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
166 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketbrandsData($data);
|
167 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
168 |
+
return;
|
169 |
+
} catch (Exception $e) {
|
170 |
+
Mage::logException($e);
|
171 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
172 |
+
Mage::helper('db1_anymarket')->__('There was a problem saving the brand.')
|
173 |
+
);
|
174 |
+
Mage::getSingleton('adminhtml/session')->setAnymarketbrandsData($data);
|
175 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
176 |
+
return;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
180 |
+
Mage::helper('db1_anymarket')->__('Unable to find brand to save.')
|
181 |
+
);
|
182 |
+
$this->_redirect('*/*/');
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* delete anymarketbrands - action
|
187 |
+
*
|
188 |
+
* @access public
|
189 |
+
* @return void
|
190 |
+
|
191 |
+
*/
|
192 |
+
public function deleteAction()
|
193 |
+
{
|
194 |
+
if ( $this->getRequest()->getParam('id') > 0) {
|
195 |
+
try {
|
196 |
+
$anymarketbrands = Mage::getModel('db1_anymarket/anymarketbrands');
|
197 |
+
$anymarketbrands->setId($this->getRequest()->getParam('id'))->delete();
|
198 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
199 |
+
Mage::helper('db1_anymarket')->__('Brand was successfully deleted.')
|
200 |
+
);
|
201 |
+
$this->_redirect('*/*/');
|
202 |
+
return;
|
203 |
+
} catch (Mage_Core_Exception $e) {
|
204 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
205 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
206 |
+
} catch (Exception $e) {
|
207 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
208 |
+
Mage::helper('db1_anymarket')->__('There was an error deleting brand.')
|
209 |
+
);
|
210 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
211 |
+
Mage::logException($e);
|
212 |
+
return;
|
213 |
+
}
|
214 |
+
}
|
215 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
216 |
+
Mage::helper('db1_anymarket')->__('Could not find brand to delete.')
|
217 |
+
);
|
218 |
+
$this->_redirect('*/*/');
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* mass delete anymarketbrands - action
|
223 |
+
*
|
224 |
+
* @access public
|
225 |
+
* @return void
|
226 |
+
|
227 |
+
*/
|
228 |
+
public function massDeleteAction()
|
229 |
+
{
|
230 |
+
$anymarketbrandsIds = $this->getRequest()->getParam('anymarketbrands');
|
231 |
+
if (!is_array($anymarketbrandsIds)) {
|
232 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
233 |
+
Mage::helper('db1_anymarket')->__('Please select brand to delete.')
|
234 |
+
);
|
235 |
+
} else {
|
236 |
+
try {
|
237 |
+
foreach ($anymarketbrandsIds as $anymarketbrandsId) {
|
238 |
+
$anymarketbrands = Mage::getModel('db1_anymarket/anymarketbrands');
|
239 |
+
$anymarketbrands->setId($anymarketbrandsId)->delete();
|
240 |
+
}
|
241 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
242 |
+
Mage::helper('db1_anymarket')->__('Total of %d brand were successfully deleted.', count($anymarketbrandsIds))
|
243 |
+
);
|
244 |
+
} catch (Mage_Core_Exception $e) {
|
245 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
246 |
+
} catch (Exception $e) {
|
247 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
248 |
+
Mage::helper('db1_anymarket')->__('There was an error deleting brand.')
|
249 |
+
);
|
250 |
+
Mage::logException($e);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
$this->_redirect('*/*/index');
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* mass status change - action
|
258 |
+
*
|
259 |
+
* @access public
|
260 |
+
* @return void
|
261 |
+
|
262 |
+
*/
|
263 |
+
public function massStatusAction()
|
264 |
+
{
|
265 |
+
$anymarketbrandsIds = $this->getRequest()->getParam('anymarketbrands');
|
266 |
+
if (!is_array($anymarketbrandsIds)) {
|
267 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
268 |
+
Mage::helper('db1_anymarket')->__('Please select brands.')
|
269 |
+
);
|
270 |
+
} else {
|
271 |
+
try {
|
272 |
+
foreach ($anymarketbrandsIds as $anymarketbrandsId) {
|
273 |
+
$anymarketbrands = Mage::getSingleton('db1_anymarket/anymarketbrands')->load($anymarketbrandsId)
|
274 |
+
->setStatus($this->getRequest()->getParam('status'))
|
275 |
+
->setIsMassupdate(true)
|
276 |
+
->save();
|
277 |
+
}
|
278 |
+
$this->_getSession()->addSuccess(
|
279 |
+
$this->__('Total of %d brand were successfully updated.', count($anymarketbrandsIds))
|
280 |
+
);
|
281 |
+
} catch (Mage_Core_Exception $e) {
|
282 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
283 |
+
} catch (Exception $e) {
|
284 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
285 |
+
Mage::helper('db1_anymarket')->__('There was an error updating brand.')
|
286 |
+
);
|
287 |
+
Mage::logException($e);
|
288 |
+
}
|
289 |
+
}
|
290 |
+
$this->_redirect('*/*/index');
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* export as csv - action
|
295 |
+
*
|
296 |
+
* @access public
|
297 |
+
* @return void
|
298 |
+
|
299 |
+
*/
|
300 |
+
public function exportCsvAction()
|
301 |
+
{
|
302 |
+
$fileName = 'anymarketbrands.csv';
|
303 |
+
$content = $this->getLayout()->createBlock('db1_anymarket/adminhtml_anymarketbrands_grid')
|
304 |
+
->getCsv();
|
305 |
+
$this->_prepareDownloadResponse($fileName, $content);
|
306 |
+
}
|
307 |
+
|