Version Notes
0.0.9
- Refactored Code
- You can choose if attributes are always transfered or only on product creation
- Moved Test Connection to database connection details
- Renamed the configurations
- Added Sycn Products button to enable you to test it is working without waiting for cron
- Added Sycn Stock button to enable you to test it is working without waiting for cron
- Fixed bug for Magento installations with a prefix
0.0.5
* Product set can be configured from Admin. This also solves a problem when Magento's default attribute set was deleted.
* The warehouse that will track the stock can be selected from admin configuration.
* Images on Unicenta are tranfered to Magento when the Magento Product does not have any images.
0.0.4
Advanced log to identify database connection issues
0.0.3
First official public release
Release Info
Developer | asulpunto |
Extension | Asulpunto_Unicentaopos |
Version | 0.0.9 |
Comparing to | |
See all releases |
Code changes from version 0.0.5 to 0.0.9
- app/code/community/Asulpunto/Unicentaopos/Block/Adminhtml/System/Config/Form/Button.php +1 -1
- app/code/community/Asulpunto/Unicentaopos/Block/Adminhtml/System/Config/Form/Buttongetproducts.php +71 -0
- app/code/community/Asulpunto/Unicentaopos/Block/Adminhtml/System/Config/Form/Buttonstock.php +71 -0
- app/code/community/Asulpunto/Unicentaopos/Helper/Data.php +10 -0
- app/code/community/Asulpunto/Unicentaopos/Model/Orders.php +43 -0
- app/code/community/Asulpunto/Unicentaopos/Model/Productstock.php +285 -0
- app/code/community/Asulpunto/Unicentaopos/Model/Source/Attributes.php +29 -0
- app/code/community/Asulpunto/Unicentaopos/Model/Source/Transfer.php +19 -0
- app/code/community/Asulpunto/Unicentaopos/Model/Unicentaoposapi.php +48 -228
- app/code/community/Asulpunto/Unicentaopos/Model/Unicentaoposproductapi.php +0 -58
- app/code/community/Asulpunto/Unicentaopos/controllers/Adminhtml/UnicentaoposController.php +25 -0
- app/code/community/Asulpunto/Unicentaopos/etc/system.xml +104 -16
- app/design/adminhtml/default/default/template/asulpunto/unicentaopos/system/config/button.phtml +1 -1
- app/design/adminhtml/default/default/template/asulpunto/unicentaopos/system/config/buttongetproducts.phtml +42 -0
- app/design/adminhtml/default/default/template/asulpunto/unicentaopos/system/config/buttonstock.phtml +42 -0
- package.xml +16 -5
@@ -63,7 +63,7 @@ class Asulpunto_Unicentaopos_Block_Adminhtml_System_Config_Form_Button extends M
|
|
63 |
->setData(array(
|
64 |
'id' => 'asulpuntounicentaopos_button',
|
65 |
'label' => $this->helper('adminhtml')->__('Test Connection'),
|
66 |
-
'onclick' => 'javascript:
|
67 |
));
|
68 |
|
69 |
return $button->toHtml();
|
63 |
->setData(array(
|
64 |
'id' => 'asulpuntounicentaopos_button',
|
65 |
'label' => $this->helper('adminhtml')->__('Test Connection'),
|
66 |
+
'onclick' => 'javascript:unicentaoposcheck(); return false;'
|
67 |
));
|
68 |
|
69 |
return $button->toHtml();
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
+
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
+
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* @category Asulpunto
|
17 |
+
* @package Asulpunto_Unicentaopos
|
18 |
+
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
+
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Asulpunto_Unicentaopos_Block_Adminhtml_System_Config_Form_Buttongetproducts extends Mage_Adminhtml_Block_System_Config_Form_Field
|
24 |
+
{
|
25 |
+
/*
|
26 |
+
* Set template
|
27 |
+
*/
|
28 |
+
protected function _construct()
|
29 |
+
{
|
30 |
+
parent::_construct();
|
31 |
+
$this->setTemplate('asulpunto/unicentaopos/system/config/buttongetproducts.phtml');
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Return element html
|
36 |
+
*
|
37 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
41 |
+
{
|
42 |
+
return $this->_toHtml();
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Return ajax url for button
|
47 |
+
*
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getAjaxCheckUrl()
|
51 |
+
{
|
52 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_unicentaopos/sendproducts');
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Generate button html
|
57 |
+
*
|
58 |
+
* @return string
|
59 |
+
*/
|
60 |
+
public function getButtonHtml()
|
61 |
+
{
|
62 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
63 |
+
->setData(array(
|
64 |
+
'id' => 'asulpuntounicentaopos_buttongetproducts',
|
65 |
+
'label' => $this->helper('adminhtml')->__('Get uniCenta oPOS Products'),
|
66 |
+
'onclick' => 'javascript:unicentaoposproduct(); return false;'
|
67 |
+
));
|
68 |
+
|
69 |
+
return $button->toHtml();
|
70 |
+
}
|
71 |
+
}
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
+
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
+
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* @category Asulpunto
|
17 |
+
* @package Asulpunto_Unicentaopos
|
18 |
+
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
+
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Asulpunto_Unicentaopos_Block_Adminhtml_System_Config_Form_Buttonstock extends Mage_Adminhtml_Block_System_Config_Form_Field
|
24 |
+
{
|
25 |
+
/*
|
26 |
+
* Set template
|
27 |
+
*/
|
28 |
+
protected function _construct()
|
29 |
+
{
|
30 |
+
parent::_construct();
|
31 |
+
$this->setTemplate('asulpunto/unicentaopos/system/config/buttonstock.phtml');
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Return element html
|
36 |
+
*
|
37 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
41 |
+
{
|
42 |
+
return $this->_toHtml();
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Return ajax url for button
|
47 |
+
*
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getAjaxCheckUrl()
|
51 |
+
{
|
52 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_unicentaopos/stock');
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Generate button html
|
57 |
+
*
|
58 |
+
* @return string
|
59 |
+
*/
|
60 |
+
public function getButtonHtml()
|
61 |
+
{
|
62 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
63 |
+
->setData(array(
|
64 |
+
'id' => 'asulpuntounicentaopos_buttongetstock',
|
65 |
+
'label' => $this->helper('adminhtml')->__('Syncronise Stock'),
|
66 |
+
'onclick' => 'javascript:unicentaoposstock(); return false;'
|
67 |
+
));
|
68 |
+
|
69 |
+
return $button->toHtml();
|
70 |
+
}
|
71 |
+
}
|
@@ -58,5 +58,15 @@ class Asulpunto_Unicentaopos_Helper_Data extends Mage_Core_Helper_Abstract
|
|
58 |
}
|
59 |
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
}
|
58 |
}
|
59 |
|
60 |
|
61 |
+
public function getRowByCode($skucode){
|
62 |
+
$col=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection()->addFilter('sku',$skucode);
|
63 |
+
if ($col->count()>0){
|
64 |
+
$item= $col->getFirstItem();
|
65 |
+
return $item;
|
66 |
+
}
|
67 |
+
return false; //not found
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
|
72 |
}
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
+
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
+
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* @category Asulpunto
|
17 |
+
* @package Asulpunto_Unicentaopos
|
18 |
+
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
+
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Asulpunto_Unicentaopos_Model_Orders extends Mage_Core_Model_Abstract{
|
24 |
+
|
25 |
+
public function writeStockOrder($order){
|
26 |
+
$items=$order->getAllItems();
|
27 |
+
foreach ($items as $item){
|
28 |
+
if (!Mage::Helper('unicentaopos')->getRowByCode($item->getSku()))continue;
|
29 |
+
$oitem=Mage::getModel('unicentaopos/unicentaoposorderitem');
|
30 |
+
$oitem->setMagentoOrderId($order->getId());
|
31 |
+
$oitem->setMagentoIncrementId($order->getIncrementId());
|
32 |
+
$oitem->setSku($item->getSku());
|
33 |
+
$oitem->setQuantity($item->getQtyOrdered());
|
34 |
+
$oitem->setAction('-');
|
35 |
+
$oitem->setStockupdated(1);
|
36 |
+
$oitem->save();
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
}
|
@@ -0,0 +1,285 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
+
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
+
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* @category Asulpunto
|
17 |
+
* @package Asulpunto_Unicentaopos
|
18 |
+
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
+
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
|
23 |
+
class Asulpunto_Unicentaopos_Model_Productstock extends Mage_Core_Model_Abstract
|
24 |
+
{
|
25 |
+
private $_imageFolder='';
|
26 |
+
private $_UPPHash=array();
|
27 |
+
private $_UPS=array();
|
28 |
+
private $_NoImageProducts=array();
|
29 |
+
|
30 |
+
private $_cnf_longdescription='';
|
31 |
+
private $_cnf_shortdescription='';
|
32 |
+
private $_cnf_price='';
|
33 |
+
private $_cnf_name='';
|
34 |
+
private $_cnf_barcode_attribute='';
|
35 |
+
|
36 |
+
public function __construct() {
|
37 |
+
$this->_cnf_longdescription= Mage::getStoreConfig('asulpuntounicentaopos/attributes/longdescription');
|
38 |
+
$this->_cnf_shortdescription= Mage::getStoreConfig('asulpuntounicentaopos/attributes/shortdescription');
|
39 |
+
$this->_cnf_price= Mage::getStoreConfig('asulpuntounicentaopos/attributes/price');
|
40 |
+
$this->_cnf_name= Mage::getStoreConfig('asulpuntounicentaopos/attributes/name');
|
41 |
+
$this->_cnf_barcode_attribute=Mage::getStoreConfig('asulpuntounicentaopos/attributes/barcode');
|
42 |
+
parent::_construct();
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
public function setProductImage($image,$product){
|
47 |
+
if (empty($image)) return $product;
|
48 |
+
|
49 |
+
$col=$product->getMediaGalleryImages();
|
50 |
+
if (!is_null($col) && $col->getSize()>0) return $product; //We do not overwrite images. Never.
|
51 |
+
$name=trim($product->getSku());
|
52 |
+
$imageFolder=$this->getImageFolder();
|
53 |
+
$path=$imageFolder.DIRECTORY_SEPARATOR.$name.'.png';
|
54 |
+
$res=file_put_contents($path,$image);
|
55 |
+
if ($res===false){
|
56 |
+
Mage::log(__METHOD__."Cannot create image for $name in folder: $imageFolder ",null,"asulpunto_unicentaopos.log");
|
57 |
+
}else{
|
58 |
+
$product->addImageToMediaGallery($path, array('thumbnail','small_image','image'),true,false);
|
59 |
+
}
|
60 |
+
unset($image);
|
61 |
+
return $product;
|
62 |
+
}
|
63 |
+
|
64 |
+
private function getImageFolder(){
|
65 |
+
if (empty($this->_imageFolder)){
|
66 |
+
$media=Mage::getBaseDir('media');
|
67 |
+
$unicenta=$media.DIRECTORY_SEPARATOR.'unicenta';
|
68 |
+
if (!file_exists($unicenta)){
|
69 |
+
$res=mkdir($unicenta,0777);
|
70 |
+
if (!$res) $this->_imageFolder=Mage::getBaseDir('media');
|
71 |
+
}
|
72 |
+
$this->_imageFolder=$unicenta;
|
73 |
+
}
|
74 |
+
return $this->_imageFolder;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function saveMagentoProduct($row){
|
78 |
+
try
|
79 |
+
{
|
80 |
+
$ptype=$this->getProductType();
|
81 |
+
$newProduct=false;
|
82 |
+
$product = Mage::getModel('catalog/product');
|
83 |
+
if ($row->getMagentoProductId()){
|
84 |
+
$product = $product->load($row->getMagentoProductId());
|
85 |
+
}
|
86 |
+
|
87 |
+
if (!$product->getId()){
|
88 |
+
$product->setSku($row->getSku());
|
89 |
+
$product->setTypeId('simple');
|
90 |
+
$product->setAttributeSetId($ptype);
|
91 |
+
$product->setTaxClassId(1);
|
92 |
+
$product->setWeight(0.0);
|
93 |
+
$sData['qty']=$row->getStock();
|
94 |
+
if ($row->getStock()>0) $sData['is_in_stock']=1;
|
95 |
+
$product->setStockData($sData);
|
96 |
+
$newProduct=true;
|
97 |
+
}
|
98 |
+
|
99 |
+
//$product->setWebsiteIds(array(1));
|
100 |
+
$product=$this->_transferField($product,'name',$row->getName(),$this->_cnf_name,$newProduct);
|
101 |
+
$product=$this->_transferField($product,'description',$row->getLongdesc(),$this->_cnf_longdescription,$newProduct);
|
102 |
+
$product=$this->_transferField($product,'short_description',$row->getName(),$this->_cnf_shortdescription,$newProduct);
|
103 |
+
$product=$this->_transferField($product,'price',$row->getPrice(),$this->_cnf_price,$newProduct);
|
104 |
+
$product=$this->_transferField($product,$this->_cnf_barcode_attribute,$row->getBarcode(),Asulpunto_Unicentaopos_Model_Source_Transfer::TRANSFER_ALWAYS,$newProduct);
|
105 |
+
|
106 |
+
//$product->setName($row->getName());
|
107 |
+
//$product->setDescription();
|
108 |
+
//$product->setShortDescription($row->getName());
|
109 |
+
//$product->setPrice($row->getPrice());
|
110 |
+
if ($row->getInfoupdated()==2) $product=$this->setProductImage($row->getImage(),$product);
|
111 |
+
$product->save();
|
112 |
+
|
113 |
+
if ($newProduct) Mage::getModel('catalog/product_status')->updateProductStatus($product->getId(), 0, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
114 |
+
if ($row->getInfoupdated()==2) $this->setProductImage($row->getImage(),$product);
|
115 |
+
$row->setInfoupdated(0);
|
116 |
+
$row->setMagentoProductId($product->getId());
|
117 |
+
$row->save();
|
118 |
+
return $product->getId();
|
119 |
+
}
|
120 |
+
catch (exception $e)
|
121 |
+
{
|
122 |
+
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
123 |
+
}
|
124 |
+
unset($row);
|
125 |
+
return 0;
|
126 |
+
}
|
127 |
+
|
128 |
+
public function loadProductHash(){
|
129 |
+
$cols=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection();
|
130 |
+
foreach ($cols as $item){
|
131 |
+
$this->_UPPHash[$item->getSku()]=md5(
|
132 |
+
$item->getBarcode().'|'.
|
133 |
+
$item->getName().'|'.
|
134 |
+
$item->getLongdesc().'|'.
|
135 |
+
$item->getCost().'|'.
|
136 |
+
$item->getPrice()
|
137 |
+
);
|
138 |
+
}
|
139 |
+
unset($cols);
|
140 |
+
}
|
141 |
+
|
142 |
+
public function updateMagentoProducts(){
|
143 |
+
$col=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection()->addFieldToFilter('infoupdated',array('in' => array('1', '2')));
|
144 |
+
foreach ($col as $row){
|
145 |
+
$this->saveMagentoProduct($row);
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
public function updateMagentoStock(){
|
150 |
+
$col=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection()->addFilter('stockupdated',1);
|
151 |
+
foreach ($col as $row){
|
152 |
+
if ($row->getMagentoProductId()){
|
153 |
+
$product = Mage::getModel('catalog/product')->load($row->getMagentoProductId());
|
154 |
+
if ($product->getId()){
|
155 |
+
$sData=$product->getStockData();
|
156 |
+
$sData['qty']=$row->getStock();
|
157 |
+
if ($row->getStock()>0) {
|
158 |
+
$sData['is_in_stock']=1;
|
159 |
+
} else {
|
160 |
+
$sData['is_in_stock']=0;
|
161 |
+
}
|
162 |
+
$product->setStockData($sData);
|
163 |
+
$product->save();
|
164 |
+
}
|
165 |
+
}
|
166 |
+
$row->setStockupdated(0);
|
167 |
+
$row->save();
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
public function loadStock(){
|
172 |
+
$cols=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection();
|
173 |
+
foreach ($cols as $item){
|
174 |
+
$this->_UPS[$item->getSku()]=$item->getStock();
|
175 |
+
}
|
176 |
+
unset($cols);
|
177 |
+
}
|
178 |
+
|
179 |
+
|
180 |
+
|
181 |
+
private function getProductType(){
|
182 |
+
return Mage::getStoreConfig('asulpuntounicentaopos/tools/product_type');
|
183 |
+
}
|
184 |
+
|
185 |
+
public function getUnicentaProducts($row){
|
186 |
+
$updateNeeded=false;
|
187 |
+
$state=0;
|
188 |
+
|
189 |
+
$md5=md5(
|
190 |
+
$row['CODE'].'|'.
|
191 |
+
$row['NAME'].'|'.
|
192 |
+
$row['ATTRIBUTES'].'|'.
|
193 |
+
$row['PRICEBUY'].'|'.
|
194 |
+
$row['PRICESELL']
|
195 |
+
);
|
196 |
+
|
197 |
+
if (array_key_exists($row['REFERENCE'],$this->_UPPHash)){
|
198 |
+
//First Check Hashkey
|
199 |
+
if ($this->_UPPHash[$row['REFERENCE']]!=$md5){
|
200 |
+
$updateNeeded=true;
|
201 |
+
$state=1; //if 1 do not do image
|
202 |
+
$mageRow=Mage::Helper('unicentaopos')->getRowByCode($row['REFERENCE']);
|
203 |
+
}
|
204 |
+
}else{
|
205 |
+
$updateNeeded=true;
|
206 |
+
$state=2; //if 2 also create image
|
207 |
+
$mageRow=Mage::getModel('unicentaopos/unicentaoposproduct');
|
208 |
+
}
|
209 |
+
if ($updateNeeded){
|
210 |
+
$mageRow->setName($row['NAME']);
|
211 |
+
$mageRow->setSku($row['REFERENCE']);
|
212 |
+
$mageRow->setBarcode($row['CODE']);
|
213 |
+
$mageRow->setLongdesc($row['ATTRIBUTES']);
|
214 |
+
$mageRow->setCost($row['PRICEBUY']);
|
215 |
+
$mageRow->setPrice($row['PRICESELL']);
|
216 |
+
$mageRow->setStock($row['STOCKVOLUME']);
|
217 |
+
$mageRow->setImage($row['IMAGE']);
|
218 |
+
$mageRow->setInfoupdated($state);
|
219 |
+
$mageRow->save();
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
public function getUnicentaStock($row){
|
224 |
+
if (array_key_exists($row['REFERENCE'],$this->_UPS)){
|
225 |
+
if ($this->_UPS[$row['REFERENCE']]!=$row['UNITS']){
|
226 |
+
$mageRow=Mage::Helper('unicentaopos')->getRowByCode($row['REFERENCE']);
|
227 |
+
if ($mageRow){
|
228 |
+
$mageRow->setStock($row['UNITS']);
|
229 |
+
$mageRow->setStockupdated(1);
|
230 |
+
$mageRow->save();
|
231 |
+
}
|
232 |
+
}
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
public function noImageProducts(){
|
237 |
+
$collection=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection();
|
238 |
+
$collection->addFieldToFilter('image', array('null' => true));
|
239 |
+
foreach ($collection as $item){
|
240 |
+
$this->_NoImageProducts[$item->getSku()]=1;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
public function doImage($row){
|
245 |
+
if (empty($row['IMAGE'])) return true;
|
246 |
+
if (array_key_exists($row['REFERENCE'],$this->_NoImageProducts)){
|
247 |
+
$mageRow=Mage::Helper('unicentaopos')->getRowByCode($row['REFERENCE']);
|
248 |
+
$mageRow->setImage($row['IMAGE']);
|
249 |
+
$mageRow->setInfoupdated(2);
|
250 |
+
$mageRow->save();
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
|
256 |
+
private function _transferField($object,$name,$value,$config,$newMode){
|
257 |
+
if ($newMode){
|
258 |
+
if ($config==Asulpunto_Unicentaopos_Model_Source_Transfer::TRANSFER_ALWAYS || $config==Asulpunto_Unicentaopos_Model_Source_Transfer::TRANSFER_CREATE){
|
259 |
+
$arr=explode('_',$name);
|
260 |
+
$name='';
|
261 |
+
foreach($arr as $s){
|
262 |
+
$name=$name.ucfirst($name);
|
263 |
+
}
|
264 |
+
$f="set$name";
|
265 |
+
$object->$f($value);
|
266 |
+
}
|
267 |
+
}else{ //This is update mode
|
268 |
+
if ($config==Asulpunto_Unicentaopos_Model_Source_Transfer::TRANSFER_ALWAYS ){
|
269 |
+
$name=ucfirst($name);
|
270 |
+
$f="set$name";
|
271 |
+
$object->$f($value);
|
272 |
+
}
|
273 |
+
}
|
274 |
+
return $object;
|
275 |
+
}
|
276 |
+
|
277 |
+
|
278 |
+
public function configSim($cfg){
|
279 |
+
$this->_cnf_longdescription=$cfg;
|
280 |
+
$this->_cnf_shortdescription=$cfg;
|
281 |
+
$this->_cnf_price=$cfg;
|
282 |
+
$this->_cnf_name=$cfg;
|
283 |
+
}
|
284 |
+
|
285 |
+
}
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Asulpunto_Unicentaopos_Model_Source_Attributes
|
3 |
+
{
|
4 |
+
protected $_options;
|
5 |
+
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
$attributes = Mage::getModel('catalog/product')->getAttributes();
|
9 |
+
$attributeArray = array();
|
10 |
+
|
11 |
+
$attributeArray[] = array(
|
12 |
+
'label' => '-- Do Not Transfer --',
|
13 |
+
'value' => ''
|
14 |
+
);
|
15 |
+
|
16 |
+
foreach($attributes as $a){
|
17 |
+
foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {
|
18 |
+
|
19 |
+
//$attributeArray[$attributeName] = $attributeName;
|
20 |
+
$attributeArray[] = array(
|
21 |
+
'label' => $attributeName,
|
22 |
+
'value' => $attributeName
|
23 |
+
);
|
24 |
+
}
|
25 |
+
break;
|
26 |
+
}
|
27 |
+
return $attributeArray;
|
28 |
+
}
|
29 |
+
}
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Asulpunto_Unicentaopos_Model_Source_Transfer
|
3 |
+
{
|
4 |
+
const TRANSFER_ALWAYS='always';
|
5 |
+
const TRANSFER_CREATE='create';
|
6 |
+
const TRANSFER_NEVER='never';
|
7 |
+
|
8 |
+
protected $_options;
|
9 |
+
|
10 |
+
public function toOptionArray()
|
11 |
+
{
|
12 |
+
|
13 |
+
$list= array();
|
14 |
+
$list[]=array('value' => self::TRANSFER_ALWAYS, 'label' =>'Create & Update' );
|
15 |
+
$list[]=array('value' => self::TRANSFER_CREATE, 'label' =>'Create Only' );
|
16 |
+
$list[]=array('value' => self::TRANSFER_NEVER, 'label' =>'Never transfer' );
|
17 |
+
return $list;
|
18 |
+
}
|
19 |
+
}
|
@@ -22,9 +22,8 @@
|
|
22 |
|
23 |
class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstract
|
24 |
{
|
25 |
-
|
26 |
-
|
27 |
-
private $_NoImageProducts=array();
|
28 |
|
29 |
public function checkActivate(){
|
30 |
try{
|
@@ -42,133 +41,100 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
|
|
42 |
$error['login']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/login');
|
43 |
$error['password']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/password');
|
44 |
$error['name']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/dbname');
|
|
|
45 |
return json_encode($error);
|
46 |
}
|
47 |
|
48 |
-
public function cronProducts(){
|
49 |
try{
|
50 |
-
$
|
51 |
-
$
|
|
|
52 |
|
|
|
|
|
|
|
53 |
$db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
|
|
|
54 |
$sql="select * from `PRODUCTS`";
|
55 |
$rows=$db->query($sql);
|
56 |
|
57 |
foreach ($rows as $row){
|
58 |
-
$
|
59 |
-
$
|
60 |
}
|
61 |
-
$
|
62 |
}catch(Exception $e){
|
63 |
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
|
|
64 |
}
|
|
|
65 |
}
|
66 |
|
67 |
public function cronStock(){
|
68 |
try{
|
69 |
-
$
|
|
|
70 |
$loc=Mage::getStoreConfig('asulpuntounicentaopos/tools/location');
|
71 |
$db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
|
|
|
72 |
$sql="select b.REFERENCE as REFERENCE,a.UNITS as UNITS from `STOCKCURRENT` a , `PRODUCTS` b where a.PRODUCT=b.ID and location='$loc'";
|
|
|
73 |
$rows=$db->query($sql);
|
74 |
foreach ($rows as $row){
|
75 |
-
$
|
76 |
}
|
77 |
-
$
|
78 |
}catch(Exception $e){
|
79 |
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
|
|
80 |
}
|
|
|
81 |
}
|
82 |
|
83 |
-
private function _noImageProducts(){
|
84 |
-
$collection=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection();
|
85 |
-
$collection->addFieldToFilter('image', array('null' => true));
|
86 |
-
foreach ($collection as $item){
|
87 |
-
$this->_NoImageProducts[$item->getSku()]=1;
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
private function _doImage($row){
|
92 |
-
if (empty($row['IMAGE'])) return true;
|
93 |
-
if (array_key_exists($row['REFERENCE'],$this->_NoImageProducts)){
|
94 |
-
$mageRow=$this->_getRowByCode($row['REFERENCE']);
|
95 |
-
$mageRow->setImage($row['IMAGE']);
|
96 |
-
$mageRow->setInfoupdated(2);
|
97 |
-
$mageRow->save();
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
|
102 |
|
103 |
-
private function
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
$md5=md5(
|
108 |
-
$row['CODE'].'|'.
|
109 |
-
$row['NAME'].'|'.
|
110 |
-
$row['ATTRIBUTES'].'|'.
|
111 |
-
$row['PRICEBUY'].'|'.
|
112 |
-
$row['PRICESELL']
|
113 |
-
);
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
$
|
119 |
-
$
|
120 |
-
$
|
|
|
121 |
}
|
122 |
-
}
|
123 |
-
|
124 |
-
$state=2; //if 2 also create image
|
125 |
-
$mageRow=Mage::getModel('unicentaopos/unicentaoposproduct');
|
126 |
-
}
|
127 |
|
128 |
-
if ($updateNeeded){
|
129 |
-
$mageRow->setName($row['NAME']);
|
130 |
-
$mageRow->setSku($row['REFERENCE']);
|
131 |
-
$mageRow->setBarcode($row['CODE']);
|
132 |
-
$mageRow->setLongdesc($row['ATTRIBUTES']);
|
133 |
-
$mageRow->setCost($row['PRICEBUY']);
|
134 |
-
$mageRow->setPrice($row['PRICESELL']);
|
135 |
-
$mageRow->setStock($row['STOCKVOLUME']);
|
136 |
-
$mageRow->setImage($row['IMAGE']);
|
137 |
-
$mageRow->setInfoupdated($state);
|
138 |
-
$mageRow->save();
|
139 |
}
|
140 |
}
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
if ($this->_UPS[$row['REFERENCE']]!=$row['UNITS']){
|
145 |
-
$mageRow=$this->_getRowByCode($row['REFERENCE']);
|
146 |
-
if ($mageRow){
|
147 |
-
$mageRow->setStock($row['UNITS']);
|
148 |
-
$mageRow->setStockupdated(1);
|
149 |
-
$mageRow->save();
|
150 |
-
}
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
|
155 |
public function cronOrders(){
|
156 |
|
157 |
$maxorder=$this->getMaxOrderId();
|
158 |
$status=Mage::getStoreConfig('asulpuntounicentaopos/tools/orderstatus');
|
159 |
-
$
|
|
|
|
|
|
|
|
|
160 |
|
161 |
-
$sql="select entity_id from
|
162 |
status = '$status'
|
163 |
and a.entity_id > $maxorder
|
164 |
and a.entity_id not in
|
165 |
-
(select magento_order_id from
|
166 |
|
167 |
$res=$readCon->query($sql);
|
168 |
-
|
169 |
foreach($res as $row){
|
170 |
$order=Mage::getModel('sales/order')->load($row['entity_id']);
|
171 |
-
$
|
172 |
}
|
173 |
$this->_updateUnicentaStock();
|
174 |
}
|
@@ -185,153 +151,6 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
|
|
185 |
return $orderNo;
|
186 |
}
|
187 |
|
188 |
-
private function _writeStockOrder($order){
|
189 |
-
$items=$order->getAllItems();
|
190 |
-
foreach ($items as $item){
|
191 |
-
if (!$this->_getRowByCode($item->getSku()))continue;
|
192 |
-
$oitem=Mage::getModel('unicentaopos/unicentaoposorderitem');
|
193 |
-
$oitem->setMagentoOrderId($order->getId());
|
194 |
-
$oitem->setMagentoIncrementId($order->getIncrementId());
|
195 |
-
$oitem->setSku($item->getSku());
|
196 |
-
$oitem->setQuantity($item->getQtyOrdered());
|
197 |
-
$oitem->setAction('-');
|
198 |
-
$oitem->setStockupdated(1);
|
199 |
-
$oitem->save();
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
private function _updateUnicentaStock(){
|
204 |
-
$loc=Mage::getStoreConfig('asulpuntounicentaopos/tools/location');
|
205 |
-
$col=Mage::getModel('unicentaopos/unicentaoposorderitem')->getCollection()->addFilter('stockupdated',1);
|
206 |
-
|
207 |
-
try{
|
208 |
-
$db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
|
209 |
-
foreach($col as $item){
|
210 |
-
$sql="UPDATE `STOCKCURRENT` set UNITS=UNITS-{$item->getQuantity()} where PRODUCT=(SELECT ID FROM PRODUCTS WHERE REFERENCE='{$item->getSku()}') and location='$loc'";
|
211 |
-
$res=$db->query($sql);
|
212 |
-
$item->setStockupdated(0);
|
213 |
-
$item->save();
|
214 |
-
}
|
215 |
-
}catch(Exception $e){
|
216 |
-
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
private function _getRowByCode($skucode){
|
221 |
-
|
222 |
-
$col=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection()->addFilter('sku',$skucode);
|
223 |
-
if ($col->count()>0){
|
224 |
-
$item= $col->getFirstItem();
|
225 |
-
return $item;
|
226 |
-
}
|
227 |
-
|
228 |
-
return false; //not found
|
229 |
-
}
|
230 |
-
|
231 |
-
public function updateMagentoProducts(){
|
232 |
-
$col=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection()->addFieldToFilter('infoupdated',array('in' => array('1', '2')));
|
233 |
-
foreach ($col as $row){
|
234 |
-
$this->_saveMagentoProduct($row);
|
235 |
-
}
|
236 |
-
}
|
237 |
-
|
238 |
-
public function updateMagentoStock(){
|
239 |
-
$col=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection()->addFilter('stockupdated',1);
|
240 |
-
foreach ($col as $row){
|
241 |
-
if ($row->getMagentoProductId()){
|
242 |
-
$product = Mage::getModel('catalog/product')->load($row->getMagentoProductId());
|
243 |
-
if ($product->getId()){
|
244 |
-
$sData=$product->getStockData();
|
245 |
-
$sData['qty']=$row->getStock();
|
246 |
-
if ($row->getStock()>0) {
|
247 |
-
$sData['is_in_stock']=1;
|
248 |
-
} else {
|
249 |
-
$sData['is_in_stock']=0;
|
250 |
-
}
|
251 |
-
$product->setStockData($sData);
|
252 |
-
$product->save();
|
253 |
-
}
|
254 |
-
}
|
255 |
-
$row->setStockupdated(0);
|
256 |
-
$row->save();
|
257 |
-
}
|
258 |
-
}
|
259 |
-
|
260 |
-
|
261 |
-
private function _saveMagentoProduct($row){
|
262 |
-
try
|
263 |
-
{
|
264 |
-
$ptype=$this->getProductType();
|
265 |
-
$newProduct=false;
|
266 |
-
$product = Mage::getModel('catalog/product');
|
267 |
-
if ($row->getMagentoProductId()){
|
268 |
-
$product = $product->load($row->getMagentoProductId());
|
269 |
-
}
|
270 |
-
|
271 |
-
if (!$product->getId()){
|
272 |
-
$product->setSku($row->getSku());
|
273 |
-
$product->setTypeId('simple');
|
274 |
-
$product->setAttributeSetId($ptype);
|
275 |
-
$product->setTaxClassId(1);
|
276 |
-
$product->setWeight(0.0);
|
277 |
-
$sData['qty']=$row->getStock();
|
278 |
-
if ($row->getStock()>0) $sData['is_in_stock']=1;
|
279 |
-
$product->setStockData($sData);
|
280 |
-
$newProduct=true;
|
281 |
-
}
|
282 |
-
|
283 |
-
//$product->setWebsiteIds(array(1));
|
284 |
-
|
285 |
-
$product->setName($row->getName());
|
286 |
-
$product->setDescription($row->getLongdesc());
|
287 |
-
$product->setShortDescription($row->getName());
|
288 |
-
$sData=$product->getStockData($sData);
|
289 |
-
$product->setCostPrice($row->getCost());
|
290 |
-
$product->setPrice($row->getPrice());
|
291 |
-
if ($row->getInfoupdated()==2) $product=Mage::getModel('unicentaopos/unicentaoposproductapi')->setProductImage($row->getImage(),$product);
|
292 |
-
$product->save();
|
293 |
-
|
294 |
-
if ($newProduct) Mage::getModel('catalog/product_status')->updateProductStatus($product->getId(), 0, Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
|
295 |
-
if ($row->getInfoupdated()==2) Mage::getModel('unicentaopos/unicentaoposproductapi')->setProductImage($row->getImage(),$product);
|
296 |
-
$row->setInfoupdated(0);
|
297 |
-
$row->setMagentoProductId($product->getId());
|
298 |
-
$row->save();
|
299 |
-
return $product->getId();
|
300 |
-
}
|
301 |
-
catch (exception $e)
|
302 |
-
{
|
303 |
-
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
304 |
-
}
|
305 |
-
unset($row);
|
306 |
-
return 0;
|
307 |
-
}
|
308 |
-
|
309 |
-
private function _loadProductHash(){
|
310 |
-
$cols=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection();
|
311 |
-
foreach ($cols as $item){
|
312 |
-
$this->_UPPHash[$item->getSku()]=md5(
|
313 |
-
$item->getBarcode().'|'.
|
314 |
-
$item->getName().'|'.
|
315 |
-
$item->getLongdesc().'|'.
|
316 |
-
$item->getCost().'|'.
|
317 |
-
$item->getPrice()
|
318 |
-
);
|
319 |
-
}
|
320 |
-
unset($cols);
|
321 |
-
}
|
322 |
-
|
323 |
-
private function _loadStock(){
|
324 |
-
$cols=Mage::getModel('unicentaopos/unicentaoposproduct')->getCollection();
|
325 |
-
foreach ($cols as $item){
|
326 |
-
$this->_UPS[$item->getSku()]=$item->getStock();
|
327 |
-
}
|
328 |
-
unset($cols);
|
329 |
-
}
|
330 |
-
|
331 |
-
private function getProductType(){
|
332 |
-
return Mage::getStoreConfig('asulpuntounicentaopos/tools/product_type');
|
333 |
-
}
|
334 |
-
|
335 |
public function getLocations(){
|
336 |
try{
|
337 |
$ARR=array();
|
@@ -348,4 +167,5 @@ class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstr
|
|
348 |
}
|
349 |
|
350 |
|
|
|
351 |
}
|
22 |
|
23 |
class Asulpunto_Unicentaopos_Model_Unicentaoposapi extends Mage_Core_Model_Abstract
|
24 |
{
|
25 |
+
|
26 |
+
|
|
|
27 |
|
28 |
public function checkActivate(){
|
29 |
try{
|
41 |
$error['login']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/login');
|
42 |
$error['password']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/password');
|
43 |
$error['name']=Mage::getStoreConfig('asulpuntounicentaopos/unicentaconfig/dbname');
|
44 |
+
|
45 |
return json_encode($error);
|
46 |
}
|
47 |
|
48 |
+
public function cronProducts($mode=''){
|
49 |
try{
|
50 |
+
$ps=Mage::getModel('unicentaopos/productstock');
|
51 |
+
$ps->loadProductHash();//load a hash of history
|
52 |
+
$ps->noImageProducts();//load products without images so that if change is detected we load them.
|
53 |
|
54 |
+
if ($mode!=''){
|
55 |
+
$ps->configSim($mode);
|
56 |
+
}
|
57 |
$db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
|
58 |
+
if (is_null($db))return false;
|
59 |
$sql="select * from `PRODUCTS`";
|
60 |
$rows=$db->query($sql);
|
61 |
|
62 |
foreach ($rows as $row){
|
63 |
+
$ps->getUnicentaProducts($row);
|
64 |
+
$ps->doImage($row);
|
65 |
}
|
66 |
+
$ps->updateMagentoProducts();
|
67 |
}catch(Exception $e){
|
68 |
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
69 |
+
return false;
|
70 |
}
|
71 |
+
return true;
|
72 |
}
|
73 |
|
74 |
public function cronStock(){
|
75 |
try{
|
76 |
+
$ps=Mage::getModel('unicentaopos/productstock');
|
77 |
+
$ps->loadStock();
|
78 |
$loc=Mage::getStoreConfig('asulpuntounicentaopos/tools/location');
|
79 |
$db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
|
80 |
+
if (is_null($db)) return false;
|
81 |
$sql="select b.REFERENCE as REFERENCE,a.UNITS as UNITS from `STOCKCURRENT` a , `PRODUCTS` b where a.PRODUCT=b.ID and location='$loc'";
|
82 |
+
|
83 |
$rows=$db->query($sql);
|
84 |
foreach ($rows as $row){
|
85 |
+
$ps->getUnicentaStock($row);
|
86 |
}
|
87 |
+
$ps->updateMagentoStock();
|
88 |
}catch(Exception $e){
|
89 |
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
90 |
+
return false;
|
91 |
}
|
92 |
+
return true;
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
private function _updateUnicentaStock(){
|
97 |
+
$loc=Mage::getStoreConfig('asulpuntounicentaopos/tools/location');
|
98 |
+
$col=Mage::getModel('unicentaopos/unicentaoposorderitem')->getCollection()->addFilter('stockupdated',1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
try{
|
101 |
+
$db=Mage::Helper('unicentaopos')->getUnicentaOposConnection();
|
102 |
+
foreach($col as $item){
|
103 |
+
$sql="UPDATE `STOCKCURRENT` set UNITS=UNITS-{$item->getQuantity()} where PRODUCT=(SELECT ID FROM PRODUCTS WHERE REFERENCE='{$item->getSku()}') and location='$loc'";
|
104 |
+
$res=$db->query($sql);
|
105 |
+
$item->setStockupdated(0);
|
106 |
+
$item->save();
|
107 |
}
|
108 |
+
}catch(Exception $e){
|
109 |
+
Mage::log(__METHOD__.$e->getMessage(),null,"asulpunto_unicentaopos.log");
|
|
|
|
|
|
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
112 |
}
|
113 |
|
114 |
+
|
115 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
public function cronOrders(){
|
118 |
|
119 |
$maxorder=$this->getMaxOrderId();
|
120 |
$status=Mage::getStoreConfig('asulpuntounicentaopos/tools/orderstatus');
|
121 |
+
$resource = Mage::getSingleton('core/resource');
|
122 |
+
$readCon=$resource->getConnection('core_read');
|
123 |
+
|
124 |
+
$salesTable = $resource->getTableName('sales/order');
|
125 |
+
$aoiTable= $resource->getTableName('unicentaopos/unicentaoposorderitem');
|
126 |
|
127 |
+
$sql="select entity_id from $salesTable a where
|
128 |
status = '$status'
|
129 |
and a.entity_id > $maxorder
|
130 |
and a.entity_id not in
|
131 |
+
(select magento_order_id from $aoiTable b where b.magento_order_id=a.entity_id)";
|
132 |
|
133 |
$res=$readCon->query($sql);
|
134 |
+
$so= Mage::getModel('unicentaopos/orders');
|
135 |
foreach($res as $row){
|
136 |
$order=Mage::getModel('sales/order')->load($row['entity_id']);
|
137 |
+
$so->writeStockOrder($order);
|
138 |
}
|
139 |
$this->_updateUnicentaStock();
|
140 |
}
|
151 |
return $orderNo;
|
152 |
}
|
153 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
public function getLocations(){
|
155 |
try{
|
156 |
$ARR=array();
|
167 |
}
|
168 |
|
169 |
|
170 |
+
|
171 |
}
|
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
* This program is free software: you can redistribute it and/or modify
|
7 |
-
* it under the terms of the GNU General Public License as published by
|
8 |
-
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
-
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
-
|
11 |
-
* This program is distributed in the hope that it will be useful,
|
12 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
-
* GNU General Public License for more details.
|
15 |
-
*
|
16 |
-
* @category Asulpunto
|
17 |
-
* @package Asulpunto_Unicentaopos
|
18 |
-
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
-
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
-
*
|
21 |
-
*/
|
22 |
-
|
23 |
-
class Asulpunto_Unicentaopos_Model_Unicentaoposproductapi extends Mage_Core_Model_Abstract
|
24 |
-
{
|
25 |
-
private $_imageFolder='';
|
26 |
-
|
27 |
-
public function setProductImage($image,$product){
|
28 |
-
if (empty($image)) return $product;
|
29 |
-
|
30 |
-
$col=$product->getMediaGalleryImages();
|
31 |
-
if (!is_null($col) && $col->getSize()>0) return $product; //We do not overwrite images. Never.
|
32 |
-
$name=trim($product->getSku());
|
33 |
-
$imageFolder=$this->getImageFolder();
|
34 |
-
$path=$imageFolder.DIRECTORY_SEPARATOR.$name.'.png';
|
35 |
-
$res=file_put_contents($path,$image);
|
36 |
-
if ($res===false){
|
37 |
-
Mage::log(__METHOD__."Cannot create image for $name in folder: $imageFolder ",null,"asulpunto_unicentaopos.log");
|
38 |
-
}else{
|
39 |
-
$product->addImageToMediaGallery($path, array('thumbnail','small_image','image'),true,false);
|
40 |
-
}
|
41 |
-
unset($image);
|
42 |
-
return $product;
|
43 |
-
}
|
44 |
-
|
45 |
-
private function getImageFolder(){
|
46 |
-
if (empty($this->_imageFolder)){
|
47 |
-
$media=Mage::getBaseDir('media');
|
48 |
-
$unicenta=$media.DIRECTORY_SEPARATOR.'unicenta';
|
49 |
-
if (!file_exists($unicenta)){
|
50 |
-
$res=mkdir($unicenta,0777);
|
51 |
-
if (!$res) $this->_imageFolder=Mage::getBaseDir('media');
|
52 |
-
}
|
53 |
-
$this->_imageFolder=$unicenta;
|
54 |
-
}
|
55 |
-
return $this->_imageFolder;
|
56 |
-
}
|
57 |
-
|
58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -35,4 +35,29 @@ class Asulpunto_Unicentaopos_Adminhtml_UnicentaoposController extends Mage_Admin
|
|
35 |
Mage::app()->getResponse()->setBody($result);
|
36 |
|
37 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
35 |
Mage::app()->getResponse()->setBody($result);
|
36 |
|
37 |
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Do products
|
41 |
+
*
|
42 |
+
* @return void
|
43 |
+
*/
|
44 |
+
public function sendproductsAction()
|
45 |
+
{
|
46 |
+
$res=Mage::getModel('unicentaopos/unicentaoposapi')->cronProducts();
|
47 |
+
Mage::app()->getResponse()->setBody('OK');
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Do stock
|
53 |
+
*
|
54 |
+
* @return void
|
55 |
+
*/
|
56 |
+
public function stockAction()
|
57 |
+
{
|
58 |
+
$res=Mage::getModel('unicentaopos/unicentaoposapi')->cronStock();
|
59 |
+
Mage::app()->getResponse()->setBody('OK');
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
}
|
@@ -47,10 +47,10 @@
|
|
47 |
<show_in_website>1</show_in_website>
|
48 |
<show_in_store>1</show_in_store>
|
49 |
<comment>
|
50 |
-
<![CDATA[Module developed by Asulpunto
|
51 |
</banner>
|
52 |
<unicentaconfig translate="label">
|
53 |
-
<label>Configuration</label>
|
54 |
<sort_order>10</sort_order>
|
55 |
<show_in_default>1</show_in_default>
|
56 |
<show_in_website>0</show_in_website>
|
@@ -92,26 +92,26 @@
|
|
92 |
<show_in_store>1</show_in_store>
|
93 |
<validate>required-entry</validate>
|
94 |
</password>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
</fields>
|
96 |
</unicentaconfig>
|
97 |
<tools translate="label">
|
98 |
-
<label>
|
99 |
<sort_order>15</sort_order>
|
100 |
<show_in_default>1</show_in_default>
|
101 |
<show_in_website>0</show_in_website>
|
102 |
<show_in_store>0</show_in_store>
|
103 |
<fields>
|
104 |
-
|
105 |
-
<label>Check the connection details</label>
|
106 |
-
<frontend_type>button</frontend_type>
|
107 |
-
<frontend_model>asulpuntounicentaopos/adminhtml_system_config_form_button</frontend_model>
|
108 |
-
<sort_order>20</sort_order>
|
109 |
-
<show_in_default>1</show_in_default>
|
110 |
-
<show_in_website>0</show_in_website>
|
111 |
-
<show_in_store>0</show_in_store>
|
112 |
-
<comment>Please, save the database configuration before testing the connection.</comment>
|
113 |
-
</check>
|
114 |
-
<orderstatus translate="label">
|
115 |
<label>Order Status for Stock Syncronisation</label>
|
116 |
<comment>Only orders with this status will have the stock value updated in Unicenta Opos</comment>
|
117 |
<frontend_type>select</frontend_type>
|
@@ -130,6 +130,7 @@
|
|
130 |
<show_in_default>1</show_in_default>
|
131 |
<show_in_website>0</show_in_website>
|
132 |
<show_in_store>0</show_in_store>
|
|
|
133 |
<comment>New products will be created in this Product Attribute Set when uniCenta oPOS creates them in Magento</comment>
|
134 |
</product_type>
|
135 |
<location translate="label">
|
@@ -143,8 +144,37 @@
|
|
143 |
<comment>New products will be created in this Product Attribute Set when uniCenta oPOS creates them in Magento</comment>
|
144 |
</location>
|
145 |
</fields>
|
146 |
-
|
147 |
</tools>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
<advanced translate="label">
|
149 |
<label>Advanced</label>
|
150 |
<sort_order>20</sort_order>
|
@@ -161,9 +191,67 @@
|
|
161 |
<show_in_store>0</show_in_store>
|
162 |
<comment>This order and any orders done before it will not update uniCenta oPOS stock diary.</comment>
|
163 |
</orderno>
|
164 |
-
|
165 |
</fields>
|
166 |
</advanced>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
</groups>
|
168 |
</asulpuntounicentaopos>
|
169 |
</sections>
|
47 |
<show_in_website>1</show_in_website>
|
48 |
<show_in_store>1</show_in_store>
|
49 |
<comment>
|
50 |
+
<![CDATA[Version: 0.9<br/>Module developed by <a href="http://www.asulpunto.com">Asulpunto</a><br/>Support: <a href="http://www.asulpunto.com/supportforum">http://www.asulpunto.com/supportforum</a>]]></comment>
|
51 |
</banner>
|
52 |
<unicentaconfig translate="label">
|
53 |
+
<label>uniCenta Connection Configuration</label>
|
54 |
<sort_order>10</sort_order>
|
55 |
<show_in_default>1</show_in_default>
|
56 |
<show_in_website>0</show_in_website>
|
92 |
<show_in_store>1</show_in_store>
|
93 |
<validate>required-entry</validate>
|
94 |
</password>
|
95 |
+
<check translate="label">
|
96 |
+
<label>Test Connection Details</label>
|
97 |
+
<frontend_type>button</frontend_type>
|
98 |
+
<frontend_model>asulpuntounicentaopos/adminhtml_system_config_form_button</frontend_model>
|
99 |
+
<sort_order>50</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>0</show_in_website>
|
102 |
+
<show_in_store>0</show_in_store>
|
103 |
+
<comment><![CDATA[<b><font color="red">IMPORTANT! </font>Please, press on 'Save Config' button before testing the connection.</b>]]></comment>
|
104 |
+
</check>
|
105 |
</fields>
|
106 |
</unicentaconfig>
|
107 |
<tools translate="label">
|
108 |
+
<label>Configuration</label>
|
109 |
<sort_order>15</sort_order>
|
110 |
<show_in_default>1</show_in_default>
|
111 |
<show_in_website>0</show_in_website>
|
112 |
<show_in_store>0</show_in_store>
|
113 |
<fields>
|
114 |
+
<orderstatus translate="label">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
<label>Order Status for Stock Syncronisation</label>
|
116 |
<comment>Only orders with this status will have the stock value updated in Unicenta Opos</comment>
|
117 |
<frontend_type>select</frontend_type>
|
130 |
<show_in_default>1</show_in_default>
|
131 |
<show_in_website>0</show_in_website>
|
132 |
<show_in_store>0</show_in_store>
|
133 |
+
<validate>required-entry</validate>
|
134 |
<comment>New products will be created in this Product Attribute Set when uniCenta oPOS creates them in Magento</comment>
|
135 |
</product_type>
|
136 |
<location translate="label">
|
144 |
<comment>New products will be created in this Product Attribute Set when uniCenta oPOS creates them in Magento</comment>
|
145 |
</location>
|
146 |
</fields>
|
|
|
147 |
</tools>
|
148 |
+
<sync>
|
149 |
+
<label>Synchronisation</label>
|
150 |
+
<sort_order>16</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>0</show_in_website>
|
153 |
+
<show_in_store>0</show_in_store>
|
154 |
+
<fields>
|
155 |
+
<getproducts translate="label">
|
156 |
+
<label>Manual Product Update From uniCenta oPOS</label>
|
157 |
+
<frontend_type>button</frontend_type>
|
158 |
+
<frontend_model>asulpuntounicentaopos/adminhtml_system_config_form_buttongetproducts</frontend_model>
|
159 |
+
<sort_order>50</sort_order>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>0</show_in_website>
|
162 |
+
<show_in_store>0</show_in_store>
|
163 |
+
<comment><![CDATA[Test the connection before trying to get product updates from uniCenta oPOS]]></comment>
|
164 |
+
</getproducts>
|
165 |
+
<stock translate="label">
|
166 |
+
<label>Manual Stock Synchronisation</label>
|
167 |
+
<frontend_type>button</frontend_type>
|
168 |
+
<frontend_model>asulpuntounicentaopos/adminhtml_system_config_form_buttonstock</frontend_model>
|
169 |
+
<sort_order>51</sort_order>
|
170 |
+
<show_in_default>1</show_in_default>
|
171 |
+
<show_in_website>0</show_in_website>
|
172 |
+
<show_in_store>0</show_in_store>
|
173 |
+
<comment><![CDATA[Test the connection before trying to synchronise stock]]></comment>
|
174 |
+
</stock>
|
175 |
+
</fields>
|
176 |
+
</sync>
|
177 |
+
|
178 |
<advanced translate="label">
|
179 |
<label>Advanced</label>
|
180 |
<sort_order>20</sort_order>
|
191 |
<show_in_store>0</show_in_store>
|
192 |
<comment>This order and any orders done before it will not update uniCenta oPOS stock diary.</comment>
|
193 |
</orderno>
|
|
|
194 |
</fields>
|
195 |
</advanced>
|
196 |
+
<attributes translate="label">
|
197 |
+
<label>Attribute Settings</label>
|
198 |
+
<sort_order>30</sort_order>
|
199 |
+
<show_in_default>1</show_in_default>
|
200 |
+
<show_in_website>0</show_in_website>
|
201 |
+
<show_in_store>0</show_in_store>
|
202 |
+
<fields>
|
203 |
+
<name translate="label">
|
204 |
+
<label>Name</label>
|
205 |
+
<frontend_type>select</frontend_type>
|
206 |
+
<source_model>unicentaopos/source_transfer</source_model>
|
207 |
+
<sort_order>10</sort_order>
|
208 |
+
<show_in_default>1</show_in_default>
|
209 |
+
<show_in_website>0</show_in_website>
|
210 |
+
<show_in_store>0</show_in_store>
|
211 |
+
<comment>Name</comment>
|
212 |
+
</name>
|
213 |
+
<shortdescription translate="label">
|
214 |
+
<label>Short Description</label>
|
215 |
+
<frontend_type>select</frontend_type>
|
216 |
+
<source_model>unicentaopos/source_transfer</source_model>
|
217 |
+
<sort_order>20</sort_order>
|
218 |
+
<show_in_default>1</show_in_default>
|
219 |
+
<show_in_website>0</show_in_website>
|
220 |
+
<show_in_store>0</show_in_store>
|
221 |
+
<comment>Name</comment>
|
222 |
+
</shortdescription>
|
223 |
+
<longdescription translate="label">
|
224 |
+
<label>Long Description</label>
|
225 |
+
<frontend_type>select</frontend_type>
|
226 |
+
<source_model>unicentaopos/source_transfer</source_model>
|
227 |
+
<sort_order>30</sort_order>
|
228 |
+
<show_in_default>1</show_in_default>
|
229 |
+
<show_in_website>0</show_in_website>
|
230 |
+
<show_in_store>0</show_in_store>
|
231 |
+
<comment>Name</comment>
|
232 |
+
</longdescription>
|
233 |
+
<price translate="label">
|
234 |
+
<label>Price</label>
|
235 |
+
<frontend_type>select</frontend_type>
|
236 |
+
<source_model>unicentaopos/source_transfer</source_model>
|
237 |
+
<sort_order>40</sort_order>
|
238 |
+
<show_in_default>1</show_in_default>
|
239 |
+
<show_in_website>0</show_in_website>
|
240 |
+
<show_in_store>0</show_in_store>
|
241 |
+
<comment>Name</comment>
|
242 |
+
</price>
|
243 |
+
<barcode translate="label">
|
244 |
+
<label>Magento Barcode Attribute</label>
|
245 |
+
<frontend_type>select</frontend_type>
|
246 |
+
<source_model>unicentaopos/source_attributes</source_model>
|
247 |
+
<sort_order>50</sort_order>
|
248 |
+
<show_in_default>1</show_in_default>
|
249 |
+
<show_in_website>0</show_in_website>
|
250 |
+
<show_in_store>0</show_in_store>
|
251 |
+
<comment>The attribute that will contain the Barcode from uniCenta oPOS </comment>
|
252 |
+
</barcode>
|
253 |
+
</fields>
|
254 |
+
</attributes>
|
255 |
</groups>
|
256 |
</asulpuntounicentaopos>
|
257 |
</sections>
|
@@ -23,7 +23,7 @@
|
|
23 |
|
24 |
<script type="text/javascript">
|
25 |
//<![CDATA[
|
26 |
-
function
|
27 |
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
28 |
method: 'get',
|
29 |
onSuccess: function(transport){
|
23 |
|
24 |
<script type="text/javascript">
|
25 |
//<![CDATA[
|
26 |
+
function unicentaoposcheck() {
|
27 |
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
28 |
method: 'get',
|
29 |
onSuccess: function(transport){
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
+
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
+
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* @category Asulpunto
|
17 |
+
* @package Asulpunto_Unicentaopos
|
18 |
+
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
+
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
?>
|
23 |
+
|
24 |
+
<script type="text/javascript">
|
25 |
+
//<![CDATA[
|
26 |
+
function unicentaoposproduct() {
|
27 |
+
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
28 |
+
method: 'get',
|
29 |
+
onSuccess: function(transport){
|
30 |
+
|
31 |
+
if (transport.responseText=='OK'){
|
32 |
+
alert('Product update complete.');
|
33 |
+
}else{
|
34 |
+
alert('Product update failed. Please Test Connection and try again.');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
});
|
38 |
+
}
|
39 |
+
//]]>
|
40 |
+
</script>
|
41 |
+
|
42 |
+
<?php echo $this->getButtonHtml() ?>
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento - Unicenta Opos Integrator by Asulpunto
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
* This program is free software: you can redistribute it and/or modify
|
7 |
+
* it under the terms of the GNU General Public License as published by
|
8 |
+
* the Free Software Foundation, Version 3 of the License. You can view
|
9 |
+
* the license here http://opensource.org/licenses/GPL-3.0
|
10 |
+
|
11 |
+
* This program is distributed in the hope that it will be useful,
|
12 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
+
* GNU General Public License for more details.
|
15 |
+
*
|
16 |
+
* @category Asulpunto
|
17 |
+
* @package Asulpunto_Unicentaopos
|
18 |
+
* @copyright Copyright (c) 2013 Asulpunto (http://www.asulpunto.com)
|
19 |
+
* @license http://opensource.org/licenses/GPL-3.0 GNU General Public License, version 3 (GPL-3.0)
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
?>
|
23 |
+
|
24 |
+
<script type="text/javascript">
|
25 |
+
//<![CDATA[
|
26 |
+
function unicentaoposstock() {
|
27 |
+
new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
|
28 |
+
method: 'get',
|
29 |
+
onSuccess: function(transport){
|
30 |
+
|
31 |
+
if (transport.responseText=='OK'){
|
32 |
+
alert('Stock Synchronisation done.');
|
33 |
+
}else{
|
34 |
+
alert('Stock Synchronisation failed. Please Test Connection and try again.');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
});
|
38 |
+
}
|
39 |
+
//]]>
|
40 |
+
</script>
|
41 |
+
|
42 |
+
<?php echo $this->getButtonHtml() ?>
|
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Asulpunto_Unicentaopos</name>
|
4 |
-
<version>0.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License 3.0</license>
|
7 |
<channel>community</channel>
|
@@ -15,11 +15,22 @@ Features:
|
|
15 |
-Stock Diary updates on uniCenta oPOS are sent to Magento.
|
16 |
-Purchases on uniCenta oPOS reduce stock from Magento.
|
17 |
-Purchases on Magento subtract stock from uniCenta oPOS Stock Diary.
|
|
|
18 |

|
19 |
To use this extension you have to install uniCenta oPOS's database on a Mysql server accessible by the Magento server.
|
20 |

|
21 |
</description>
|
22 |
-
<notes>0.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
* Product set can be configured from Admin. This also solves a problem when Magento's default attribute set was deleted.
|
24 |
* The warehouse that will track the stock can be selected from admin configuration.
|
25 |
* Images on Unicenta are tranfered to Magento when the Magento Product does not have any images. 
|
@@ -30,9 +41,9 @@ Advanced log to identify database connection issues
|
|
30 |
0.0.3
|
31 |
First official public release </notes>
|
32 |
<authors><author><name>asulpunto</name><user>asulpunto</user><email>asulpunto@asulpunto.com</email></author></authors>
|
33 |
-
<date>
|
34 |
-
<time>
|
35 |
-
<contents><target name="magecommunity"><dir name="Asulpunto"><dir name="Unicentaopos"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="
|
36 |
<compatible/>
|
37 |
<dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
|
38 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Asulpunto_Unicentaopos</name>
|
4 |
+
<version>0.0.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License 3.0</license>
|
7 |
<channel>community</channel>
|
15 |
-Stock Diary updates on uniCenta oPOS are sent to Magento.
|
16 |
-Purchases on uniCenta oPOS reduce stock from Magento.
|
17 |
-Purchases on Magento subtract stock from uniCenta oPOS Stock Diary.
|
18 |
+
-Syncronisation works via cron, synchronization of stock or products can now be triggered manually from the admin.
|
19 |

|
20 |
To use this extension you have to install uniCenta oPOS's database on a Mysql server accessible by the Magento server.
|
21 |

|
22 |
</description>
|
23 |
+
<notes>0.0.9
|
24 |
+
- Refactored Code
|
25 |
+
- You can choose if attributes are always transfered or only on product creation
|
26 |
+
- Moved Test Connection to database connection details
|
27 |
+
- Renamed the configurations
|
28 |
+
- Added Sycn Products button to enable you to test it is working without waiting for cron
|
29 |
+
- Added Sycn Stock button to enable you to test it is working without waiting for cron
|
30 |
+
- Fixed bug for Magento installations with a prefix
|
31 |
+

|
32 |
+

|
33 |
+
0.0.5
|
34 |
* Product set can be configured from Admin. This also solves a problem when Magento's default attribute set was deleted.
|
35 |
* The warehouse that will track the stock can be selected from admin configuration.
|
36 |
* Images on Unicenta are tranfered to Magento when the Magento Product does not have any images. 
|
41 |
0.0.3
|
42 |
First official public release </notes>
|
43 |
<authors><author><name>asulpunto</name><user>asulpunto</user><email>asulpunto@asulpunto.com</email></author></authors>
|
44 |
+
<date>2014-01-06</date>
|
45 |
+
<time>19:15:19</time>
|
46 |
+
<contents><target name="magecommunity"><dir name="Asulpunto"><dir name="Unicentaopos"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="8de2e6e124cdcd67597725a9a7368ed8"/><file name="Buttongetproducts.php" hash="8d5667a1c1f9d56875d71f6b628c9f36"/><file name="Buttonstock.php" hash="a41f426871cb05ce6b1ddc755419a7be"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="24367b6eebc579be96158d8e71c067f5"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Unicentaoposorderitem"><file name="Collection.php" hash="bb9cf8ab48304c34fd7bd575e1002574"/></dir><file name="Unicentaoposorderitem.php" hash="edc7cfecd2b60b0bc372da8c0509cf7d"/><dir name="Unicentaoposproduct"><file name="Collection.php" hash="03f65e284b426d36daa2376e38a813e1"/></dir><file name="Unicentaoposproduct.php" hash="1f849c04da97b863ee88c3b34dc8255b"/></dir><file name="Orders.php" hash="105bd671d41de1b163ec1bb458337136"/><file name="Productstock.php" hash="45d0abf7fbf1d37d41f2a3eafcb97a9e"/><dir name="Source"><file name="Attributes.php" hash="0c9d1465dbeb8c22dc1bf2c207d27738"/><file name="Location.php" hash="231c61909cef275342fe746e6b1a3406"/><file name="Producttypelist.php" hash="ee920c29a4c36e5d39503d049729c206"/><file name="Transfer.php" hash="c6b83cd1c753d8712ae8dcdb79428740"/></dir><file name="Unicentaoposapi.php" hash="b23cc1ed20abeec4e6b0cf16627dae4d"/><file name="Unicentaoposorderitem.php" hash="31b0f22a1fa3af396a01b741fd9d4adf"/><file name="Unicentaoposproduct.php" hash="8754d16acf3372355bf379deb563ab03"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="UnicentaoposController.php" hash="5890605a3563955fb5a33431bde12a1f"/></dir></dir><dir name="etc"><file name="config.xml" hash="d1e4e03c1ce228cd9af2af12ac985315"/><file name="system.xml" hash="80bfc6265954a48e077cdf34206d0f5a"/></dir><dir name="sql"><dir name="unicentaopos_setup"><file name="mysql4-install-0.0.1.php" hash="84ba3c4373b2a1c6b1219e8fbd881b51"/><file name="mysql4-upgrade-0.0.1-0.0.2.php" hash="76ea73b06b500e88db0891df95744b65"/><file name="mysql4-upgrade-0.0.4-0.0.5.php" hash="666324a87a44f9e4f161bbea4f4c8c06"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="asulpunto"><dir name="unicentaopos"><dir name="system"><dir name="config"><file name="button.phtml" hash="a938d25a39d87ebeaa7f5e6c4eca64b2"/><file name="buttongetproducts.phtml" hash="7b42df54ec62f90ea3e949655db481d5"/><file name="buttonstock.phtml" hash="dcba538825ce28f86d7e809203b4a591"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Asulpunto_Unicentaopos.xml" hash="0b81c393d2739bbabe04eeccadeaf858"/></dir></target></contents>
|
47 |
<compatible/>
|
48 |
<dependencies><required><php><min>5.2.0</min><max>5.5.0</max></php></required></dependencies>
|
49 |
</package>
|