Version Notes
Download this release
Release Info
Developer | Codisto |
Extension | codistoconnect |
Version | 1.90.16 |
Comparing to | |
See all releases |
Code changes from version 1.90.15 to 1.90.16
- app/code/community/Codisto/Sync/Helper/Data.php +12 -1
- app/code/community/Codisto/Sync/Model/Sync.php +202 -23
- app/code/community/Codisto/Sync/controllers/IndexController.php +26 -2
- app/code/community/Codisto/Sync/controllers/SyncController.php +32 -7
- app/code/community/Codisto/Sync/data/codisto_setup/{data-install-1.90.15.php → data-install-1.90.16.php} +0 -0
- app/code/community/Codisto/Sync/etc/config.xml +1 -1
- app/code/community/Codisto/Sync/sql/codisto_setup/{mysql4-install-1.90.15.php → mysql4-install-1.90.16.php} +7 -1
- package.xml +1 -1
app/code/community/Codisto/Sync/Helper/Data.php
CHANGED
@@ -114,7 +114,18 @@ class Codisto_Sync_Helper_Data extends Mage_Core_Helper_Abstract
|
|
114 |
if(file_exists($nonceDbPath))
|
115 |
unlink($nonceDbPath);
|
116 |
}
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
return $this->checkHash($key, $nonce, $hash);
|
114 |
if(file_exists($nonceDbPath))
|
115 |
unlink($nonceDbPath);
|
116 |
}
|
117 |
+
else if(property_exists($e, 'errorInfo') &&
|
118 |
+
$e->errorInfo[0] == 'HY000' &&
|
119 |
+
$e->errorInfo[1] == 11 &&
|
120 |
+
$e->errorInfo[2] == 'database disk image is malformed')
|
121 |
+
{
|
122 |
+
if(file_exists($nonceDbPath))
|
123 |
+
unlink($nonceDbPath);
|
124 |
+
}
|
125 |
+
else
|
126 |
+
{
|
127 |
+
$this->logExceptionCodisto($e, 'https://ui.codisto.com/installed');
|
128 |
+
}
|
129 |
}
|
130 |
|
131 |
return $this->checkHash($key, $nonce, $hash);
|
app/code/community/Codisto/Sync/Model/Sync.php
CHANGED
@@ -260,7 +260,7 @@ class Codisto_Sync_Model_Sync
|
|
260 |
->columns(array('codisto_in_store'=> new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')))
|
261 |
->where($sqlCheckModified);
|
262 |
|
263 |
-
// Simple Products
|
264 |
$simpleProducts = $this->getProductCollection()
|
265 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
266 |
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
@@ -269,6 +269,15 @@ class Codisto_Sync_Model_Sync
|
|
269 |
$simpleProducts->getSelect()
|
270 |
->columns(array('codisto_in_store'=> new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')));
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
// Grouped products
|
273 |
$groupedProducts = $this->getProductCollection()
|
274 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
@@ -369,6 +378,26 @@ class Codisto_Sync_Model_Sync
|
|
369 |
'store' => $store )
|
370 |
);
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
Mage::getSingleton('core/resource_iterator')->walk($groupedProducts->getSelect(), array(array($this, 'SyncGroupedProductData')),
|
373 |
array(
|
374 |
'type' => 'grouped',
|
@@ -823,7 +852,36 @@ class Codisto_Sync_Model_Sync
|
|
823 |
$insertProductQuestionSQL = $args['preparedproductquestionStatement'];
|
824 |
$insertProductAnswerSQL = $args['preparedproductanswerStatement'];
|
825 |
|
826 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
827 |
|
828 |
$listPrice = $this->getExTaxPrice($product, $product->getPrice(), $store);
|
829 |
if(!is_numeric($listPrice))
|
@@ -844,7 +902,7 @@ class Codisto_Sync_Model_Sync
|
|
844 |
}
|
845 |
|
846 |
$description = Mage::helper('codistosync')->processCmsContent($description);
|
847 |
-
if($type == 'simple' &&
|
848 |
$description == '')
|
849 |
{
|
850 |
if(!isset($parentids))
|
@@ -878,7 +936,7 @@ class Codisto_Sync_Model_Sync
|
|
878 |
$data = array();
|
879 |
|
880 |
$data[] = $product_id;
|
881 |
-
$data[] = $type == 'configurable' ? 'c' : ($type == 'grouped' ? 'g' : 's');
|
882 |
$data[] = $productData['sku'];
|
883 |
$data[] = html_entity_decode($productName);
|
884 |
$data[] = $price;
|
@@ -1040,7 +1098,6 @@ class Codisto_Sync_Model_Sync
|
|
1040 |
$attrTypeSelect = $adapter->select()
|
1041 |
->from(array('default_value' => $table), array('attribute_id'))
|
1042 |
->where('default_value.attribute_id IN (?)', array_keys($_attributes))
|
1043 |
-
->where('default_value.entity_type_id = :entity_type_id')
|
1044 |
->where('default_value.entity_id = :entity_id')
|
1045 |
->where('default_value.store_id = 0');
|
1046 |
|
@@ -1057,7 +1114,6 @@ class Codisto_Sync_Model_Sync
|
|
1057 |
array('store_value' => $table),
|
1058 |
'store_value.attribute_id = default_value.attribute_id '.
|
1059 |
'AND store_value.attribute_id IN (SELECT attribute_id FROM `'.$coreResource->getTableName('catalog/eav_attribute').'` WHERE is_global != 0) '.
|
1060 |
-
'AND store_value.entity_type_id = default_value.entity_type_id '.
|
1061 |
'AND store_value.entity_id = default_value.entity_id '.
|
1062 |
'AND store_value.store_id = :store_id ',
|
1063 |
array('attr_value' => new Zend_Db_Expr('CAST(COALESCE(store_value.value, default_value.value) AS CHAR)'))
|
@@ -1075,7 +1131,6 @@ class Codisto_Sync_Model_Sync
|
|
1075 |
$attrSelect = $adapter->select()->union($attrTypeSelects, Zend_Db_Select::SQL_UNION_ALL);
|
1076 |
|
1077 |
$attrArgs = array(
|
1078 |
-
'entity_type_id' => 4,
|
1079 |
'entity_id' => $product_id,
|
1080 |
'store_id' => $store->getId()
|
1081 |
);
|
@@ -1470,7 +1525,7 @@ class Codisto_Sync_Model_Sync
|
|
1470 |
}
|
1471 |
}
|
1472 |
|
1473 |
-
if($type == 'simple')
|
1474 |
{
|
1475 |
$this->productsProcessed[] = $product_id;
|
1476 |
|
@@ -1485,7 +1540,7 @@ class Codisto_Sync_Model_Sync
|
|
1485 |
|
1486 |
$orderData = $args['row'];
|
1487 |
|
1488 |
-
$insertOrdersSQL->execute(array($orderData['codisto_orderid'], ($orderData['status'])?$orderData['status']:'processing', $orderData['pay_date'], $orderData['ship_date'], $orderData['carrier'], $orderData['track_number'], $orderData['externalreference']));
|
1489 |
|
1490 |
$this->ordersProcessed[] = $orderData['entity_id'];
|
1491 |
$this->currentEntityId = $orderData['entity_id'];
|
@@ -1622,7 +1677,7 @@ class Codisto_Sync_Model_Sync
|
|
1622 |
$insertProductQuestion = $db->prepare('INSERT OR REPLACE INTO ProductQuestion(ExternalReference, ProductExternalReference, Name, Type, Sequence) VALUES (?, ?, ?, ?, ?)');
|
1623 |
$insertProductAnswer = $db->prepare('INSERT INTO ProductQuestionAnswer(ProductQuestionExternalReference, Value, PriceModifier, SKUModifier, Sequence) VALUES (?, ?, ?, ?, ?)');
|
1624 |
|
1625 |
-
// Simple Products
|
1626 |
$simpleProducts = $this->getProductCollection()
|
1627 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
1628 |
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
@@ -1649,6 +1704,34 @@ class Codisto_Sync_Model_Sync
|
|
1649 |
'preparedproductanswerStatement' => $insertProductAnswer,
|
1650 |
'store' => $storeObject ));
|
1651 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1652 |
// Configurable products
|
1653 |
$configurableProducts = $this->getProductCollection()
|
1654 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
@@ -1727,7 +1810,32 @@ class Codisto_Sync_Model_Sync
|
|
1727 |
|
1728 |
if(!empty($orderUpdateIds))
|
1729 |
{
|
1730 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1731 |
|
1732 |
$orderStoreId = $storeId;
|
1733 |
if($storeId == 0)
|
@@ -1748,7 +1856,7 @@ class Codisto_Sync_Model_Sync
|
|
1748 |
$ts -= 7776000; // 90 days
|
1749 |
|
1750 |
$orders = Mage::getModel('sales/order')->getCollection()
|
1751 |
-
->addFieldToSelect(array('codisto_orderid', 'status' ))
|
1752 |
->addFieldToSelect('entity_id','externalreference')
|
1753 |
->addAttributeToFilter('entity_id', array('in' => $orderUpdateIds ))
|
1754 |
->addAttributeToFilter('main_table.store_id', array('eq' => $orderStoreId ))
|
@@ -1757,7 +1865,7 @@ class Codisto_Sync_Model_Sync
|
|
1757 |
$orders->getSelect()->joinLeft( array('i' => $invoiceName), 'i.order_id = main_table.entity_id AND i.state = 2', array('pay_date' => 'MIN(i.created_at)'));
|
1758 |
$orders->getSelect()->joinLeft( array('s' => $shipmentName), 's.order_id = main_table.entity_id', array('ship_date' => 'MIN(s.created_at)'));
|
1759 |
$orders->getSelect()->joinLeft( array('t' => $shipmentTrackName), 't.order_id = main_table.entity_id', array('carrier' => 'GROUP_CONCAT(COALESCE(t.title, \'\') SEPARATOR \',\')', 'track_number' => 'GROUP_CONCAT(COALESCE(t.track_number, \'\') SEPARATOR \',\')'));
|
1760 |
-
$orders->getSelect()->group(array('main_table.entity_id', 'main_table.codisto_orderid', 'main_table.status'));
|
1761 |
$orders->setOrder('entity_id', 'ASC');
|
1762 |
|
1763 |
Mage::getSingleton('core/resource_iterator')->walk($orders->getSelect(), array(array($this, 'SyncOrderData')),
|
@@ -1970,7 +2078,7 @@ class Codisto_Sync_Model_Sync
|
|
1970 |
$insertProductAttributeDefault = $db->prepare('INSERT OR IGNORE INTO ProductAttributeDefaultValue(ProductExternalReference, AttributeID, Value) VALUES (?, ?, ?)');
|
1971 |
$insertProductQuestion = $db->prepare('INSERT OR REPLACE INTO ProductQuestion(ExternalReference, ProductExternalReference, Name, Type, Sequence) VALUES (?, ?, ?, ?, ?)');
|
1972 |
$insertProductAnswer = $db->prepare('INSERT INTO ProductQuestionAnswer(ProductQuestionExternalReference, Value, PriceModifier, SKUModifier, Sequence) VALUES (?, ?, ?, ?, ?)');
|
1973 |
-
$insertOrders = $db->prepare('INSERT OR REPLACE INTO [Order] (ID, Status, PaymentDate, ShipmentDate, Carrier, TrackingNumber, ExternalReference) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
1974 |
|
1975 |
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
1976 |
|
@@ -2057,7 +2165,7 @@ class Codisto_Sync_Model_Sync
|
|
2057 |
|
2058 |
if($state == 'simple')
|
2059 |
{
|
2060 |
-
// Simple Products
|
2061 |
|
2062 |
$simpleProducts = $this->getProductCollection()->addAttributeToSelect($this->availableProductFields, 'left')
|
2063 |
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
@@ -2093,6 +2201,50 @@ class Codisto_Sync_Model_Sync
|
|
2093 |
$db->exec('INSERT OR REPLACE INTO Progress (Sentinel, State, entity_id) VALUES (1, \'simple\', '.$this->currentEntityId.')');
|
2094 |
}
|
2095 |
else
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2096 |
{
|
2097 |
$state = 'configurable';
|
2098 |
$this->currentEntityId = 0;
|
@@ -2211,6 +2363,18 @@ class Codisto_Sync_Model_Sync
|
|
2211 |
catch(Exception $e)
|
2212 |
{
|
2213 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2214 |
}
|
2215 |
|
2216 |
$orderStoreId = $storeId;
|
@@ -2232,7 +2396,7 @@ class Codisto_Sync_Model_Sync
|
|
2232 |
$ts -= 7776000; // 90 days
|
2233 |
|
2234 |
$orders = Mage::getModel('sales/order')->getCollection()
|
2235 |
-
->addFieldToSelect(array('codisto_orderid', 'status'))
|
2236 |
->addFieldToSelect('entity_id','externalreference')
|
2237 |
->addAttributeToFilter('entity_id', array('gt' => (int)$this->currentEntityId ))
|
2238 |
->addAttributeToFilter('main_table.store_id', array('eq' => $orderStoreId ))
|
@@ -2241,7 +2405,7 @@ class Codisto_Sync_Model_Sync
|
|
2241 |
$orders->getSelect()->joinLeft( array('i' => $invoiceName), 'i.order_id = main_table.entity_id AND i.state = 2', array('pay_date' => 'MIN(i.created_at)'));
|
2242 |
$orders->getSelect()->joinLeft( array('s' => $shipmentName), 's.order_id = main_table.entity_id', array('ship_date' => 'MIN(s.created_at)'));
|
2243 |
$orders->getSelect()->joinLeft( array('t' => $shipmentTrackName), 't.order_id = main_table.entity_id', array('carrier' => 'GROUP_CONCAT(COALESCE(t.title, \'\') SEPARATOR \',\')', 'track_number' => 'GROUP_CONCAT(COALESCE(t.track_number, \'\') SEPARATOR \',\')'));
|
2244 |
-
$orders->getSelect()->group(array('main_table.entity_id', 'main_table.codisto_orderid', 'main_table.status'));
|
2245 |
$orders->getSelect()->limit(1000);
|
2246 |
$orders->setOrder('entity_id', 'ASC');
|
2247 |
|
@@ -2295,7 +2459,7 @@ class Codisto_Sync_Model_Sync
|
|
2295 |
$db->exec('INSERT OR REPLACE INTO Progress (Sentinel, State, entity_id) VALUES (1, \'complete\', 0)');
|
2296 |
}
|
2297 |
|
2298 |
-
if(
|
2299 |
{
|
2300 |
$uniqueId = uniqid();
|
2301 |
|
@@ -2310,6 +2474,12 @@ class Codisto_Sync_Model_Sync
|
|
2310 |
|
2311 |
return 'complete';
|
2312 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2313 |
else
|
2314 |
{
|
2315 |
$db->exec('COMMIT TRANSACTION');
|
@@ -2330,7 +2500,7 @@ class Codisto_Sync_Model_Sync
|
|
2330 |
|
2331 |
$simpleProducts = $this->getProductCollection()
|
2332 |
->addAttributeToSelect(array('entity_id'), 'left')
|
2333 |
-
->addAttributeToFilter('type_id', array('
|
2334 |
|
2335 |
$simplecount = $simpleProducts->getSize();
|
2336 |
|
@@ -2557,7 +2727,7 @@ class Codisto_Sync_Model_Sync
|
|
2557 |
|
2558 |
$db = $this->GetSyncDb($syncDb, 5 );
|
2559 |
|
2560 |
-
$insertOrders = $db->prepare('INSERT OR REPLACE INTO [Order] (ID, Status, PaymentDate, ShipmentDate, Carrier, TrackingNumber, ExternalReference) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
2561 |
|
2562 |
$coreResource = Mage::getSingleton('core/resource');
|
2563 |
|
@@ -2568,14 +2738,14 @@ class Codisto_Sync_Model_Sync
|
|
2568 |
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
2569 |
|
2570 |
$orders = Mage::getModel('sales/order')->getCollection()
|
2571 |
-
->addFieldToSelect(array('codisto_orderid', 'status'))
|
2572 |
->addFieldToSelect('entity_id','externalreference')
|
2573 |
->addAttributeToFilter('codisto_orderid', array('in' => $orders ));
|
2574 |
|
2575 |
$orders->getSelect()->joinLeft( array('i' => $invoiceName), 'i.order_id = main_table.entity_id AND i.state = 2', array('pay_date' => 'MIN(i.created_at)'));
|
2576 |
$orders->getSelect()->joinLeft( array('s' => $shipmentName), 's.order_id = main_table.entity_id', array('ship_date' => 'MIN(s.created_at)'));
|
2577 |
$orders->getSelect()->joinLeft( array('t' => $shipmentTrackName), 't.order_id = main_table.entity_id', array('carrier' => 'GROUP_CONCAT(COALESCE(t.title, \'\') SEPARATOR \',\')', 'track_number' => 'GROUP_CONCAT(COALESCE(t.track_number, \'\') SEPARATOR \',\')'));
|
2578 |
-
$orders->getSelect()->group(array('main_table.entity_id', 'main_table.codisto_orderid', 'main_table.status'));
|
2579 |
|
2580 |
$orders->setOrder('entity_id', 'ASC');
|
2581 |
|
@@ -2639,7 +2809,7 @@ class Codisto_Sync_Model_Sync
|
|
2639 |
$db->exec('CREATE TABLE IF NOT EXISTS Store(ID integer NOT NULL PRIMARY KEY, Code text NOT NULL, Name text NOT NULL, Currency text NOT NULL)');
|
2640 |
$db->exec('CREATE TABLE IF NOT EXISTS StoreMerchant(StoreID integer NOT NULL, MerchantID integer NOT NULL, PRIMARY KEY (StoreID, MerchantID))');
|
2641 |
|
2642 |
-
$db->exec('CREATE TABLE IF NOT EXISTS [Order](ID integer NOT NULL PRIMARY KEY, Status text NOT NULL, PaymentDate datetime NULL, ShipmentDate datetime NULL, Carrier text NOT NULL, TrackingNumber text NOT NULL, ExternalReference text NOT NULL DEFAULT \'\')');
|
2643 |
|
2644 |
$db->exec('CREATE TABLE IF NOT EXISTS StaticBlock(BlockID integer NOT NULL PRIMARY KEY, Title text NOT NULL, Identifier text NOT NULL, Content text NOT NULL)');
|
2645 |
|
@@ -2666,6 +2836,15 @@ class Codisto_Sync_Model_Sync
|
|
2666 |
$db->exec('ALTER TABLE [Order] ADD COLUMN ExternalReference text NOT NULL DEFAULT \'\'');
|
2667 |
}
|
2668 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2669 |
try
|
2670 |
{
|
2671 |
$db->exec('SELECT 1 FROM ProductAttributeValue WHERE ProductExternalReference IS NULL LIMIT 1');
|
260 |
->columns(array('codisto_in_store'=> new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')))
|
261 |
->where($sqlCheckModified);
|
262 |
|
263 |
+
// Simple Products
|
264 |
$simpleProducts = $this->getProductCollection()
|
265 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
266 |
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
269 |
$simpleProducts->getSelect()
|
270 |
->columns(array('codisto_in_store'=> new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')));
|
271 |
|
272 |
+
// Virtual Products
|
273 |
+
$virtualProducts = $this->getProductCollection()
|
274 |
+
->addAttributeToSelect($this->availableProductFields, 'left')
|
275 |
+
->addAttributeToFilter('type_id', array('eq' => 'virtual'))
|
276 |
+
->addAttributeToFilter('entity_id', array('in' => $ids));
|
277 |
+
|
278 |
+
$virtualProducts->getSelect()
|
279 |
+
->columns(array('codisto_in_store'=> new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')));
|
280 |
+
|
281 |
// Grouped products
|
282 |
$groupedProducts = $this->getProductCollection()
|
283 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
378 |
'store' => $store )
|
379 |
);
|
380 |
|
381 |
+
Mage::getSingleton('core/resource_iterator')->walk($virtualProducts->getSelect(), array(array($this, 'SyncSimpleProductData')),
|
382 |
+
array(
|
383 |
+
'type' => 'virtual',
|
384 |
+
'db' => $db,
|
385 |
+
'preparedStatement' => $insertProduct,
|
386 |
+
'preparedcheckproductStatement' => $checkProduct,
|
387 |
+
'preparedcategoryproductStatement' => $insertCategoryProduct,
|
388 |
+
'preparedimageStatement' => $insertImage,
|
389 |
+
'preparedproducthtmlStatement' => $insertProductHTML,
|
390 |
+
'preparedproductrelatedStatement' => $insertProductRelated,
|
391 |
+
'preparedattributeStatement' => $insertAttribute,
|
392 |
+
'preparedattributegroupStatement' => $insertAttributeGroup,
|
393 |
+
'preparedattributegroupmapStatement' => $insertAttributeGroupMap,
|
394 |
+
'preparedproductattributeStatement' => $insertProductAttribute,
|
395 |
+
'preparedproductattributedefaultStatement' => $insertProductAttributeDefault,
|
396 |
+
'preparedproductquestionStatement' => $insertProductQuestion,
|
397 |
+
'preparedproductanswerStatement' => $insertProductAnswer,
|
398 |
+
'store' => $store )
|
399 |
+
);
|
400 |
+
|
401 |
Mage::getSingleton('core/resource_iterator')->walk($groupedProducts->getSelect(), array(array($this, 'SyncGroupedProductData')),
|
402 |
array(
|
403 |
'type' => 'grouped',
|
852 |
$insertProductQuestionSQL = $args['preparedproductquestionStatement'];
|
853 |
$insertProductAnswerSQL = $args['preparedproductanswerStatement'];
|
854 |
|
855 |
+
|
856 |
+
$badoptiondata = false;
|
857 |
+
|
858 |
+
if($type == 'configurable') {
|
859 |
+
|
860 |
+
$attributes = null;
|
861 |
+
try {
|
862 |
+
$configurableData = Mage::getModel('catalog/product_type_configurable');
|
863 |
+
$attributes = $configurableData->getConfigurableAttributes($product);
|
864 |
+
} catch(Exception $e) {
|
865 |
+
$badoptiondata = true;
|
866 |
+
}
|
867 |
+
|
868 |
+
if($attributes) {
|
869 |
+
foreach($attributes as $attribute)
|
870 |
+
{
|
871 |
+
$prodAttr = $attribute->getProductAttribute();
|
872 |
+
if(!is_object($prodAttr) || !$prodAttr->getAttributeCode())
|
873 |
+
{
|
874 |
+
$badoptiondata = true;
|
875 |
+
}
|
876 |
+
}
|
877 |
+
}
|
878 |
+
|
879 |
+
}
|
880 |
+
|
881 |
+
if(!$badoptiondata)
|
882 |
+
$price = $this->SyncProductPrice($store, $product);
|
883 |
+
else
|
884 |
+
$price = 0;
|
885 |
|
886 |
$listPrice = $this->getExTaxPrice($product, $product->getPrice(), $store);
|
887 |
if(!is_numeric($listPrice))
|
902 |
}
|
903 |
|
904 |
$description = Mage::helper('codistosync')->processCmsContent($description);
|
905 |
+
if(($type == 'simple' || $type == 'virtual') &&
|
906 |
$description == '')
|
907 |
{
|
908 |
if(!isset($parentids))
|
936 |
$data = array();
|
937 |
|
938 |
$data[] = $product_id;
|
939 |
+
$data[] = $type == 'configurable' ? 'c' : ($type == 'grouped' ? 'g' : ($type == 'virtual' ? 'v' : 's'));
|
940 |
$data[] = $productData['sku'];
|
941 |
$data[] = html_entity_decode($productName);
|
942 |
$data[] = $price;
|
1098 |
$attrTypeSelect = $adapter->select()
|
1099 |
->from(array('default_value' => $table), array('attribute_id'))
|
1100 |
->where('default_value.attribute_id IN (?)', array_keys($_attributes))
|
|
|
1101 |
->where('default_value.entity_id = :entity_id')
|
1102 |
->where('default_value.store_id = 0');
|
1103 |
|
1114 |
array('store_value' => $table),
|
1115 |
'store_value.attribute_id = default_value.attribute_id '.
|
1116 |
'AND store_value.attribute_id IN (SELECT attribute_id FROM `'.$coreResource->getTableName('catalog/eav_attribute').'` WHERE is_global != 0) '.
|
|
|
1117 |
'AND store_value.entity_id = default_value.entity_id '.
|
1118 |
'AND store_value.store_id = :store_id ',
|
1119 |
array('attr_value' => new Zend_Db_Expr('CAST(COALESCE(store_value.value, default_value.value) AS CHAR)'))
|
1131 |
$attrSelect = $adapter->select()->union($attrTypeSelects, Zend_Db_Select::SQL_UNION_ALL);
|
1132 |
|
1133 |
$attrArgs = array(
|
|
|
1134 |
'entity_id' => $product_id,
|
1135 |
'store_id' => $store->getId()
|
1136 |
);
|
1525 |
}
|
1526 |
}
|
1527 |
|
1528 |
+
if($type == 'simple' || $type == 'virtual')
|
1529 |
{
|
1530 |
$this->productsProcessed[] = $product_id;
|
1531 |
|
1540 |
|
1541 |
$orderData = $args['row'];
|
1542 |
|
1543 |
+
$insertOrdersSQL->execute(array($orderData['codisto_orderid'], ($orderData['status'])?$orderData['status']:'processing', $orderData['pay_date'], $orderData['ship_date'], $orderData['carrier'], $orderData['track_number'], $orderData['externalreference'], $orderData['codisto_merchantid']));
|
1544 |
|
1545 |
$this->ordersProcessed[] = $orderData['entity_id'];
|
1546 |
$this->currentEntityId = $orderData['entity_id'];
|
1677 |
$insertProductQuestion = $db->prepare('INSERT OR REPLACE INTO ProductQuestion(ExternalReference, ProductExternalReference, Name, Type, Sequence) VALUES (?, ?, ?, ?, ?)');
|
1678 |
$insertProductAnswer = $db->prepare('INSERT INTO ProductQuestionAnswer(ProductQuestionExternalReference, Value, PriceModifier, SKUModifier, Sequence) VALUES (?, ?, ?, ?, ?)');
|
1679 |
|
1680 |
+
// Simple Products
|
1681 |
$simpleProducts = $this->getProductCollection()
|
1682 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
1683 |
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
1704 |
'preparedproductanswerStatement' => $insertProductAnswer,
|
1705 |
'store' => $storeObject ));
|
1706 |
|
1707 |
+
// Virtual Products
|
1708 |
+
$virtualProducts = $this->getProductCollection()
|
1709 |
+
->addAttributeToSelect($this->availableProductFields, 'left')
|
1710 |
+
->addAttributeToFilter('type_id', array('eq' => 'virtual'))
|
1711 |
+
->addAttributeToFilter('entity_id', array('in' => $productUpdateIds) );
|
1712 |
+
$virtualProducts->getSelect()
|
1713 |
+
->columns(array('codisto_in_store' => new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')));
|
1714 |
+
|
1715 |
+
Mage::getSingleton('core/resource_iterator')->walk($virtualProducts->getSelect(), array(array($this, 'SyncSimpleProductData')),
|
1716 |
+
array(
|
1717 |
+
'type' => 'virtual',
|
1718 |
+
'db' => $db,
|
1719 |
+
'preparedStatement' => $insertProduct,
|
1720 |
+
'preparedcheckproductStatement' => $checkProduct,
|
1721 |
+
'preparedcategoryproductStatement' => $insertCategoryProduct,
|
1722 |
+
'preparedimageStatement' => $insertImage,
|
1723 |
+
'preparedproducthtmlStatement' => $insertProductHTML,
|
1724 |
+
'preparedproductrelatedStatement' => $insertProductRelated,
|
1725 |
+
'preparedattributeStatement' => $insertAttribute,
|
1726 |
+
'preparedattributegroupStatement' => $insertAttributeGroup,
|
1727 |
+
'preparedattributegroupmapStatement' => $insertAttributeGroupMap,
|
1728 |
+
'preparedproductattributeStatement' => $insertProductAttribute,
|
1729 |
+
'preparedproductattributedefaultStatement' => $insertProductAttributeDefault,
|
1730 |
+
'preparedproductquestionStatement' => $insertProductQuestion,
|
1731 |
+
'preparedproductanswerStatement' => $insertProductAnswer,
|
1732 |
+
'store' => $storeObject ));
|
1733 |
+
|
1734 |
+
|
1735 |
// Configurable products
|
1736 |
$configurableProducts = $this->getProductCollection()
|
1737 |
->addAttributeToSelect($this->availableProductFields, 'left')
|
1810 |
|
1811 |
if(!empty($orderUpdateIds))
|
1812 |
{
|
1813 |
+
$connection = $coreResource->getConnection(Mage_Core_Model_Resource::DEFAULT_WRITE_RESOURCE);
|
1814 |
+
try
|
1815 |
+
{
|
1816 |
+
$connection->addColumn(
|
1817 |
+
$tablePrefix . 'sales_flat_order',
|
1818 |
+
'codisto_orderid',
|
1819 |
+
'varchar(10)'
|
1820 |
+
);
|
1821 |
+
}
|
1822 |
+
catch(Exception $e)
|
1823 |
+
{
|
1824 |
+
}
|
1825 |
+
|
1826 |
+
try
|
1827 |
+
{
|
1828 |
+
$connection->addColumn(
|
1829 |
+
$tablePrefix . 'sales_flat_order',
|
1830 |
+
'codisto_merchantid',
|
1831 |
+
'varchar(10)'
|
1832 |
+
);
|
1833 |
+
}
|
1834 |
+
catch(Exception $e)
|
1835 |
+
{
|
1836 |
+
}
|
1837 |
+
|
1838 |
+
$insertOrders = $db->prepare('INSERT OR REPLACE INTO [Order] (ID, Status, PaymentDate, ShipmentDate, Carrier, TrackingNumber, ExternalReference, MerchantID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
|
1839 |
|
1840 |
$orderStoreId = $storeId;
|
1841 |
if($storeId == 0)
|
1856 |
$ts -= 7776000; // 90 days
|
1857 |
|
1858 |
$orders = Mage::getModel('sales/order')->getCollection()
|
1859 |
+
->addFieldToSelect(array('codisto_orderid', 'codisto_merchantid', 'status' ))
|
1860 |
->addFieldToSelect('entity_id','externalreference')
|
1861 |
->addAttributeToFilter('entity_id', array('in' => $orderUpdateIds ))
|
1862 |
->addAttributeToFilter('main_table.store_id', array('eq' => $orderStoreId ))
|
1865 |
$orders->getSelect()->joinLeft( array('i' => $invoiceName), 'i.order_id = main_table.entity_id AND i.state = 2', array('pay_date' => 'MIN(i.created_at)'));
|
1866 |
$orders->getSelect()->joinLeft( array('s' => $shipmentName), 's.order_id = main_table.entity_id', array('ship_date' => 'MIN(s.created_at)'));
|
1867 |
$orders->getSelect()->joinLeft( array('t' => $shipmentTrackName), 't.order_id = main_table.entity_id', array('carrier' => 'GROUP_CONCAT(COALESCE(t.title, \'\') SEPARATOR \',\')', 'track_number' => 'GROUP_CONCAT(COALESCE(t.track_number, \'\') SEPARATOR \',\')'));
|
1868 |
+
$orders->getSelect()->group(array('main_table.entity_id', 'main_table.codisto_orderid', 'main_table.codisto_merchantid', 'main_table.status'));
|
1869 |
$orders->setOrder('entity_id', 'ASC');
|
1870 |
|
1871 |
Mage::getSingleton('core/resource_iterator')->walk($orders->getSelect(), array(array($this, 'SyncOrderData')),
|
2078 |
$insertProductAttributeDefault = $db->prepare('INSERT OR IGNORE INTO ProductAttributeDefaultValue(ProductExternalReference, AttributeID, Value) VALUES (?, ?, ?)');
|
2079 |
$insertProductQuestion = $db->prepare('INSERT OR REPLACE INTO ProductQuestion(ExternalReference, ProductExternalReference, Name, Type, Sequence) VALUES (?, ?, ?, ?, ?)');
|
2080 |
$insertProductAnswer = $db->prepare('INSERT INTO ProductQuestionAnswer(ProductQuestionExternalReference, Value, PriceModifier, SKUModifier, Sequence) VALUES (?, ?, ?, ?, ?)');
|
2081 |
+
$insertOrders = $db->prepare('INSERT OR REPLACE INTO [Order] (ID, Status, PaymentDate, ShipmentDate, Carrier, TrackingNumber, ExternalReference, MerchantID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
|
2082 |
|
2083 |
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
2084 |
|
2165 |
|
2166 |
if($state == 'simple')
|
2167 |
{
|
2168 |
+
// Simple Products
|
2169 |
|
2170 |
$simpleProducts = $this->getProductCollection()->addAttributeToSelect($this->availableProductFields, 'left')
|
2171 |
->addAttributeToFilter('type_id', array('eq' => 'simple'))
|
2201 |
$db->exec('INSERT OR REPLACE INTO Progress (Sentinel, State, entity_id) VALUES (1, \'simple\', '.$this->currentEntityId.')');
|
2202 |
}
|
2203 |
else
|
2204 |
+
{
|
2205 |
+
$state = 'virtual';
|
2206 |
+
$this->currentEntityId = 0;
|
2207 |
+
}
|
2208 |
+
}
|
2209 |
+
|
2210 |
+
if($state == 'virtual')
|
2211 |
+
{
|
2212 |
+
// Virtual Products
|
2213 |
+
|
2214 |
+
$virtualProducts = $this->getProductCollection()->addAttributeToSelect($this->availableProductFields, 'left')
|
2215 |
+
->addAttributeToFilter('type_id', array('eq' => 'virtual'))
|
2216 |
+
->addAttributeToFilter('entity_id', array('gt' => (int)$this->currentEntityId));
|
2217 |
+
|
2218 |
+
$virtualProducts->getSelect()
|
2219 |
+
->columns(array('codisto_in_store' => new Zend_Db_Expr('CASE WHEN `e`.entity_id IN (SELECT product_id FROM `'.$catalogWebsiteName.'` WHERE website_id IN (SELECT website_id FROM `'.$storeName.'` WHERE store_id = '.$storeId.' OR EXISTS(SELECT 1 FROM `'.$storeName.'` WHERE store_id = '.$storeId.' AND website_id = 0))) THEN -1 ELSE 0 END')))
|
2220 |
+
->order('entity_id')
|
2221 |
+
->limit($simpleCount);
|
2222 |
+
$virtualProducts->setOrder('entity_id', 'ASC');
|
2223 |
+
|
2224 |
+
Mage::getSingleton('core/resource_iterator')->walk($virtualProducts->getSelect(), array(array($this, 'SyncSimpleProductData')),
|
2225 |
+
array(
|
2226 |
+
'type' => 'virtual',
|
2227 |
+
'db' => $db,
|
2228 |
+
'preparedStatement' => $insertProduct,
|
2229 |
+
'preparedcheckproductStatement' => $checkProduct,
|
2230 |
+
'preparedcategoryproductStatement' => $insertCategoryProduct,
|
2231 |
+
'preparedimageStatement' => $insertImage,
|
2232 |
+
'preparedproducthtmlStatement' => $insertProductHTML,
|
2233 |
+
'preparedproductrelatedStatement' => $insertProductRelated,
|
2234 |
+
'preparedattributeStatement' => $insertAttribute,
|
2235 |
+
'preparedattributegroupStatement' => $insertAttributeGroup,
|
2236 |
+
'preparedattributegroupmapStatement' => $insertAttributeGroupMap,
|
2237 |
+
'preparedproductattributeStatement' => $insertProductAttribute,
|
2238 |
+
'preparedproductattributedefaultStatement' => $insertProductAttributeDefault,
|
2239 |
+
'preparedproductquestionStatement' => $insertProductQuestion,
|
2240 |
+
'preparedproductanswerStatement' => $insertProductAnswer,
|
2241 |
+
'store' => $store ));
|
2242 |
+
|
2243 |
+
if(!empty($this->productsProcessed))
|
2244 |
+
{
|
2245 |
+
$db->exec('INSERT OR REPLACE INTO Progress (Sentinel, State, entity_id) VALUES (1, \'virtual\', '.$this->currentEntityId.')');
|
2246 |
+
}
|
2247 |
+
else
|
2248 |
{
|
2249 |
$state = 'configurable';
|
2250 |
$this->currentEntityId = 0;
|
2363 |
catch(Exception $e)
|
2364 |
{
|
2365 |
}
|
2366 |
+
|
2367 |
+
try
|
2368 |
+
{
|
2369 |
+
$connection->addColumn(
|
2370 |
+
$tablePrefix . 'sales_flat_order',
|
2371 |
+
'codisto_merchantid',
|
2372 |
+
'varchar(10)'
|
2373 |
+
);
|
2374 |
+
}
|
2375 |
+
catch(Exception $e)
|
2376 |
+
{
|
2377 |
+
}
|
2378 |
}
|
2379 |
|
2380 |
$orderStoreId = $storeId;
|
2396 |
$ts -= 7776000; // 90 days
|
2397 |
|
2398 |
$orders = Mage::getModel('sales/order')->getCollection()
|
2399 |
+
->addFieldToSelect(array('codisto_orderid', 'codisto_merchantid', 'status'))
|
2400 |
->addFieldToSelect('entity_id','externalreference')
|
2401 |
->addAttributeToFilter('entity_id', array('gt' => (int)$this->currentEntityId ))
|
2402 |
->addAttributeToFilter('main_table.store_id', array('eq' => $orderStoreId ))
|
2405 |
$orders->getSelect()->joinLeft( array('i' => $invoiceName), 'i.order_id = main_table.entity_id AND i.state = 2', array('pay_date' => 'MIN(i.created_at)'));
|
2406 |
$orders->getSelect()->joinLeft( array('s' => $shipmentName), 's.order_id = main_table.entity_id', array('ship_date' => 'MIN(s.created_at)'));
|
2407 |
$orders->getSelect()->joinLeft( array('t' => $shipmentTrackName), 't.order_id = main_table.entity_id', array('carrier' => 'GROUP_CONCAT(COALESCE(t.title, \'\') SEPARATOR \',\')', 'track_number' => 'GROUP_CONCAT(COALESCE(t.track_number, \'\') SEPARATOR \',\')'));
|
2408 |
+
$orders->getSelect()->group(array('main_table.entity_id', 'main_table.codisto_orderid', 'main_table.codisto_merchantid', 'main_table.status'));
|
2409 |
$orders->getSelect()->limit(1000);
|
2410 |
$orders->setOrder('entity_id', 'ASC');
|
2411 |
|
2459 |
$db->exec('INSERT OR REPLACE INTO Progress (Sentinel, State, entity_id) VALUES (1, \'complete\', 0)');
|
2460 |
}
|
2461 |
|
2462 |
+
if(empty($this->productsProcessed) && empty($this->ordersProcessed))
|
2463 |
{
|
2464 |
$uniqueId = uniqid();
|
2465 |
|
2474 |
|
2475 |
return 'complete';
|
2476 |
}
|
2477 |
+
else if($first)
|
2478 |
+
{
|
2479 |
+
$db->exec('COMMIT TRANSACTION');
|
2480 |
+
|
2481 |
+
return 'complete';
|
2482 |
+
}
|
2483 |
else
|
2484 |
{
|
2485 |
$db->exec('COMMIT TRANSACTION');
|
2500 |
|
2501 |
$simpleProducts = $this->getProductCollection()
|
2502 |
->addAttributeToSelect(array('entity_id'), 'left')
|
2503 |
+
->addAttributeToFilter('type_id', array('in' => array('simple', 'virtual')));
|
2504 |
|
2505 |
$simplecount = $simpleProducts->getSize();
|
2506 |
|
2727 |
|
2728 |
$db = $this->GetSyncDb($syncDb, 5 );
|
2729 |
|
2730 |
+
$insertOrders = $db->prepare('INSERT OR REPLACE INTO [Order] (ID, Status, PaymentDate, ShipmentDate, Carrier, TrackingNumber, ExternalReference, MerchantID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
|
2731 |
|
2732 |
$coreResource = Mage::getSingleton('core/resource');
|
2733 |
|
2738 |
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
2739 |
|
2740 |
$orders = Mage::getModel('sales/order')->getCollection()
|
2741 |
+
->addFieldToSelect(array('codisto_orderid', 'codisto_merchantid', 'status'))
|
2742 |
->addFieldToSelect('entity_id','externalreference')
|
2743 |
->addAttributeToFilter('codisto_orderid', array('in' => $orders ));
|
2744 |
|
2745 |
$orders->getSelect()->joinLeft( array('i' => $invoiceName), 'i.order_id = main_table.entity_id AND i.state = 2', array('pay_date' => 'MIN(i.created_at)'));
|
2746 |
$orders->getSelect()->joinLeft( array('s' => $shipmentName), 's.order_id = main_table.entity_id', array('ship_date' => 'MIN(s.created_at)'));
|
2747 |
$orders->getSelect()->joinLeft( array('t' => $shipmentTrackName), 't.order_id = main_table.entity_id', array('carrier' => 'GROUP_CONCAT(COALESCE(t.title, \'\') SEPARATOR \',\')', 'track_number' => 'GROUP_CONCAT(COALESCE(t.track_number, \'\') SEPARATOR \',\')'));
|
2748 |
+
$orders->getSelect()->group(array('main_table.entity_id', 'main_table.codisto_orderid', 'main_table.codisto_merchantid', 'main_table.status'));
|
2749 |
|
2750 |
$orders->setOrder('entity_id', 'ASC');
|
2751 |
|
2809 |
$db->exec('CREATE TABLE IF NOT EXISTS Store(ID integer NOT NULL PRIMARY KEY, Code text NOT NULL, Name text NOT NULL, Currency text NOT NULL)');
|
2810 |
$db->exec('CREATE TABLE IF NOT EXISTS StoreMerchant(StoreID integer NOT NULL, MerchantID integer NOT NULL, PRIMARY KEY (StoreID, MerchantID))');
|
2811 |
|
2812 |
+
$db->exec('CREATE TABLE IF NOT EXISTS [Order](ID integer NOT NULL PRIMARY KEY, Status text NOT NULL, PaymentDate datetime NULL, ShipmentDate datetime NULL, Carrier text NOT NULL, TrackingNumber text NOT NULL, ExternalReference text NOT NULL DEFAULT \'\', MerchantID text NOT NULL DEFAULT \'\')');
|
2813 |
|
2814 |
$db->exec('CREATE TABLE IF NOT EXISTS StaticBlock(BlockID integer NOT NULL PRIMARY KEY, Title text NOT NULL, Identifier text NOT NULL, Content text NOT NULL)');
|
2815 |
|
2836 |
$db->exec('ALTER TABLE [Order] ADD COLUMN ExternalReference text NOT NULL DEFAULT \'\'');
|
2837 |
}
|
2838 |
|
2839 |
+
try
|
2840 |
+
{
|
2841 |
+
$db->exec('SELECT 1 FROM [Order] WHERE MerchantID IS NULL LIMIT 1');
|
2842 |
+
}
|
2843 |
+
catch(Exception $e)
|
2844 |
+
{
|
2845 |
+
$db->exec('ALTER TABLE [Order] ADD COLUMN MerchantID text NOT NULL DEFAULT \'\'');
|
2846 |
+
}
|
2847 |
+
|
2848 |
try
|
2849 |
{
|
2850 |
$db->exec('SELECT 1 FROM ProductAttributeValue WHERE ProductExternalReference IS NULL LIMIT 1');
|
app/code/community/Codisto/Sync/controllers/IndexController.php
CHANGED
@@ -24,6 +24,9 @@ class Codisto_Sync_IndexController extends Mage_Core_Controller_Front_Action
|
|
24 |
{
|
25 |
set_time_limit(0);
|
26 |
ignore_user_abort(false);
|
|
|
|
|
|
|
27 |
|
28 |
$output = '';
|
29 |
|
@@ -294,6 +297,9 @@ class Codisto_Sync_IndexController extends Mage_Core_Controller_Front_Action
|
|
294 |
{
|
295 |
set_time_limit(0);
|
296 |
ignore_user_abort(false);
|
|
|
|
|
|
|
297 |
|
298 |
$request = $this->getRequest();
|
299 |
$response = $this->getResponse();
|
@@ -351,6 +357,19 @@ class Codisto_Sync_IndexController extends Mage_Core_Controller_Front_Action
|
|
351 |
|
352 |
}
|
353 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
if($storeId == 0)
|
355 |
{
|
356 |
// jump the storeid to first non admin store
|
@@ -406,7 +425,11 @@ class Codisto_Sync_IndexController extends Mage_Core_Controller_Front_Action
|
|
406 |
|
407 |
try
|
408 |
{
|
409 |
-
$order = Mage::getModel('sales/order')
|
|
|
|
|
|
|
|
|
410 |
|
411 |
if($order && $order->getId())
|
412 |
{
|
@@ -567,6 +590,7 @@ class Codisto_Sync_IndexController extends Mage_Core_Controller_Front_Action
|
|
567 |
$order->setPayment($quoteConverter->paymentToOrderPayment($quote->getPayment()));
|
568 |
$order->setCustomer($quote->getCustomer());
|
569 |
$order->setCodistoOrderid((string)$ordercontent->orderid);
|
|
|
570 |
|
571 |
if(preg_match('/\{ordernumber\}|\{ebaysalesrecordnumber\}|\{ebaytransactionid\}/', $ordernumberformat))
|
572 |
{
|
@@ -757,7 +781,7 @@ class Codisto_Sync_IndexController extends Mage_Core_Controller_Front_Action
|
|
757 |
if($shippingDescription)
|
758 |
{
|
759 |
$shippingRates = $quote->getShippingAddress()->getAllShippingRates();
|
760 |
-
|
761 |
foreach($shippingRates as $rate)
|
762 |
{
|
763 |
$shippingMethodTitle = $rate->getMethodTitle();
|
24 |
{
|
25 |
set_time_limit(0);
|
26 |
ignore_user_abort(false);
|
27 |
+
@ini_set('display_errors', 1);
|
28 |
+
@ini_set('display_startup_errors', 1);
|
29 |
+
@error_reporting(E_ALL);
|
30 |
|
31 |
$output = '';
|
32 |
|
297 |
{
|
298 |
set_time_limit(0);
|
299 |
ignore_user_abort(false);
|
300 |
+
@ini_set('display_errors', 1);
|
301 |
+
@ini_set('display_startup_errors', 1);
|
302 |
+
@error_reporting(E_ALL);
|
303 |
|
304 |
$request = $this->getRequest();
|
305 |
$response = $this->getResponse();
|
357 |
|
358 |
}
|
359 |
|
360 |
+
try
|
361 |
+
{
|
362 |
+
$connection->addColumn(
|
363 |
+
Mage::getConfig()->getTablePrefix() . 'sales_flat_order',
|
364 |
+
'codisto_merchantid',
|
365 |
+
'varchar(10)'
|
366 |
+
);
|
367 |
+
}
|
368 |
+
catch(Exception $e)
|
369 |
+
{
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
if($storeId == 0)
|
374 |
{
|
375 |
// jump the storeid to first non admin store
|
425 |
|
426 |
try
|
427 |
{
|
428 |
+
$order = Mage::getModel('sales/order')
|
429 |
+
->getCollection()
|
430 |
+
->addAttributeToFilter('codisto_orderid', $ordercontent->orderid)
|
431 |
+
->addAttributeToFilter('codisto_merchantid', $ordercontent->merchantid)
|
432 |
+
->getFirstItem();
|
433 |
|
434 |
if($order && $order->getId())
|
435 |
{
|
590 |
$order->setPayment($quoteConverter->paymentToOrderPayment($quote->getPayment()));
|
591 |
$order->setCustomer($quote->getCustomer());
|
592 |
$order->setCodistoOrderid((string)$ordercontent->orderid);
|
593 |
+
$order->setCodistoMerchantid((string)$ordercontent->merchantid);
|
594 |
|
595 |
if(preg_match('/\{ordernumber\}|\{ebaysalesrecordnumber\}|\{ebaytransactionid\}/', $ordernumberformat))
|
596 |
{
|
781 |
if($shippingDescription)
|
782 |
{
|
783 |
$shippingRates = $quote->getShippingAddress()->getAllShippingRates();
|
784 |
+
|
785 |
foreach($shippingRates as $rate)
|
786 |
{
|
787 |
$shippingMethodTitle = $rate->getMethodTitle();
|
app/code/community/Codisto/Sync/controllers/SyncController.php
CHANGED
@@ -42,6 +42,9 @@ class Codisto_Sync_SyncController extends Mage_Core_Controller_Front_Action
|
|
42 |
@ini_set('zlib.output_compression', 'Off');
|
43 |
@ini_set('output_buffering', 'Off');
|
44 |
@ini_set('output_handler', '');
|
|
|
|
|
|
|
45 |
|
46 |
ignore_user_abort(true);
|
47 |
|
@@ -182,8 +185,6 @@ class Codisto_Sync_SyncController extends Mage_Core_Controller_Front_Action
|
|
182 |
}
|
183 |
else
|
184 |
{
|
185 |
-
$sendFullDb = true;
|
186 |
-
|
187 |
if(!$request->getQuery('first') &&
|
188 |
is_string($request->getQuery('incremental')))
|
189 |
{
|
@@ -197,6 +198,16 @@ class Codisto_Sync_SyncController extends Mage_Core_Controller_Front_Action
|
|
197 |
|
198 |
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
$qry = $db->query('SELECT CASE WHEN EXISTS(SELECT 1 FROM SyncDb.sqlite_master WHERE type COLLATE NOCASE = \'TABLE\' AND name = \'ProductChange\') THEN -1 ELSE 0 END');
|
201 |
$productChange = $qry->fetchColumn();
|
202 |
$qry->closeCursor();
|
@@ -266,13 +277,27 @@ class Codisto_Sync_SyncController extends Mage_Core_Controller_Front_Action
|
|
266 |
$this->sendFile($tmpDb, 'incremental');
|
267 |
|
268 |
unlink($tmpDb);
|
269 |
-
|
270 |
-
$sendFullDb = false;
|
271 |
}
|
272 |
-
|
273 |
-
if($sendFullDb)
|
274 |
{
|
275 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
}
|
277 |
}
|
278 |
}
|
42 |
@ini_set('zlib.output_compression', 'Off');
|
43 |
@ini_set('output_buffering', 'Off');
|
44 |
@ini_set('output_handler', '');
|
45 |
+
@ini_set('display_errors', 1);
|
46 |
+
@ini_set('display_startup_errors', 1);
|
47 |
+
@error_reporting(E_ALL);
|
48 |
|
49 |
ignore_user_abort(true);
|
50 |
|
185 |
}
|
186 |
else
|
187 |
{
|
|
|
|
|
188 |
if(!$request->getQuery('first') &&
|
189 |
is_string($request->getQuery('incremental')))
|
190 |
{
|
198 |
|
199 |
$db->exec('BEGIN EXCLUSIVE TRANSACTION');
|
200 |
|
201 |
+
$qry = $db->query('SELECT CASE WHEN EXISTS(SELECT 1 FROM SyncDb.sqlite_master WHERE type COLLATE NOCASE = \'TABLE\' AND name = \'Sync\') THEN -1 ELSE 0 END');
|
202 |
+
$syncComplete = $qry->fetchColumn();
|
203 |
+
$qry->closeCursor();
|
204 |
+
if(!$syncComplete)
|
205 |
+
{
|
206 |
+
@unlink($tmpDb);
|
207 |
+
|
208 |
+
throw new Exception('Attempting to download partial sync db - incremental');
|
209 |
+
}
|
210 |
+
|
211 |
$qry = $db->query('SELECT CASE WHEN EXISTS(SELECT 1 FROM SyncDb.sqlite_master WHERE type COLLATE NOCASE = \'TABLE\' AND name = \'ProductChange\') THEN -1 ELSE 0 END');
|
212 |
$productChange = $qry->fetchColumn();
|
213 |
$qry->closeCursor();
|
277 |
$this->sendFile($tmpDb, 'incremental');
|
278 |
|
279 |
unlink($tmpDb);
|
|
|
|
|
280 |
}
|
281 |
+
else
|
|
|
282 |
{
|
283 |
+
$syncComplete = true;
|
284 |
+
|
285 |
+
if(!$request->getQuery('first'))
|
286 |
+
{
|
287 |
+
$db = new PDO('sqlite:' . $syncDb);
|
288 |
+
$qry = $db->query('SELECT CASE WHEN EXISTS(SELECT 1 FROM sqlite_master WHERE type COLLATE NOCASE = \'TABLE\' AND name = \'Sync\') THEN -1 ELSE 0 END');
|
289 |
+
$syncComplete = $qry->fetchColumn();
|
290 |
+
$qry->closeCursor();
|
291 |
+
}
|
292 |
+
|
293 |
+
if($syncComplete)
|
294 |
+
{
|
295 |
+
$this->sendFile($syncDb);
|
296 |
+
}
|
297 |
+
else
|
298 |
+
{
|
299 |
+
throw new Exception('Attempting to download partial sync db');
|
300 |
+
}
|
301 |
}
|
302 |
}
|
303 |
}
|
app/code/community/Codisto/Sync/data/codisto_setup/{data-install-1.90.15.php → data-install-1.90.16.php}
RENAMED
File without changes
|
app/code/community/Codisto/Sync/etc/config.xml
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Codisto_Sync>
|
26 |
-
<version>1.90.
|
27 |
<depends>
|
28 |
<Mage_Payment/>
|
29 |
</depends>
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Codisto_Sync>
|
26 |
+
<version>1.90.16</version>
|
27 |
<depends>
|
28 |
<Mage_Payment/>
|
29 |
</depends>
|
app/code/community/Codisto/Sync/sql/codisto_setup/{mysql4-install-1.90.15.php → mysql4-install-1.90.16.php}
RENAMED
@@ -30,4 +30,10 @@ $connection->addColumn(
|
|
30 |
'varchar(10)'
|
31 |
);
|
32 |
|
33 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
30 |
'varchar(10)'
|
31 |
);
|
32 |
|
33 |
+
$connection->addColumn(
|
34 |
+
$tablename,
|
35 |
+
'codisto_merchantid',
|
36 |
+
'varchar(10)'
|
37 |
+
);
|
38 |
+
|
39 |
+
$installer->endSetup();
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
<package><name>codistoconnect</name><version>1.90.
|
1 |
<?xml version="1.0"?>
|
2 |
+
<package><name>codistoconnect</name><version>1.90.16</version><stability>stable</stability><license>OSL-3.0</license><channel>community</channel><extends></extends><summary>Fastest, Easiest eBay listing</summary><description>CodistoConnect enables you to list on eBay in the simplest way possible with maximum performance</description><notes></notes><authors><author><name>Codisto</name><user>Codisto</user><email>hello@codisto.com</email></author></authors><date>2016-09-28</date><time>20:10:49</time><compatible></compatible><dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><dir name="app"><dir name="design"><dir name="ebay"><file name="README" hash="8a3f3351f68ccde9f161cdbe3960392f"/></dir></dir><dir name="code"><dir name="community"><dir name="Codisto"><dir name="Sync"><dir name="Helper"><file name="CmsContent.php" hash="f00b4523d681c60c660089d0de0f2e03"/><file name="Data.php" hash="8a0721d8d2d882c4ba64e9dab9de4fe9"/><file name="Signal.php" hash="998380ec7df67fe41a27475fc7fe7ed2"/></dir><dir name="controllers"><file name="CodistoController.php" hash="eccbf167582d60ae559b7455b9b8e7ea"/><file name="IndexController.php" hash="0499471f5b7a99dfcbda40018928244e"/><file name="SyncController.php" hash="fcff6d6e902a74314e522c1d71bb6636"/></dir><dir name="Controller"><file name="Router.php" hash="66d43bfbe826fe525dc764d42146cd50"/></dir><dir name="Test"><file name="README" hash="8299e52f9198536ff5fd3fb42f4a29d8"/><dir name="Config"><file name="AdminHtml.php" hash="6ee6404e52ed6376ad41b7556f265c32"/><file name="Config.php" hash="2e9023fcbab484d03936394934f44f13"/><dir name="Config"><dir name="expectations"><file name="testCodistoCoreConfig.yaml" hash="4a4e07f62981139ff6eb8a63420cbf0d"/></dir></dir></dir><dir name="Controllers"><file name="CodistoController.php" hash="a2be4faeac73ff1847c0d7dc4fbdc0e0"/><file name="IndexController.php" hash="f7252fae8d2f7b67397ae56524db49d1"/><file name="SyncController.php" hash="33436e4935631488073765d723a82ff7"/></dir><dir name="Controller"><file name="Router.php" hash="8afc0dca269dd0977ff6b3ac6802d0ee"/></dir><dir name="Model"><file name="Paymentmethod.php" hash="862365909073ffbba057f6f152933826"/><file name="Sync.php" hash="10a38bbb62260208a8b1529e762b7b75"/></dir></dir><dir name="sql"><dir name="codisto_setup"><file name="mysql4-install-1.90.16.php" hash="f5e7410bdb70ae4c021e3d257ccbf9a9"/></dir></dir><dir name="data"><dir name="codisto_setup"><file name="data-install-1.90.16.php" hash="29334830432cf1a02e4a992b9a42d6c5"/></dir></dir><dir name="Block"><file name="PaymentInfo.php" hash="7aa15fed37766d20d9d5a7d707aff80d"/></dir><dir name="Ebaypayment"><dir name="Model"><file name="Paymentmethod.php" hash="480787461a5b952a739f20a752bffb5d"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="9503ace98df8dfa2f2ec460b30e1053d"/><file name="config.xml" hash="142006a6dbb6b5556e3911b04f4b345b"/></dir><dir name="Model"><file name="Observer.php" hash="81c22aef68f97ef2e89c32729e3b378b"/><file name="Sync.php" hash="380df62a188b83592db593efc18905c3"/><dir name="Indexer"><file name="Ebay.php" hash="556b1aabc7c3202f31a2e6c250e7d590"/></dir><dir name="Resource"><dir name="Mysql4"><file name="Setup.php" hash="6a6664ea18d93bcdd0f45530caa56244"/></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Codisto_Sync.xml" hash="a791bc2a9302d085eb29edf77421f525"/></dir></dir></dir></target></contents></package>
|