Version Notes
* Pequenas Correções.
Para mais informações acesse:
https://github.com/AnyMarket/magento
Download this release
Release Info
| Developer | Anymarket |
| Extension | d7db67d0d012350a01ce05c31f91754d |
| Version | 2.12.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.10.1 to 2.12.1
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Form.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Stores.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tabs.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Grid.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/Buttoncheckconfig.php +0 -0
- app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/Callback.php +0 -0
- app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusammg/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusmgam/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Block/System/Config/Source/Products/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Controller/Adminhtml/AnyMarket.php +0 -0
- app/code/community/DB1/AnyMarket/Helper/Brand.php +0 -0
- app/code/community/DB1/AnyMarket/Helper/Category.php +0 -0
- app/code/community/DB1/AnyMarket/Helper/Customergenerator.php +0 -0
- app/code/community/DB1/AnyMarket/Helper/Data.php +12 -3
- app/code/community/DB1/AnyMarket/Helper/Image.php +215 -152
- app/code/community/DB1/AnyMarket/Helper/Order.php +638 -509
- app/code/community/DB1/AnyMarket/Helper/Ordergenerator.php +2 -2
- app/code/community/DB1/AnyMarket/Helper/Product.php +84 -50
- app/code/community/DB1/AnyMarket/Helper/Productgenerator.php +64 -17
- app/code/community/DB1/AnyMarket/Helper/Queue.php +52 -19
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketattributes.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketbrands.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketimage.php +60 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketlog.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketorders.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketproducts.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketqueue.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketattributes.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketbrands.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketcategories.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketimage.php +84 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketlog.php +4 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketorders.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api.php +8 -1
- app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketproducts.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api.php +32 -18
- app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketqueue.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api/V2.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Cron.php +2 -2
- app/code/community/DB1/AnyMarket/Model/Observer.php +90 -7
- app/code/community/DB1/AnyMarket/Model/PaymentMethod.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketimage.php +62 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketimage/Collection.php +110 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue/Collection.php +0 -0
- app/code/community/DB1/AnyMarket/Model/Resource/Setup.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Group/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Street/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Booleantp/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Price/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Set/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Categories/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/General/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Logs/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Massunit/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Measurementunit/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Orders/Values.php +0 -0
- app/code/community/DB1/AnyMarket/Model/System/Config/Source/Typesync/Order/Values.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketattributesController.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketbrandsController.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketcategoriesController.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketlogController.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketordersController.php +3 -3
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketproductsController.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketqueueController.php +0 -0
- app/code/community/DB1/AnyMarket/controllers/Adminhtml/AnymarketController.php +0 -4
- app/code/community/DB1/AnyMarket/controllers/IndexController.php +73 -59
- app/code/community/DB1/AnyMarket/etc/adminhtml.xml +0 -0
- app/code/community/DB1/AnyMarket/etc/api.xml +0 -0
- app/code/community/DB1/AnyMarket/etc/config.xml +37 -18
- app/code/community/DB1/AnyMarket/etc/system.xml +29 -41
- app/code/community/DB1/AnyMarket/etc/wsdl.xml +0 -0
- app/code/community/DB1/AnyMarket/etc/wsi.xml +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-install-1.0.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.0.0-1.1.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.1.0-1.2.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.2.0-1.3.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.3.0-1.4.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.4.0-1.5.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.5.0-1.6.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.6.0-1.7.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.7.0-1.8.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-1.8.0-2.0.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.0.0-2.1.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.1.0-2.2.0.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.11.1-2.11.2.php +8 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.11.2-2.11.3.php +3 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.11.3-2.11.4.php +39 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.2.0-2.3.6.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.3.6-2.3.9.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.3.9-2.4.0.php +1 -1
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.4.0-2.4.3.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.4.3-2.4.4.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.4.4-2.9.1.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.9.1-2.9.2.php +0 -0
- app/code/community/DB1/AnyMarket/sql/db1_anymarket_setup/mysql4-upgrade-2.9.2-2.11.1.php +4 -0
- app/design/adminhtml/default/default/layout/db1_anymarket.xml +9 -0
- app/design/adminhtml/default/default/template/db1/anymarket/system/config/form/field/array_dropdown.phtml +0 -0
- app/design/adminhtml/default/default/template/db1/anymarket/system/config/form/field/button_check_configuration.phtml +0 -0
- app/etc/modules/DB1_AnyMarket.xml +0 -0
- app/locale/en_US/DB1_AnyMarket.csv +0 -0
- app/locale/pt_BR/DB1_AnyMarket.csv +0 -0
- package.xml +7 -7
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketattributes/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketbrands/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketcategories/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketlog/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketorders/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketproducts/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Form.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tab/Stores.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Edit/Tabs.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/Anymarketqueue/Grid.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/Buttoncheckconfig.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/Adminhtml/System/Config/Form/Callback.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusammg/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/System/Config/Source/Orders/Statusmgam/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Block/System/Config/Source/Products/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Controller/Adminhtml/AnyMarket.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Helper/Brand.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Helper/Category.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Helper/Customergenerator.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Helper/Data.php
CHANGED
|
@@ -278,11 +278,20 @@ class DB1_AnyMarket_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 278 |
$temp_array = array();
|
| 279 |
$i = 0;
|
| 280 |
$key_array = array();
|
|
|
|
| 281 |
|
| 282 |
foreach($array as $val) {
|
| 283 |
-
if (
|
| 284 |
-
$
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
}
|
| 287 |
$i++;
|
| 288 |
}
|
| 278 |
$temp_array = array();
|
| 279 |
$i = 0;
|
| 280 |
$key_array = array();
|
| 281 |
+
$var_array = array();
|
| 282 |
|
| 283 |
foreach($array as $val) {
|
| 284 |
+
if( isset($val['variation']) ){
|
| 285 |
+
if (!in_array($val[$key], $key_array) || !in_array($val['variation'], $var_array) ) {
|
| 286 |
+
$key_array[$i] = $val[$key];
|
| 287 |
+
$var_array[$i] = $val['variation'];
|
| 288 |
+
array_push($temp_array, $val);
|
| 289 |
+
}
|
| 290 |
+
}else {
|
| 291 |
+
if (!in_array($val[$key], $key_array)) {
|
| 292 |
+
$key_array[$i] = $val[$key];
|
| 293 |
+
array_push($temp_array, $val);
|
| 294 |
+
}
|
| 295 |
}
|
| 296 |
$i++;
|
| 297 |
}
|
app/code/community/DB1/AnyMarket/Helper/Image.php
CHANGED
|
@@ -21,17 +21,13 @@ class DB1_AnyMarket_Helper_Image extends DB1_AnyMarket_Helper_Data
|
|
| 21 |
$imgSize = filesize($g_image['path']);
|
| 22 |
$processImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_transform_process_image_field', $storeID);
|
| 23 |
if ($processImage == 0) {
|
| 24 |
-
if (($infoImg[0] != "") && ((float)$infoImg[0] < 350 || (float)$infoImg[1] < 350 || $imgSize > 4100000))
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
$anymarketlog->setStatus("1");
|
| 32 |
-
$anymarketlog->setStores(array($storeID));
|
| 33 |
-
$anymarketlog->save();
|
| 34 |
-
}
|
| 35 |
} else {
|
| 36 |
$urlImageImport = $g_image['url'];
|
| 37 |
$defaultImage = $product->getImage();
|
|
@@ -104,9 +100,48 @@ class DB1_AnyMarket_Helper_Image extends DB1_AnyMarket_Helper_Data
|
|
| 104 |
}
|
| 105 |
}
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
}
|
| 111 |
|
| 112 |
/**
|
|
@@ -117,177 +152,205 @@ class DB1_AnyMarket_Helper_Image extends DB1_AnyMarket_Helper_Data
|
|
| 117 |
* @param $product
|
| 118 |
* @param $variation
|
| 119 |
*
|
|
|
|
| 120 |
*/
|
| 121 |
public function sendImageToAnyMarket($storeID, $product, $variation){
|
| 122 |
-
if(
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
| 126 |
-
$exportImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_export_image_field', $storeID);
|
| 127 |
-
$transformToHttp = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_transform_http_image_field', $storeID);
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
|
|
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
$imgsProdMagento = $productIMG->getMediaGalleryImages();
|
| 148 |
-
}
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
} else {
|
| 168 |
-
$imgProdMagentoURL = $imgProdMagento->getData('url');
|
| 169 |
-
if ($transformToHttp != 0) {
|
| 170 |
-
$imgProdMagentoURL = str_replace("https", "http", $imgProdMagentoURL);
|
| 171 |
-
}
|
| 172 |
-
array_push($arrAdd, $imgProdMagentoURL);
|
| 173 |
-
}
|
| 174 |
}
|
| 175 |
-
}else {
|
| 176 |
-
$with = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_width_image_field', $storeID);
|
| 177 |
-
$height = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_height_image_field', $storeID);
|
| 178 |
-
foreach ($imgsProdMagento as $imgProdMagento) {
|
| 179 |
-
if( ((int)$with > 0) && ((int)$height > 0) ){
|
| 180 |
-
$thumbnail12 = Mage::helper('catalog/image')->init($product, 'image', $imgProdMagento->getFile())->resize($with, $height);
|
| 181 |
-
}else{
|
| 182 |
-
$thumbnail12 = Mage::helper('catalog/image')->init($product, 'image', $imgProdMagento->getFile());
|
| 183 |
-
}
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
}
|
|
|
|
| 191 |
}
|
| 192 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
|
|
|
| 199 |
}
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
-
if( $
|
| 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 |
-
if( !empty($arrImgs) ){
|
| 234 |
-
$returnProd['error'] = '1';
|
| 235 |
-
$returnProd['json'] = '';
|
| 236 |
|
| 237 |
-
|
| 238 |
-
foreach ($arrImgs as $field) {
|
| 239 |
-
$emptyFields .= $field.', ';
|
| 240 |
-
}
|
| 241 |
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
foreach ($arrAdd as $imgAdd) {
|
| 247 |
-
$isMain = strpos($imgAdd, $defaultImage) === false ? false : true;
|
| 248 |
-
if ($variation) {
|
| 249 |
-
$JSONAdd = array(
|
| 250 |
-
"url" => $imgAdd,
|
| 251 |
-
"variation" => $variation,
|
| 252 |
-
"main" => $isMain
|
| 253 |
-
);
|
| 254 |
-
} else {
|
| 255 |
-
$JSONAdd = array(
|
| 256 |
-
"url" => $imgAdd,
|
| 257 |
-
"main" => $isMain
|
| 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 |
}
|
| 21 |
$imgSize = filesize($g_image['path']);
|
| 22 |
$processImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_transform_process_image_field', $storeID);
|
| 23 |
if ($processImage == 0) {
|
| 24 |
+
if ($exportImage == 0 && ($infoImg[0] != "") && ((float)$infoImg[0] < 350 || (float)$infoImg[1] < 350 || $imgSize > 4100000)){
|
| 25 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 26 |
+
$anymarketlog->setLogDesc('Error on export image - ' . $g_image['url'] . ' - Width: ' . $infoImg[0] . ' - Height: ' . $infoImg[1] . ' - Size: ' . $imgSize );
|
| 27 |
+
$anymarketlog->setLogId($product->getSku());
|
| 28 |
+
$anymarketlog->setStatus("1");
|
| 29 |
+
$anymarketlog->setStores(array($storeID));
|
| 30 |
+
$anymarketlog->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
} else {
|
| 32 |
$urlImageImport = $g_image['url'];
|
| 33 |
$defaultImage = $product->getImage();
|
| 100 |
}
|
| 101 |
}
|
| 102 |
|
| 103 |
+
private function getMediaEntityGalleryDirect($valueId){
|
| 104 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 105 |
+
$sql = "SELECT * FROM `catalog_product_entity_media_gallery` WHERE `value_id`=".$valueId;
|
| 106 |
+
$rows = $connection->fetchAll($sql);
|
| 107 |
+
|
| 108 |
+
return count($rows) > 0;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
private function deleteImageAnymarket($storeID, $HOST, $product, $headers, $imgRemove, $valueId){
|
| 112 |
+
if( $valueId != null && $this->getMediaEntityGalleryDirect($valueId) ){
|
| 113 |
+
return false;
|
| 114 |
+
}
|
| 115 |
+
$imgDelRet = $this->CallAPICurl("DELETE", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/images/" . $imgRemove, $headers, null);
|
| 116 |
+
if ($imgDelRet['error'] == '1') {
|
| 117 |
+
$anymarketlogDel = Mage::getModel('db1_anymarket/anymarketlog');
|
| 118 |
+
|
| 119 |
+
if (is_string($imgDelRet['return'])) {
|
| 120 |
+
$anymarketlogDel->setLogDesc('Error on delete image in Anymarket (' . $imgRemove . ') - ' . $imgDelRet['return']);
|
| 121 |
+
} else {
|
| 122 |
+
$anymarketlogDel->setLogDesc('Error on delete image in Anymarket (' . $imgRemove . ') - ' . json_encode($imgDelRet['return']));
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
$anymarketlogDel->setLogJson('');
|
| 126 |
+
$anymarketlogDel->setLogId($product->getSku());
|
| 127 |
+
$anymarketlogDel->setStatus("1");
|
| 128 |
+
$anymarketlogDel->setStores(array($storeID));
|
| 129 |
+
$anymarketlogDel->save();
|
| 130 |
+
} else {
|
| 131 |
+
$anymarketlogDel = Mage::getModel('db1_anymarket/anymarketlog');
|
| 132 |
+
$anymarketlogDel->setLogDesc('Deleted image from Anymarket ('.$imgRemove.')');
|
| 133 |
+
$anymarketlogDel->setLogJson('');
|
| 134 |
+
$anymarketlogDel->setLogId($product->getSku());
|
| 135 |
+
$anymarketlogDel->setStatus("1");
|
| 136 |
+
$anymarketlogDel->setStores(array($storeID));
|
| 137 |
+
$anymarketlogDel->save();
|
| 138 |
+
|
| 139 |
|
| 140 |
+
$anymarketCtrlImg = Mage::getModel('db1_anymarket/anymarketimage')->load($imgRemove, 'id_image');
|
| 141 |
+
if( $anymarketCtrlImg->getData('value_id') != "" || $anymarketCtrlImg->getData('value_id') != null ) {
|
| 142 |
+
$anymarketCtrlImg->delete();
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
}
|
| 146 |
|
| 147 |
/**
|
| 152 |
* @param $product
|
| 153 |
* @param $variation
|
| 154 |
*
|
| 155 |
+
* @return boolean
|
| 156 |
*/
|
| 157 |
public function sendImageToAnyMarket($storeID, $product, $variation){
|
| 158 |
+
if(!$product){
|
| 159 |
+
return false;
|
| 160 |
+
}
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 163 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
| 164 |
+
$exportImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_export_image_field', $storeID);
|
| 165 |
+
$transformToHttp = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_transform_http_image_field', $storeID);
|
| 166 |
|
| 167 |
+
$headers = array(
|
| 168 |
+
"Content-type: application/json",
|
| 169 |
+
"gumgaToken: ".$TOKEN
|
| 170 |
+
);
|
| 171 |
|
| 172 |
+
$imgGetRet = $this->CallAPICurl("GET", $HOST."/v2/products/".$product->getData('id_anymarket')."/images", $headers, null);
|
| 173 |
+
if($imgGetRet['error'] == '0'){
|
| 174 |
+
$imgsProdAnymarket = $imgGetRet['return'];
|
| 175 |
|
| 176 |
+
$arrAdd = array();
|
| 177 |
+
$arrImgs = array();
|
| 178 |
|
| 179 |
+
$processImage = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_transform_process_image_field', $storeID);
|
| 180 |
+
$imgsProdMagento = $product->getMediaGalleryImages();
|
|
|
|
|
|
|
| 181 |
|
| 182 |
+
if (count($imgsProdMagento) <= 0) {
|
| 183 |
+
$productIMG = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $product->getId() );
|
| 184 |
+
$imgsProdMagento = $productIMG->getMediaGalleryImages();
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
if (count($imgsProdMagento) > 0) {
|
| 188 |
+
if( $processImage == 0 ) {
|
| 189 |
+
foreach ($imgsProdMagento as $imgProdMagento) {
|
| 190 |
+
$loadedImagCtrl = Mage::getModel('db1_anymarket/anymarketimage')->load( $imgProdMagento->getData('value_id'), 'value_id');
|
| 191 |
+
|
| 192 |
+
if( $loadedImagCtrl->getData('value_id') != "" && $loadedImagCtrl->getData('value_id') != null ) {
|
| 193 |
+
$imgValDeleted = $this->CallAPICurl("GET", $HOST."/v2/products/".$product->getData('id_anymarket')."/images/".$loadedImagCtrl->getData('id_image'), $headers, null);
|
| 194 |
+
|
| 195 |
+
if($imgValDeleted['error'] == '1'){
|
| 196 |
+
$loadedImagCtrl->delete();
|
| 197 |
+
}else{
|
| 198 |
+
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
+
}
|
| 202 |
+
$urlImage = $imgProdMagento->getData('url');
|
| 203 |
+
$infoImg = getimagesize($urlImage);
|
| 204 |
+
$imgSize = filesize($imgProdMagento->getData('path'));
|
| 205 |
+
|
| 206 |
+
if ($exportImage == 0 && ($infoImg[0] != "") && ((float)$infoImg[0] < 350 || (float)$infoImg[1] < 350 || $imgSize > 4100000)) {
|
| 207 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 208 |
+
$anymarketlog->setLogDesc('Error on export image - ' . $urlImage . ' - Width: ' . $infoImg[0] . ' - Height: ' . $infoImg[1] . ' - Size: ' . $imgSize );
|
| 209 |
+
$anymarketlog->setLogId($product->getSku());
|
| 210 |
+
$anymarketlog->setStatus("1");
|
| 211 |
+
$anymarketlog->setStores(array($storeID));
|
| 212 |
+
$anymarketlog->save();
|
| 213 |
+
} else {
|
| 214 |
+
$imgProdMagentoURL = $imgProdMagento->getData('url');
|
| 215 |
+
if ($transformToHttp != 0) {
|
| 216 |
+
$imgProdMagentoURL = str_replace("https", "http", $imgProdMagentoURL);
|
| 217 |
}
|
| 218 |
+
array_push($arrAdd, array('URL' => $imgProdMagentoURL, 'ID' =>$imgProdMagento->getData('value_id') ));
|
| 219 |
}
|
| 220 |
}
|
| 221 |
+
}else {
|
| 222 |
+
$with = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_width_image_field', $storeID);
|
| 223 |
+
$height = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_height_image_field', $storeID);
|
| 224 |
+
foreach ($imgsProdMagento as $imgProdMagento) {
|
| 225 |
+
$loadedImagCtrl = Mage::getModel('db1_anymarket/anymarketimage')->load($imgProdMagento->getData('value_id'), 'value_id');
|
| 226 |
|
| 227 |
+
if( $loadedImagCtrl->getData('value_id') != "" && $loadedImagCtrl->getData('value_id') != null ) {
|
| 228 |
+
$imgValDeleted = $this->CallAPICurl("GET", $HOST."/v2/products/".$product->getData('id_anymarket')."/images/".$loadedImagCtrl->getData('id_image'), $headers, null);
|
| 229 |
+
if($imgValDeleted['error'] == '1'){
|
| 230 |
+
$loadedImagCtrl->delete();
|
| 231 |
+
}else{
|
| 232 |
+
continue;
|
| 233 |
}
|
| 234 |
+
|
| 235 |
}
|
| 236 |
|
| 237 |
+
if (((int)$with > 0) && ((int)$height > 0)) {
|
| 238 |
+
$thumbnail12 = Mage::helper('catalog/image')->init($product, 'image', $imgProdMagento->getFile())->resize($with, $height);
|
| 239 |
+
} else {
|
| 240 |
+
$thumbnail12 = Mage::helper('catalog/image')->init($product, 'image', $imgProdMagento->getFile());
|
| 241 |
+
}
|
| 242 |
|
| 243 |
+
$imgProdMagentoURL = str_replace('/webApps/migration/productapi/new/', '/', $thumbnail12);
|
| 244 |
+
if ($transformToHttp != 0) {
|
| 245 |
+
$imgProdMagentoURL = str_replace("https", "http", $imgProdMagentoURL);
|
| 246 |
+
}
|
| 247 |
+
array_push($arrAdd, array('URL' => $imgProdMagentoURL, 'ID' =>$imgProdMagento->getData('value_id') ));
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
|
| 252 |
+
//REMOVE IMAGE
|
| 253 |
+
foreach ($imgsProdAnymarket as $imgProdAnymarket) {
|
| 254 |
+
$exportImages = true;
|
| 255 |
+
if ($variation) {
|
| 256 |
+
if( !isset($imgProdAnymarket->variation) || $imgProdAnymarket->variation != $variation ){
|
| 257 |
+
$exportImages = false;
|
| 258 |
+
}
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
if( $exportImages ) {
|
| 262 |
+
$imgRemove = $imgProdAnymarket->id;
|
| 263 |
+
$loadedImagCtrl = Mage::getModel('db1_anymarket/anymarketimage')->load($imgRemove, 'id_image');
|
| 264 |
+
|
| 265 |
+
if( $loadedImagCtrl->getData('value_id') != "" || $loadedImagCtrl->getData('value_id') != null ) {
|
| 266 |
+
$deleteImage = true;
|
| 267 |
+
foreach ($imgsProdMagento as $imgProdMagento) {
|
| 268 |
+
$urlImage = $imgProdMagento->getData('value_id');
|
| 269 |
+
if( $urlImage == $loadedImagCtrl->getData('value_id') ){
|
| 270 |
+
$deleteImage = false;
|
| 271 |
+
break;
|
| 272 |
}
|
| 273 |
}
|
| 274 |
+
if($deleteImage){
|
| 275 |
+
$this->deleteImageAnymarket($storeID, $HOST, $product, $headers, $imgRemove, $loadedImagCtrl->getData('value_id'));
|
| 276 |
+
}
|
| 277 |
|
| 278 |
+
}else{
|
| 279 |
+
$this->deleteImageAnymarket($storeID, $HOST, $product, $headers, $imgRemove, null);
|
| 280 |
}
|
| 281 |
|
| 282 |
+
}
|
|
|
|
|
|
|
|
|
|
| 283 |
|
| 284 |
+
}
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
+
// Add Image
|
| 287 |
+
if( !empty($arrImgs) ){
|
| 288 |
+
$returnProd['error'] = '1';
|
| 289 |
+
$returnProd['json'] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
+
$emptyFields = ' ';
|
| 292 |
+
foreach ($arrImgs as $field) {
|
| 293 |
+
$emptyFields .= $field.', ';
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Product with inconsistency:').' '.$emptyFields;
|
| 297 |
+
$this->saveLogsProds($storeID, "0", $returnProd, $product);
|
| 298 |
+
}else {
|
| 299 |
+
$defaultImage = $product->getImage();
|
| 300 |
+
|
| 301 |
+
foreach ($arrAdd as $imgAddArr) {
|
| 302 |
+
$imgAdd = $imgAddArr['URL'];
|
| 303 |
+
|
| 304 |
+
$isMain = strpos($imgAdd, $defaultImage) === false ? false : true;
|
| 305 |
+
if ($variation) {
|
| 306 |
+
$JSONAdd = array(
|
| 307 |
+
"url" => $imgAdd,
|
| 308 |
+
"variation" => $variation,
|
| 309 |
+
"main" => $isMain
|
| 310 |
+
);
|
| 311 |
+
} else {
|
| 312 |
+
$JSONAdd = array(
|
| 313 |
+
"url" => $imgAdd,
|
| 314 |
+
"main" => $isMain
|
| 315 |
+
);
|
| 316 |
}
|
| 317 |
|
| 318 |
+
$imgPostRet = $this->CallAPICurl("POST", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/images", $headers, $JSONAdd);
|
| 319 |
+
if ($imgPostRet['error'] == '1') {
|
| 320 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 321 |
+
$anymarketlog->setLogDesc('Error on export image (' . $product->getData('id_anymarket') . ') - ' . is_string($imgPostRet['return']) ? $imgPostRet['return'] : json_encode($imgPostRet['return']));
|
| 322 |
+
$anymarketlog->setLogJson($imgPostRet['json']);
|
| 323 |
+
$anymarketlog->setLogId($product->getSku());
|
| 324 |
+
$anymarketlog->setStatus("1");
|
| 325 |
+
$anymarketlog->setStores(array($storeID));
|
| 326 |
+
$anymarketlog->save();
|
| 327 |
+
} else {
|
| 328 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 329 |
+
$anymarketlog->setLogDesc('Exported image (' . $imgAdd . ')');
|
| 330 |
+
$anymarketlog->setLogJson($imgPostRet['json']);
|
| 331 |
+
$anymarketlog->setLogId($product->getSku());
|
| 332 |
+
$anymarketlog->setStatus("1");
|
| 333 |
+
$anymarketlog->setStores(array($storeID));
|
| 334 |
+
$anymarketlog->save();
|
| 335 |
+
|
| 336 |
+
$retJson = $imgPostRet['return'];
|
| 337 |
+
$anymarketImage = Mage::getModel('db1_anymarket/anymarketimage');
|
| 338 |
+
$anymarketImage->setValueId( $imgAddArr['ID'] );
|
| 339 |
+
$anymarketImage->setIdImage( $retJson->id );
|
| 340 |
+
$anymarketImage->save();
|
| 341 |
+
}
|
| 342 |
}
|
| 343 |
}
|
| 344 |
+
|
| 345 |
+
}else{
|
| 346 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 347 |
+
$anymarketlog->setLogDesc( 'Error on get images from Anymarket ('.$product->getData('id_anymarket').') ');
|
| 348 |
+
$anymarketlog->setStatus("1");
|
| 349 |
+
$anymarketlog->setStores(array($storeID));
|
| 350 |
+
$anymarketlog->save();
|
| 351 |
}
|
| 352 |
+
|
| 353 |
+
|
| 354 |
}
|
| 355 |
|
| 356 |
}
|
app/code/community/DB1/AnyMarket/Helper/Order.php
CHANGED
|
@@ -9,7 +9,7 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 9 |
* @param $OrderRowData
|
| 10 |
* @return string
|
| 11 |
*/
|
| 12 |
-
|
| 13 |
if($OrderRowData == null){
|
| 14 |
$OrderRowData = "new";
|
| 15 |
}
|
|
@@ -25,7 +25,6 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 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;
|
|
@@ -70,6 +69,78 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 70 |
}
|
| 71 |
}
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
/**
|
| 74 |
* get status order MG to AM from configs
|
| 75 |
*
|
|
@@ -223,10 +294,12 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 223 |
|
| 224 |
$this->getSpecificOrderFromAnyMarket($order->id, $order->token, $storeID);
|
| 225 |
|
| 226 |
-
$
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
| 230 |
}
|
| 231 |
}
|
| 232 |
}
|
|
@@ -255,316 +328,312 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 255 |
$IDOrderAnyMarket = $OrderJSON->marketPlaceId;
|
| 256 |
$anymarketordersSpec = Mage::getModel('db1_anymarket/anymarketorders');
|
| 257 |
$anymarketordersSpec->load($idSeqAnyMarket, 'nmo_id_seq_anymarket');
|
| 258 |
-
|
| 259 |
|
| 260 |
if( ($anymarketordersSpec->getData('nmo_id_anymarket') == null) ||
|
| 261 |
($anymarketordersSpec->getData('nmo_status_int') == "Não integrado (AnyMarket)") ||
|
| 262 |
($anymarketordersSpec->getData('nmo_status_int') == "ERROR 01") ){
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
array_push($shippingDesc, $shippItem->shippingtype);
|
| 280 |
-
}
|
| 281 |
}
|
| 282 |
}
|
|
|
|
| 283 |
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
}
|
| 301 |
-
|
| 302 |
-
$arrayTMP['bundle_option'] = $boundOpt;
|
| 303 |
-
$arrayTMP['bundle_option_qty'] = $boundOptQty;
|
| 304 |
}
|
| 305 |
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders');
|
| 310 |
-
} else {
|
| 311 |
-
$anymarketorders = $anymarketordersSpec;
|
| 312 |
-
}
|
| 313 |
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
| 330 |
-
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ') . "Anymarket(" . $IDOrderAnyMarket . ") <br/>" .
|
| 331 |
-
Mage::helper('db1_anymarket')->__('Product is not registered') . ' (SKU: ' . $item->sku->partnerId . ')',
|
| 332 |
-
'');
|
| 333 |
-
$stateProds = false;
|
| 334 |
-
break;
|
| 335 |
-
}
|
| 336 |
}
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
if (isset($OrderJSON->buyer->document)) {
|
| 343 |
-
$document = $OrderJSON->buyer->document;
|
| 344 |
-
}
|
| 345 |
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
$
|
| 350 |
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
$customer = Mage::getModel('customer/customer')
|
| 354 |
->getCollection()
|
| 355 |
->addFieldToFilter($AttrToDoc, $document)->load()->getFirstItem();
|
| 356 |
|
| 357 |
-
//caso nao
|
| 358 |
if(!$customer->getId()) {
|
| 359 |
-
if (strlen($document) == 11) {
|
| 360 |
-
$document = $this->Mask('###.###.###-##', $document);
|
| 361 |
-
} else {
|
| 362 |
-
$document = $this->Mask('##.###.###/####-##', $document);
|
| 363 |
-
}
|
| 364 |
-
|
| 365 |
$customer = Mage::getModel('customer/customer')
|
| 366 |
->getCollection()
|
| 367 |
-
->addFieldToFilter(
|
| 368 |
|
| 369 |
-
//caso ainda nao encontrou valida se existe o email
|
| 370 |
-
if(!$customer->getId()) {
|
| 371 |
-
$customer = Mage::getModel('customer/customer')
|
| 372 |
-
->getCollection()
|
| 373 |
-
->addFieldToFilter('email', $email)->load()->getFirstItem();
|
| 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 |
-
'firstname' => $firstName,
|
| 422 |
-
'lastname' => $lastName,
|
| 423 |
-
'street' => $addressFullData,
|
| 424 |
-
'city' => (isset($OrderJSON->shipping->city)) ? $OrderJSON->shipping->city : 'Não especificado',
|
| 425 |
-
'country_id' => 'BR',
|
| 426 |
-
'region_id' => $regionID,
|
| 427 |
-
'region' => (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado',
|
| 428 |
-
'postcode' => (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado',
|
| 429 |
-
'telephone' => $OrderJSON->buyer->phone,
|
| 430 |
-
),
|
| 431 |
-
),
|
| 432 |
-
);
|
| 433 |
-
|
| 434 |
-
$customerRet = Mage::helper('db1_anymarket/customergenerator')->createCustomer($_DataCustomer);
|
| 435 |
-
$customer = $customerRet['customer'];
|
| 436 |
-
$AddressShipBill = $customerRet['addr'];
|
| 437 |
-
} else {
|
| 438 |
-
//PERCORRE OS ENDERECOS PARA VER SE JA HA CADASTRADO O INFORMADO
|
| 439 |
-
$needRegister = true;
|
| 440 |
-
foreach ($customer->getAddresses() as $address) {
|
| 441 |
-
$zipCodeOrder = (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado';
|
| 442 |
-
$addressOrder = (isset($OrderJSON->shipping->address)) ? $OrderJSON->shipping->address : 'Frete não especificado.';
|
| 443 |
-
if (($address->getData('postcode') == $zipCodeOrder) && ($address->getData('street') == $addressOrder)) {
|
| 444 |
-
$AddressShipBill = $address;
|
| 445 |
-
$needRegister = false;
|
| 446 |
-
break;
|
| 447 |
-
}
|
| 448 |
-
}
|
| 449 |
-
|
| 450 |
-
//CRIA O ENDERECO CASO NAO TENHA O INFORMADO
|
| 451 |
-
if ($needRegister) {
|
| 452 |
-
$address = Mage::getModel('customer/address');
|
| 453 |
-
|
| 454 |
-
$addressData = array(
|
| 455 |
'firstname' => $firstName,
|
| 456 |
'lastname' => $lastName,
|
| 457 |
'street' => $addressFullData,
|
| 458 |
'city' => (isset($OrderJSON->shipping->city)) ? $OrderJSON->shipping->city : 'Não especificado',
|
| 459 |
'country_id' => 'BR',
|
| 460 |
-
'region' => (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado',
|
| 461 |
'region_id' => $regionID,
|
|
|
|
| 462 |
'postcode' => (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado',
|
| 463 |
-
'telephone' => $OrderJSON->buyer->phone
|
| 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 |
-
$OrderCheck = Mage::getModel('sales/order')->loadByIncrementId($OrderIDMage);
|
| 490 |
|
| 491 |
-
|
| 492 |
|
| 493 |
-
|
| 494 |
-
$comment = '<b>Código do Pedido no Canal de Vendas: </b>'.$OrderJSON->marketPlaceNumber.'<br>';
|
| 495 |
-
$comment .= '<b>Canal de Vendas: </b>'.$OrderJSON->marketPlace.'<br>';
|
| 496 |
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
$comment .= '<b>Forma de Pagamento: </b>' . $iMetPag . '<br>';
|
| 500 |
-
}
|
| 501 |
-
}else{
|
| 502 |
-
$comment .= '<b>Forma de Pagamento: </b>Inf. não disponibilizada pelo marketplace.<br>';
|
| 503 |
-
}
|
| 504 |
|
| 505 |
-
|
| 506 |
-
$
|
| 507 |
-
|
| 508 |
-
$OrderCheck->addStatusHistoryComment( $comment );
|
| 509 |
-
$OrderCheck->setEmailSent(false);
|
| 510 |
-
$OrderCheck->save();
|
| 511 |
|
|
|
|
|
|
|
| 512 |
|
| 513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
}
|
| 515 |
-
} catch (Exception $e) {
|
| 516 |
-
$this->saveLogOrder('nmo_id_seq_anymarket',
|
| 517 |
-
$idSeqAnyMarket,
|
| 518 |
-
'ERROR 01',
|
| 519 |
-
'System: ' . $e->getMessage(),
|
| 520 |
-
$idSeqAnyMarket,
|
| 521 |
-
$IDOrderAnyMarket,
|
| 522 |
-
'',
|
| 523 |
-
$storeID);
|
| 524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
}
|
| 526 |
-
}
|
|
|
|
|
|
|
| 527 |
$this->saveLogOrder('nmo_id_seq_anymarket',
|
| 528 |
$idSeqAnyMarket,
|
| 529 |
-
|
| 530 |
-
|
| 531 |
$idSeqAnyMarket,
|
| 532 |
$IDOrderAnyMarket,
|
| 533 |
-
|
| 534 |
$storeID);
|
| 535 |
|
| 536 |
-
$
|
| 537 |
-
$anymarketlog->setLogDesc('Error on import Order: ' . Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'));
|
| 538 |
-
$anymarketlog->setStatus("0");
|
| 539 |
-
$anymarketlog->setStores(array($storeID));
|
| 540 |
-
$anymarketlog->save();
|
| 541 |
-
|
| 542 |
-
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
| 543 |
-
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ') . "Anymarket(" . $IDOrderAnyMarket . ") <br/>" .
|
| 544 |
-
Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'),
|
| 545 |
-
'');
|
| 546 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
}
|
| 548 |
-
} else {
|
| 549 |
-
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 550 |
-
$anymarketlog->setLogDesc($statusMage);
|
| 551 |
-
$anymarketlog->setLogId($IDOrderAnyMarket);
|
| 552 |
-
$anymarketlog->setStatus("0");
|
| 553 |
-
$anymarketlog->save();
|
| 554 |
}
|
|
|
|
| 555 |
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
|
| 561 |
-
|
| 562 |
-
}
|
| 563 |
}
|
| 564 |
}
|
| 565 |
}else{
|
| 566 |
-
$
|
| 567 |
-
|
|
|
|
| 568 |
if ($anymarketordersSpec->getData('nmo_id_order') != null) {
|
| 569 |
$this->changeStatusOrder($storeID, $OrderJSON, $anymarketordersSpec->getData('nmo_id_order'));
|
| 570 |
}
|
|
@@ -644,28 +713,13 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 644 |
Mage::getSingleton('core/session')->setImportOrdersVariable('false');
|
| 645 |
$order = Mage::getModel('sales/order')->loadByIncrementId( $IDOrderMagento );
|
| 646 |
|
| 647 |
-
if( $order->getData('state') == $stateMage ){
|
| 648 |
return false;
|
| 649 |
}
|
| 650 |
|
| 651 |
$createRegPay = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_create_reg_pay_field', $storeID);
|
| 652 |
$itemsarray = null;
|
| 653 |
|
| 654 |
-
if( $createRegPay == "1" && $StatusPedAnyMarket == 'PAID_WAITING_SHIP' ){
|
| 655 |
-
if( $order->canInvoice() ){
|
| 656 |
-
if( $this->checkIfCanCreateInvoice($order) ) {
|
| 657 |
-
$orderItems = $order->getAllItems();
|
| 658 |
-
foreach ($orderItems as $_eachItem) {
|
| 659 |
-
$opid = $_eachItem->getId();
|
| 660 |
-
$qty = $_eachItem->getQtyOrdered();
|
| 661 |
-
$itemsarray[$opid] = $qty;
|
| 662 |
-
}
|
| 663 |
-
$nfeString = "Registro de Pagamento criado por Anymarket";
|
| 664 |
-
Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(), $itemsarray, $nfeString, 0, 0);
|
| 665 |
-
}
|
| 666 |
-
}
|
| 667 |
-
}
|
| 668 |
-
|
| 669 |
if( isset($JSON->invoice) && $StatusPedAnyMarket == 'INVOICED' ){
|
| 670 |
if( $order->canInvoice() ){
|
| 671 |
if(isset($JSON->invoice->accessKey) ) {
|
|
@@ -730,28 +784,43 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 730 |
}
|
| 731 |
}
|
| 732 |
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
$order->
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
foreach ($order->getAllItems() as $item) {
|
| 743 |
-
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct( $item->getProductId() );
|
| 744 |
-
if ($stockItem->getManageStock()) {
|
| 745 |
-
$stockItem->setData('qty', $stockItem->getQty() + $item->getQtyOrdered());
|
| 746 |
-
}
|
| 747 |
-
$stockItem->save();
|
| 748 |
|
| 749 |
-
|
| 750 |
-
|
|
|
|
|
|
|
|
|
|
| 751 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 752 |
}
|
|
|
|
|
|
|
| 753 |
|
| 754 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 755 |
}
|
| 756 |
|
| 757 |
$this->saveLogOrder('nmo_id_anymarket',
|
|
@@ -770,12 +839,24 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 770 |
$anymarketlog->save();
|
| 771 |
|
| 772 |
Mage::getSingleton('core/session')->setImportOrdersVariable('true');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 773 |
}else{
|
| 774 |
-
|
| 775 |
-
$anymarketlog->setLogDesc( $statusMage );
|
| 776 |
-
$anymarketlog->setLogId( $IDOrderMagento );
|
| 777 |
-
$anymarketlog->setStatus("0");
|
| 778 |
-
$anymarketlog->save();
|
| 779 |
}
|
| 780 |
}
|
| 781 |
|
|
@@ -794,19 +875,12 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 794 |
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId( $inv->getIncrementId() );
|
| 795 |
foreach ($invoice->getCommentsCollection() as $item) {
|
| 796 |
$CommentCurr = $item->getComment();
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
$
|
| 802 |
-
|
| 803 |
-
$chaveAcID = substr( $nfeTmp, $nfeCount+4, 44);
|
| 804 |
-
$nfeID = $chaveAcID;
|
| 805 |
-
|
| 806 |
-
$date = substr( $CommentCurr, $emissaoCount+8, 19);
|
| 807 |
-
$dateTmp = str_replace("/", "-", $date );
|
| 808 |
-
|
| 809 |
-
$date = $this->formatDateTimeZone($dateTmp);
|
| 810 |
}
|
| 811 |
}
|
| 812 |
}
|
|
@@ -816,75 +890,80 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 816 |
foreach ($Order->getStatusHistoryCollection() as $item) {
|
| 817 |
$CommentCurr = $item->getComment();
|
| 818 |
|
| 819 |
-
$
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
$
|
| 824 |
-
|
| 825 |
-
$
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 829 |
|
| 830 |
-
|
| 831 |
-
|
|
|
|
|
|
|
| 832 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 833 |
}
|
| 834 |
-
|
| 835 |
-
$dateTmp = new DateTime(str_replace("/", "-", $item->getData('created_at') ));
|
| 836 |
-
$date = date_format($dateTmp, 'Y-m-d\TH:i:s\Z');
|
| 837 |
-
break;
|
| 838 |
}
|
| 839 |
}
|
| 840 |
}
|
| 841 |
|
| 842 |
-
if( $chaveAcID == "" ) {
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
$
|
| 850 |
-
$
|
| 851 |
-
|
| 852 |
-
$caracts = array("/", "-", ".");
|
| 853 |
-
$nfeTmp = str_replace($caracts, "", $CommentCurr );
|
| 854 |
-
$chaveAcID = substr( $nfeTmp, $nfeCount+4, 44);
|
| 855 |
-
$nfeID = $chaveAcID;
|
| 856 |
-
|
| 857 |
-
$date = substr( $CommentCurr, $emissaoCount+8, 19);
|
| 858 |
-
$dateTmp = str_replace("/", "-", $date );
|
| 859 |
-
|
| 860 |
-
$date = $this->formatDateTimeZone($dateTmp);
|
| 861 |
-
}
|
| 862 |
}
|
| 863 |
}
|
| 864 |
}
|
| 865 |
}
|
| 866 |
-
|
| 867 |
-
$retArr = array("number" => $nfeID, "date" => $date, "accessKey" => $chaveAcID);
|
| 868 |
-
return $retArr;
|
| 869 |
}
|
| 870 |
|
| 871 |
/**
|
| 872 |
* get tracking order
|
| 873 |
*
|
| 874 |
-
* * @param $storeID
|
| 875 |
* @param $Order
|
| 876 |
* @return array
|
| 877 |
*/
|
| 878 |
-
public function getTrackingOrder($
|
| 879 |
$TrackNum = '';
|
| 880 |
$TrackTitle = '';
|
| 881 |
$TrackCreate = '';
|
| 882 |
$dateTrack = '';
|
| 883 |
-
|
| 884 |
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
| 885 |
->setOrderFilter($Order)
|
| 886 |
->load();
|
| 887 |
foreach ($shipmentCollection as $shipment){
|
|
|
|
| 888 |
foreach($shipment->getAllTracks() as $tracknum){
|
| 889 |
$TrackNum = $tracknum->getNumber();
|
| 890 |
$TrackTitle = $tracknum->getTitle();
|
|
@@ -895,121 +974,150 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 895 |
}
|
| 896 |
}
|
| 897 |
|
| 898 |
-
$
|
|
|
|
|
|
|
|
|
|
| 899 |
|
| 900 |
-
$
|
| 901 |
-
$
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 908 |
}
|
| 909 |
|
| 910 |
/**
|
| 911 |
* update order in AM
|
| 912 |
*
|
|
|
|
| 913 |
* @param $Order
|
|
|
|
|
|
|
| 914 |
*/
|
| 915 |
-
public function
|
| 916 |
-
$
|
| 917 |
-
|
| 918 |
-
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 919 |
-
$idOrder = $Order->getIncrementId();
|
| 920 |
-
$status = $Order->getStatus();
|
| 921 |
-
$anymarketorderupdt = Mage::getModel('db1_anymarket/anymarketorders')->load($idOrder, 'nmo_id_order');
|
| 922 |
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
|
|
|
| 926 |
|
| 927 |
-
|
| 928 |
-
|
|
|
|
|
|
|
| 929 |
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
"Accept: */*",
|
| 933 |
-
"gumgaToken: ".$TOKEN
|
| 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 |
-
$anymarketlog->setLogId( $idOrder );
|
| 979 |
-
$anymarketlog->setLogJson('');
|
| 980 |
-
$anymarketlog->setStores(array($storeID));
|
| 981 |
-
$anymarketlog->setStatus("0");
|
| 982 |
-
$anymarketlog->save();
|
| 983 |
-
}
|
| 984 |
-
}else{
|
| 985 |
-
if($ConfigOrder == 0){
|
| 986 |
-
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 987 |
-
$anymarketlog->setStatus("0");
|
| 988 |
-
$anymarketlog->setLogDesc( $statuAM );
|
| 989 |
-
$anymarketlog->setLogId( $idOrder );
|
| 990 |
-
$anymarketlog->setStores(array($storeID));
|
| 991 |
-
$anymarketlog->save();
|
| 992 |
-
}
|
| 993 |
-
}
|
| 994 |
-
}else{
|
| 995 |
-
$this->sendOrderToAnyMarket($storeID, $idOrder, $HOST, $TOKEN);
|
| 996 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 997 |
}
|
| 998 |
-
}
|
| 999 |
|
|
|
|
| 1000 |
}
|
| 1001 |
|
| 1002 |
/**
|
| 1003 |
* send order to AM
|
| 1004 |
*
|
| 1005 |
-
* @param $
|
| 1006 |
-
* @param $
|
| 1007 |
-
* @param $TOKEN
|
| 1008 |
*/
|
| 1009 |
-
|
| 1010 |
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 1011 |
-
if($ConfigOrder == 0
|
| 1012 |
-
$
|
|
|
|
|
|
|
| 1013 |
|
| 1014 |
//TRATA OS ITEMS
|
| 1015 |
$orderedItems = $Order->getAllVisibleItems();
|
|
@@ -1053,101 +1161,121 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 1053 |
}
|
| 1054 |
|
| 1055 |
|
| 1056 |
-
if( (strpos($statuAM, 'ERROR:')
|
| 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 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
),
|
| 1090 |
-
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
)
|
|
|
|
|
|
|
|
|
|
| 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 |
$anymarketorders->setNmoStatusInt('ERROR 02');
|
| 1124 |
$anymarketorders->setNmoDescError($returnOrder['return']);
|
| 1125 |
}else{
|
| 1126 |
-
$
|
| 1127 |
-
$anymarketorders->setNmoStatusInt('Integrado');
|
| 1128 |
-
$anymarketorders->setNmoDescError('');
|
| 1129 |
-
$anymarketorders->setNmoIdAnymarket( $retOrderJSON->marketPlaceId );
|
| 1130 |
-
$anymarketorders->setNmoIdSeqAnymarket( $retOrderJSON->id );
|
| 1131 |
-
|
| 1132 |
-
$anymarketlog->setLogId( $retOrderJSON->marketPlaceId );
|
| 1133 |
-
}
|
| 1134 |
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
|
| 1140 |
-
|
| 1141 |
-
|
| 1142 |
-
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
| 1146 |
-
|
| 1147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1148 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1149 |
}
|
| 1150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1151 |
$anymarketorders->setNmoIdOrder($idOrder);
|
| 1152 |
$anymarketorders->save();
|
| 1153 |
}
|
|
@@ -1162,7 +1290,6 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 1162 |
public function listOrdersFromAnyMarketMagento($storeID){
|
| 1163 |
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 1164 |
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
| 1165 |
-
$STATUSIMPORT = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_stauts_order_field', $storeID);
|
| 1166 |
|
| 1167 |
$headers = array(
|
| 1168 |
"Content-type: application/json",
|
|
@@ -1194,7 +1321,9 @@ class DB1_AnyMarket_Helper_Order extends DB1_AnyMarket_Helper_Data
|
|
| 1194 |
foreach ($JsonReturn->content as $value) {
|
| 1195 |
$IDOrderAnyMarket = $value->marketPlaceId;
|
| 1196 |
|
| 1197 |
-
|
|
|
|
|
|
|
| 1198 |
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
| 1199 |
$anymarketorders->load($IDOrderAnyMarket, 'nmo_id_anymarket');
|
| 1200 |
if ($anymarketorders->getData('nmo_id_anymarket') == null || (is_array($anymarketorders->getData('store_id')) && !in_array($storeID, $anymarketorders->getData('store_id')))) {
|
| 9 |
* @param $OrderRowData
|
| 10 |
* @return string
|
| 11 |
*/
|
| 12 |
+
public function getStatusAnyMarketToMageOrderConfig($storeID, $OrderRowData){
|
| 13 |
if($OrderRowData == null){
|
| 14 |
$OrderRowData = "new";
|
| 15 |
}
|
| 25 |
$OrderReturn = $StatusOrderRow['orderStatusMG'];
|
| 26 |
$statuses = Mage::getModel('sales/order_status')->getCollection()->joinStates()
|
| 27 |
->addFieldToFilter('main_table.status',array('eq'=>$OrderReturn));
|
|
|
|
| 28 |
|
| 29 |
$StateReturn = $statuses->getFirstItem()->getData('state');
|
| 30 |
break;
|
| 69 |
}
|
| 70 |
}
|
| 71 |
|
| 72 |
+
/**
|
| 73 |
+
* get estimated date from order comment
|
| 74 |
+
*
|
| 75 |
+
* @param $Order
|
| 76 |
+
* @return string
|
| 77 |
+
*/
|
| 78 |
+
public function getEstimatedDateFromOrder( $Order ){
|
| 79 |
+
$estimatedDate = "";
|
| 80 |
+
foreach ($Order->getStatusHistoryCollection() as $item) {
|
| 81 |
+
$CommentCurr = $item->getComment();
|
| 82 |
+
|
| 83 |
+
$CommentCurr = str_replace(array("<br>"), "<br/>", $CommentCurr );
|
| 84 |
+
$iniEstimatedDate = strpos($CommentCurr, 'Entrega esperada para:');
|
| 85 |
+
if( $iniEstimatedDate !== false ) {
|
| 86 |
+
$estimatedDate = substr( $CommentCurr, $iniEstimatedDate+27, 19);
|
| 87 |
+
break;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
}
|
| 91 |
+
return $estimatedDate;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* get delivered date from order comment
|
| 96 |
+
*
|
| 97 |
+
* @param $Order
|
| 98 |
+
* @return string
|
| 99 |
+
*/
|
| 100 |
+
public function getDeliveredDateFromOrder( $Order ){
|
| 101 |
+
$delivedDate = null;
|
| 102 |
+
foreach ($Order->getStatusHistoryCollection() as $item) {
|
| 103 |
+
$CommentCurr = strtolower($item->getComment());
|
| 104 |
+
|
| 105 |
+
$iniDelivedDate = strpos($CommentCurr, 'data de entrega:');
|
| 106 |
+
if( $iniDelivedDate !== false ) {
|
| 107 |
+
$delivedDate = substr( $CommentCurr, $iniDelivedDate+16, 19);
|
| 108 |
+
break;
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
return $delivedDate;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* get estimated date from order comment
|
| 116 |
+
*
|
| 117 |
+
* @param $shipping
|
| 118 |
+
* @return string
|
| 119 |
+
*/
|
| 120 |
+
public function getDatesFromShipping( $shipping ){
|
| 121 |
+
$estimatedDate = "";
|
| 122 |
+
$shippedDate = "";
|
| 123 |
+
foreach ($shipping->getCommentsCollection() as $item) {
|
| 124 |
+
$CommentCurr = strtolower($item->getComment());
|
| 125 |
+
|
| 126 |
+
$iniEstimatedDate = strpos($CommentCurr, 'data estimada de entrega:');
|
| 127 |
+
if ($iniEstimatedDate !== false) {
|
| 128 |
+
$estimatedDate = substr($CommentCurr, $iniEstimatedDate+30, 19);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
$iniShippedDate = strpos($CommentCurr, 'data de entrega na transportadora:');
|
| 132 |
+
if ($iniShippedDate !== false) {
|
| 133 |
+
$shippedDate = substr($CommentCurr, $iniShippedDate + 39, 19);
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
$shippedDate = ($shippedDate != "") ? $this->formatDateTimeZone( str_replace("/", "-", $shippedDate ) ) : "";
|
| 140 |
+
$estimatedDate = ($estimatedDate != "") ? $this->formatDateTimeZone( str_replace("/", "-", $estimatedDate ) ) : "";
|
| 141 |
+
return array($estimatedDate, $shippedDate);
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
/**
|
| 145 |
* get status order MG to AM from configs
|
| 146 |
*
|
| 294 |
|
| 295 |
$this->getSpecificOrderFromAnyMarket($order->id, $order->token, $storeID);
|
| 296 |
|
| 297 |
+
if($order->token != 'notoken') {
|
| 298 |
+
$paramFeed = array(
|
| 299 |
+
"token" => $order->token
|
| 300 |
+
);
|
| 301 |
+
$this->CallAPICurl("PUT", $HOST . "/rest/api/v2/orders/feeds/" . $order->id, $headers, $paramFeed);
|
| 302 |
+
}
|
| 303 |
}
|
| 304 |
}
|
| 305 |
}
|
| 328 |
$IDOrderAnyMarket = $OrderJSON->marketPlaceId;
|
| 329 |
$anymarketordersSpec = Mage::getModel('db1_anymarket/anymarketorders');
|
| 330 |
$anymarketordersSpec->load($idSeqAnyMarket, 'nmo_id_seq_anymarket');
|
| 331 |
+
$OrderIDMage = '';
|
| 332 |
|
| 333 |
if( ($anymarketordersSpec->getData('nmo_id_anymarket') == null) ||
|
| 334 |
($anymarketordersSpec->getData('nmo_status_int') == "Não integrado (AnyMarket)") ||
|
| 335 |
($anymarketordersSpec->getData('nmo_status_int') == "ERROR 01") ){
|
| 336 |
+
|
| 337 |
+
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 338 |
+
if($ConfigOrder == 1) {
|
| 339 |
+
$statsConfig = $this->getStatusAnyMarketToMageOrderConfig($storeID, $OrderJSON->status);
|
| 340 |
+
$statusMage = $statsConfig["status"];
|
| 341 |
+
|
| 342 |
+
if (strpos($statusMage, 'ERROR:') === false) {
|
| 343 |
+
//TRATA OS PRODUTOS
|
| 344 |
+
$_products = array();
|
| 345 |
+
$shippingDesc = array();
|
| 346 |
+
foreach ($OrderJSON->items as $item) {
|
| 347 |
+
|
| 348 |
+
if( isset($item->shippings) ) {
|
| 349 |
+
foreach ($item->shippings as $shippItem) {
|
| 350 |
+
if (!in_array($shippItem->shippingtype, $shippingDesc)) {
|
| 351 |
+
array_push($shippingDesc, $shippItem->shippingtype);
|
|
|
|
|
|
|
| 352 |
}
|
| 353 |
}
|
| 354 |
+
}
|
| 355 |
|
| 356 |
+
$productLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $item->sku->partnerId);
|
| 357 |
+
if ($productLoaded) {
|
| 358 |
+
$arrayTMP = array(
|
| 359 |
+
'product' => $productLoaded->getId(),
|
| 360 |
+
'price' => $item->unit,
|
| 361 |
+
'qty' => $item->amount,
|
| 362 |
+
);
|
| 363 |
+
|
| 364 |
+
if($productLoaded->getTypeID() == "bundle") {
|
| 365 |
+
$optionsBundle = Mage::helper('db1_anymarket/product')->getDetailsOfBundle($productLoaded);
|
| 366 |
+
|
| 367 |
+
$boundOpt = array();
|
| 368 |
+
$boundOptQty = array();
|
| 369 |
+
foreach ($optionsBundle as $detProd) {
|
| 370 |
+
$boundOpt[$detProd['option_id']] = $detProd['selection_id'];
|
| 371 |
+
$boundOptQty[$detProd['option_id']] = (float)$detProd['selection_qty'];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
}
|
| 373 |
|
| 374 |
+
$arrayTMP['bundle_option'] = $boundOpt;
|
| 375 |
+
$arrayTMP['bundle_option_qty'] = $boundOptQty;
|
| 376 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
|
| 378 |
+
array_push($_products, $arrayTMP);
|
| 379 |
+
} else {
|
| 380 |
+
$this->saveLogOrder('nmo_id_seq_anymarket',
|
| 381 |
+
$idSeqAnyMarket,
|
| 382 |
+
'ERROR 01',
|
| 383 |
+
Mage::helper('db1_anymarket')->__('Product is not registered') . ' (SKU: ' . $item->sku->partnerId . ')',
|
| 384 |
+
$idSeqAnyMarket,
|
| 385 |
+
$IDOrderAnyMarket,
|
| 386 |
+
'',
|
| 387 |
+
$storeID);
|
| 388 |
+
|
| 389 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 390 |
+
$anymarketlog->setLogDesc(Mage::helper('db1_anymarket')->__('Product is not registered') . ' (Order: ' . $idSeqAnyMarket . ', SKU : ' . $item->sku->partnerId . ')');
|
| 391 |
+
$anymarketlog->setStores(array($storeID));
|
| 392 |
+
$anymarketlog->setStatus("0");
|
| 393 |
+
$anymarketlog->save();
|
| 394 |
+
|
| 395 |
+
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
| 396 |
+
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ') . "Anymarket(" . $IDOrderAnyMarket . ") <br/>" .
|
| 397 |
+
Mage::helper('db1_anymarket')->__('Product is not registered') . ' (SKU: ' . $item->sku->partnerId . ')',
|
| 398 |
+
'');
|
| 399 |
+
$stateProds = false;
|
| 400 |
+
break;
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
|
| 404 |
+
//verifica se criou o produto
|
| 405 |
+
if ($stateProds) {
|
| 406 |
+
//TRATA O CLIENTE
|
| 407 |
+
$document = null;
|
| 408 |
+
if (isset($OrderJSON->buyer->document)) {
|
| 409 |
+
$document = $OrderJSON->buyer->document;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 410 |
}
|
| 411 |
|
| 412 |
+
if ($document != null) {
|
| 413 |
+
try {
|
| 414 |
+
$AttrToDoc = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_doc_type_field', $storeID));
|
| 415 |
+
$groupCustomer = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_customer_group_field', $storeID);
|
|
|
|
|
|
|
|
|
|
| 416 |
|
| 417 |
+
$email = $OrderJSON->buyer->email;
|
| 418 |
+
$customer = Mage::getModel('customer/customer')
|
| 419 |
+
->getCollection()
|
| 420 |
+
->addFieldToFilter($AttrToDoc, $document)->load()->getFirstItem();
|
| 421 |
|
| 422 |
+
//caso nao ache pelo CPF valida se nao tem mascara
|
| 423 |
+
if(!$customer->getId()) {
|
| 424 |
+
if (strlen($document) == 11) {
|
| 425 |
+
$document = $this->Mask('###.###.###-##', $document);
|
| 426 |
+
} else {
|
| 427 |
+
$document = $this->Mask('##.###.###/####-##', $document);
|
| 428 |
+
}
|
| 429 |
|
| 430 |
$customer = Mage::getModel('customer/customer')
|
| 431 |
->getCollection()
|
| 432 |
->addFieldToFilter($AttrToDoc, $document)->load()->getFirstItem();
|
| 433 |
|
| 434 |
+
//caso ainda nao encontrou valida se existe o email
|
| 435 |
if(!$customer->getId()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
$customer = Mage::getModel('customer/customer')
|
| 437 |
->getCollection()
|
| 438 |
+
->addFieldToFilter('email', $email)->load()->getFirstItem();
|
| 439 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
}
|
| 441 |
+
}
|
| 442 |
|
| 443 |
+
$AddressShipBill = null;
|
| 444 |
|
| 445 |
+
$firstName = $OrderJSON->buyer->name;
|
| 446 |
+
$lastName = 'Lastname';
|
| 447 |
+
if ($firstName != '') {
|
| 448 |
+
$nameComplete = explode(" ", $firstName);
|
| 449 |
|
| 450 |
+
$lastNameP = array_slice($nameComplete, 1);
|
| 451 |
+
$lastNameImp = implode(" ", $lastNameP);
|
| 452 |
|
| 453 |
+
$firstName = array_shift($nameComplete);
|
| 454 |
+
$lastName = $lastNameImp == '' ? 'Lastname' : $lastNameImp;
|
| 455 |
+
}
|
| 456 |
|
| 457 |
+
$addressFullData = $this->getCompleteAddressOrder($storeID, $OrderJSON);
|
| 458 |
+
$regionCollection = Mage::getModel('directory/region')->getCollection();
|
| 459 |
+
$regionName = (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado';
|
| 460 |
+
$regionID = 0;
|
| 461 |
+
foreach ($regionCollection as $key) {
|
| 462 |
+
if( $key->getData('name') == $regionName){
|
| 463 |
+
$regionID = $key->getData('region_id');
|
| 464 |
+
break;
|
|
|
|
| 465 |
}
|
| 466 |
+
}
|
| 467 |
|
| 468 |
+
$addressFullData = $this->getCompleteAddressOrder($storeID, $OrderJSON);
|
| 469 |
+
|
| 470 |
+
if ($customer->getId() == null) {
|
| 471 |
+
$_DataCustomer = array(
|
| 472 |
+
'account' => array(
|
| 473 |
+
'firstname' => $firstName,
|
| 474 |
+
'lastname' => $lastName,
|
| 475 |
+
'email' => $email,
|
| 476 |
+
$AttrToDoc => $document,
|
| 477 |
+
'password' => 'a111111',
|
| 478 |
+
'default_billing' => '_item1',
|
| 479 |
+
'default_shipping' => '_item1',
|
| 480 |
+
'store_id' => $storeID,
|
| 481 |
+
'website_id' => Mage::app()->getWebsite()->getId(),
|
| 482 |
+
'group_id' => $groupCustomer,
|
| 483 |
+
),
|
| 484 |
+
'address' => array(
|
| 485 |
+
'_item1' => array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
'firstname' => $firstName,
|
| 487 |
'lastname' => $lastName,
|
| 488 |
'street' => $addressFullData,
|
| 489 |
'city' => (isset($OrderJSON->shipping->city)) ? $OrderJSON->shipping->city : 'Não especificado',
|
| 490 |
'country_id' => 'BR',
|
|
|
|
| 491 |
'region_id' => $regionID,
|
| 492 |
+
'region' => (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado',
|
| 493 |
'postcode' => (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado',
|
| 494 |
+
'telephone' => $OrderJSON->buyer->phone,
|
| 495 |
+
),
|
| 496 |
+
),
|
| 497 |
+
);
|
| 498 |
+
|
| 499 |
+
$customerRet = Mage::helper('db1_anymarket/customergenerator')->createCustomer($_DataCustomer);
|
| 500 |
+
$customer = $customerRet['customer'];
|
| 501 |
+
$AddressShipBill = $customerRet['addr'];
|
| 502 |
+
} else {
|
| 503 |
+
//PERCORRE OS ENDERECOS PARA VER SE JA HA CADASTRADO O INFORMADO
|
| 504 |
+
$needRegister = true;
|
| 505 |
+
foreach ($customer->getAddresses() as $address) {
|
| 506 |
+
$zipCodeOrder = (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado';
|
| 507 |
+
$addressOrder = (isset($OrderJSON->shipping->address)) ? $OrderJSON->shipping->address : 'Frete não especificado.';
|
| 508 |
+
if (($address->getData('postcode') == $zipCodeOrder) && ($address->getData('street') == $addressOrder)) {
|
| 509 |
+
$AddressShipBill = $address;
|
| 510 |
+
$needRegister = false;
|
| 511 |
+
break;
|
| 512 |
}
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
//CRIA O ENDERECO CASO NAO TENHA O INFORMADO
|
| 516 |
+
if ($needRegister) {
|
| 517 |
+
$address = Mage::getModel('customer/address');
|
| 518 |
+
|
| 519 |
+
$addressData = array(
|
| 520 |
+
'firstname' => $firstName,
|
| 521 |
+
'lastname' => $lastName,
|
| 522 |
+
'street' => $addressFullData,
|
| 523 |
+
'city' => (isset($OrderJSON->shipping->city)) ? $OrderJSON->shipping->city : 'Não especificado',
|
| 524 |
+
'country_id' => 'BR',
|
| 525 |
+
'region' => (isset($OrderJSON->shipping->state)) ? $OrderJSON->shipping->state : 'Não especificado',
|
| 526 |
+
'region_id' => $regionID,
|
| 527 |
+
'postcode' => (isset($OrderJSON->shipping->zipCode)) ? $OrderJSON->shipping->zipCode : 'Não especificado',
|
| 528 |
+
'telephone' => $OrderJSON->buyer->phone
|
| 529 |
+
);
|
| 530 |
|
| 531 |
+
$address->setIsDefaultBilling(1);
|
| 532 |
+
$address->setIsDefaultShipping(1);
|
| 533 |
+
$address->addData($addressData);
|
| 534 |
+
$address->setPostIndex('_item1');
|
| 535 |
+
$customer->addAddress($address);
|
| 536 |
+
$customer->save();
|
| 537 |
}
|
| 538 |
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
$infoMetPag = 'ANYMARKET';
|
| 542 |
+
$infoMetPagCom = array();
|
| 543 |
+
if( isset($OrderJSON->payments) ) {
|
| 544 |
+
foreach ($OrderJSON->payments as $payment) {
|
| 545 |
+
$infoMetPag = $payment->method;
|
| 546 |
+
if($payment->paymentMethodNormalized) {
|
| 547 |
+
$parcelas = isset($payment->installments) ? $payment->installments : '0';
|
| 548 |
+
array_push($infoMetPagCom, $payment->paymentMethodNormalized." - Parcelas: ".$parcelas );
|
| 549 |
}
|
| 550 |
}
|
| 551 |
+
}
|
| 552 |
|
| 553 |
+
$OrderIDMage = $this->create_order($storeID, $anymarketordersSpec, $_products, $customer, $IDOrderAnyMarket, $idSeqAnyMarket, $infoMetPag, $AddressShipBill, $AddressShipBill, $OrderJSON->freight, implode(",", $shippingDesc) );
|
| 554 |
+
$OrderCheck = Mage::getModel('sales/order')->loadByIncrementId($OrderIDMage);
|
|
|
|
| 555 |
|
| 556 |
+
$this->changeFeedOrder($HOST, $headers, $idSeqAnyMarket, $tokenFeed);
|
| 557 |
|
| 558 |
+
if ($OrderCheck->getId()) {
|
|
|
|
|
|
|
| 559 |
|
| 560 |
+
$comment = '<b>Código do Pedido no Canal de Vendas: </b>'.$OrderJSON->marketPlaceNumber.'<br>';
|
| 561 |
+
$comment .= '<b>Canal de Vendas: </b>'.$OrderJSON->marketPlace.'<br>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
|
| 563 |
+
if(isset($OrderJSON->shipping->promisedShippingTime)){
|
| 564 |
+
$dateTmpPromis = new DateTime($OrderJSON->shipping->promisedShippingTime);
|
| 565 |
+
$dateTmpPromis = date_format($dateTmpPromis, 'd/m/Y H:i:s');
|
|
|
|
|
|
|
|
|
|
| 566 |
|
| 567 |
+
$comment .= '<b>Entrega esperada para: </b>'.$dateTmpPromis.'<br>';
|
| 568 |
+
}
|
| 569 |
|
| 570 |
+
if( count($infoMetPagCom) > 0 ) {
|
| 571 |
+
foreach ($infoMetPagCom as $iMetPag) {
|
| 572 |
+
$comment .= '<b>Forma de Pagamento: </b>' . $iMetPag . '<br>';
|
| 573 |
+
}
|
| 574 |
+
}else{
|
| 575 |
+
$comment .= '<b>Forma de Pagamento: </b>Inf. não disponibilizada pelo marketplace.<br>';
|
| 576 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
|
| 578 |
+
$addressComp = (isset($OrderJSON->shipping->address)) ? $OrderJSON->shipping->address : 'Não especificado';
|
| 579 |
+
$comment .= '<b>Endereço Completo: </b>'.$addressComp;
|
| 580 |
+
|
| 581 |
+
$OrderCheck->addStatusHistoryComment( $comment );
|
| 582 |
+
$OrderCheck->setEmailSent(false);
|
| 583 |
+
$OrderCheck->save();
|
| 584 |
+
|
| 585 |
+
$this->changeStatusOrder($storeID, $OrderJSON, $OrderIDMage);
|
| 586 |
}
|
| 587 |
+
} catch (Exception $e) {
|
| 588 |
+
$orderCheckExcpt = Mage::getModel('sales/order')->loadByIncrementId($OrderIDMage);
|
| 589 |
+
$statusExpt = $orderCheckExcpt->getId() ? 'Integrado' : 'ERROR 01';
|
| 590 |
$this->saveLogOrder('nmo_id_seq_anymarket',
|
| 591 |
$idSeqAnyMarket,
|
| 592 |
+
$statusExpt,
|
| 593 |
+
'System: ' . $e->getMessage(),
|
| 594 |
$idSeqAnyMarket,
|
| 595 |
$IDOrderAnyMarket,
|
| 596 |
+
$OrderIDMage,
|
| 597 |
$storeID);
|
| 598 |
|
| 599 |
+
Mage::log($e, null, 'anymarket_exception.log');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 600 |
}
|
| 601 |
+
} else {
|
| 602 |
+
$this->saveLogOrder('nmo_id_seq_anymarket',
|
| 603 |
+
$idSeqAnyMarket,
|
| 604 |
+
'ERROR 01',
|
| 605 |
+
Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'),
|
| 606 |
+
$idSeqAnyMarket,
|
| 607 |
+
$IDOrderAnyMarket,
|
| 608 |
+
'',
|
| 609 |
+
$storeID);
|
| 610 |
+
|
| 611 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 612 |
+
$anymarketlog->setLogDesc('Error on import Order: ' . Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'));
|
| 613 |
+
$anymarketlog->setStatus("0");
|
| 614 |
+
$anymarketlog->setStores(array($storeID));
|
| 615 |
+
$anymarketlog->save();
|
| 616 |
+
|
| 617 |
+
$this->addMessageInBox($storeID, Mage::helper('db1_anymarket')->__('Error on synchronize order.'),
|
| 618 |
+
Mage::helper('db1_anymarket')->__('Error synchronizing order number: ') . "Anymarket(" . $IDOrderAnyMarket . ") <br/>" .
|
| 619 |
+
Mage::helper('db1_anymarket')->__('Customer invalid or blank document.'),
|
| 620 |
+
'');
|
| 621 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 622 |
}
|
| 623 |
+
}
|
| 624 |
|
| 625 |
+
if ($tokenFeed != null && $tokenFeed != 'notoken') {
|
| 626 |
+
$paramFeed = array(
|
| 627 |
+
"token" => $tokenFeed
|
| 628 |
+
);
|
| 629 |
|
| 630 |
+
$this->CallAPICurl("PUT", $HOST . "/rest/api/v2/orders/feeds/" . $idSeqAnyMarket, $headers, $paramFeed);
|
|
|
|
| 631 |
}
|
| 632 |
}
|
| 633 |
}else{
|
| 634 |
+
$statsConfig = $this->getStatusAnyMarketToMageOrderConfig($storeID, $OrderJSON->status);
|
| 635 |
+
$statusMage = $statsConfig["status"];
|
| 636 |
+
if (strpos($statusMage, 'ERROR:') === false) {
|
| 637 |
if ($anymarketordersSpec->getData('nmo_id_order') != null) {
|
| 638 |
$this->changeStatusOrder($storeID, $OrderJSON, $anymarketordersSpec->getData('nmo_id_order'));
|
| 639 |
}
|
| 713 |
Mage::getSingleton('core/session')->setImportOrdersVariable('false');
|
| 714 |
$order = Mage::getModel('sales/order')->loadByIncrementId( $IDOrderMagento );
|
| 715 |
|
| 716 |
+
if( ($order->getData('state') == $stateMage) && ($order->getData('status') == $statusMage) ){
|
| 717 |
return false;
|
| 718 |
}
|
| 719 |
|
| 720 |
$createRegPay = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_create_reg_pay_field', $storeID);
|
| 721 |
$itemsarray = null;
|
| 722 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
if( isset($JSON->invoice) && $StatusPedAnyMarket == 'INVOICED' ){
|
| 724 |
if( $order->canInvoice() ){
|
| 725 |
if(isset($JSON->invoice->accessKey) ) {
|
| 784 |
}
|
| 785 |
}
|
| 786 |
|
| 787 |
+
$order->setData('state', $stateMage);
|
| 788 |
+
$order->setStatus($statusMage, true);
|
| 789 |
+
|
| 790 |
+
if($stateMage == Mage_Sales_Model_Order::STATE_COMPLETE){
|
| 791 |
+
$history = $order->addStatusHistoryComment('Finalizado pelo AnyMarket.', false);
|
| 792 |
+
}else{
|
| 793 |
+
$history = $order->addStatusHistoryComment('', false);
|
| 794 |
+
}
|
| 795 |
+
$history->setIsCustomerNotified(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 796 |
|
| 797 |
+
if($stateMage == Mage_Sales_Model_Order::STATE_CANCELED) {
|
| 798 |
+
foreach ($order->getAllItems() as $item) {
|
| 799 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct( $item->getProductId() );
|
| 800 |
+
if ($stockItem->getManageStock()) {
|
| 801 |
+
$stockItem->setData('qty', $stockItem->getQty() + $item->getQtyOrdered());
|
| 802 |
}
|
| 803 |
+
$stockItem->save();
|
| 804 |
+
|
| 805 |
+
$item->setQtyCanceled($item->getQtyOrdered());
|
| 806 |
+
$item->save();
|
| 807 |
}
|
| 808 |
+
}
|
| 809 |
+
$order->save();
|
| 810 |
|
| 811 |
+
if( $createRegPay == "1" && $StatusPedAnyMarket == 'PAID_WAITING_SHIP' ){
|
| 812 |
+
if( $order->canInvoice() ){
|
| 813 |
+
if( $this->checkIfCanCreateInvoice($order) ) {
|
| 814 |
+
$orderItems = $order->getAllItems();
|
| 815 |
+
foreach ($orderItems as $_eachItem) {
|
| 816 |
+
$opid = $_eachItem->getId();
|
| 817 |
+
$qty = $_eachItem->getQtyOrdered();
|
| 818 |
+
$itemsarray[$opid] = $qty;
|
| 819 |
+
}
|
| 820 |
+
$nfeString = "Registro de Pagamento criado por Anymarket";
|
| 821 |
+
Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(), $itemsarray, $nfeString, 0, 0);
|
| 822 |
+
}
|
| 823 |
+
}
|
| 824 |
}
|
| 825 |
|
| 826 |
$this->saveLogOrder('nmo_id_anymarket',
|
| 839 |
$anymarketlog->save();
|
| 840 |
|
| 841 |
Mage::getSingleton('core/session')->setImportOrdersVariable('true');
|
| 842 |
+
}
|
| 843 |
+
}
|
| 844 |
+
|
| 845 |
+
public function procInvoiceModelsToAnymarket($CommentCurr){
|
| 846 |
+
$nfeCount = strpos($CommentCurr, 'nfe:');
|
| 847 |
+
$emissaoCount = strpos($CommentCurr, 'emiss');
|
| 848 |
+
if( (strpos($CommentCurr, 'nfe:') !== false) && (strpos($CommentCurr, 'emiss') !== false) ) {
|
| 849 |
+
$caracts = array("/", "-", ".");
|
| 850 |
+
$nfeTmp = str_replace($caracts, "", $CommentCurr );
|
| 851 |
+
$chaveAcID = substr( $nfeTmp, $nfeCount+4, 44);
|
| 852 |
+
|
| 853 |
+
$date = substr( $CommentCurr, $emissaoCount+8, 19);
|
| 854 |
+
$dateTmp = str_replace("/", "-", $date );
|
| 855 |
+
|
| 856 |
+
$date = $this->formatDateTimeZone($dateTmp);
|
| 857 |
+
return array("key" => $chaveAcID, "date" => $date);
|
| 858 |
}else{
|
| 859 |
+
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 860 |
}
|
| 861 |
}
|
| 862 |
|
| 875 |
$invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId( $inv->getIncrementId() );
|
| 876 |
foreach ($invoice->getCommentsCollection() as $item) {
|
| 877 |
$CommentCurr = $item->getComment();
|
| 878 |
+
$invData = $this->procInvoiceModelsToAnymarket($CommentCurr);
|
| 879 |
+
if( $invData ){
|
| 880 |
+
$nfeID = $invData["key"];
|
| 881 |
+
$chaveAcID = $invData["key"];
|
| 882 |
+
$date = $invData["date"];
|
| 883 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 884 |
}
|
| 885 |
}
|
| 886 |
}
|
| 890 |
foreach ($Order->getStatusHistoryCollection() as $item) {
|
| 891 |
$CommentCurr = $item->getComment();
|
| 892 |
|
| 893 |
+
$invData = $this->procInvoiceModelsToAnymarket($CommentCurr);
|
| 894 |
+
if( $invData ){
|
| 895 |
+
$nfeID = $invData["key"];
|
| 896 |
+
$chaveAcID = $invData["key"];
|
| 897 |
+
$date = $invData["date"];
|
| 898 |
+
}else {
|
| 899 |
+
$CommentCurr = str_replace(array(" ", "<b>", "</b>"), "", $CommentCurr);
|
| 900 |
+
$CommentCurr = str_replace(array("<br>"), "<br/>", $CommentCurr);
|
| 901 |
+
$chaveAcesso = strpos($CommentCurr, 'ChavedeAcesso:');
|
| 902 |
+
if ((strpos($CommentCurr, 'ChavedeAcesso:') !== false)) {
|
| 903 |
+
$chaveAcID = substr($CommentCurr, $chaveAcesso + 14, 44);
|
| 904 |
+
|
| 905 |
+
$notaFiscal = strpos($CommentCurr, 'Notafiscal:');
|
| 906 |
+
if ((strpos($CommentCurr, 'Notafiscal:') !== false)) {
|
| 907 |
+
$endNF = strpos($CommentCurr, '<br/>');
|
| 908 |
+
$nfeID = substr($CommentCurr, $notaFiscal + 11, $endNF - 11);
|
| 909 |
+
|
| 910 |
+
if ($nfeID == "") {
|
| 911 |
+
$nfeID = $chaveAcID;
|
| 912 |
+
}
|
| 913 |
+
} else {
|
| 914 |
+
$notaFiscal = strpos($CommentCurr, 'NrNF-e');
|
| 915 |
+
if ($notaFiscal !== false) {
|
| 916 |
+
$endNF = strpos($CommentCurr, '<br/>');
|
| 917 |
+
$nfeID = substr($CommentCurr, $notaFiscal + 6, $endNF - 6);
|
| 918 |
|
| 919 |
+
if ($nfeID == "") {
|
| 920 |
+
$nfeID = $chaveAcID;
|
| 921 |
+
}
|
| 922 |
+
}
|
| 923 |
}
|
| 924 |
+
|
| 925 |
+
$dateTmp = new DateTime(str_replace("/", "-", $item->getData('created_at')));
|
| 926 |
+
$date = date_format($dateTmp, 'Y-m-d\TH:i:s\Z');
|
| 927 |
+
break;
|
| 928 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 929 |
}
|
| 930 |
}
|
| 931 |
}
|
| 932 |
|
| 933 |
+
if( $chaveAcID == "" && $Order->hasShipments() ) {
|
| 934 |
+
foreach ($Order->getShipmentsCollection() as $ship) {
|
| 935 |
+
$shippment = Mage::getModel('sales/order_shipment')->loadByIncrementId( $ship->getIncrementId() );
|
| 936 |
+
foreach ($shippment->getCommentsCollection() as $item) {
|
| 937 |
+
$CommentCurr = $item->getComment();
|
| 938 |
+
$invData = $this->procInvoiceModelsToAnymarket($CommentCurr);
|
| 939 |
+
if( $invData ){
|
| 940 |
+
$nfeID = $invData["key"];
|
| 941 |
+
$chaveAcID = $invData["key"];
|
| 942 |
+
$date = $invData["date"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 943 |
}
|
| 944 |
}
|
| 945 |
}
|
| 946 |
}
|
| 947 |
+
return array("number" => $nfeID, "date" => $date, "accessKey" => $chaveAcID);
|
|
|
|
|
|
|
| 948 |
}
|
| 949 |
|
| 950 |
/**
|
| 951 |
* get tracking order
|
| 952 |
*
|
|
|
|
| 953 |
* @param $Order
|
| 954 |
* @return array
|
| 955 |
*/
|
| 956 |
+
public function getTrackingOrder($Order){
|
| 957 |
$TrackNum = '';
|
| 958 |
$TrackTitle = '';
|
| 959 |
$TrackCreate = '';
|
| 960 |
$dateTrack = '';
|
| 961 |
+
$datesRes = array("", "");
|
| 962 |
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
| 963 |
->setOrderFilter($Order)
|
| 964 |
->load();
|
| 965 |
foreach ($shipmentCollection as $shipment){
|
| 966 |
+
$datesRes = $this->getDatesFromShipping($shipment);
|
| 967 |
foreach($shipment->getAllTracks() as $tracknum){
|
| 968 |
$TrackNum = $tracknum->getNumber();
|
| 969 |
$TrackTitle = $tracknum->getTitle();
|
| 974 |
}
|
| 975 |
}
|
| 976 |
|
| 977 |
+
$retArray = array("number" => $TrackNum,
|
| 978 |
+
"carrier" => $TrackTitle,
|
| 979 |
+
"date" => $dateTrack,
|
| 980 |
+
"url" => "");
|
| 981 |
|
| 982 |
+
$retArray["shippedDate"] = ($datesRes[1] != "") ? $datesRes[1] : $dateTrack;
|
| 983 |
+
if($datesRes[0] != "") {
|
| 984 |
+
$retArray["estimateDate"] = $datesRes[0];
|
| 985 |
+
}else{
|
| 986 |
+
$estFromOrder = $this->getEstimatedDateFromOrder($Order);
|
| 987 |
+
if($estFromOrder != ""){
|
| 988 |
+
$retArray["estimateDate"] = $estFromOrder;
|
| 989 |
+
}
|
| 990 |
+
}
|
| 991 |
+
|
| 992 |
+
$deliveredDate = $this->getDeliveredDateFromOrder( $Order );
|
| 993 |
+
if( $deliveredDate ){
|
| 994 |
+
$retArray['deliveredDate'] = $this->formatDateTimeZone(str_replace("/", "-", $deliveredDate ));
|
| 995 |
+
}
|
| 996 |
+
|
| 997 |
+
return $retArray;
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
/**
|
| 1001 |
+
* update or create order in AM
|
| 1002 |
+
*
|
| 1003 |
+
* @param $Order
|
| 1004 |
+
*/
|
| 1005 |
+
public function updateOrCreateOrderAnyMarket($storeID, $Order){
|
| 1006 |
+
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 1007 |
+
$canUpdateOrder = $this->updateOrderAnymarket($storeID, $Order);
|
| 1008 |
+
if (!$canUpdateOrder && $ConfigOrder == 0) {
|
| 1009 |
+
$this->sendOrderToAnyMarket($storeID, $Order);
|
| 1010 |
+
}
|
| 1011 |
}
|
| 1012 |
|
| 1013 |
/**
|
| 1014 |
* update order in AM
|
| 1015 |
*
|
| 1016 |
+
* @param $storeID
|
| 1017 |
* @param $Order
|
| 1018 |
+
*
|
| 1019 |
+
* @return bool
|
| 1020 |
*/
|
| 1021 |
+
public function updateOrderAnymarket($storeID, $Order){
|
| 1022 |
+
$idOrder = $Order->getIncrementId();
|
| 1023 |
+
$anymarketorderupdt = Mage::getModel('db1_anymarket/anymarketorders')->load($idOrder, 'nmo_id_order');
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1024 |
|
| 1025 |
+
if($anymarketorderupdt->getData('nmo_id_seq_anymarket') == null ||
|
| 1026 |
+
$anymarketorderupdt->getData('nmo_id_seq_anymarket') == ""){
|
| 1027 |
+
return false;
|
| 1028 |
+
}
|
| 1029 |
|
| 1030 |
+
if( ($anymarketorderupdt->getData('nmo_status_int') != 'ERROR 02') &&
|
| 1031 |
+
($anymarketorderupdt->getData('nmo_status_int') != 'Integrado')){
|
| 1032 |
+
return false;
|
| 1033 |
+
}
|
| 1034 |
|
| 1035 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 1036 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
|
|
|
|
|
|
|
|
|
| 1037 |
|
| 1038 |
+
$status = $Order->getStatus();
|
| 1039 |
+
$statuAM = $this->getStatusMageToAnyMarketOrderConfig($storeID, $status);
|
| 1040 |
+
if (strpos($statuAM, 'ERROR:') !== false) {
|
| 1041 |
+
return false;
|
| 1042 |
+
}
|
|
|
|
| 1043 |
|
| 1044 |
+
if($statuAM == "PENDING" ){
|
| 1045 |
+
return false;
|
| 1046 |
+
}
|
| 1047 |
|
| 1048 |
+
$headers = array(
|
| 1049 |
+
"Content-type: application/json",
|
| 1050 |
+
"Accept: */*",
|
| 1051 |
+
"gumgaToken: ".$TOKEN
|
| 1052 |
+
);
|
| 1053 |
|
| 1054 |
+
$params = array(
|
| 1055 |
+
"status" => $statuAM
|
| 1056 |
+
);
|
| 1057 |
|
| 1058 |
+
$invoiceData = $this->getInvoiceOrder($Order);
|
| 1059 |
+
if ($invoiceData['accessKey'] != '') {
|
| 1060 |
+
$params["invoice"] = $invoiceData;
|
| 1061 |
+
}else if($statuAM == "INVOICED"){
|
| 1062 |
+
return false;
|
| 1063 |
+
}
|
| 1064 |
|
| 1065 |
+
$trackingData = $this->getTrackingOrder($Order);
|
| 1066 |
+
if ($trackingData['number'] != '') {
|
| 1067 |
+
$params["tracking"] = $trackingData;
|
| 1068 |
+
}
|
| 1069 |
|
| 1070 |
+
if( isset( $params["tracking"] ) && $statuAM == "CONCLUDED" ){
|
| 1071 |
+
$deliveredDate = $params["tracking"];
|
| 1072 |
+
if( !isset($deliveredDate['deliveredDate']) ){
|
| 1073 |
+
return false;
|
| 1074 |
+
}
|
| 1075 |
+
}
|
|
|
|
| 1076 |
|
| 1077 |
+
if( isset($params["tracking"]) || isset($params["invoice"]) ){
|
| 1078 |
+
$IDOrderAnyMarket = $anymarketorderupdt->getData('nmo_id_seq_anymarket');
|
| 1079 |
+
|
| 1080 |
+
$returnOrder = $this->CallAPICurl("PUT", $HOST."/v2/orders/".$IDOrderAnyMarket, $headers, $params);
|
| 1081 |
+
if($returnOrder['error'] == '1'){
|
| 1082 |
+
$anymarketorderupdt->setStatus("0");
|
| 1083 |
+
$anymarketorderupdt->setNmoStatusInt('ERROR 02');
|
| 1084 |
+
$anymarketorderupdt->setNmoDescError($returnOrder['return']);
|
| 1085 |
+
$anymarketorderupdt->setStores(array($storeID));
|
| 1086 |
+
$anymarketorderupdt->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1087 |
}
|
| 1088 |
+
|
| 1089 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 1090 |
+
$anymarketlog->setLogDesc( json_encode($returnOrder['return']) );
|
| 1091 |
+
$anymarketlog->setLogId( $idOrder );
|
| 1092 |
+
$anymarketlog->setLogJson( json_encode($returnOrder['json']) );
|
| 1093 |
+
$anymarketlog->setStores(array($storeID));
|
| 1094 |
+
$anymarketlog->setStatus("0");
|
| 1095 |
+
$anymarketlog->save();
|
| 1096 |
+
}else{
|
| 1097 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 1098 |
+
$anymarketlog->setLogDesc( Mage::helper('db1_anymarket')->__('There was some error getting data Invoice or Tracking.') );
|
| 1099 |
+
$anymarketlog->setLogId( $idOrder );
|
| 1100 |
+
$anymarketlog->setLogJson('');
|
| 1101 |
+
$anymarketlog->setStores(array($storeID));
|
| 1102 |
+
$anymarketlog->setStatus("0");
|
| 1103 |
+
$anymarketlog->save();
|
| 1104 |
}
|
|
|
|
| 1105 |
|
| 1106 |
+
return true;
|
| 1107 |
}
|
| 1108 |
|
| 1109 |
/**
|
| 1110 |
* send order to AM
|
| 1111 |
*
|
| 1112 |
+
* @param $storeID
|
| 1113 |
+
* @param $Order
|
|
|
|
| 1114 |
*/
|
| 1115 |
+
public function sendOrderToAnyMarket($storeID, $Order){
|
| 1116 |
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 1117 |
+
if($ConfigOrder == 0){
|
| 1118 |
+
$idOrder = $Order->getIncrementId();
|
| 1119 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 1120 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
| 1121 |
|
| 1122 |
//TRATA OS ITEMS
|
| 1123 |
$orderedItems = $Order->getAllVisibleItems();
|
| 1161 |
}
|
| 1162 |
|
| 1163 |
|
| 1164 |
+
if( (strpos($statuAM, 'ERROR:') !== false) || ($statuAM == '') ) {
|
| 1165 |
+
return false;
|
| 1166 |
+
}
|
| 1167 |
+
$dateTmp = new DateTime(str_replace("/", "-", $Order->getData('created_at') ));
|
| 1168 |
+
$params = array(
|
| 1169 |
+
'marketPlaceId' => $idOrder,
|
| 1170 |
+
"createdAt" => date_format($dateTmp, 'Y-m-d\TH:i:s\Z'),
|
| 1171 |
+
"status" => $statuAM,
|
| 1172 |
+
"marketPlace" => "ECOMMERCE",
|
| 1173 |
+
"marketPlaceStatus" => $statuAM,
|
| 1174 |
+
"marketPlaceUrl" => null,
|
| 1175 |
+
"shipping" => array(
|
| 1176 |
+
"city" => $shipping->getCity(),
|
| 1177 |
+
"state" => $shipping->getRegion(),
|
| 1178 |
+
"country" => $shipping->getCountry(),
|
| 1179 |
+
"address" => $shipping->getStreetFull(),
|
| 1180 |
+
"street" => $shipping->getStreet(1),
|
| 1181 |
+
"number" => $shipping->getStreet(2),
|
| 1182 |
+
"comment" => $shipping->getStreet(3),
|
| 1183 |
+
"neighborhood" => $shipping->getStreet(4),
|
| 1184 |
+
"zipCode" => $shipping->getPostcode()
|
| 1185 |
+
),
|
| 1186 |
+
"buyer" => array(
|
| 1187 |
+
"id" => 0,
|
| 1188 |
+
"name" => $Order->getCustomerFirstname()." ".$Order->getCustomerLastname(),
|
| 1189 |
+
"email" => $Order->getCustomerEmail(),
|
| 1190 |
+
"document" => $docData,
|
| 1191 |
+
"documentType" => $this->getDocumentType($docData),
|
| 1192 |
+
"phone" => $shipping->getTelephone(),
|
| 1193 |
+
),
|
| 1194 |
+
"items" => $orderedProductIds,
|
| 1195 |
+
"payments" => array(
|
| 1196 |
+
array(
|
| 1197 |
+
"method" => $payment->getMethodInstance()->getTitle(),
|
| 1198 |
+
"status" => "",
|
| 1199 |
+
"value" => $Order->getBaseGrandTotal()
|
| 1200 |
+
),
|
| 1201 |
+
),
|
| 1202 |
+
"discount" => floatval( $Order->getDiscountAmount() ) < 0 ? floatval( $Order->getDiscountAmount() )*-1 : $Order->getDiscountAmount(),
|
| 1203 |
+
"freight" => $Order->getShippingAmount(),
|
| 1204 |
+
"gross" => $Order->getBaseSubtotal(),
|
| 1205 |
+
"total" => $Order->getBaseGrandTotal()
|
| 1206 |
+
);
|
| 1207 |
|
| 1208 |
+
$arrTracking = $this->getTrackingOrder($Order);
|
| 1209 |
+
$arrInvoice = $this->getInvoiceOrder($Order);
|
| 1210 |
|
| 1211 |
+
if($arrTracking["number"] != ''){
|
| 1212 |
+
$params["tracking"] = $arrTracking;
|
| 1213 |
+
};
|
| 1214 |
|
| 1215 |
+
if($arrInvoice["number"] != ''){
|
| 1216 |
+
$params["invoice"] = $arrInvoice;
|
| 1217 |
+
};
|
| 1218 |
|
| 1219 |
+
$headers = array(
|
| 1220 |
+
"Content-type: application/json",
|
| 1221 |
+
"Accept: */*",
|
| 1222 |
+
"gumgaToken: ".$TOKEN
|
| 1223 |
+
);
|
| 1224 |
|
| 1225 |
+
$returnOrder = $this->CallAPICurl("POST", $HOST."/v2/orders/", $headers, $params);
|
| 1226 |
|
| 1227 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 1228 |
+
$anymarketlog->setLogDesc( json_encode($returnOrder['return']) );
|
| 1229 |
|
| 1230 |
+
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->load($idOrder, 'nmo_id_order');
|
| 1231 |
+
$anymarketorders->setStatus("1");
|
| 1232 |
+
$anymarketorders->setStores(array($storeID));
|
| 1233 |
+
if($returnOrder['error'] == '1'){
|
| 1234 |
+
if( strpos($returnOrder['return'], 'existe uma venda de ECOMMERCE cadastrada com o') === false ) {
|
| 1235 |
$anymarketorders->setNmoStatusInt('ERROR 02');
|
| 1236 |
$anymarketorders->setNmoDescError($returnOrder['return']);
|
| 1237 |
}else{
|
| 1238 |
+
$OrderResp = json_decode($returnOrder['return']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1239 |
|
| 1240 |
+
$IDAnymarket = strpos($OrderResp, 'ID Anymarket');
|
| 1241 |
+
if ($IDAnymarket !== false) {
|
| 1242 |
+
$idAnymarketOrder = substr($OrderResp, $IDAnymarket+14, 100);
|
| 1243 |
+
$idAnymarketOrder = str_replace(']"}', "", $idAnymarketOrder );
|
| 1244 |
|
| 1245 |
+
if( is_numeric ($idAnymarketOrder) ) {
|
| 1246 |
+
$anymarketorders->setNmoStatusInt('Integrado');
|
| 1247 |
+
$anymarketorders->setNmoDescError('');
|
| 1248 |
+
$anymarketorders->setNmoIdSeqAnymarket($idAnymarketOrder);
|
| 1249 |
+
$anymarketorders->setNmoIdOrder($idOrder);
|
| 1250 |
+
$anymarketorders->setNmoIdAnymarket($idOrder);
|
| 1251 |
+
$anymarketorders->save();
|
| 1252 |
+
|
| 1253 |
+
$anymarketlog->setStores(array($storeID));
|
| 1254 |
+
$anymarketlog->setLogDesc("Pedido encontrado [" . $idAnymarketOrder . "] e realizado o relacionamento.");
|
| 1255 |
+
$anymarketlog->setStatus("0");
|
| 1256 |
+
$anymarketlog->save();
|
| 1257 |
+
|
| 1258 |
+
$OrderRetry = Mage::getModel('sales/order')->loadByIncrementId($idOrder);
|
| 1259 |
+
$this->updateOrCreateOrderAnyMarket($storeID, $OrderRetry);
|
| 1260 |
+
return $this;
|
| 1261 |
+
}
|
| 1262 |
+
}
|
| 1263 |
}
|
| 1264 |
+
}else{
|
| 1265 |
+
$retOrderJSON = $returnOrder['return'];
|
| 1266 |
+
$anymarketorders->setNmoStatusInt('Integrado');
|
| 1267 |
+
$anymarketorders->setNmoDescError('');
|
| 1268 |
+
$anymarketorders->setNmoIdAnymarket( $retOrderJSON->marketPlaceId );
|
| 1269 |
+
$anymarketorders->setNmoIdSeqAnymarket( $retOrderJSON->id );
|
| 1270 |
+
|
| 1271 |
+
$anymarketlog->setLogId( $retOrderJSON->marketPlaceId );
|
| 1272 |
}
|
| 1273 |
|
| 1274 |
+
$anymarketlog->setStores(array($storeID));
|
| 1275 |
+
$anymarketlog->setLogJson( $returnOrder['json'] );
|
| 1276 |
+
$anymarketlog->setStatus("0");
|
| 1277 |
+
$anymarketlog->save();
|
| 1278 |
+
|
| 1279 |
$anymarketorders->setNmoIdOrder($idOrder);
|
| 1280 |
$anymarketorders->save();
|
| 1281 |
}
|
| 1290 |
public function listOrdersFromAnyMarketMagento($storeID){
|
| 1291 |
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 1292 |
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
|
|
|
| 1293 |
|
| 1294 |
$headers = array(
|
| 1295 |
"Content-type: application/json",
|
| 1321 |
foreach ($JsonReturn->content as $value) {
|
| 1322 |
$IDOrderAnyMarket = $value->marketPlaceId;
|
| 1323 |
|
| 1324 |
+
$statsConfig = $this->getStatusAnyMarketToMageOrderConfig($storeID, $value->status);
|
| 1325 |
+
$statusMage = $statsConfig["status"];
|
| 1326 |
+
if (strpos($statusMage, 'ERROR:') === false) {
|
| 1327 |
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
| 1328 |
$anymarketorders->load($IDOrderAnyMarket, 'nmo_id_anymarket');
|
| 1329 |
if ($anymarketorders->getData('nmo_id_anymarket') == null || (is_array($anymarketorders->getData('store_id')) && !in_array($storeID, $anymarketorders->getData('store_id')))) {
|
app/code/community/DB1/AnyMarket/Helper/Ordergenerator.php
CHANGED
|
@@ -252,9 +252,10 @@ class DB1_AnyMarket_Helper_OrderGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 252 |
|
| 253 |
unset($arrToComp1['qty']);
|
| 254 |
unset($arrToComp2['qty']);
|
|
|
|
|
|
|
| 255 |
if (md5(serialize($arrToComp1)) == md5(serialize($arrToComp2))) {
|
| 256 |
$prod['qty'] += $prodToGroup['qty'];
|
| 257 |
-
|
| 258 |
if( isset($prod['bundle_option_qty']) ) {
|
| 259 |
foreach ($prod['bundle_option_qty'] as $key => $value) {
|
| 260 |
$prod['bundle_option_qty'][$key] += $prodToGroup['bundle_option_qty'][$key];
|
|
@@ -269,7 +270,6 @@ class DB1_AnyMarket_Helper_OrderGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 269 |
array_push($ctrlProds, $prod['product']);
|
| 270 |
}
|
| 271 |
}
|
| 272 |
-
|
| 273 |
return $arryProdAt;
|
| 274 |
}
|
| 275 |
|
| 252 |
|
| 253 |
unset($arrToComp1['qty']);
|
| 254 |
unset($arrToComp2['qty']);
|
| 255 |
+
unset($arrToComp1['bundle_option_qty']);
|
| 256 |
+
unset($arrToComp2['bundle_option_qty']);
|
| 257 |
if (md5(serialize($arrToComp1)) == md5(serialize($arrToComp2))) {
|
| 258 |
$prod['qty'] += $prodToGroup['qty'];
|
|
|
|
| 259 |
if( isset($prod['bundle_option_qty']) ) {
|
| 260 |
foreach ($prod['bundle_option_qty'] as $key => $value) {
|
| 261 |
$prod['bundle_option_qty'][$key] += $prodToGroup['bundle_option_qty'][$key];
|
| 270 |
array_push($ctrlProds, $prod['product']);
|
| 271 |
}
|
| 272 |
}
|
|
|
|
| 273 |
return $arryProdAt;
|
| 274 |
}
|
| 275 |
|
app/code/community/DB1/AnyMarket/Helper/Product.php
CHANGED
|
@@ -341,8 +341,13 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 341 |
* @return Mage_Catalog_Model_Product
|
| 342 |
*/
|
| 343 |
private function update_configurable_product($storeID, $idProd, $dataProdConfig, $simpleProducts){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
$productGenerator = Mage::helper('db1_anymarket/productgenerator');
|
| 345 |
-
$product = $productGenerator->updateConfigurableProduct($storeID, $idProd, $dataProdConfig, $
|
| 346 |
|
| 347 |
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Configurable product Updated').' ('.$product->getSku().')';
|
| 348 |
$returnProd['error'] = '0';
|
|
@@ -351,7 +356,6 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 351 |
|
| 352 |
return $product;
|
| 353 |
}
|
| 354 |
-
|
| 355 |
/**
|
| 356 |
* create simple prod in magento
|
| 357 |
*
|
|
@@ -490,6 +494,8 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 490 |
* @param $product
|
| 491 |
* @param $skusParam
|
| 492 |
* @param $storeID
|
|
|
|
|
|
|
| 493 |
*/
|
| 494 |
public function sendImageSkuToAnyMarket($storeID, $product, $skusParam) {
|
| 495 |
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
|
@@ -500,56 +506,61 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 500 |
"Cache-Control: no-cache",
|
| 501 |
"gumgaToken: ".$TOKEN
|
| 502 |
);
|
|
|
|
| 503 |
// SINCRONIZA AS FOTOS E SKUS
|
| 504 |
if($product->getData('id_anymarket') != "" || $product->getData('id_anymarket') != 0) {
|
| 505 |
$skusProd = $this->CallAPICurl("GET", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus", $headers, null);
|
| 506 |
if ($skusProd['error'] == '0') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
foreach ($skusParam as $skuPut) {
|
| 508 |
$prodSimple = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $skuPut['partnerId']);
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
);
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
}
|
| 522 |
-
$paramSku['variations'] = $skuPut['variations'];
|
| 523 |
-
} else {
|
| 524 |
-
Mage::helper('db1_anymarket/image')->sendImageToAnyMarket($storeID, $product, null);
|
| 525 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
}
|
| 534 |
}
|
| 535 |
}
|
|
|
|
| 536 |
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
if ($skuProdReturn['error'] == '0') {
|
| 541 |
-
$skuProdReturn['return'] = Mage::helper('db1_anymarket')->__('SKU Updated') . ' (' . $skuPut['partnerId'] . ')';
|
| 542 |
-
}
|
| 543 |
-
} else {
|
| 544 |
-
$skuProdReturn = $this->CallAPICurl("POST", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus", $headers, $paramSku);
|
| 545 |
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
}
|
| 549 |
}
|
|
|
|
|
|
|
| 550 |
|
| 551 |
-
|
|
|
|
|
|
|
| 552 |
}
|
|
|
|
|
|
|
|
|
|
| 553 |
}
|
| 554 |
} else {
|
| 555 |
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
|
@@ -1316,7 +1327,7 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1316 |
* @param $storeID
|
| 1317 |
*/
|
| 1318 |
public function getStockProductAnyMarket($storeID, $IDProd){
|
| 1319 |
-
$product = Mage::getModel('catalog/product')->load( $IDProd );
|
| 1320 |
if($product->getIdAnymarket() != ''){
|
| 1321 |
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 1322 |
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
|
@@ -1481,7 +1492,8 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1481 |
"idProduct" => $IDProdTrans,
|
| 1482 |
"idInClient" => isset($transmission->sku->idInClient) ? $transmission->sku->idInClient : $transmission->sku->partnerId,
|
| 1483 |
"price" => $transmission->sku->price,
|
| 1484 |
-
"
|
|
|
|
| 1485 |
"ean" => isset($transmission->sku->ean) ? $transmission->sku->ean : null,
|
| 1486 |
"variations" => $arrVarSku
|
| 1487 |
)
|
|
@@ -1505,6 +1517,7 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1505 |
"idProduct" => $IDProdTrans,
|
| 1506 |
"idInClient" => isset($transmission->sku->idInClient) ? $transmission->sku->idInClient : $transmission->sku->partnerId,
|
| 1507 |
"price" => $transmission->sku->price,
|
|
|
|
| 1508 |
"stockAmount" => $transmission->sku->amount,
|
| 1509 |
"ean" => isset($transmission->sku->ean) ? $transmission->sku->ean : null,
|
| 1510 |
"variations" => $arrVarSku
|
|
@@ -1556,15 +1569,14 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1556 |
}
|
| 1557 |
|
| 1558 |
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 1559 |
-
if( $typeSincOrder ==
|
| 1560 |
if( $transmissionReturn['error'] == '0' ) {
|
| 1561 |
$transmissionStock = $transmissionReturn['return'];
|
| 1562 |
-
|
| 1563 |
$skuToLoad = isset($transmissionStock->sku->partnerId) ? $transmissionStock->sku->partnerId : $transmissionStock->product->id;
|
| 1564 |
$prodLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $skuToLoad);
|
| 1565 |
if ($prodLoaded != null) {
|
| 1566 |
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($prodLoaded->getId());
|
| 1567 |
-
if ($stockItem->getManageStock()) {
|
| 1568 |
$stockItem->setData('qty', $transmissionStock->sku->amount);
|
| 1569 |
if ($transmissionStock->sku->amount > 0) {
|
| 1570 |
$stockItem->setData('is_in_stock', 1);
|
|
@@ -1572,14 +1584,21 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1572 |
$stockItem->setData('is_in_stock', 0);
|
| 1573 |
}
|
| 1574 |
$stockItem->save();
|
| 1575 |
-
}
|
| 1576 |
|
| 1577 |
-
|
| 1578 |
-
|
| 1579 |
-
|
| 1580 |
-
|
| 1581 |
-
|
| 1582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1583 |
|
| 1584 |
$prodRet = $prodLoaded->getSku()." - Stock Updated";
|
| 1585 |
}else{
|
|
@@ -1713,6 +1732,9 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1713 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 1714 |
}
|
| 1715 |
|
|
|
|
|
|
|
|
|
|
| 1716 |
$brand = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_brand_field', $storeID);
|
| 1717 |
$nbm = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_nbm_field', $storeID);
|
| 1718 |
$model = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_model_field', $storeID);
|
|
@@ -1780,6 +1802,9 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1780 |
'description' => $sku->title,
|
| 1781 |
'short_description' => $sku->title,
|
| 1782 |
$priceField => $sku->price,
|
|
|
|
|
|
|
|
|
|
| 1783 |
'created_at' => strtotime('now'),
|
| 1784 |
'updated_at' => strtotime('now'),
|
| 1785 |
'id_anymarket' => $sku->idProduct,
|
|
@@ -1844,6 +1869,9 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1844 |
$product->setData('weight', $MassUnit == 1 ? $ProdsJSON->weight*1000 : $ProdsJSON->weight);
|
| 1845 |
|
| 1846 |
$product->setData($priceField, $sku->price);
|
|
|
|
|
|
|
|
|
|
| 1847 |
$product->setData($brand, $this->procAttrConfig($brand, $ProdsJSON->brand, 0));
|
| 1848 |
$product->setData($model, $this->procAttrConfig($model, $ProdsJSON->model, 0));
|
| 1849 |
$product->setData($video_url, $this->procAttrConfig($video_url, $ProdsJSON->videoURL, 0));
|
|
@@ -1859,7 +1887,7 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1859 |
$product->setData($warranty_text, $this->procAttrConfig($warranty_text, $ProdsJSON->warranty, 0));
|
| 1860 |
$product->setData('id_anymarket', $sku->idProduct);
|
| 1861 |
$product->setData('categoria_anymarket', $ProdsJSON->category);
|
| 1862 |
-
$product->setData('name', $
|
| 1863 |
$product->setStatus(1);
|
| 1864 |
$product->save();
|
| 1865 |
|
|
@@ -1953,8 +1981,8 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1953 |
$anymarketlog->setStores(array($storeID));
|
| 1954 |
$anymarketlog->save();
|
| 1955 |
}
|
| 1956 |
-
// PROD SIMPLES
|
| 1957 |
}else{
|
|
|
|
| 1958 |
foreach ($ProdsJSON->skus as $ProdJSON) {
|
| 1959 |
$skuProd = $ProdJSON;
|
| 1960 |
}
|
|
@@ -1982,6 +2010,9 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 1982 |
'sku' => $IDSkuJsonProd,
|
| 1983 |
'name' => $skuProd->title,
|
| 1984 |
$priceField => $skuProd->price,
|
|
|
|
|
|
|
|
|
|
| 1985 |
'created_at' => strtotime('now'),
|
| 1986 |
'updated_at' => strtotime('now'),
|
| 1987 |
'id_anymarket' => $ProdsJSON->id,
|
|
@@ -2068,6 +2099,9 @@ class DB1_AnyMarket_Helper_Product extends DB1_AnyMarket_Helper_Data
|
|
| 2068 |
}
|
| 2069 |
|
| 2070 |
$product->setData($priceField, $skuProd->price);
|
|
|
|
|
|
|
|
|
|
| 2071 |
|
| 2072 |
if( $typeSincOrder == 0 ) {
|
| 2073 |
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
| 341 |
* @return Mage_Catalog_Model_Product
|
| 342 |
*/
|
| 343 |
private function update_configurable_product($storeID, $idProd, $dataProdConfig, $simpleProducts){
|
| 344 |
+
$productsIDs = array();
|
| 345 |
+
foreach ($simpleProducts as $prodVal) {
|
| 346 |
+
array_push($productsIDs, $prodVal['Id']);
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
$productGenerator = Mage::helper('db1_anymarket/productgenerator');
|
| 350 |
+
$product = $productGenerator->updateConfigurableProduct($storeID, $idProd, $dataProdConfig, $productsIDs);
|
| 351 |
|
| 352 |
$returnProd['return'] = Mage::helper('db1_anymarket')->__('Configurable product Updated').' ('.$product->getSku().')';
|
| 353 |
$returnProd['error'] = '0';
|
| 356 |
|
| 357 |
return $product;
|
| 358 |
}
|
|
|
|
| 359 |
/**
|
| 360 |
* create simple prod in magento
|
| 361 |
*
|
| 494 |
* @param $product
|
| 495 |
* @param $skusParam
|
| 496 |
* @param $storeID
|
| 497 |
+
*
|
| 498 |
+
* @return Boolean
|
| 499 |
*/
|
| 500 |
public function sendImageSkuToAnyMarket($storeID, $product, $skusParam) {
|
| 501 |
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 506 |
"Cache-Control: no-cache",
|
| 507 |
"gumgaToken: ".$TOKEN
|
| 508 |
);
|
| 509 |
+
|
| 510 |
// SINCRONIZA AS FOTOS E SKUS
|
| 511 |
if($product->getData('id_anymarket') != "" || $product->getData('id_anymarket') != 0) {
|
| 512 |
$skusProd = $this->CallAPICurl("GET", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus", $headers, null);
|
| 513 |
if ($skusProd['error'] == '0') {
|
| 514 |
+
if($product->getTypeID() == "configurable" && $product->getData('integra_images_root_anymarket') == 1 ){
|
| 515 |
+
//obtem as imagens do produto(Config)
|
| 516 |
+
Mage::helper('db1_anymarket/image')->sendImageToAnyMarket($storeID, $product, null);
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
foreach ($skusParam as $skuPut) {
|
| 520 |
$prodSimple = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $skuPut['partnerId']);
|
| 521 |
+
$paramSku = array(
|
| 522 |
+
"title" => $skuPut['title'],
|
| 523 |
+
"partnerId" => $skuPut['partnerId'],
|
| 524 |
+
"ean" => $skuPut['ean'],
|
| 525 |
+
"amount" => $skuPut['amount'],
|
| 526 |
+
"price" => $skuPut['price'],
|
| 527 |
+
);
|
|
|
|
| 528 |
|
| 529 |
+
if (isset($skuPut['variations'])) {
|
| 530 |
+
foreach ($skuPut['variations'] as $variationPut) {
|
| 531 |
+
Mage::helper('db1_anymarket/image')->sendImageToAnyMarket($storeID, $prodSimple, $variationPut);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
}
|
| 533 |
+
$paramSku['variations'] = $skuPut['variations'];
|
| 534 |
+
} else {
|
| 535 |
+
Mage::helper('db1_anymarket/image')->sendImageToAnyMarket($storeID, $product, null);
|
| 536 |
+
}
|
| 537 |
|
| 538 |
+
$flagHSku = '';
|
| 539 |
+
if (isset($skusProd['return'])) {
|
| 540 |
+
foreach ($skusProd['return'] as $skuAM) {
|
| 541 |
+
if ($skuAM->partnerId == $prodSimple->getSku()) {
|
| 542 |
+
$flagHSku = $skuAM->id;
|
| 543 |
+
break;
|
|
|
|
| 544 |
}
|
| 545 |
}
|
| 546 |
+
}
|
| 547 |
|
| 548 |
+
if ($flagHSku != '') {
|
| 549 |
+
$skuProdReturn = $this->CallAPICurl("PUT", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus/" . $flagHSku, $headers, $paramSku);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
|
| 551 |
+
if ($skuProdReturn['error'] == '0') {
|
| 552 |
+
$skuProdReturn['return'] = Mage::helper('db1_anymarket')->__('SKU Updated') . ' (' . $skuPut['partnerId'] . ')';
|
|
|
|
| 553 |
}
|
| 554 |
+
} else {
|
| 555 |
+
$skuProdReturn = $this->CallAPICurl("POST", $HOST . "/v2/products/" . $product->getData('id_anymarket') . "/skus", $headers, $paramSku);
|
| 556 |
|
| 557 |
+
if ($skuProdReturn['error'] == '0') {
|
| 558 |
+
$skuProdReturn['return'] = Mage::helper('db1_anymarket')->__('SKU Created') . ' (' . $skuPut['partnerId'] . ')';
|
| 559 |
+
}
|
| 560 |
}
|
| 561 |
+
|
| 562 |
+
$this->saveLogsProds($storeID, "1", $skuProdReturn, $prodSimple);
|
| 563 |
+
|
| 564 |
}
|
| 565 |
} else {
|
| 566 |
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 1327 |
* @param $storeID
|
| 1328 |
*/
|
| 1329 |
public function getStockProductAnyMarket($storeID, $IDProd){
|
| 1330 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $IDProd );
|
| 1331 |
if($product->getIdAnymarket() != ''){
|
| 1332 |
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 1333 |
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
| 1492 |
"idProduct" => $IDProdTrans,
|
| 1493 |
"idInClient" => isset($transmission->sku->idInClient) ? $transmission->sku->idInClient : $transmission->sku->partnerId,
|
| 1494 |
"price" => $transmission->sku->price,
|
| 1495 |
+
"specialPrice" => ($transmission->sku->price != $transmission->sku->discountPrice) ? $transmission->sku->discountPrice : null,
|
| 1496 |
+
"stockAmount" => $transmission->sku->amount,
|
| 1497 |
"ean" => isset($transmission->sku->ean) ? $transmission->sku->ean : null,
|
| 1498 |
"variations" => $arrVarSku
|
| 1499 |
)
|
| 1517 |
"idProduct" => $IDProdTrans,
|
| 1518 |
"idInClient" => isset($transmission->sku->idInClient) ? $transmission->sku->idInClient : $transmission->sku->partnerId,
|
| 1519 |
"price" => $transmission->sku->price,
|
| 1520 |
+
"specialPrice" => ($transmission->sku->price != $transmission->sku->discountPrice) ? $transmission->sku->discountPrice : null,
|
| 1521 |
"stockAmount" => $transmission->sku->amount,
|
| 1522 |
"ean" => isset($transmission->sku->ean) ? $transmission->sku->ean : null,
|
| 1523 |
"variations" => $arrVarSku
|
| 1569 |
}
|
| 1570 |
|
| 1571 |
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 1572 |
+
if( $typeSincOrder == 1 ){
|
| 1573 |
if( $transmissionReturn['error'] == '0' ) {
|
| 1574 |
$transmissionStock = $transmissionReturn['return'];
|
|
|
|
| 1575 |
$skuToLoad = isset($transmissionStock->sku->partnerId) ? $transmissionStock->sku->partnerId : $transmissionStock->product->id;
|
| 1576 |
$prodLoaded = Mage::getModel('catalog/product')->setStoreId($storeID)->loadByAttribute('sku', $skuToLoad);
|
| 1577 |
if ($prodLoaded != null) {
|
| 1578 |
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($prodLoaded->getId());
|
| 1579 |
+
if( ($stockItem->getManageStock()) && ($stockItem->getData('qty') != $transmissionStock->sku->amount) ) {
|
| 1580 |
$stockItem->setData('qty', $transmissionStock->sku->amount);
|
| 1581 |
if ($transmissionStock->sku->amount > 0) {
|
| 1582 |
$stockItem->setData('is_in_stock', 1);
|
| 1584 |
$stockItem->setData('is_in_stock', 0);
|
| 1585 |
}
|
| 1586 |
$stockItem->save();
|
|
|
|
| 1587 |
|
| 1588 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 1589 |
+
$anymarketlog->setLogDesc( "Stock Updated: ".$transmissionStock->sku->amount );
|
| 1590 |
+
$anymarketlog->setLogId( $prodLoaded->getSku() );
|
| 1591 |
+
$anymarketlog->setStatus("0");
|
| 1592 |
+
$anymarketlog->setStores(array($storeID));
|
| 1593 |
+
$anymarketlog->save();
|
| 1594 |
+
}else{
|
| 1595 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 1596 |
+
$anymarketlog->setLogDesc( "Estoques iguais." );
|
| 1597 |
+
$anymarketlog->setLogId( $prodLoaded->getSku() );
|
| 1598 |
+
$anymarketlog->setStatus("0");
|
| 1599 |
+
$anymarketlog->setStores(array($storeID));
|
| 1600 |
+
$anymarketlog->save();
|
| 1601 |
+
}
|
| 1602 |
|
| 1603 |
$prodRet = $prodLoaded->getSku()." - Stock Updated";
|
| 1604 |
}else{
|
| 1732 |
Mage::app()->getCacheInstance()->cleanType('config');
|
| 1733 |
}
|
| 1734 |
|
| 1735 |
+
$specialToDate = date('Y-m-dTH:i:sZ', strtotime('+5 years'));
|
| 1736 |
+
$specialFromDate = date('Y-m-dTH:i:sZ', strtotime('-1 years'));
|
| 1737 |
+
|
| 1738 |
$brand = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_brand_field', $storeID);
|
| 1739 |
$nbm = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_nbm_field', $storeID);
|
| 1740 |
$model = Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_model_field', $storeID);
|
| 1802 |
'description' => $sku->title,
|
| 1803 |
'short_description' => $sku->title,
|
| 1804 |
$priceField => $sku->price,
|
| 1805 |
+
'special_price' => $sku->specialPrice,
|
| 1806 |
+
'special_to_date' => $sku->specialPrice != null ? $specialToDate : null,
|
| 1807 |
+
'special_from_date' => $sku->specialPrice != null ? $specialFromDate : null,
|
| 1808 |
'created_at' => strtotime('now'),
|
| 1809 |
'updated_at' => strtotime('now'),
|
| 1810 |
'id_anymarket' => $sku->idProduct,
|
| 1869 |
$product->setData('weight', $MassUnit == 1 ? $ProdsJSON->weight*1000 : $ProdsJSON->weight);
|
| 1870 |
|
| 1871 |
$product->setData($priceField, $sku->price);
|
| 1872 |
+
$product->setData('special_price', $sku->specialPrice);
|
| 1873 |
+
$product->setData('special_to_date', $sku->specialPrice != null ? $specialToDate : null);
|
| 1874 |
+
$product->setData('special_from_date', $sku->specialPrice != null ? $specialFromDate : null);
|
| 1875 |
$product->setData($brand, $this->procAttrConfig($brand, $ProdsJSON->brand, 0));
|
| 1876 |
$product->setData($model, $this->procAttrConfig($model, $ProdsJSON->model, 0));
|
| 1877 |
$product->setData($video_url, $this->procAttrConfig($video_url, $ProdsJSON->videoURL, 0));
|
| 1887 |
$product->setData($warranty_text, $this->procAttrConfig($warranty_text, $ProdsJSON->warranty, 0));
|
| 1888 |
$product->setData('id_anymarket', $sku->idProduct);
|
| 1889 |
$product->setData('categoria_anymarket', $ProdsJSON->category);
|
| 1890 |
+
$product->setData('name', $sku->title);
|
| 1891 |
$product->setStatus(1);
|
| 1892 |
$product->save();
|
| 1893 |
|
| 1981 |
$anymarketlog->setStores(array($storeID));
|
| 1982 |
$anymarketlog->save();
|
| 1983 |
}
|
|
|
|
| 1984 |
}else{
|
| 1985 |
+
// PROD SIMPLES
|
| 1986 |
foreach ($ProdsJSON->skus as $ProdJSON) {
|
| 1987 |
$skuProd = $ProdJSON;
|
| 1988 |
}
|
| 2010 |
'sku' => $IDSkuJsonProd,
|
| 2011 |
'name' => $skuProd->title,
|
| 2012 |
$priceField => $skuProd->price,
|
| 2013 |
+
'special_price' => $skuProd->specialPrice,
|
| 2014 |
+
'special_to_date' => $skuProd->specialPrice != null ? $specialToDate : null,
|
| 2015 |
+
'special_from_date' => $skuProd->specialPrice != null ? $specialFromDate : null,
|
| 2016 |
'created_at' => strtotime('now'),
|
| 2017 |
'updated_at' => strtotime('now'),
|
| 2018 |
'id_anymarket' => $ProdsJSON->id,
|
| 2099 |
}
|
| 2100 |
|
| 2101 |
$product->setData($priceField, $skuProd->price);
|
| 2102 |
+
$product->setData('special_price', $skuProd->specialPrice);
|
| 2103 |
+
$product->setData('special_to_date', $skuProd->specialPrice != null ? $specialToDate : null);
|
| 2104 |
+
$product->setData('special_from_date', $skuProd->specialPrice != null ? $specialFromDate : null);
|
| 2105 |
|
| 2106 |
if( $typeSincOrder == 0 ) {
|
| 2107 |
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
app/code/community/DB1/AnyMarket/Helper/Productgenerator.php
CHANGED
|
@@ -62,7 +62,8 @@ class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 62 |
),
|
| 63 |
'images' => array(),
|
| 64 |
'stock_item' => array(
|
| 65 |
-
'use_config_manage_stock' => '
|
|
|
|
| 66 |
'manage_stock' => '1',
|
| 67 |
'min_sale_qty' => '1',
|
| 68 |
'max_sale_qty' => '',
|
|
@@ -206,7 +207,7 @@ class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 206 |
|
| 207 |
$configurableProductsData = array();
|
| 208 |
$configurableAttributesData = $this->getConfigurableAttributes($AttributeIds);
|
| 209 |
-
|
| 210 |
foreach ($simpleProducts as $simpleProduct) {
|
| 211 |
$sProd = Mage::getModel('catalog/product')->load( $simpleProduct['Id'] );
|
| 212 |
|
|
@@ -221,6 +222,8 @@ class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 221 |
|
| 222 |
$configurableProductsData[ $sProd->getId() ] = $simpleProductsData;
|
| 223 |
$configurableAttributesData[0]['values'][] = $simpleProductsData;
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
$confProduct->setCanSaveConfigurableAttributes(true);
|
| 226 |
|
|
@@ -237,13 +240,24 @@ class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 237 |
foreach ($dataProdConfig as $key => $value) {
|
| 238 |
$confProduct->setData($key, $value);
|
| 239 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
$confProduct->save();
|
| 241 |
$sku = $dataProdConfig['sku'];
|
| 242 |
foreach ($dataProdConfig['images'] as $image) {
|
| 243 |
$this->importImages($confProduct, $image, $sku);
|
| 244 |
}
|
| 245 |
|
| 246 |
-
return $confProduct;
|
| 247 |
}
|
| 248 |
|
| 249 |
/**
|
|
@@ -252,28 +266,61 @@ class DB1_AnyMarket_Helper_ProductGenerator extends DB1_AnyMarket_Helper_Data
|
|
| 252 |
* @param $storeID
|
| 253 |
* @param $idProd
|
| 254 |
* @param array $dataProdConfig
|
| 255 |
-
* @param array $
|
| 256 |
* @return Mage_Catalog_Model_Product
|
| 257 |
*/
|
| 258 |
-
public function updateConfigurableProduct($storeID, $idProd, $dataProdConfig = array() , $
|
| 259 |
-
$
|
| 260 |
-
$simplesToAddConfig = array();
|
| 261 |
-
foreach ($simpleProducts as $simpleProduct) {
|
| 262 |
-
array_push( $simplesToAddConfig, $simpleProduct['Id'] );
|
| 263 |
-
}
|
| 264 |
|
| 265 |
-
//ADICIONA OS JA EXISTENTES NO PRODUTO
|
| 266 |
$childProducts = Mage::getModel('catalog/product_type_configurable')
|
| 267 |
-
->getUsedProducts(null, $
|
| 268 |
|
| 269 |
foreach($childProducts as $child) {
|
| 270 |
-
array_push( $
|
| 271 |
}
|
| 272 |
|
| 273 |
-
$
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
|
| 278 |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 279 |
$confProduct = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $idProd );
|
| 62 |
),
|
| 63 |
'images' => array(),
|
| 64 |
'stock_item' => array(
|
| 65 |
+
'use_config_manage_stock' => '1',
|
| 66 |
+
'inventory_manage_stock' => '1',
|
| 67 |
'manage_stock' => '1',
|
| 68 |
'min_sale_qty' => '1',
|
| 69 |
'max_sale_qty' => '',
|
| 207 |
|
| 208 |
$configurableProductsData = array();
|
| 209 |
$configurableAttributesData = $this->getConfigurableAttributes($AttributeIds);
|
| 210 |
+
$simpleProductIds = array();
|
| 211 |
foreach ($simpleProducts as $simpleProduct) {
|
| 212 |
$sProd = Mage::getModel('catalog/product')->load( $simpleProduct['Id'] );
|
| 213 |
|
| 222 |
|
| 223 |
$configurableProductsData[ $sProd->getId() ] = $simpleProductsData;
|
| 224 |
$configurableAttributesData[0]['values'][] = $simpleProductsData;
|
| 225 |
+
|
| 226 |
+
array_push($simpleProductIds, $simpleProduct['Id']);
|
| 227 |
}
|
| 228 |
$confProduct->setCanSaveConfigurableAttributes(true);
|
| 229 |
|
| 240 |
foreach ($dataProdConfig as $key => $value) {
|
| 241 |
$confProduct->setData($key, $value);
|
| 242 |
}
|
| 243 |
+
|
| 244 |
+
$stockConfig = array(
|
| 245 |
+
'use_config_manage_stock' => '1',
|
| 246 |
+
'inventory_manage_stock' => '1',
|
| 247 |
+
'manage_stock' => '1',
|
| 248 |
+
'min_sale_qty' => '1',
|
| 249 |
+
'max_sale_qty' => '',
|
| 250 |
+
'is_in_stock' => '1',
|
| 251 |
+
);
|
| 252 |
+
$confProduct->setStockData( $stockConfig );
|
| 253 |
+
|
| 254 |
$confProduct->save();
|
| 255 |
$sku = $dataProdConfig['sku'];
|
| 256 |
foreach ($dataProdConfig['images'] as $image) {
|
| 257 |
$this->importImages($confProduct, $image, $sku);
|
| 258 |
}
|
| 259 |
|
| 260 |
+
return $this->updateConfigurableProduct($storeID, $confProduct->getId(), $dataProdConfig, $simpleProductIds);
|
| 261 |
}
|
| 262 |
|
| 263 |
/**
|
| 266 |
* @param $storeID
|
| 267 |
* @param $idProd
|
| 268 |
* @param array $dataProdConfig
|
| 269 |
+
* @param array $simpleProductIds
|
| 270 |
* @return Mage_Catalog_Model_Product
|
| 271 |
*/
|
| 272 |
+
public function updateConfigurableProduct($storeID, $idProd, $dataProdConfig = array() , $simpleProductIds = array()){
|
| 273 |
+
$mainProduct = Mage::getModel('catalog/product')->load( $idProd );
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
|
|
|
|
| 275 |
$childProducts = Mage::getModel('catalog/product_type_configurable')
|
| 276 |
+
->getUsedProducts(null, $mainProduct);
|
| 277 |
|
| 278 |
foreach($childProducts as $child) {
|
| 279 |
+
array_push( $simpleProductIds, $child->getId() );
|
| 280 |
}
|
| 281 |
|
| 282 |
+
$mainProduct->setConfigurableProductsData(array_flip($simpleProductIds));
|
| 283 |
+
$productType = $mainProduct->getTypeInstance(true);
|
| 284 |
+
$productType->setProduct($mainProduct);
|
| 285 |
+
$attributesData = $productType->getConfigurableAttributesAsArray();
|
| 286 |
+
if (empty($attributesData)) {
|
| 287 |
+
// Auto generation if configurable product has no attribute
|
| 288 |
+
$attributeIds = array();
|
| 289 |
+
foreach ($productType->getSetAttributes() as $attribute) {
|
| 290 |
+
if ($productType->canUseAttribute($attribute)) {
|
| 291 |
+
$attributeIds[] = $attribute->getAttributeId();
|
| 292 |
+
}
|
| 293 |
+
}
|
| 294 |
+
$productType->setUsedProductAttributeIds($attributeIds);
|
| 295 |
+
$attributesData = $productType->getConfigurableAttributesAsArray();
|
| 296 |
+
}
|
| 297 |
+
if (!empty($configurableAttributes)){
|
| 298 |
+
foreach ($attributesData as $idx => $val) {
|
| 299 |
+
if (!in_array($val['attribute_id'], $configurableAttributes)) {
|
| 300 |
+
unset($attributesData[$idx]);
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
$products = Mage::getModel('catalog/product')->getCollection()
|
| 305 |
+
->addIdFilter($simpleProductIds);
|
| 306 |
+
if (count($products)) {
|
| 307 |
+
foreach ($attributesData as &$attribute) {
|
| 308 |
+
$attribute['label'] = $attribute['frontend_label'];
|
| 309 |
+
$attributeCode = $attribute['attribute_code'];
|
| 310 |
+
foreach ($products as $product) {
|
| 311 |
+
$product->load($product->getId());
|
| 312 |
+
$optionId = $product->getData($attributeCode);
|
| 313 |
+
|
| 314 |
+
$attribute['values'][$optionId] = array(
|
| 315 |
+
'value_index' => $optionId,
|
| 316 |
+
'is_percent' => 0,
|
| 317 |
+
'pricing_value' => $product->getPrice(),
|
| 318 |
+
);
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
$mainProduct->setConfigurableAttributesData($attributesData);
|
| 322 |
+
$mainProduct->save();
|
| 323 |
+
}
|
| 324 |
|
| 325 |
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 326 |
$confProduct = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $idProd );
|
app/code/community/DB1/AnyMarket/Helper/Queue.php
CHANGED
|
@@ -60,16 +60,7 @@ class DB1_AnyMarket_Helper_Queue extends DB1_AnyMarket_Helper_Data
|
|
| 60 |
if ($item['nmq_table'] == 'ORDER') {
|
| 61 |
try {
|
| 62 |
if ($typImp == 'IMP') {
|
| 63 |
-
|
| 64 |
-
$anymarketorders->load($IdItemQueue, 'nmo_id_anymarket');
|
| 65 |
-
//Import
|
| 66 |
-
if ($anymarketorders->getNmoStatusInt() != "Não integrado (Magento)") {
|
| 67 |
-
$idAnyMarket = $anymarketorders->getNmoIdSeqAnymarket();
|
| 68 |
-
if ($idAnyMarket) {
|
| 69 |
-
$idReg = $anymarketorders->getId();
|
| 70 |
-
Mage::helper('db1_anymarket/order')->getSpecificOrderFromAnyMarket($idAnyMarket, "notoken", $storeID);
|
| 71 |
-
}
|
| 72 |
-
}
|
| 73 |
} else {
|
| 74 |
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
| 75 |
$anymarketorders->load($IdItemQueue, 'nmo_id_order');
|
|
@@ -77,7 +68,7 @@ class DB1_AnyMarket_Helper_Queue extends DB1_AnyMarket_Helper_Data
|
|
| 77 |
if ($anymarketorders->getNmoStatusInt() != "Não integrado (AnyMarket)") {
|
| 78 |
$idOrderToLoad = ($anymarketorders->getNmoIdOrder() == null) ? $IdItemQueue : $anymarketorders->getNmoIdOrder();
|
| 79 |
$Order = Mage::getModel('sales/order')->loadByIncrementId( $idOrderToLoad );
|
| 80 |
-
Mage::helper('db1_anymarket/order')->
|
| 81 |
}
|
| 82 |
}
|
| 83 |
|
|
@@ -85,14 +76,33 @@ class DB1_AnyMarket_Helper_Queue extends DB1_AnyMarket_Helper_Data
|
|
| 85 |
Mage::logException($e);
|
| 86 |
}
|
| 87 |
} else if ($item['nmq_table'] == 'STOCK') {
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
} else if ($item['nmq_table'] == 'PRODUCT') {
|
| 97 |
// EXPORT PRODUCT
|
| 98 |
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
|
@@ -165,6 +175,29 @@ class DB1_AnyMarket_Helper_Queue extends DB1_AnyMarket_Helper_Data
|
|
| 165 |
|
| 166 |
}
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
/**
|
| 169 |
* process Stocks By CRON
|
| 170 |
*/
|
| 60 |
if ($item['nmq_table'] == 'ORDER') {
|
| 61 |
try {
|
| 62 |
if ($typImp == 'IMP') {
|
| 63 |
+
Mage::helper('db1_anymarket/order')->getSpecificOrderFromAnyMarket($IdItemQueue, "notoken", $storeID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
} else {
|
| 65 |
$anymarketorders = Mage::getModel('db1_anymarket/anymarketorders')->setStoreId($storeID);
|
| 66 |
$anymarketorders->load($IdItemQueue, 'nmo_id_order');
|
| 68 |
if ($anymarketorders->getNmoStatusInt() != "Não integrado (AnyMarket)") {
|
| 69 |
$idOrderToLoad = ($anymarketorders->getNmoIdOrder() == null) ? $IdItemQueue : $anymarketorders->getNmoIdOrder();
|
| 70 |
$Order = Mage::getModel('sales/order')->loadByIncrementId( $idOrderToLoad );
|
| 71 |
+
Mage::helper('db1_anymarket/order')->updateOrCreateOrderAnyMarket($storeID, $Order);
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 76 |
Mage::logException($e);
|
| 77 |
}
|
| 78 |
} else if ($item['nmq_table'] == 'STOCK') {
|
| 79 |
+
if ($typImp == 'EXP') {
|
| 80 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeID)->load( $IdItemQueue );
|
| 81 |
+
if ($product) {
|
| 82 |
+
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
| 83 |
+
$ProdStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
| 84 |
+
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product->getId(), $ProdStock->getQty(), $product->getData($filter));
|
| 85 |
+
}
|
| 86 |
+
} else {
|
| 87 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 88 |
+
$TOKEN = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_token_field', $storeID);
|
| 89 |
+
|
| 90 |
+
$headers = array(
|
| 91 |
+
"Content-type: application/json",
|
| 92 |
+
"Accept: */*",
|
| 93 |
+
"gumgaToken: " . $TOKEN
|
| 94 |
+
);
|
| 95 |
+
|
| 96 |
+
$listTransmissions = array();
|
| 97 |
+
array_push($listTransmissions, array(
|
| 98 |
+
"id" => $IdItemQueue,
|
| 99 |
+
"token" => "notoken"
|
| 100 |
+
)
|
| 101 |
+
);
|
| 102 |
+
|
| 103 |
+
$JSON = json_encode($listTransmissions);
|
| 104 |
+
Mage::helper('db1_anymarket/product')->getSpecificFeedProduct($storeID, json_decode($JSON), $headers, $HOST);
|
| 105 |
+
}
|
| 106 |
} else if ($item['nmq_table'] == 'PRODUCT') {
|
| 107 |
// EXPORT PRODUCT
|
| 108 |
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 175 |
|
| 176 |
}
|
| 177 |
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* process Orders with erros 01 By CRON
|
| 181 |
+
*/
|
| 182 |
+
public function processOrdersWithError01(){
|
| 183 |
+
$allStores = Mage::helper('db1_anymarket')->getAllStores();
|
| 184 |
+
foreach ($allStores as $store) {
|
| 185 |
+
$storeID = $store['store_id'];
|
| 186 |
+
$cronEnabled = Mage::getStoreConfig('anymarket_section/anymarket_cron_group/anymarket_order_field', $storeID);
|
| 187 |
+
$orderSync = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 188 |
+
|
| 189 |
+
if( $cronEnabled == '1' && $orderSync == '1' ) {
|
| 190 |
+
$ordersError = Mage::getModel('db1_anymarket/anymarketorders')
|
| 191 |
+
->getCollection()
|
| 192 |
+
->addFilter('nmo_status_int', 'ERROR 01');
|
| 193 |
+
|
| 194 |
+
foreach ($ordersError as $order) {
|
| 195 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $order->getData('nmo_id_seq_anymarket'), 'IMP', 'ORDER');
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
/**
|
| 202 |
* process Stocks By CRON
|
| 203 |
*/
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketattributes.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketbrands.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketimage.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) 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_Anymarketimage extends Varien_Object
|
| 25 |
+
{
|
| 26 |
+
/**
|
| 27 |
+
* Load search results
|
| 28 |
+
*
|
| 29 |
+
* @access public
|
| 30 |
+
* @return DB1_AnyMarket_Model_Adminhtml_Search_Anymarketimage
|
| 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/anymarketimage_collection')
|
| 41 |
+
->addFieldToFilter('log_desc', array('like' => $this->getQuery().'%'))
|
| 42 |
+
->setCurPage($this->getStart())
|
| 43 |
+
->setPageSize($this->getLimit())
|
| 44 |
+
->load();
|
| 45 |
+
foreach ($collection->getItems() as $anymarketimage) {
|
| 46 |
+
$arr[] = array(
|
| 47 |
+
'id' => 'anymarketimage/1/'.$anymarketimage->getId(),
|
| 48 |
+
'type' => Mage::helper('db1_anymarket')->__('AnyMarket Image'),
|
| 49 |
+
'name' => $anymarketimage->getLogDesc(),
|
| 50 |
+
'description' => $anymarketimage->getLogDesc(),
|
| 51 |
+
'url' => Mage::helper('adminhtml')->getUrl(
|
| 52 |
+
'*/anymarket_anymarketimage/edit',
|
| 53 |
+
array('id'=>$anymarketimage->getId())
|
| 54 |
+
),
|
| 55 |
+
);
|
| 56 |
+
}
|
| 57 |
+
$this->setResults($arr);
|
| 58 |
+
return $this;
|
| 59 |
+
}
|
| 60 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketlog.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketorders.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketproducts.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Adminhtml/Search/Anymarketqueue.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketattributes.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketattributes/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketbrands.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketbrands/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketcategories.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketcategories/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketimage.php
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Anymarketimage 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_anymarketimage';
|
| 31 |
+
const CACHE_TAG = 'db1_anymarket_anymarketimage';
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Prefix of model events names
|
| 35 |
+
*
|
| 36 |
+
* @var string
|
| 37 |
+
*/
|
| 38 |
+
protected $_eventPrefix = 'db1_anymarket_anymarketimage';
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Parameter name in event
|
| 42 |
+
*
|
| 43 |
+
* @var string
|
| 44 |
+
*/
|
| 45 |
+
protected $_eventObject = 'anymarketimage';
|
| 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/anymarketimage');
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* before save anymarketimage
|
| 62 |
+
*
|
| 63 |
+
* @access protected
|
| 64 |
+
* @return DB1_AnyMarket_Model_Anymarketimage
|
| 65 |
+
|
| 66 |
+
*/
|
| 67 |
+
protected function _beforeSave()
|
| 68 |
+
{
|
| 69 |
+
return parent::_beforeSave();
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* save anymarketbrands relation
|
| 74 |
+
*
|
| 75 |
+
* @access public
|
| 76 |
+
* @return DB1_AnyMarket_Model_Anymarketbrands
|
| 77 |
+
|
| 78 |
+
*/
|
| 79 |
+
protected function _afterSave()
|
| 80 |
+
{
|
| 81 |
+
return parent::_afterSave();
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketlog.php
CHANGED
|
@@ -107,6 +107,10 @@ class DB1_AnyMarket_Model_Anymarketlog extends Mage_Core_Model_Abstract
|
|
| 107 |
}
|
| 108 |
$this->setUpdatedAt($now);
|
| 109 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
}else {
|
| 111 |
$this->_dataSaveAllowed = false;
|
| 112 |
}
|
| 107 |
}
|
| 108 |
$this->setUpdatedAt($now);
|
| 109 |
}
|
| 110 |
+
|
| 111 |
+
if( $this->getLogDesc() == "" && $this->getLogJson() == "" ){
|
| 112 |
+
$this->_dataSaveAllowed = false;
|
| 113 |
+
}
|
| 114 |
}else {
|
| 115 |
$this->_dataSaveAllowed = false;
|
| 116 |
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketlog/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketorders.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api.php
CHANGED
|
@@ -90,7 +90,14 @@ class DB1_AnyMarket_Model_Anymarketorders_Api extends Mage_Api_Model_Resource_Ab
|
|
| 90 |
$TOKEN = $store['token'];
|
| 91 |
|
| 92 |
if ($TOKEN != '') {
|
| 93 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
}
|
| 96 |
}
|
| 90 |
$TOKEN = $store['token'];
|
| 91 |
|
| 92 |
if ($TOKEN != '') {
|
| 93 |
+
$sincMode = Mage::getStoreConfig('anymarket_section/anymarket_general_group/anymarket_operation_type_imp_field', $storeID);
|
| 94 |
+
if( $sincMode == "1" ) {
|
| 95 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $data['id'], 'IMP', 'ORDER');
|
| 96 |
+
$ret = "Adicionado a fila do Magento";
|
| 97 |
+
}else{
|
| 98 |
+
$ret = Mage::helper('db1_anymarket/order')->getSpecificOrderFromAnyMarket($data['id'], "notoken", $storeID);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
}
|
| 102 |
}
|
| 103 |
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketorders/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketproducts.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api.php
CHANGED
|
@@ -91,24 +91,38 @@ class DB1_AnyMarket_Model_Anymarketproducts_Api extends Mage_Api_Model_Resource_
|
|
| 91 |
$TOKEN = $store['token'];
|
| 92 |
|
| 93 |
if ($TOKEN != '') {
|
| 94 |
-
|
| 95 |
-
$
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
}
|
| 113 |
}
|
| 114 |
}
|
| 91 |
$TOKEN = $store['token'];
|
| 92 |
|
| 93 |
if ($TOKEN != '') {
|
| 94 |
+
$sincMode = Mage::getStoreConfig('anymarket_section/anymarket_general_group/anymarket_operation_type_imp_field', $storeID);
|
| 95 |
+
if( $sincMode == "1" ) {
|
| 96 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
| 97 |
+
if($typeSincProd == "1") {
|
| 98 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $data['id'], 'IMP', 'PRODUCT');
|
| 99 |
+
}else{
|
| 100 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 101 |
+
if( $typeSincOrder == "1" ){
|
| 102 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $data['id'], 'IMP', 'STOCK');
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
$ret = "Adicionado na fila Magento.";
|
| 107 |
+
}else{
|
| 108 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 109 |
+
|
| 110 |
+
$headers = array(
|
| 111 |
+
"Content-type: application/json",
|
| 112 |
+
"Accept: */*",
|
| 113 |
+
"gumgaToken: " . $TOKEN
|
| 114 |
+
);
|
| 115 |
+
|
| 116 |
+
$listTransmissions = array();
|
| 117 |
+
array_push($listTransmissions, array(
|
| 118 |
+
"id" => $data['id'],
|
| 119 |
+
"token" => "notoken"
|
| 120 |
+
)
|
| 121 |
+
);
|
| 122 |
+
|
| 123 |
+
$JSON = json_encode($listTransmissions);
|
| 124 |
+
$ret = Mage::helper('db1_anymarket/product')->getSpecificFeedProduct($storeID, json_decode($JSON), $headers, $HOST);
|
| 125 |
+
}
|
| 126 |
}
|
| 127 |
}
|
| 128 |
}
|
app/code/community/DB1/AnyMarket/Model/Anymarketproducts/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketqueue.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Anymarketqueue/Api/V2.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Cron.php
CHANGED
|
@@ -22,8 +22,8 @@ class DB1_AnyMarket_Model_Cron{
|
|
| 22 |
Mage::helper('db1_anymarket/queue')->processQueue("CRON");
|
| 23 |
}
|
| 24 |
|
| 25 |
-
public function
|
| 26 |
-
Mage::helper('db1_anymarket/queue')->
|
| 27 |
}
|
| 28 |
|
| 29 |
/**
|
| 22 |
Mage::helper('db1_anymarket/queue')->processQueue("CRON");
|
| 23 |
}
|
| 24 |
|
| 25 |
+
public function sincOrdersWithErrors(){
|
| 26 |
+
Mage::helper('db1_anymarket/queue')->processOrdersWithError01();
|
| 27 |
}
|
| 28 |
|
| 29 |
/**
|
app/code/community/DB1/AnyMarket/Model/Observer.php
CHANGED
|
@@ -120,25 +120,105 @@ class DB1_AnyMarket_Model_Observer {
|
|
| 120 |
* @param $observer
|
| 121 |
* @return $this
|
| 122 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
public function updateOrderAnyMarketObs($observer){
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
try {
|
| 127 |
if(Mage::registry('order_save_observer_executed_'.$OrderID )){
|
| 128 |
Mage::unregister( 'order_save_observer_executed_'.$OrderID );
|
| 129 |
return $this;
|
| 130 |
}
|
| 131 |
-
|
| 132 |
Mage::register('order_save_observer_executed_'.$OrderID, true);
|
| 133 |
-
$order = $observer->getEvent()->getOrder();
|
| 134 |
|
| 135 |
if( $this->asyncMode($storeID) ){
|
| 136 |
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $OrderID, 'EXP', 'ORDER');
|
| 137 |
}else{
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
-
//DECREMENTA STOCK ANYMARKET
|
| 142 |
$orderItems = $order->getItemsCollection();
|
| 143 |
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
| 144 |
foreach ($orderItems as $item){
|
|
@@ -152,14 +232,15 @@ class DB1_AnyMarket_Model_Observer {
|
|
| 152 |
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product_id, $stock->getQty(), $_product->getData($filter));
|
| 153 |
}
|
| 154 |
}
|
|
|
|
| 155 |
Mage::unregister( 'order_save_observer_executed_'.$OrderID );
|
| 156 |
} catch (Exception $e) {
|
| 157 |
Mage::unregister( 'order_save_observer_executed_'.$OrderID );
|
| 158 |
Mage::logException($e);
|
| 159 |
}
|
| 160 |
-
|
| 161 |
}
|
| 162 |
|
|
|
|
| 163 |
/**
|
| 164 |
* @param $observer
|
| 165 |
*/
|
|
@@ -176,6 +257,8 @@ class DB1_AnyMarket_Model_Observer {
|
|
| 176 |
|
| 177 |
/**
|
| 178 |
* @param $observer
|
|
|
|
|
|
|
| 179 |
*/
|
| 180 |
public function catalogInventorySave($observer){
|
| 181 |
$ImportOrderSession = Mage::getSingleton('core/session')->getImportOrdersVariable();
|
| 120 |
* @param $observer
|
| 121 |
* @return $this
|
| 122 |
*/
|
| 123 |
+
public function saveShippingObs($observer){
|
| 124 |
+
if (Mage::registry('salesOrderShipmentSaveBeforeTriggered')) {
|
| 125 |
+
return $this;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
$shipment = $observer->getEvent()->getShipment();
|
| 129 |
+
if ($shipment) {
|
| 130 |
+
$shipped_date = Mage::app()->getRequest()->getParam('shipped_date');
|
| 131 |
+
$estimated_date = Mage::app()->getRequest()->getParam('estimated_date');
|
| 132 |
+
|
| 133 |
+
if ($shipped_date != "" && $estimated_date != ""){
|
| 134 |
+
|
| 135 |
+
$comment = 'Informações inseridas pelo Anymarket:<br>';
|
| 136 |
+
$comment .= '<b>Data de Entrega na Transportadora: </b>' . $shipped_date . '<br>';
|
| 137 |
+
$comment .= '<b>Data Estimada de Entrega: </b>' . $estimated_date . '<br>';
|
| 138 |
+
|
| 139 |
+
$shipment->addComment($comment, "");
|
| 140 |
+
$shipment->setEmailSent(false);
|
| 141 |
+
}
|
| 142 |
+
Mage::register('salesOrderShipmentSaveBeforeTriggered', true);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
return $this;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* @param $observer
|
| 150 |
+
*/
|
| 151 |
+
public function sendOrderAnyMarketObs($observer){
|
| 152 |
+
$order = new Mage_Sales_Model_Order();
|
| 153 |
+
$OrderID = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 154 |
+
$order->loadByIncrementId($OrderID);
|
| 155 |
+
$storeID = $order->getStoreId();
|
| 156 |
+
|
| 157 |
+
$this->prepareOrderForProc($storeID, "INSERT", $order, $OrderID);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* @param $observer
|
| 162 |
+
*
|
| 163 |
+
* @return $this
|
| 164 |
+
*/
|
| 165 |
public function updateOrderAnyMarketObs($observer){
|
| 166 |
+
if( $observer->getEvent()->getOrder() ) {
|
| 167 |
+
$storeID = $observer->getEvent()->getOrder()->getStoreId();
|
| 168 |
+
$OrderID = $observer->getEvent()->getOrder()->getIncrementId();
|
| 169 |
+
|
| 170 |
+
$order = new Mage_Sales_Model_Order();
|
| 171 |
+
$order->loadByIncrementId($OrderID);
|
| 172 |
+
|
| 173 |
+
$this->prepareOrderForProc($storeID, "UPDATE", $order, $OrderID);
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
/**
|
| 178 |
+
* @param $observer
|
| 179 |
+
*
|
| 180 |
+
* @return $this
|
| 181 |
+
*/
|
| 182 |
+
public function updateOrInsertOrderAnyMarketObs($observer){
|
| 183 |
+
if( $observer->getEvent()->getOrder() ) {
|
| 184 |
+
$storeID = $observer->getEvent()->getOrder()->getStoreId();
|
| 185 |
+
$OrderID = $observer->getEvent()->getOrder()->getIncrementId();
|
| 186 |
+
|
| 187 |
+
$order = new Mage_Sales_Model_Order();
|
| 188 |
+
$order->loadByIncrementId($OrderID);
|
| 189 |
+
|
| 190 |
+
$this->prepareOrderForProc($storeID, "BOTH", $order, $OrderID);
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* @param $storeID
|
| 196 |
+
* @param $order
|
| 197 |
+
* @param $typeProc
|
| 198 |
+
* @param $OrderID
|
| 199 |
+
*
|
| 200 |
+
* @return $this
|
| 201 |
+
*/
|
| 202 |
+
private function prepareOrderForProc($storeID, $typeProc, $order, $OrderID){
|
| 203 |
try {
|
| 204 |
if(Mage::registry('order_save_observer_executed_'.$OrderID )){
|
| 205 |
Mage::unregister( 'order_save_observer_executed_'.$OrderID );
|
| 206 |
return $this;
|
| 207 |
}
|
|
|
|
| 208 |
Mage::register('order_save_observer_executed_'.$OrderID, true);
|
|
|
|
| 209 |
|
| 210 |
if( $this->asyncMode($storeID) ){
|
| 211 |
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $OrderID, 'EXP', 'ORDER');
|
| 212 |
}else{
|
| 213 |
+
if( $typeProc == "INSERT" ){
|
| 214 |
+
Mage::helper('db1_anymarket/order')->sendOrderToAnyMarket($storeID, $order);
|
| 215 |
+
}else if( $typeProc == "UPDATE" ){
|
| 216 |
+
Mage::helper('db1_anymarket/order')->updateOrderAnymarket($storeID, $order);
|
| 217 |
+
}else{
|
| 218 |
+
Mage::helper('db1_anymarket/order')->updateOrCreateOrderAnyMarket($storeID, $order);
|
| 219 |
+
}
|
| 220 |
}
|
| 221 |
|
|
|
|
| 222 |
$orderItems = $order->getItemsCollection();
|
| 223 |
$filter = strtolower(Mage::getStoreConfig('anymarket_section/anymarket_attribute_group/anymarket_preco_field', $storeID));
|
| 224 |
foreach ($orderItems as $item){
|
| 232 |
Mage::helper('db1_anymarket/product')->updatePriceStockAnyMarket($storeID, $product_id, $stock->getQty(), $_product->getData($filter));
|
| 233 |
}
|
| 234 |
}
|
| 235 |
+
|
| 236 |
Mage::unregister( 'order_save_observer_executed_'.$OrderID );
|
| 237 |
} catch (Exception $e) {
|
| 238 |
Mage::unregister( 'order_save_observer_executed_'.$OrderID );
|
| 239 |
Mage::logException($e);
|
| 240 |
}
|
|
|
|
| 241 |
}
|
| 242 |
|
| 243 |
+
|
| 244 |
/**
|
| 245 |
* @param $observer
|
| 246 |
*/
|
| 257 |
|
| 258 |
/**
|
| 259 |
* @param $observer
|
| 260 |
+
*
|
| 261 |
+
* @return $this
|
| 262 |
*/
|
| 263 |
public function catalogInventorySave($observer){
|
| 264 |
$ImportOrderSession = Mage::getSingleton('core/session')->getImportOrdersVariable();
|
app/code/community/DB1/AnyMarket/Model/PaymentMethod.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketattributes/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketbrands/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketcategories/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketimage.php
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 Image resource model
|
| 19 |
+
*
|
| 20 |
+
* @category DB1
|
| 21 |
+
* @package DB1_AnyMarket
|
| 22 |
+
|
| 23 |
+
*/
|
| 24 |
+
class DB1_AnyMarket_Model_Resource_Anymarketimage 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/anymarketimage', 'entity_id');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* Perform operations after object load
|
| 40 |
+
*
|
| 41 |
+
* @access public
|
| 42 |
+
* @param Mage_Core_Model_Abstract $object
|
| 43 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketimage
|
| 44 |
+
*
|
| 45 |
+
*/
|
| 46 |
+
protected function _afterLoad(Mage_Core_Model_Abstract $object)
|
| 47 |
+
{
|
| 48 |
+
return parent::_afterLoad($object);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* Assign anymarket image to store views
|
| 53 |
+
*
|
| 54 |
+
* @access protected
|
| 55 |
+
* @param Mage_Core_Model_Abstract $object
|
| 56 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketimage
|
| 57 |
+
*
|
| 58 |
+
*/
|
| 59 |
+
protected function _afterSave(Mage_Core_Model_Abstract $object)
|
| 60 |
+
{
|
| 61 |
+
return parent::_afterSave($object);
|
| 62 |
+
}}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketimage/Collection.php
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_Anymarketimage_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/anymarketimage');
|
| 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_Anymarketimage_Collection
|
| 48 |
+
*
|
| 49 |
+
*/
|
| 50 |
+
public function addStoreFilter($store, $withAdmin = true)
|
| 51 |
+
{
|
| 52 |
+
return $this;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Join store relation table if there is store filter
|
| 57 |
+
*
|
| 58 |
+
* @access protected
|
| 59 |
+
* @return DB1_AnyMarket_Model_Resource_Anymarketimage_Collection
|
| 60 |
+
*
|
| 61 |
+
*/
|
| 62 |
+
protected function _renderFiltersBefore()
|
| 63 |
+
{
|
| 64 |
+
return parent::_renderFiltersBefore();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* get anymarket log as array
|
| 69 |
+
*
|
| 70 |
+
* @access protected
|
| 71 |
+
* @param string $valueField
|
| 72 |
+
* @param string $labelField
|
| 73 |
+
* @param array $additional
|
| 74 |
+
* @return array
|
| 75 |
+
*
|
| 76 |
+
*/
|
| 77 |
+
protected function _toOptionArray($valueField='entity_id', $labelField='id_image', $additional=array())
|
| 78 |
+
{
|
| 79 |
+
return parent::_toOptionArray($valueField, $labelField, $additional);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* get options hash
|
| 84 |
+
*
|
| 85 |
+
* @access protected
|
| 86 |
+
* @param string $valueField
|
| 87 |
+
* @param string $labelField
|
| 88 |
+
* @return array
|
| 89 |
+
*
|
| 90 |
+
*/
|
| 91 |
+
protected function _toOptionHash($valueField='entity_id', $labelField='id_image')
|
| 92 |
+
{
|
| 93 |
+
return parent::_toOptionHash($valueField, $labelField);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* Get SQL for get record count.
|
| 98 |
+
* Extra GROUP BY strip added.
|
| 99 |
+
*
|
| 100 |
+
* @access public
|
| 101 |
+
* @return Varien_Db_Select
|
| 102 |
+
*
|
| 103 |
+
*/
|
| 104 |
+
public function getSelectCountSql()
|
| 105 |
+
{
|
| 106 |
+
$countSelect = parent::getSelectCountSql();
|
| 107 |
+
$countSelect->reset(Zend_Db_Select::GROUP);
|
| 108 |
+
return $countSelect;
|
| 109 |
+
}
|
| 110 |
+
}
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketlog/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketorders/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketproducts/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Anymarketqueue/Collection.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/Resource/Setup.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Group/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Street/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Customer/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Booleantp/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Price/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Product/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Attributes/Set/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Categories/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/General/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Logs/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Massunit/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Measurementunit/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Orders/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/Model/System/Config/Source/Typesync/Order/Values.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketattributesController.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketbrandsController.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketcategoriesController.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketlogController.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketordersController.php
CHANGED
|
@@ -95,14 +95,14 @@ class DB1_AnyMarket_Adminhtml_Anymarket_AnymarketordersController extends DB1_An
|
|
| 95 |
}
|
| 96 |
|
| 97 |
if($anymarketorders->getData('nmo_status_int') == 'ERROR 01'){
|
| 98 |
-
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->
|
| 99 |
}else if($anymarketorders->getData('nmo_status_int') == 'ERROR 02'){
|
| 100 |
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->getNmoIdOrder(), 'EXP', 'ORDER');
|
| 101 |
}else{
|
| 102 |
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', Mage::app()->getStore()->getId());
|
| 103 |
if($ConfigOrder == 1){ //IMPORT
|
| 104 |
if($anymarketorders->getNmoIdAnymarket() != ''){
|
| 105 |
-
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->
|
| 106 |
}
|
| 107 |
}else{ //EXPORT
|
| 108 |
if($anymarketorders->getNmoIdOrder()){
|
|
@@ -144,7 +144,7 @@ class DB1_AnyMarket_Adminhtml_Anymarket_AnymarketordersController extends DB1_An
|
|
| 144 |
}
|
| 145 |
|
| 146 |
if($anymarketorders->getNmoIdAnymarket() != '') {
|
| 147 |
-
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->
|
| 148 |
}
|
| 149 |
}
|
| 150 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 95 |
}
|
| 96 |
|
| 97 |
if($anymarketorders->getData('nmo_status_int') == 'ERROR 01'){
|
| 98 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->getNmoIdSeqAnymarket(), 'IMP', 'ORDER');
|
| 99 |
}else if($anymarketorders->getData('nmo_status_int') == 'ERROR 02'){
|
| 100 |
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->getNmoIdOrder(), 'EXP', 'ORDER');
|
| 101 |
}else{
|
| 102 |
$ConfigOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', Mage::app()->getStore()->getId());
|
| 103 |
if($ConfigOrder == 1){ //IMPORT
|
| 104 |
if($anymarketorders->getNmoIdAnymarket() != ''){
|
| 105 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->getNmoIdSeqAnymarket(), 'IMP', 'ORDER');
|
| 106 |
}
|
| 107 |
}else{ //EXPORT
|
| 108 |
if($anymarketorders->getNmoIdOrder()){
|
| 144 |
}
|
| 145 |
|
| 146 |
if($anymarketorders->getNmoIdAnymarket() != '') {
|
| 147 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $anymarketorders->getNmoIdSeqAnymarket(), 'IMP', 'ORDER');
|
| 148 |
}
|
| 149 |
}
|
| 150 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketproductsController.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/Anymarket/AnymarketqueueController.php
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/controllers/Adminhtml/AnymarketController.php
CHANGED
|
@@ -42,10 +42,6 @@ class DB1_Anymarket_Adminhtml_AnymarketController extends Mage_Adminhtml_Control
|
|
| 42 |
if ($ConfigDescProd == 'a:0:{}') {
|
| 43 |
array_push($errors, " Configuração de Descrição Inválida.");
|
| 44 |
}
|
| 45 |
-
$STATUSIMPORT = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_stauts_order_field', $storeID);
|
| 46 |
-
if( $STATUSIMPORT == null ){
|
| 47 |
-
array_push($errors, " Não ha nada configurado em Status do Pedido.");
|
| 48 |
-
}
|
| 49 |
$StatusOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_status_mg_am_field', $storeID);
|
| 50 |
if ($StatusOrder == 'a:0:{}') {
|
| 51 |
array_push($errors, " Não ha nada configurado em Status Magento-Anymarket.");
|
| 42 |
if ($ConfigDescProd == 'a:0:{}') {
|
| 43 |
array_push($errors, " Configuração de Descrição Inválida.");
|
| 44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
$StatusOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_status_mg_am_field', $storeID);
|
| 46 |
if ($StatusOrder == 'a:0:{}') {
|
| 47 |
array_push($errors, " Não ha nada configurado em Status Magento-Anymarket.");
|
app/code/community/DB1/AnyMarket/controllers/IndexController.php
CHANGED
|
@@ -11,7 +11,6 @@ class DB1_AnyMarket_IndexController extends Mage_Core_Controller_Front_Action {
|
|
| 11 |
$anymarketlog->setLogJson(file_get_contents('php://input'));
|
| 12 |
$anymarketlog->setStatus("0");
|
| 13 |
$anymarketlog->save();
|
| 14 |
-
sleep(rand(5,25));
|
| 15 |
|
| 16 |
$allStores = Mage::helper('db1_anymarket')->getTokenByOi( $value->content->oi );
|
| 17 |
if( !empty($allStores) ) {
|
|
@@ -21,72 +20,87 @@ class DB1_AnyMarket_IndexController extends Mage_Core_Controller_Front_Action {
|
|
| 21 |
|
| 22 |
if ($TOKEN != '') {
|
| 23 |
if ($value->type == 'ORDER') {
|
|
|
|
|
|
|
|
|
|
| 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 |
} elseif ($value->type == 'TRANSMISSION') {
|
| 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 |
-
$JSON = json_encode($listTransmissions);
|
| 85 |
-
$sincMode = Mage::getStoreConfig('anymarket_section/anymarket_general_group/anymarket_operation_type_field', $storeID);
|
| 86 |
-
if( $sincMode ) {
|
| 87 |
-
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $value->content->id, 'IMP', 'PRODUCT');
|
| 88 |
-
echo "Adicionado na fila Magento.";
|
| 89 |
-
}else{
|
| 90 |
$transRet = Mage::helper('db1_anymarket/product')->getSpecificFeedProduct($storeID, json_decode($JSON), $headers, $HOST);
|
| 91 |
echo $transRet;
|
| 92 |
}
|
| 11 |
$anymarketlog->setLogJson(file_get_contents('php://input'));
|
| 12 |
$anymarketlog->setStatus("0");
|
| 13 |
$anymarketlog->save();
|
|
|
|
| 14 |
|
| 15 |
$allStores = Mage::helper('db1_anymarket')->getTokenByOi( $value->content->oi );
|
| 16 |
if( !empty($allStores) ) {
|
| 20 |
|
| 21 |
if ($TOKEN != '') {
|
| 22 |
if ($value->type == 'ORDER') {
|
| 23 |
+
$sincMode = Mage::getStoreConfig('anymarket_section/anymarket_general_group/anymarket_operation_type_imp_field', $storeID);
|
| 24 |
+
if( $sincMode == "1" ) {
|
| 25 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $value->content->id, 'IMP', 'ORDER');
|
| 26 |
|
| 27 |
+
echo "Adicionado na fila Magento.";
|
| 28 |
+
}else {
|
| 29 |
+
if (Mage::registry('callback_order_executed_' . $value->content->id)) {
|
| 30 |
+
Mage::unregister('callback_order_executed_' . $value->content->id);
|
| 31 |
+
return $this;
|
| 32 |
+
}
|
| 33 |
+
Mage::register('callback_order_executed_' . $value->content->id, true);
|
| 34 |
+
|
| 35 |
+
try {
|
| 36 |
+
$cache = Mage::app()->getCache();
|
| 37 |
+
|
| 38 |
+
$lastProcOrder = $cache->load('order_' . $value->content->id);
|
| 39 |
+
$lastProc = true;
|
| 40 |
+
if ($lastProcOrder != null) {
|
| 41 |
+
$dateOld = new DateTime(date('y-m-d H:i:s', strtotime($lastProcOrder)));
|
| 42 |
+
$dateNew = new DateTime(date('y-m-d H:i:s'));
|
| 43 |
+
|
| 44 |
+
$difDate = $dateOld->diff($dateNew);
|
| 45 |
+
if ($difDate->h <= 0 && $difDate->i <= 0 && $difDate->s <= 20) {
|
| 46 |
+
$lastProc = false;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
if ($lastProc) {
|
| 51 |
+
$cache->save(date('y-m-d H:i:s'), 'order_' . $value->content->id, array($value->content->id), 60 * 60);
|
| 52 |
+
Mage::helper('db1_anymarket/order')->getSpecificOrderFromAnyMarket($value->content->id, "notoken", $storeID);
|
| 53 |
+
}
|
| 54 |
+
Mage::unregister('callback_order_executed_' . $value->content->id);
|
| 55 |
+
|
| 56 |
+
} catch (Exception $e) {
|
| 57 |
+
echo "Erro ao inserir Pedido, verificar os logs do Magento";
|
| 58 |
+
Mage::unregister('callback_order_executed_' . $value->content->id);
|
| 59 |
+
Mage::logException($e);
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
} elseif ($value->type == 'TRANSMISSION') {
|
| 63 |
+
$sincMode = Mage::getStoreConfig('anymarket_section/anymarket_general_group/anymarket_operation_type_imp_field', $storeID);
|
| 64 |
+
if( $sincMode == "1" ) {
|
| 65 |
+
$typeSincProd = Mage::getStoreConfig('anymarket_section/anymarket_integration_prod_group/anymarket_type_prod_sync_field', $storeID);
|
| 66 |
+
if($typeSincProd == "1") {
|
| 67 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $value->content->id, 'IMP', 'PRODUCT');
|
| 68 |
+
}else{
|
| 69 |
+
$typeSincOrder = Mage::getStoreConfig('anymarket_section/anymarket_integration_order_group/anymarket_type_order_sync_field', $storeID);
|
| 70 |
+
if( $typeSincOrder == "1" ){
|
| 71 |
+
Mage::helper('db1_anymarket/queue')->addQueue($storeID, $value->content->id, 'IMP', 'STOCK');
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
echo "Adicionado na fila Magento.";
|
| 75 |
+
}else{
|
| 76 |
+
$listTransmissions = array();
|
| 77 |
|
| 78 |
+
if( !Mage::helper('db1_anymarket/product')->validateCallbackReceiver($storeID, $value->content->id) ){
|
| 79 |
+
$anymarketlog = Mage::getModel('db1_anymarket/anymarketlog');
|
| 80 |
+
$anymarketlog->setLogDesc('Callback Rejected');
|
| 81 |
+
$anymarketlog->setLogJson(file_get_contents('php://input'));
|
| 82 |
+
$anymarketlog->setStatus("0");
|
| 83 |
+
$anymarketlog->save();
|
| 84 |
|
| 85 |
+
return $this;
|
| 86 |
+
}
|
| 87 |
|
| 88 |
+
$HOST = Mage::getStoreConfig('anymarket_section/anymarket_acesso_group/anymarket_host_field', $storeID);
|
| 89 |
|
| 90 |
+
$headers = array(
|
| 91 |
+
"Content-type: application/json",
|
| 92 |
+
"Accept: */*",
|
| 93 |
+
"gumgaToken: " . $TOKEN
|
| 94 |
+
);
|
| 95 |
|
| 96 |
+
array_push($listTransmissions, array(
|
| 97 |
+
"id" => $value->content->id,
|
| 98 |
+
"token" => "notoken"
|
| 99 |
+
)
|
| 100 |
+
);
|
| 101 |
+
|
| 102 |
+
$JSON = json_encode($listTransmissions);
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
$transRet = Mage::helper('db1_anymarket/product')->getSpecificFeedProduct($storeID, json_decode($JSON), $headers, $HOST);
|
| 105 |
echo $transRet;
|
| 106 |
}
|
app/code/community/DB1/AnyMarket/etc/adminhtml.xml
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/etc/api.xml
CHANGED
|
File without changes
|
app/code/community/DB1/AnyMarket/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<DB1_AnyMarket>
|
| 5 |
-
<version>2.
|
| 6 |
</DB1_AnyMarket>
|
| 7 |
</modules>
|
| 8 |
<global>
|
|
@@ -85,6 +85,9 @@
|
|
| 85 |
<anymarketbrands>
|
| 86 |
<table>db1_anymarket_anymarketbrands</table>
|
| 87 |
</anymarketbrands>
|
|
|
|
|
|
|
|
|
|
| 88 |
<anymarketlog_store>
|
| 89 |
<table>db1_anymarket_anymarketlog_store</table>
|
| 90 |
</anymarketlog_store>
|
|
@@ -122,17 +125,6 @@
|
|
| 122 |
</observers>
|
| 123 |
</admin_system_config_changed_section_anymarket_section>
|
| 124 |
|
| 125 |
-
<sales_order_save_commit_after>
|
| 126 |
-
<observers>
|
| 127 |
-
<sales_order_save_commit_after_handler>
|
| 128 |
-
<type>model</type>
|
| 129 |
-
<class>db1_anymarket/observer</class>
|
| 130 |
-
<method>updateOrderAnyMarketObs</method>
|
| 131 |
-
<args></args>
|
| 132 |
-
</sales_order_save_commit_after_handler>
|
| 133 |
-
</observers>
|
| 134 |
-
</sales_order_save_commit_after>
|
| 135 |
-
|
| 136 |
<!-- CATEGORIA -->
|
| 137 |
<catalog_category_save_commit_after>
|
| 138 |
<observers>
|
|
@@ -185,14 +177,26 @@
|
|
| 185 |
</catalog_product_delete_after>
|
| 186 |
|
| 187 |
<!-- ORDER -->
|
| 188 |
-
<
|
| 189 |
<observers>
|
| 190 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
<class>db1_anymarket/observer</class>
|
| 192 |
<method>updateOrderAnyMarketObs</method>
|
| 193 |
-
|
|
|
|
| 194 |
</observers>
|
| 195 |
-
</
|
| 196 |
|
| 197 |
<!-- ESTOQUE -->
|
| 198 |
<cataloginventory_stock_item_save_commit_after>
|
|
@@ -240,8 +244,15 @@
|
|
| 240 |
</observers>
|
| 241 |
</sales_order_creditmemo_save_after>
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
</events>
|
| 244 |
-
|
| 245 |
</global>
|
| 246 |
<default>
|
| 247 |
<queue_qty>
|
|
@@ -271,6 +282,11 @@
|
|
| 271 |
<anymarket_type_order_sync_field>1</anymarket_type_order_sync_field>
|
| 272 |
</anymarket_integration_order_group>
|
| 273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
<anymarket_attribute_group>
|
| 275 |
<anymarket_customer_group_field>1</anymarket_customer_group_field>
|
| 276 |
<anymarket_doc_type_field>taxvat</anymarket_doc_type_field>
|
|
@@ -322,12 +338,15 @@
|
|
| 322 |
<schedule><cron_expr>*/15 * * * *</cron_expr></schedule> <!-- 15 min -->
|
| 323 |
<run><model>db1_anymarket/cron::executeQueue</model></run>
|
| 324 |
</db1_anymarket_execqueue>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
</jobs>
|
| 326 |
</crontab>
|
| 327 |
<!-- CRON -->
|
| 328 |
|
| 329 |
<adminhtml>
|
| 330 |
-
|
| 331 |
<layout>
|
| 332 |
<updates>
|
| 333 |
<db1_anymarket>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<DB1_AnyMarket>
|
| 5 |
+
<version>2.12.1</version>
|
| 6 |
</DB1_AnyMarket>
|
| 7 |
</modules>
|
| 8 |
<global>
|
| 85 |
<anymarketbrands>
|
| 86 |
<table>db1_anymarket_anymarketbrands</table>
|
| 87 |
</anymarketbrands>
|
| 88 |
+
<anymarketimage>
|
| 89 |
+
<table>db1_anymarket_anymarketimage</table>
|
| 90 |
+
</anymarketimage>
|
| 91 |
<anymarketlog_store>
|
| 92 |
<table>db1_anymarket_anymarketlog_store</table>
|
| 93 |
</anymarketlog_store>
|
| 125 |
</observers>
|
| 126 |
</admin_system_config_changed_section_anymarket_section>
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
<!-- CATEGORIA -->
|
| 129 |
<catalog_category_save_commit_after>
|
| 130 |
<observers>
|
| 177 |
</catalog_product_delete_after>
|
| 178 |
|
| 179 |
<!-- ORDER -->
|
| 180 |
+
<checkout_onepage_controller_success_action>
|
| 181 |
<observers>
|
| 182 |
+
<sales_order_save_commit_after_handler>
|
| 183 |
+
<class>db1_anymarket/observer</class>
|
| 184 |
+
<method>sendOrderAnyMarketObs</method>
|
| 185 |
+
</sales_order_save_commit_after_handler>
|
| 186 |
+
</observers>
|
| 187 |
+
</checkout_onepage_controller_success_action>
|
| 188 |
+
|
| 189 |
+
<!-- ORDER UPDATE -->
|
| 190 |
+
<sales_order_save_commit_after>
|
| 191 |
+
<observers>
|
| 192 |
+
<sales_order_save_commit_after_handler>
|
| 193 |
+
<type>model</type>
|
| 194 |
<class>db1_anymarket/observer</class>
|
| 195 |
<method>updateOrderAnyMarketObs</method>
|
| 196 |
+
<args></args>
|
| 197 |
+
</sales_order_save_commit_after_handler>
|
| 198 |
</observers>
|
| 199 |
+
</sales_order_save_commit_after>
|
| 200 |
|
| 201 |
<!-- ESTOQUE -->
|
| 202 |
<cataloginventory_stock_item_save_commit_after>
|
| 244 |
</observers>
|
| 245 |
</sales_order_creditmemo_save_after>
|
| 246 |
|
| 247 |
+
<sales_order_shipment_save_before>
|
| 248 |
+
<observers>
|
| 249 |
+
<db1_anymarket>
|
| 250 |
+
<class>db1_anymarket/observer</class>
|
| 251 |
+
<method>saveShippingObs</method>
|
| 252 |
+
</db1_anymarket>
|
| 253 |
+
</observers>
|
| 254 |
+
</sales_order_shipment_save_before>
|
| 255 |
</events>
|
|
|
|
| 256 |
</global>
|
| 257 |
<default>
|
| 258 |
<queue_qty>
|
| 282 |
<anymarket_type_order_sync_field>1</anymarket_type_order_sync_field>
|
| 283 |
</anymarket_integration_order_group>
|
| 284 |
|
| 285 |
+
<anymarket_general_group>
|
| 286 |
+
<anymarket_operation_type_field>0</anymarket_operation_type_field>
|
| 287 |
+
<anymarket_operation_type_imp_field>0</anymarket_operation_type_imp_field>
|
| 288 |
+
</anymarket_general_group>
|
| 289 |
+
|
| 290 |
<anymarket_attribute_group>
|
| 291 |
<anymarket_customer_group_field>1</anymarket_customer_group_field>
|
| 292 |
<anymarket_doc_type_field>taxvat</anymarket_doc_type_field>
|
| 338 |
<schedule><cron_expr>*/15 * * * *</cron_expr></schedule> <!-- 15 min -->
|
| 339 |
<run><model>db1_anymarket/cron::executeQueue</model></run>
|
| 340 |
</db1_anymarket_execqueue>
|
| 341 |
+
<db1_anymarket_execorderwitherror>
|
| 342 |
+
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule> <!-- 5 min -->
|
| 343 |
+
<run><model>db1_anymarket/cron::sincOrdersWithErrors</model></run>
|
| 344 |
+
</db1_anymarket_execorderwitherror>
|
| 345 |
</jobs>
|
| 346 |
</crontab>
|
| 347 |
<!-- CRON -->
|
| 348 |
|
| 349 |
<adminhtml>
|
|
|
|
| 350 |
<layout>
|
| 351 |
<updates>
|
| 352 |
<db1_anymarket>
|
app/code/community/DB1/AnyMarket/etc/system.xml
CHANGED
|
@@ -93,20 +93,39 @@
|
|
| 93 |
<show_in_store>1</show_in_store>
|
| 94 |
<fields>
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
<anymarket_operation_type_field>
|
| 97 |
-
<label>
|
| 98 |
<frontend_type>select</frontend_type>
|
| 99 |
<source_model>db1_anymarket/system_config_source_general_values</source_model>
|
| 100 |
-
<sort_order>
|
| 101 |
<show_in_default>0</show_in_default>
|
| 102 |
<show_in_website>0</show_in_website>
|
| 103 |
<show_in_store>1</show_in_store>
|
| 104 |
</anymarket_operation_type_field>
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
<anymarket_header_validation_field>
|
| 107 |
<label>Validações</label>
|
| 108 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 109 |
-
<sort_order>
|
| 110 |
<show_in_default>0</show_in_default>
|
| 111 |
<show_in_website>0</show_in_website>
|
| 112 |
<show_in_store>1</show_in_store>
|
|
@@ -116,7 +135,7 @@
|
|
| 116 |
<label>Check the configurations</label>
|
| 117 |
<frontend_type>Button</frontend_type>
|
| 118 |
<frontend_model>db1_anymarket/adminhtml_system_config_form_buttoncheckconfig</frontend_model>
|
| 119 |
-
<sort_order>
|
| 120 |
<show_in_default>0</show_in_default>
|
| 121 |
<show_in_website>0</show_in_website>
|
| 122 |
<show_in_store>1</show_in_store>
|
|
@@ -831,17 +850,6 @@
|
|
| 831 |
<show_in_store>1</show_in_store>
|
| 832 |
<fields>
|
| 833 |
|
| 834 |
-
<anymarket_estimate_date_field translate="label tooltip comment">
|
| 835 |
-
<label>Dias adicionais Data Estimada de Entrega</label>
|
| 836 |
-
<sort_order>0</sort_order>
|
| 837 |
-
<comment>Caso não seja informado, enviará 10 dias adicionais.</comment>
|
| 838 |
-
<tooltip>Quantidade de dias que será adicionada a data de envio para o campo Data Estimada.</tooltip>
|
| 839 |
-
<show_in_default>0</show_in_default>
|
| 840 |
-
<show_in_website>0</show_in_website>
|
| 841 |
-
<show_in_store>1</show_in_store>
|
| 842 |
-
<frontend_type>text</frontend_type>
|
| 843 |
-
</anymarket_estimate_date_field>
|
| 844 |
-
|
| 845 |
<anymarket_header_order_field>
|
| 846 |
<label>Fluxo de Integração</label>
|
| 847 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
|
@@ -862,19 +870,10 @@
|
|
| 862 |
<source_model>db1_anymarket/system_config_source_typesync_order_values</source_model>
|
| 863 |
</anymarket_type_order_sync_field>
|
| 864 |
|
| 865 |
-
<anymarket_header_order_imp_field>
|
| 866 |
-
<label>Status a serem importados do Anymarket</label>
|
| 867 |
-
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 868 |
-
<sort_order>3</sort_order>
|
| 869 |
-
<show_in_default>0</show_in_default>
|
| 870 |
-
<show_in_website>0</show_in_website>
|
| 871 |
-
<show_in_store>2</show_in_store>
|
| 872 |
-
</anymarket_header_order_imp_field>
|
| 873 |
-
|
| 874 |
<anymarket_create_reg_pay_field translate="label comment">
|
| 875 |
<label>Create payment record when importing paid</label>
|
| 876 |
<comment>By checking to yes, when it is imported into an application status paid in Anymarket, a record in Invoice will be created, remember to link a status that allows billing with PAGO.</comment>
|
| 877 |
-
<sort_order>
|
| 878 |
<show_in_default>0</show_in_default>
|
| 879 |
<show_in_website>0</show_in_website>
|
| 880 |
<show_in_store>1</show_in_store>
|
|
@@ -882,21 +881,10 @@
|
|
| 882 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 883 |
</anymarket_create_reg_pay_field>
|
| 884 |
|
| 885 |
-
<anymarket_stauts_order_field translate="label tooltip comment">
|
| 886 |
-
<label>Status Order</label>
|
| 887 |
-
<comment>Status of orders that must be imported.</comment>
|
| 888 |
-
<frontend_type>multiselect</frontend_type>
|
| 889 |
-
<source_model>db1_anymarket/system_config_source_orders_values</source_model>
|
| 890 |
-
<sort_order>5</sort_order>
|
| 891 |
-
<show_in_default>0</show_in_default>
|
| 892 |
-
<show_in_website>0</show_in_website>
|
| 893 |
-
<show_in_store>1</show_in_store>
|
| 894 |
-
</anymarket_stauts_order_field>
|
| 895 |
-
|
| 896 |
<anymarket_header_am_mg_field>
|
| 897 |
<label>Anymarket para Magento</label>
|
| 898 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 899 |
-
<sort_order>
|
| 900 |
<show_in_default>0</show_in_default>
|
| 901 |
<show_in_website>0</show_in_website>
|
| 902 |
<show_in_store>2</show_in_store>
|
|
@@ -906,7 +894,7 @@
|
|
| 906 |
<label>Status Order (Anymarket to Magento)</label>
|
| 907 |
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
| 908 |
<frontend_model>db1_anymarket/system_config_source_orders_statusammg_values</frontend_model>
|
| 909 |
-
<sort_order>
|
| 910 |
<show_in_default>0</show_in_default>
|
| 911 |
<show_in_website>0</show_in_website>
|
| 912 |
<show_in_store>1</show_in_store>
|
|
@@ -916,7 +904,7 @@
|
|
| 916 |
<anymarket_header_mg_am_field>
|
| 917 |
<label>Magento para Anymarket</label>
|
| 918 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 919 |
-
<sort_order>
|
| 920 |
<show_in_default>0</show_in_default>
|
| 921 |
<show_in_website>0</show_in_website>
|
| 922 |
<show_in_store>2</show_in_store>
|
|
@@ -926,7 +914,7 @@
|
|
| 926 |
<label>Status Order (Magento to Anymarket)</label>
|
| 927 |
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
| 928 |
<frontend_model>db1_anymarket/system_config_source_orders_statusmgam_values</frontend_model>
|
| 929 |
-
<sort_order>
|
| 930 |
<show_in_default>0</show_in_default>
|
| 931 |
<show_in_website>0</show_in_website>
|
| 932 |
<show_in_store>1</show_in_store>
|
|
@@ -945,7 +933,7 @@
|
|
| 945 |
<comment>
|
| 946 |
<