Version Notes
- fixed bug in module activation
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Channelpilotsolutions_Channelpilot |
| Version | 2.1.3 |
| Comparing to | |
| See all releases | |
Code changes from version 2.1.2 to 2.1.3
- app/code/community/Channelpilotsolutions/Channelpilot/Helper/Data.php +238 -238
- app/code/community/Channelpilotsolutions/Channelpilot/Helper/ExportData.php +646 -646
- app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/ChannelPilotSellerAPI_v1_0.php +184 -184
- app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPExportHandler.php +1 -1
- app/code/community/Channelpilotsolutions/Channelpilot/Model/PaymentTypes.php +0 -6
- app/code/community/Channelpilotsolutions/Channelpilot/etc/config.xml +1 -1
- package.xml +5 -5
app/code/community/Channelpilotsolutions/Channelpilot/Helper/Data.php
CHANGED
|
@@ -1,240 +1,240 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the GNU General Public License (GPL 3)
|
| 8 |
-
* that is bundled with this package in the file LICENSE.txt
|
| 9 |
-
*
|
| 10 |
-
* DISCLAIMER
|
| 11 |
-
*
|
| 12 |
-
* Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
|
| 13 |
-
* versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
|
| 14 |
-
* needs please refer to http://www.channelpilot.com for more information.
|
| 15 |
-
*
|
| 16 |
-
* @category Channelpilotsolutions
|
| 17 |
-
* @package Channelpilotsolutions_Channelpilot
|
| 18 |
-
* @subpackage helper
|
| 19 |
-
* @copyright Copyright (c) 2013 <info@channelpilot.com> - www.channelpilot.com
|
| 20 |
-
* @author Peter Hoffmann <info@channelpilot.com>
|
| 21 |
-
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
| 22 |
-
* @link http://www.channelpilot.com
|
| 23 |
-
*/
|
| 24 |
-
require_once 'CPErrors.php';
|
| 25 |
-
|
| 26 |
-
// Handler
|
| 27 |
-
require_once 'handler/CPAbstractHandler.php';
|
| 28 |
-
require_once 'handler/CPErrorHandler.php';
|
| 29 |
-
require_once 'handler/CPExportHandler.php';
|
| 30 |
-
require_once 'handler/CPStatusHandler.php';
|
| 31 |
-
require_once 'handler/CPRegisterHandler.php';
|
| 32 |
-
require_once 'handler/CPNewPriceHandler.php';
|
| 33 |
-
require_once 'handler/CPOrderHandler.php';
|
| 34 |
-
require_once 'handler/CPDeliveryHandler.php';
|
| 35 |
-
require_once 'handler/CPCancellationHandler.php';
|
| 36 |
-
require_once 'handler/CPNewsHandler.php';
|
| 37 |
-
require_once 'handler/CPDebugHandler.php';
|
| 38 |
-
|
| 39 |
-
// RESPONSES
|
| 40 |
-
require_once 'responses/CPHookResponse.php';
|
| 41 |
-
require_once 'responses/CPGetStatusHookResponse.php';
|
| 42 |
-
require_once 'responses/CPRegisterHookResponse.php';
|
| 43 |
-
|
| 44 |
-
// API
|
| 45 |
-
require_once 'api/1_0/thin/CPDelivery.php';
|
| 46 |
-
require_once 'api/1_0/ChannelPilotSellerAPI_v1_0.php';
|
| 47 |
-
require_once 'api/1_0/CPResultCodes.php';
|
| 48 |
-
|
| 49 |
-
// special customer functions
|
| 50 |
-
require_once 'special/CustomerFunctions.php';
|
| 51 |
-
|
| 52 |
-
class Channelpilotsolutions_Channelpilot_Helper_Data extends Mage_Core_Helper_Abstract {
|
| 53 |
-
|
| 54 |
-
const GET_REGISTER = "register";
|
| 55 |
-
const GET_EXPORT = "export";
|
| 56 |
-
const GET_STATUS = "status";
|
| 57 |
-
const GET_IMPORT_ORDERS = "orders";
|
| 58 |
-
const GET_DELIVERED = "deliveries";
|
| 59 |
-
const GET_CANCELLATION = "cancellations";
|
| 60 |
-
const GET_NEWS = "news";
|
| 61 |
-
const GET_NEWPRICES = "prices";
|
| 62 |
-
const GET_DEBUG = "debug";
|
| 63 |
-
|
| 64 |
-
public function __construct($root = 'root') {
|
| 65 |
-
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
public function createXml() {
|
| 69 |
-
if (strpos(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "true") !== false || strpos(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "1") !== false) {
|
| 70 |
-
$password = Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_password');
|
| 71 |
-
if ($password == '' || (isset($_GET['password']) AND $_GET['password'] == $password)) {
|
| 72 |
-
header('Content-Type: text/xml; charset=utf-8');
|
| 73 |
-
include 'ExportData.php';
|
| 74 |
-
$exporter = new ExportData();
|
| 75 |
-
echo('<?xml version="1.0"?>');
|
| 76 |
-
echo("<root>");
|
| 77 |
-
echo("<catalog>");
|
| 78 |
-
$exporter->_runMain();
|
| 79 |
-
echo("</catalog>");
|
| 80 |
-
echo("</root>");
|
| 81 |
-
exit();
|
| 82 |
-
return;
|
| 83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
// Send
|
| 115 |
-
case self::
|
| 116 |
-
$this->checkActivation(array($marketplaceActive
|
| 117 |
-
$
|
| 118 |
-
$
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
$this->
|
| 125 |
-
$
|
| 126 |
-
$
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
$this->
|
| 133 |
-
$
|
| 134 |
-
$
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
$
|
| 141 |
-
$
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
$
|
| 149 |
-
$
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
$
|
| 157 |
-
$
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
$
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
try {
|
| 219 |
-
$sResult = $dbConnection->fetchAll($sQuery);
|
| 220 |
-
foreach ($sResult as $resultType) {
|
| 221 |
-
$ips = explode(";", $resultType['ips_authorized']);
|
| 222 |
-
foreach ($ips as $ip) {
|
| 223 |
-
$allIps[] = $ip;
|
| 224 |
-
}
|
| 225 |
-
}
|
| 226 |
-
} catch (Exception $e) {
|
| 227 |
-
$dbConnection->closeConnection();
|
| 228 |
-
CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getAllowedIpsViaSecurityToken(): " . $e->getMessage(), "Exception in getAllowedIpsViaSecurityToken(): '$sQuery'\n" . $e->getMessage());
|
| 229 |
-
}
|
| 230 |
-
|
| 231 |
-
if (!in_array($_SERVER['REMOTE_ADDR'], $allIps)) {
|
| 232 |
-
return false;
|
| 233 |
-
}
|
| 234 |
-
}
|
| 235 |
-
return true;
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
}
|
| 239 |
-
|
| 240 |
?>
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt
|
| 9 |
+
*
|
| 10 |
+
* DISCLAIMER
|
| 11 |
+
*
|
| 12 |
+
* Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
|
| 13 |
+
* versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
|
| 14 |
+
* needs please refer to http://www.channelpilot.com for more information.
|
| 15 |
+
*
|
| 16 |
+
* @category Channelpilotsolutions
|
| 17 |
+
* @package Channelpilotsolutions_Channelpilot
|
| 18 |
+
* @subpackage helper
|
| 19 |
+
* @copyright Copyright (c) 2013 <info@channelpilot.com> - www.channelpilot.com
|
| 20 |
+
* @author Peter Hoffmann <info@channelpilot.com>
|
| 21 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
| 22 |
+
* @link http://www.channelpilot.com
|
| 23 |
+
*/
|
| 24 |
+
require_once 'CPErrors.php';
|
| 25 |
+
|
| 26 |
+
// Handler
|
| 27 |
+
require_once 'handler/CPAbstractHandler.php';
|
| 28 |
+
require_once 'handler/CPErrorHandler.php';
|
| 29 |
+
require_once 'handler/CPExportHandler.php';
|
| 30 |
+
require_once 'handler/CPStatusHandler.php';
|
| 31 |
+
require_once 'handler/CPRegisterHandler.php';
|
| 32 |
+
require_once 'handler/CPNewPriceHandler.php';
|
| 33 |
+
require_once 'handler/CPOrderHandler.php';
|
| 34 |
+
require_once 'handler/CPDeliveryHandler.php';
|
| 35 |
+
require_once 'handler/CPCancellationHandler.php';
|
| 36 |
+
require_once 'handler/CPNewsHandler.php';
|
| 37 |
+
require_once 'handler/CPDebugHandler.php';
|
| 38 |
+
|
| 39 |
+
// RESPONSES
|
| 40 |
+
require_once 'responses/CPHookResponse.php';
|
| 41 |
+
require_once 'responses/CPGetStatusHookResponse.php';
|
| 42 |
+
require_once 'responses/CPRegisterHookResponse.php';
|
| 43 |
+
|
| 44 |
+
// API
|
| 45 |
+
require_once 'api/1_0/thin/CPDelivery.php';
|
| 46 |
+
require_once 'api/1_0/ChannelPilotSellerAPI_v1_0.php';
|
| 47 |
+
require_once 'api/1_0/CPResultCodes.php';
|
| 48 |
+
|
| 49 |
+
// special customer functions
|
| 50 |
+
require_once 'special/CustomerFunctions.php';
|
| 51 |
+
|
| 52 |
+
class Channelpilotsolutions_Channelpilot_Helper_Data extends Mage_Core_Helper_Abstract {
|
| 53 |
+
|
| 54 |
+
const GET_REGISTER = "register";
|
| 55 |
+
const GET_EXPORT = "export";
|
| 56 |
+
const GET_STATUS = "status";
|
| 57 |
+
const GET_IMPORT_ORDERS = "orders";
|
| 58 |
+
const GET_DELIVERED = "deliveries";
|
| 59 |
+
const GET_CANCELLATION = "cancellations";
|
| 60 |
+
const GET_NEWS = "news";
|
| 61 |
+
const GET_NEWPRICES = "prices";
|
| 62 |
+
const GET_DEBUG = "debug";
|
| 63 |
+
|
| 64 |
+
public function __construct($root = 'root') {
|
| 65 |
+
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
public function createXml() {
|
| 69 |
+
if (strpos(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "true") !== false || strpos(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "1") !== false) {
|
| 70 |
+
$password = Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_password');
|
| 71 |
+
if ($password == '' || (isset($_GET['password']) AND $_GET['password'] == $password)) {
|
| 72 |
+
header('Content-Type: text/xml; charset=utf-8');
|
| 73 |
+
include 'ExportData.php';
|
| 74 |
+
$exporter = new ExportData();
|
| 75 |
+
echo('<?xml version="1.0"?>');
|
| 76 |
+
echo("<root>");
|
| 77 |
+
echo("<catalog>");
|
| 78 |
+
$exporter->_runMain();
|
| 79 |
+
echo("</catalog>");
|
| 80 |
+
echo("</root>");
|
| 81 |
+
exit();
|
| 82 |
+
return;
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
// API CONNECTOR
|
| 89 |
+
public function api() {
|
| 90 |
+
$hook = null;
|
| 91 |
+
if ($this->checkIp() === false) {
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
$newsActive = false;
|
| 96 |
+
if (strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_useNews'), "true") === 0 || strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_useNews'), "1") === 0) {
|
| 97 |
+
$newsActive = true;
|
| 98 |
+
}
|
| 99 |
+
$marketplaceActive = false;
|
| 100 |
+
if (strcmp(Mage::getStoreConfig('channelpilot_marketplace/channelpilot_marketplace/channelpilot_useMarketplaces'), "true") === 0 || strcmp(Mage::getStoreConfig('channelpilot_marketplace/channelpilot_marketplace/channelpilot_useMarketplaces'), "1") === 0) {
|
| 101 |
+
$marketplaceActive = true;
|
| 102 |
+
}
|
| 103 |
+
$pricecontrolActive = false;
|
| 104 |
+
if (strcmp(Mage::getStoreConfig('channelpilot_pricecontrol/channelpilot_general/channelpilot_usePricecontrol'), "true") === 0 || strcmp(Mage::getStoreConfig('channelpilot_pricecontrol/channelpilot_general/channelpilot_usePricecontrol'), "1") === 0) {
|
| 105 |
+
$pricecontrolActive = true;
|
| 106 |
}
|
| 107 |
+
$exportActive = false;
|
| 108 |
+
if (strcmp(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "true") === 0 || strcmp(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_useExport'), "1") === 0) {
|
| 109 |
+
$exportActive = true;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
switch ($_GET['method']) {
|
| 114 |
+
// Send method
|
| 115 |
+
case self::GET_STATUS:
|
| 116 |
+
$this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
|
| 117 |
+
$handler = new CPStatusHandler();
|
| 118 |
+
$hook = $handler->handle();
|
| 119 |
+
break;
|
| 120 |
+
|
| 121 |
+
// Send method + merchantid + multishopid + token + ips
|
| 122 |
+
case self::GET_REGISTER:
|
| 123 |
+
$this->checkActivation(array($marketplaceActive, $pricecontrolActive), 'marketplace OR pricecontrol');
|
| 124 |
+
$this->checkSignature();
|
| 125 |
+
$handler = new CPRegisterHandler();
|
| 126 |
+
$hook = $handler->handle();
|
| 127 |
+
break;
|
| 128 |
+
|
| 129 |
+
// Send Method + token
|
| 130 |
+
case self::GET_IMPORT_ORDERS:
|
| 131 |
+
$this->checkActivation(array($marketplaceActive), 'marketplace');
|
| 132 |
+
$this->checkSignature();
|
| 133 |
+
$handler = new CPOrderHandler();
|
| 134 |
+
$hook = $handler->handle();
|
| 135 |
+
break;
|
| 136 |
+
// Send Method + token
|
| 137 |
+
case self::GET_DELIVERED:
|
| 138 |
+
$this->checkActivation(array($marketplaceActive), 'marketplace');
|
| 139 |
+
$this->checkSignature();
|
| 140 |
+
$handler = new CPDeliveryHandler();
|
| 141 |
+
$hook = $handler->handle();
|
| 142 |
+
break;
|
| 143 |
+
|
| 144 |
+
// Send Method + token
|
| 145 |
+
case self::GET_CANCELLATION:
|
| 146 |
+
$this->checkActivation(array($marketplaceActive), 'marketplace');
|
| 147 |
+
$this->checkSignature();
|
| 148 |
+
$handler = new CPCancellationHandler();
|
| 149 |
+
$hook = $handler->handle();
|
| 150 |
+
break;
|
| 151 |
+
|
| 152 |
+
// Send method
|
| 153 |
+
case self::GET_NEWS:
|
| 154 |
+
$this->checkActivation(array($newsActive), 'news');
|
| 155 |
+
$this->checkSignature();
|
| 156 |
+
$handler = new CPNewsHandler();
|
| 157 |
+
$hook = $handler->handle();
|
| 158 |
+
break;
|
| 159 |
+
|
| 160 |
+
// Send method + token + priceId
|
| 161 |
+
case self::GET_NEWPRICES:
|
| 162 |
+
$this->checkActivation(array($pricecontrolActive), 'pricecontrol');
|
| 163 |
+
// $this->checkSignature();
|
| 164 |
+
$handler = new CPNewPriceHandler();
|
| 165 |
+
$hook = $handler->handle();
|
| 166 |
+
break;
|
| 167 |
+
|
| 168 |
+
// Send method + limit + shopId ( + last)
|
| 169 |
+
case self::GET_EXPORT:
|
| 170 |
+
$this->checkActivation(array($exportActive), 'export');
|
| 171 |
+
// $this->checkSignature();
|
| 172 |
+
$handler = new CPExportHandler();
|
| 173 |
+
$hook = $handler->handle();
|
| 174 |
+
break;
|
| 175 |
+
|
| 176 |
+
// Send method + limit + shopId ( + last)
|
| 177 |
+
case self::GET_DEBUG:
|
| 178 |
+
$this->checkSignature();
|
| 179 |
+
$handler = new CPDebugHandler();
|
| 180 |
+
$hook = $handler->handle();
|
| 181 |
+
break;
|
| 182 |
+
|
| 183 |
+
default:
|
| 184 |
+
$hook = "not supported method: " . $_GET['method'];
|
| 185 |
+
break;
|
| 186 |
+
}
|
| 187 |
+
header("Content-Type: application/json;");
|
| 188 |
+
print_r(json_encode($hook));
|
| 189 |
+
exit();
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
private function checkSignature() {
|
| 193 |
+
IF (isset($_GET['php']) && isset($_GET['shop']) && isset($_GET['plugin'])) {
|
| 194 |
+
if ($_GET['php'] == phpversion() && $_GET['shop'] == CPHookResponse::getSignatureShop() && $_GET['plugin'] == CPHookResponse::getModuleVersion()) {
|
| 195 |
+
return true;
|
| 196 |
+
}
|
| 197 |
+
CPErrorHandler::handle(CPErrors::RESULT_SIGNATURE_MISMATCH, "Signature changed", "Signature changed \n" . $_GET['php'] . " -> " . phpversion() . "\n" . $_GET['shop'] . " -> " . CPHookResponse::getSignatureShop() . "\n" . $_GET['plugin'] . " -> " . CPHookResponse::getModuleVersion());
|
| 198 |
+
} else {
|
| 199 |
+
CPErrorHandler::handle(CPErrors::RESULT_MISSING_PARAMS, "Missing params for signature check", "Missing params for signature check");
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
private function checkActivation($configs, $function) {
|
| 204 |
+
foreach ($configs as $config) {
|
| 205 |
+
if ($config === true) {
|
| 206 |
+
return true;
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
CPErrorHandler::handle(CPErrors::RESULT_API_DEACTIVATED, "'$function' not activated", "'$function' not activated");
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
private function checkIp() {
|
| 213 |
+
if (strcmp(Mage::getStoreConfig('channelpilot_general/channelpilot_general/channelpilot_checkIp'), "true") === 0) {
|
| 214 |
+
$allIps = array();
|
| 215 |
+
$allIps[] = CPAbstractHandler::ChannelPilot_IP;
|
| 216 |
+
$sQuery = "SELECT ips_authorized FROM " . CPAbstractHandler::DB_REGISTRATION;
|
| 217 |
+
$dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 218 |
+
try {
|
| 219 |
+
$sResult = $dbConnection->fetchAll($sQuery);
|
| 220 |
+
foreach ($sResult as $resultType) {
|
| 221 |
+
$ips = explode(";", $resultType['ips_authorized']);
|
| 222 |
+
foreach ($ips as $ip) {
|
| 223 |
+
$allIps[] = $ip;
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
} catch (Exception $e) {
|
| 227 |
+
$dbConnection->closeConnection();
|
| 228 |
+
CPErrorHandler::handle(CPResultCodes::SYSTEM_ERROR, "Exception in getAllowedIpsViaSecurityToken(): " . $e->getMessage(), "Exception in getAllowedIpsViaSecurityToken(): '$sQuery'\n" . $e->getMessage());
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
if (!in_array($_SERVER['REMOTE_ADDR'], $allIps)) {
|
| 232 |
+
return false;
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
return true;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
}
|
| 239 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
?>
|
app/code/community/Channelpilotsolutions/Channelpilot/Helper/ExportData.php
CHANGED
|
@@ -1,646 +1,646 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
/**
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the GNU General Public License (GPL 3)
|
| 8 |
-
* that is bundled with this package in the file LICENSE.txt
|
| 9 |
-
*
|
| 10 |
-
* DISCLAIMER
|
| 11 |
-
*
|
| 12 |
-
* Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
|
| 13 |
-
* versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
|
| 14 |
-
* needs please refer to http://www.channelpilot.com for more information.
|
| 15 |
-
*
|
| 16 |
-
* @category Channelpilotsolutions
|
| 17 |
-
* @package Channelpilotsolutions_Channelpilot
|
| 18 |
-
* @subpackage helper
|
| 19 |
-
* @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
|
| 20 |
-
* @author Peter Hoffmann <info@channelpilot.com>
|
| 21 |
-
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
| 22 |
-
* @link http://www.channelpilot.com
|
| 23 |
-
*/
|
| 24 |
-
class ExportData {
|
| 25 |
-
|
| 26 |
-
private $_tablePrefix;
|
| 27 |
-
private $_storeId;
|
| 28 |
-
private $_siteId;
|
| 29 |
-
private $_mediaUrl;
|
| 30 |
-
private $_webUrl;
|
| 31 |
-
private $_dbConnection;
|
| 32 |
-
private $_allCat;
|
| 33 |
-
private $oldCatPath;
|
| 34 |
-
private $xml;
|
| 35 |
-
|
| 36 |
-
function __construct() {
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
// Increase maximum execution time to 4 hours
|
| 40 |
-
ini_set('max_execution_time', 7200);
|
| 41 |
-
|
| 42 |
-
// Initialize the admin application
|
| 43 |
-
Mage::app('admin');
|
| 44 |
-
|
| 45 |
-
// Get the table prefix
|
| 46 |
-
$tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
|
| 47 |
-
$this->_tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
|
| 48 |
-
|
| 49 |
-
// Get database connection
|
| 50 |
-
$this->_dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
// Apply prefix to table names in the query
|
| 54 |
-
private function _applyTablePrefix($query) {
|
| 55 |
-
return str_replace('ChannelPilotSolutions_ChannelPilot_', $this->_tablePrefix, $query);
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
-
// Run the main application and call the appropriate function
|
| 59 |
-
// depending on the command.
|
| 60 |
-
public function _runMain() {
|
| 61 |
-
if (isset($_GET['store']) AND $_GET['store'] != '') {
|
| 62 |
-
$this->_storeId = $_GET['store'];
|
| 63 |
-
} else {
|
| 64 |
-
$this->_storeId = Mage::app()->getStore()->getId();
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
// Validate store and get information
|
| 68 |
-
$this->_getStoreInformation();
|
| 69 |
-
|
| 70 |
-
// Run extraction
|
| 71 |
-
return $this->_extractFromMySQL();
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
private function getCategory($key) {
|
| 75 |
-
$return = 0;
|
| 76 |
-
if (strpos($key, '/') != false) {
|
| 77 |
-
$tmpKey = substr($key, 0, strpos($key, strrchr($key, '/')));
|
| 78 |
-
if (isset($this->_allCat[$tmpKey])) {
|
| 79 |
-
$return = $this->_allCat[$tmpKey];
|
| 80 |
-
} else {
|
| 81 |
-
$return = $this->getCategory($tmpKey);
|
| 82 |
-
}
|
| 83 |
-
}
|
| 84 |
-
return $return;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
// Extract natively directly from the database
|
| 88 |
-
private function _extractFromMySQL() {
|
| 89 |
-
$selectLimit = 100;
|
| 90 |
-
|
| 91 |
-
// Increase maximium length for group_concat (for additional image URLs field)
|
| 92 |
-
$query = "SET SESSION group_concat_max_len = 1000000;";
|
| 93 |
-
$this->_dbConnection->query($query);
|
| 94 |
-
|
| 95 |
-
// Get category information
|
| 96 |
-
$query = '';
|
| 97 |
-
if (substr(Mage::getVersion(), 2, 3) >= 6) {
|
| 98 |
-
$query = "
|
| 99 |
-
SELECT DISTINCT fs.entity_id, fs.path, fs.name
|
| 100 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
|
| 101 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
|
| 102 |
-
ON pi.category_id = fs.entity_id
|
| 103 |
-
ORDER BY fs.path ASC
|
| 104 |
-
";
|
| 105 |
-
} else {
|
| 106 |
-
$query = "
|
| 107 |
-
SELECT DISTINCT ev.entity_id, ce.path, ev.value
|
| 108 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_entity_varchar AS ev
|
| 109 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON ev.entity_id = ce.entity_id
|
| 110 |
-
WHERE ev.attribute_id = (
|
| 111 |
-
SELECT attribute_id
|
| 112 |
-
FROM ChannelPilotSolutions_ChannelPilot_eav_attribute as att
|
| 113 |
-
WHERE att.entity_type_id = ev.entity_type_id AND att.attribute_code='name'
|
| 114 |
-
)
|
| 115 |
-
ORDER BY ce.path ASC
|
| 116 |
-
";
|
| 117 |
-
}
|
| 118 |
-
$query = $this->_applyTablePrefix($query);
|
| 119 |
-
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 120 |
-
|
| 121 |
-
$categoriesTable = $this->_dbConnection->fetchAll($query);
|
| 122 |
-
|
| 123 |
-
$this->_allCat = array();
|
| 124 |
-
$oldCatPath = 'initialize';
|
| 125 |
-
$oldCatTree = '';
|
| 126 |
-
|
| 127 |
-
foreach ($categoriesTable as $categorie) {
|
| 128 |
-
if (strpos($categorie[1], $oldCatPath) !== 0) {
|
| 129 |
-
// Start tree
|
| 130 |
-
$path = $this->getCategory($categorie[1]);
|
| 131 |
-
if ($path !== 0) {
|
| 132 |
-
$this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $path . '>' . $categorie[2]);
|
| 133 |
-
$oldCatTree = $path . '>' . $categorie[2];
|
| 134 |
-
} else {
|
| 135 |
-
$this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $categorie[2]);
|
| 136 |
-
$oldCatTree = $categorie[2];
|
| 137 |
-
}
|
| 138 |
-
} else {
|
| 139 |
-
// continue tree
|
| 140 |
-
$this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $oldCatTree . '>' . $categorie[2]);
|
| 141 |
-
$oldCatTree = $this->_allCat[$categorie[1]];
|
| 142 |
-
}
|
| 143 |
-
$oldCatPath = $categorie[1];
|
| 144 |
-
}
|
| 145 |
-
|
| 146 |
-
// print_r($this->_allCat);
|
| 147 |
-
// exit();
|
| 148 |
-
// By default, set media gallery attribute id to 703
|
| 149 |
-
// Look it up later
|
| 150 |
-
$MEDIA_GALLERY_ATTRIBUTE_ID = 703;
|
| 151 |
-
|
| 152 |
-
// Get the entity type for products
|
| 153 |
-
$query = "SELECT entity_type_id FROM ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product'";
|
| 154 |
-
$query = $this->_applyTablePrefix($query);
|
| 155 |
-
$PRODUCT_ENTITY_TYPE_ID = $this->_dbConnection->fetchOne($query);
|
| 156 |
-
|
| 157 |
-
// Get attribute codes and types
|
| 158 |
-
$query = "SELECT attribute_id, attribute_code, backend_type, frontend_input
|
| 159 |
-
FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
|
| 160 |
-
WHERE entity_type_id = $PRODUCT_ENTITY_TYPE_ID
|
| 161 |
-
";
|
| 162 |
-
$query = $this->_applyTablePrefix($query);
|
| 163 |
-
$attributes = $this->_dbConnection->FetchAssoc($query);
|
| 164 |
-
$attributeCodes = array();
|
| 165 |
-
$blankProduct = array();
|
| 166 |
-
$blankProduct['entity_id'] = '';
|
| 167 |
-
$blankProduct['sku'] = '';
|
| 168 |
-
$blankProduct['parent_id'] = '';
|
| 169 |
-
$blankProduct['variationTheme'] = '';
|
| 170 |
-
$blankProduct['name'] = '';
|
| 171 |
-
$blankProduct['description'] = '';
|
| 172 |
-
$blankProduct['price'] = '';
|
| 173 |
-
$blankProduct['categories'] = '';
|
| 174 |
-
$blankProduct['manufacturer'] = '';
|
| 175 |
-
$blankProduct['cp_product_url'] = '';
|
| 176 |
-
$blankProduct['cp_image_url'] = '';
|
| 177 |
-
$blankProduct['color'] = '';
|
| 178 |
-
$blankProduct['weight'] = '';
|
| 179 |
-
for($i = 1; $i <= Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_imagenumber'); $i++) {
|
| 180 |
-
$blankProduct['cp_additional_image_'.$i] = '';
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
$special_export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_specialexportfields'));
|
| 184 |
-
if (!empty($special_export_fields)) {
|
| 185 |
-
foreach ($special_export_fields as $element) {
|
| 186 |
-
if (!empty($element['name'])) {
|
| 187 |
-
$blankProduct[preg_replace('/\W/', '', $element['name'])] = $element['value'];
|
| 188 |
-
}
|
| 189 |
-
}
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
foreach ($attributes as $row) {
|
| 193 |
-
// Save attribute ID for media gallery
|
| 194 |
-
if ($row['attribute_code'] == 'media_gallery') {
|
| 195 |
-
$MEDIA_GALLERY_ATTRIBUTE_ID = $row['attribute_id'];
|
| 196 |
-
}
|
| 197 |
-
|
| 198 |
-
switch ($row['backend_type']) {
|
| 199 |
-
case 'datetime':
|
| 200 |
-
case 'decimal':
|
| 201 |
-
case 'int':
|
| 202 |
-
case 'text':
|
| 203 |
-
case 'varchar':
|
| 204 |
-
$attributeCodes[$row['attribute_id']] = $row['attribute_code'];
|
| 205 |
-
//$blankProduct[$row['attribute_code']] = '';
|
| 206 |
-
break;
|
| 207 |
-
case 'static':
|
| 208 |
-
// ignore columns in entity table
|
| 209 |
-
// print("Skipping static attribute: ".$row['attribute_code']."\n");
|
| 210 |
-
break;
|
| 211 |
-
default:
|
| 212 |
-
// print("Unsupported backend_type: ".$row['backend_type']."\n");
|
| 213 |
-
break;
|
| 214 |
-
}
|
| 215 |
-
|
| 216 |
-
// If the type is multiple choice, cache the option values
|
| 217 |
-
// in a lookup array for performance (avoids several joins/aggregations)
|
| 218 |
-
if ($row['frontend_input'] == 'select' || $row['frontend_input'] == 'multiselect') {
|
| 219 |
-
// Get the option_id => value from the attribute options
|
| 220 |
-
$query = "
|
| 221 |
-
SELECT
|
| 222 |
-
CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.option_id) ELSE
|
| 223 |
-
MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.option_id ELSE NULL END)
|
| 224 |
-
END AS 'option_id'
|
| 225 |
-
,CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.value) ELSE
|
| 226 |
-
MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.value ELSE NULL END)
|
| 227 |
-
END AS 'value'
|
| 228 |
-
FROM ChannelPilotSolutions_ChannelPilot_eav_attribute_option AS ao
|
| 229 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute_option_value AS aov
|
| 230 |
-
ON ao.option_id = aov.option_id
|
| 231 |
-
WHERE aov.store_id IN (" . $this->_storeId . ", 0)
|
| 232 |
-
AND ao.attribute_id = " . $row['attribute_id'] . "
|
| 233 |
-
GROUP BY aov.option_id
|
| 234 |
-
";
|
| 235 |
-
$query = $this->_applyTablePrefix($query);
|
| 236 |
-
$result = $this->_dbConnection->fetchPairs($query);
|
| 237 |
-
|
| 238 |
-
// If found, then save the lookup table in the attributeOptions array
|
| 239 |
-
if (is_array($result)) {
|
| 240 |
-
$attributeOptions[$row['attribute_id']] = $result;
|
| 241 |
-
} else {
|
| 242 |
-
// Otherwise, leave a blank array
|
| 243 |
-
$attributeOptions[$row['attribute_id']] = array();
|
| 244 |
-
}
|
| 245 |
-
$result = null;
|
| 246 |
-
}
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
$export_data_fields_codes = '';
|
| 250 |
-
$export_data_fields_ids = '';
|
| 251 |
-
foreach (array_keys($blankProduct) as $key) {
|
| 252 |
-
$export_data_fields_codes = $export_data_fields_codes . "'" . $key . "',";
|
| 253 |
-
$tmpid = array_search($key, $attributeCodes);
|
| 254 |
-
if (!empty($tmpid)) {
|
| 255 |
-
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 256 |
-
}
|
| 257 |
-
}
|
| 258 |
-
|
| 259 |
-
$export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_exportfields'));
|
| 260 |
-
if (!empty($export_fields)) {
|
| 261 |
-
foreach ($export_fields as $element) {
|
| 262 |
-
if (!empty($element['productattribute'])) {
|
| 263 |
-
$blankProduct[preg_replace('/\W/', '', $element['productattribute'])] = '';
|
| 264 |
-
$export_data_fields_codes = $export_data_fields_codes . "'" . $element['productattribute'] . "',";
|
| 265 |
-
$tmpid = array_search($element['productattribute'], $attributeCodes);
|
| 266 |
-
if (!empty($tmpid)) {
|
| 267 |
-
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 268 |
-
}
|
| 269 |
-
}
|
| 270 |
-
}
|
| 271 |
-
}
|
| 272 |
-
|
| 273 |
-
$tmpid = array_search('status', $attributeCodes);
|
| 274 |
-
if (!empty($tmpid)) {
|
| 275 |
-
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 276 |
-
}
|
| 277 |
-
$tmpid = array_search('url_path', $attributeCodes);
|
| 278 |
-
if (!empty($tmpid)) {
|
| 279 |
-
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 280 |
-
}
|
| 281 |
-
$tmpid = array_search('image', $attributeCodes);
|
| 282 |
-
if (!empty($tmpid)) {
|
| 283 |
-
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 284 |
-
}
|
| 285 |
-
$export_data_fields_ids = rtrim($export_data_fields_ids, ',');
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
// Build queries for each attribute type
|
| 290 |
-
$backendTypes = array(
|
| 291 |
-
'datetime',
|
| 292 |
-
'decimal',
|
| 293 |
-
'int',
|
| 294 |
-
'text',
|
| 295 |
-
'varchar',
|
| 296 |
-
);
|
| 297 |
-
$queries = array();
|
| 298 |
-
foreach ($backendTypes as $backendType) {
|
| 299 |
-
// Get store value if there is one, otherwise, global value
|
| 300 |
-
$queries[] = "
|
| 301 |
-
SELECT CASE WHEN SUM(ev.store_id) = 0 THEN MAX(ev.value) ELSE
|
| 302 |
-
MAX(CASE WHEN ev.store_id = " . $this->_storeId . " THEN ev.value ELSE NULL END)
|
| 303 |
-
END AS 'value', ev.attribute_id
|
| 304 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity
|
| 305 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_$backendType AS ev
|
| 306 |
-
ON ChannelPilotSolutions_ChannelPilot_catalog_product_entity.entity_id = ev.entity_id
|
| 307 |
-
WHERE ev.store_id IN (" . $this->_storeId . ", 0)
|
| 308 |
-
AND ev.entity_type_id = $PRODUCT_ENTITY_TYPE_ID
|
| 309 |
-
AND ev.entity_id = @ENTITY_ID AND ev.attribute_id IN (" . $export_data_fields_ids . ")
|
| 310 |
-
GROUP BY ev.attribute_id, ev.entity_id
|
| 311 |
-
";
|
| 312 |
-
}
|
| 313 |
-
$query = implode(" UNION ALL ", $queries);
|
| 314 |
-
$MasterProductQuery = $query;
|
| 315 |
-
|
| 316 |
-
$count = 0;
|
| 317 |
-
$query = "
|
| 318 |
-
SELECT count(*)
|
| 319 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
|
| 320 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
|
| 321 |
-
ON cpw.product_id = cpe.entity_id
|
| 322 |
-
WHERE cpw.website_id = " . $this->_siteId . "
|
| 323 |
-
AND IFNULL(cpe.sku, '') != ''
|
| 324 |
-
";
|
| 325 |
-
$query = $this->_applyTablePrefix($query);
|
| 326 |
-
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 327 |
-
$count = $this->_dbConnection->fetchAll($query);
|
| 328 |
-
|
| 329 |
-
$counter = 0;
|
| 330 |
-
|
| 331 |
-
$border = (int) $count[0][0] - $selectLimit;
|
| 332 |
-
if ($border < $count[0][0]) {
|
| 333 |
-
$border = $count[0][0];
|
| 334 |
-
}
|
| 335 |
-
|
| 336 |
-
$parentProductArray = array();
|
| 337 |
-
$replace_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_replacefields'));
|
| 338 |
-
|
| 339 |
-
$variationThemes = array();
|
| 340 |
-
while ($counter <= $border) {
|
| 341 |
-
// Get all entity_ids for all products in the selected store
|
| 342 |
-
$query = "
|
| 343 |
-
SELECT cpe.entity_id, cpe.sku,
|
| 344 |
-
(SELECT parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE product_id=cpe.entity_id LIMIT 1) as parent,
|
| 345 |
-
(SELECT count(*) FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE parent_id=cpe.entity_id LIMIT 1) as is_parent,
|
| 346 |
-
(SELECT qty FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as qty,
|
| 347 |
-
(SELECT stock_status FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as stock_status,
|
| 348 |
-
(SELECT crpp.rule_price FROM ChannelPilotSolutions_ChannelPilot_catalogrule_product_price AS crpp WHERE crpp.rule_date = CURDATE() AND crpp.product_id =cpe.entity_id AND crpp.customer_group_id = 1 AND crpp.website_id = " . $this->_siteId . ") as cat_price
|
| 349 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
|
| 350 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
|
| 351 |
-
ON cpw.product_id = cpe.entity_id
|
| 352 |
-
WHERE cpw.website_id = " . $this->_siteId . "
|
| 353 |
-
AND IFNULL(cpe.sku, '') != ''
|
| 354 |
-
ORDER BY is_parent DESC, entity_id DESC
|
| 355 |
-
LIMIT " . $counter . ", " . $selectLimit . "
|
| 356 |
-
";
|
| 357 |
-
$query = $this->_applyTablePrefix($query);
|
| 358 |
-
// Set fetch mode to numeric to save memory
|
| 359 |
-
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 360 |
-
$EntityIds = $this->_dbConnection->fetchAll($query);
|
| 361 |
-
// Loop through each product and output the data
|
| 362 |
-
foreach ($EntityIds as $entity) {
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
// Fill the master query with the entity ID
|
| 367 |
-
// $entity[0] = entity_id
|
| 368 |
-
// $entity[1] = sku
|
| 369 |
-
$query = str_replace('@ENTITY_ID', $entity[0], $MasterProductQuery);
|
| 370 |
-
$query = $this->_applyTablePrefix($query);
|
| 371 |
-
$result = $this->_dbConnection->query($query);
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
// Create a new product record
|
| 375 |
-
$product = $blankProduct;
|
| 376 |
-
|
| 377 |
-
if (intval($entity[3]) > 0) {
|
| 378 |
-
$varQuery = "SELECT ea.attribute_code FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_attribute cpsa
|
| 379 |
-
LEFT JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute ea ON ea.attribute_id = cpsa.attribute_id
|
| 380 |
-
WHERE cpsa.product_id = '$entity[0]' ORDER BY ea.attribute_id; ";
|
| 381 |
-
$varQuery = $this->_applyTablePrefix($varQuery);
|
| 382 |
-
$varresults = $this->_dbConnection->fetchAll($varQuery);
|
| 383 |
-
$variationTheme = "";
|
| 384 |
-
foreach ($varresults as $varresult) {
|
| 385 |
-
$variationTheme = $variationTheme . "|" . $varresult[0];
|
| 386 |
-
}
|
| 387 |
-
$product['variationTheme'] = ltrim($variationTheme, "|");
|
| 388 |
-
$variationThemes[$entity[0]] = ltrim($variationTheme, "|");
|
| 389 |
-
} else {
|
| 390 |
-
if (empty($entity[2]) != true) {
|
| 391 |
-
$product['variationTheme'] = $variationThemes[$entity[2]];
|
| 392 |
-
}
|
| 393 |
-
}
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
// Initialize basic product data
|
| 400 |
-
$product['entity_id'] = $entity[0];
|
| 401 |
-
$product['sku'] = $entity[1];
|
| 402 |
-
|
| 403 |
-
// Escape the SKU (it may contain double-quotes)
|
| 404 |
-
$product['sku'] = str_replace('"', '""', $product['sku']);
|
| 405 |
-
|
| 406 |
-
$product_status;
|
| 407 |
-
$product_url;
|
| 408 |
-
$product_image;
|
| 409 |
-
// Loop through each field in the row and get the value
|
| 410 |
-
while (true) {
|
| 411 |
-
// Get next column
|
| 412 |
-
// $column[0] = value
|
| 413 |
-
// $column[1] = attribute_id
|
| 414 |
-
$column = $result->fetch(Zend_Db::FETCH_NUM);
|
| 415 |
-
// Break if no more rows
|
| 416 |
-
if (empty($column)) {
|
| 417 |
-
break;
|
| 418 |
-
}
|
| 419 |
-
// Skip attributes that don't exist in eav_attribute
|
| 420 |
-
if (!isset($attributeCodes[$column[1]])) {
|
| 421 |
-
continue;
|
| 422 |
-
}
|
| 423 |
-
|
| 424 |
-
// Translate the option option_id to a value.
|
| 425 |
-
if (isset($attributeOptions[$column[1]]) == true) {
|
| 426 |
-
// Convert all option values
|
| 427 |
-
$optionValues = explode(',', $column[0]);
|
| 428 |
-
$convertedOptionValues = array();
|
| 429 |
-
foreach ($optionValues as $optionValue) {
|
| 430 |
-
if (isset($attributeOptions[$column[1]][$optionValue]) == true) {
|
| 431 |
-
// If a option_id is found, translate it
|
| 432 |
-
$convertedOptionValues[] = $attributeOptions[$column[1]][$optionValue];
|
| 433 |
-
}
|
| 434 |
-
}
|
| 435 |
-
// Erase values that are set to zero
|
| 436 |
-
if ($column[0] == '0') {
|
| 437 |
-
$column[0] = '';
|
| 438 |
-
} elseif (empty($convertedOptionValues) == false) {
|
| 439 |
-
// Use convert values if any conversions exist
|
| 440 |
-
$column[0] = implode(',', $convertedOptionValues);
|
| 441 |
-
}
|
| 442 |
-
// Otherwise, leave value as-is
|
| 443 |
-
}
|
| 444 |
-
if (strpos($export_data_fields_codes, "'" . $attributeCodes[$column[1]] . "'") != false) {
|
| 445 |
-
$product[$attributeCodes[$column[1]]] = str_replace('"', '""', $column[0]);
|
| 446 |
-
}
|
| 447 |
-
if ($attributeCodes[$column[1]] == 'status') {
|
| 448 |
-
$product_status = $column[0];
|
| 449 |
-
}
|
| 450 |
-
if ($attributeCodes[$column[1]] == 'url_path') {
|
| 451 |
-
$product_url = $column[0];
|
| 452 |
-
}
|
| 453 |
-
if ($attributeCodes[$column[1]] == 'image') {
|
| 454 |
-
$product_image = $column[0];
|
| 455 |
-
}
|
| 456 |
-
}
|
| 457 |
-
$result = null;
|
| 458 |
-
|
| 459 |
-
// Skip product that are disabled or have no status
|
| 460 |
-
if (empty($product_status) || $product_status == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
|
| 461 |
-
continue;
|
| 462 |
-
}
|
| 463 |
-
// Get category information
|
| 464 |
-
$query = '';
|
| 465 |
-
if (substr(Mage::getVersion(), 2, 3) >= 6) {
|
| 466 |
-
$query = "
|
| 467 |
-
SELECT DISTINCT fs.entity_id, fs.path, fs.name
|
| 468 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
|
| 469 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
|
| 470 |
-
ON pi.category_id = fs.entity_id
|
| 471 |
-
WHERE pi.product_id = " . $entity[0] . " ORDER BY fs.path ASC
|
| 472 |
-
";
|
| 473 |
-
} else {
|
| 474 |
-
$query = "
|
| 475 |
-
SELECT pi.category_id, ce.path
|
| 476 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
|
| 477 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON pi.category_id = ce.entity_id
|
| 478 |
-
WHERE pi.product_id = " . $entity[0] . " AND pi.is_parent = 1 AND pi.store_id = " . $this->_storeId . " ORDER BY ce.path ASC
|
| 479 |
-
";
|
| 480 |
-
}
|
| 481 |
-
$query = $this->_applyTablePrefix($query);
|
| 482 |
-
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 483 |
-
|
| 484 |
-
$categoriesTable = $this->_dbConnection->fetchAll($query);
|
| 485 |
-
$product['categories'] = '';
|
| 486 |
-
$categorieField = '';
|
| 487 |
-
$this->oldCatPath = '';
|
| 488 |
-
foreach ($categoriesTable as $categorie) {
|
| 489 |
-
if (($this->oldCatPath == '') || (strpos($categorie[1], $this->oldCatPath) !== 0)) {
|
| 490 |
-
// Start tree
|
| 491 |
-
if ($this->oldCatPath !== '') {
|
| 492 |
-
if ($categorieField !== '') {
|
| 493 |
-
$categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
|
| 494 |
-
} else {
|
| 495 |
-
$categorieField = $this->_allCat[$this->oldCatPath];
|
| 496 |
-
}
|
| 497 |
-
}
|
| 498 |
-
$this->oldCatPath = $categorie[1];
|
| 499 |
-
} else {
|
| 500 |
-
// Add to tree
|
| 501 |
-
$this->oldCatPath = $categorie[1];
|
| 502 |
-
}
|
| 503 |
-
}
|
| 504 |
-
if ($categorieField !== '') {
|
| 505 |
-
$categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
|
| 506 |
-
} else {
|
| 507 |
-
if ($this->oldCatPath !== '') {
|
| 508 |
-
$categorieField = $this->_allCat[$this->oldCatPath];
|
| 509 |
-
}
|
| 510 |
-
}
|
| 511 |
-
$product['categories'] = $categorieField;
|
| 512 |
-
|
| 513 |
-
// Get stock quantity
|
| 514 |
-
// NOTE: stock_id = 1 is the 'Default' stock
|
| 515 |
-
if (strpos($export_data_fields_codes, "'qty'") != false) {
|
| 516 |
-
if (empty($entity[4]) == true) {
|
| 517 |
-
$product['qty'] = '0';
|
| 518 |
-
} else {
|
| 519 |
-
$product['qty'] = $entity[4];
|
| 520 |
-
}
|
| 521 |
-
}
|
| 522 |
-
if (strpos($export_data_fields_codes, "'stock_status'") != false) {
|
| 523 |
-
if (empty($entity[5]) == true) {
|
| 524 |
-
$product['stock_status'] = '';
|
| 525 |
-
} else {
|
| 526 |
-
$product['stock_status'] = $entity[5];
|
| 527 |
-
}
|
| 528 |
-
}
|
| 529 |
-
$stockInfoResult = null;
|
| 530 |
-
|
| 531 |
-
// Get additional image URLs
|
| 532 |
-
$galleryImagePrefix = $this->_dbConnection->quote($this->_mediaUrl . 'catalog/product');
|
| 533 |
-
$query = "
|
| 534 |
-
SELECT
|
| 535 |
-
GROUP_CONCAT(gallery.value_id SEPARATOR ',') AS value_id
|
| 536 |
-
,GROUP_CONCAT(CONCAT(" . $galleryImagePrefix . ", gallery.value) SEPARATOR ',') AS value
|
| 537 |
-
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery AS gallery
|
| 538 |
-
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery_value AS gallery_value
|
| 539 |
-
ON gallery.value_id = gallery_value.value_id
|
| 540 |
-
WHERE gallery_value.store_id IN (" . $this->_storeId . ", 0)
|
| 541 |
-
AND gallery_value.disabled = 0
|
| 542 |
-
AND gallery.entity_id=" . $entity[0] . "
|
| 543 |
-
AND gallery.attribute_id = " . $MEDIA_GALLERY_ATTRIBUTE_ID . "
|
| 544 |
-
ORDER BY gallery_value.position ASC";
|
| 545 |
-
$query = $this->_applyTablePrefix($query);
|
| 546 |
-
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 547 |
-
$galleryValues = $this->_dbConnection->fetchAll($query);
|
| 548 |
-
if (empty($galleryValues) != true) {
|
| 549 |
-
$additional_images = explode(',', $galleryValues[0][1]);
|
| 550 |
-
for($i = 1; $i <= Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_imagenumber'); $i++) {
|
| 551 |
-
if (isset($additional_images[$i])) {
|
| 552 |
-
$product['cp_additional_image_' . ($i + 1)] = $additional_images[$i];
|
| 553 |
-
}
|
| 554 |
-
}
|
| 555 |
-
}
|
| 556 |
-
|
| 557 |
-
// Get parent ID
|
| 558 |
-
if (empty($entity[2]) != true && strpos($export_data_fields_codes, "'parent_id'") != false) {
|
| 559 |
-
$product['parent_id'] = $entity[2];
|
| 560 |
-
}
|
| 561 |
-
|
| 562 |
-
// Override price with catalog price rule, if found
|
| 563 |
-
if (empty($entity[6]) != true) {
|
| 564 |
-
// Override price with catalog rule price
|
| 565 |
-
$product['price'] = $entity[6];
|
| 566 |
-
}
|
| 567 |
-
|
| 568 |
-
// Calculate image and product URLs
|
| 569 |
-
if (empty($product_url) == false) {
|
| 570 |
-
$product['cp_product_url'] = $this->_urlPathJoin($this->_webUrl, $product_url);
|
| 571 |
-
}
|
| 572 |
-
|
| 573 |
-
if (empty($product_image) == false) {
|
| 574 |
-
$product['cp_image_url'] = $this->_urlPathJoin($this->_mediaUrl, 'catalog/product');
|
| 575 |
-
$product['cp_image_url'] = $this->_urlPathJoin($product['cp_image_url'], $product_image);
|
| 576 |
-
}
|
| 577 |
-
|
| 578 |
-
if (!empty($replace_fields)) {
|
| 579 |
-
// PARENT
|
| 580 |
-
if ($entity[3] > 0) {
|
| 581 |
-
foreach ($replace_fields as $element) {
|
| 582 |
-
if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
|
| 583 |
-
$parentProductArray[$product['entity_id']][$element['productattribute']] = $product[$element['productattribute']];
|
| 584 |
-
}
|
| 585 |
-
}
|
| 586 |
-
} else {
|
| 587 |
-
// CHILD
|
| 588 |
-
if ($entity[2] != null) {
|
| 589 |
-
foreach ($replace_fields as $element) {
|
| 590 |
-
if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
|
| 591 |
-
$product[$element['productattribute']] = $parentProductArray[$entity[2]][$element['productattribute']];
|
| 592 |
-
}
|
| 593 |
-
}
|
| 594 |
-
}
|
| 595 |
-
}
|
| 596 |
-
}
|
| 597 |
-
$this->xml = new SimpleXMLElement("<product></product>");
|
| 598 |
-
echo str_replace('<?xml version="1.0"?>', '', $this->toXML($product));
|
| 599 |
-
$this->xml = null;
|
| 600 |
-
}
|
| 601 |
-
$counter = $counter + $selectLimit;
|
| 602 |
-
}
|
| 603 |
-
return;
|
| 604 |
-
}
|
| 605 |
-
|
| 606 |
-
// Join two URL paths and handle forward slashes
|
| 607 |
-
private function _urlPathJoin($part1, $part2) {
|
| 608 |
-
return rtrim($part1, '/') . '/' . ltrim($part2, '/');
|
| 609 |
-
}
|
| 610 |
-
|
| 611 |
-
// Die if the storeId is invalid
|
| 612 |
-
private function _getStoreInformation() {
|
| 613 |
-
try {
|
| 614 |
-
// Get the store object
|
| 615 |
-
$store = Mage::app()->getStore($this->_storeId);
|
| 616 |
-
|
| 617 |
-
// Load the store information
|
| 618 |
-
$this->_siteId = $store->getWebsiteId();
|
| 619 |
-
$this->_webUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 620 |
-
$this->_mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 621 |
-
} catch (Exception $e) {
|
| 622 |
-
die('Store=' . $this->_storeId . " probably does not exist.");
|
| 623 |
-
}
|
| 624 |
-
}
|
| 625 |
-
|
| 626 |
-
private function toXML($array) {
|
| 627 |
-
$this->iterate($array, $this->xml);
|
| 628 |
-
return $this->xml->asXML();
|
| 629 |
-
}
|
| 630 |
-
|
| 631 |
-
private function iterate($element, $xmlNode) {
|
| 632 |
-
if (is_array($element)) {
|
| 633 |
-
foreach ($element as $name => $value) {
|
| 634 |
-
if (is_string($value) || is_numeric($value) || is_bool($value)) {
|
| 635 |
-
$xmlNode->$name = $value;
|
| 636 |
-
} else {
|
| 637 |
-
$xmlNode->$name = null;
|
| 638 |
-
$this->iterate($value, $xmlNode->$name);
|
| 639 |
-
}
|
| 640 |
-
}
|
| 641 |
-
}
|
| 642 |
-
}
|
| 643 |
-
|
| 644 |
-
}
|
| 645 |
-
|
| 646 |
-
?>
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the GNU General Public License (GPL 3)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt
|
| 9 |
+
*
|
| 10 |
+
* DISCLAIMER
|
| 11 |
+
*
|
| 12 |
+
* Do not edit or add to this file if you wish to upgrade Channelpilotsolutions_Channelpilot to newer
|
| 13 |
+
* versions in the future. If you wish to customize Channelpilotsolutions_Channelpilot for your
|
| 14 |
+
* needs please refer to http://www.channelpilot.com for more information.
|
| 15 |
+
*
|
| 16 |
+
* @category Channelpilotsolutions
|
| 17 |
+
* @package Channelpilotsolutions_Channelpilot
|
| 18 |
+
* @subpackage helper
|
| 19 |
+
* @copyright Copyright (c) 2012 <info@channelpilot.com> - www.channelpilot.com
|
| 20 |
+
* @author Peter Hoffmann <info@channelpilot.com>
|
| 21 |
+
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3)
|
| 22 |
+
* @link http://www.channelpilot.com
|
| 23 |
+
*/
|
| 24 |
+
class ExportData {
|
| 25 |
+
|
| 26 |
+
private $_tablePrefix;
|
| 27 |
+
private $_storeId;
|
| 28 |
+
private $_siteId;
|
| 29 |
+
private $_mediaUrl;
|
| 30 |
+
private $_webUrl;
|
| 31 |
+
private $_dbConnection;
|
| 32 |
+
private $_allCat;
|
| 33 |
+
private $oldCatPath;
|
| 34 |
+
private $xml;
|
| 35 |
+
|
| 36 |
+
function __construct() {
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
// Increase maximum execution time to 4 hours
|
| 40 |
+
ini_set('max_execution_time', 7200);
|
| 41 |
+
|
| 42 |
+
// Initialize the admin application
|
| 43 |
+
Mage::app('admin');
|
| 44 |
+
|
| 45 |
+
// Get the table prefix
|
| 46 |
+
$tableName = Mage::getSingleton('core/resource')->getTableName('core_website');
|
| 47 |
+
$this->_tablePrefix = substr($tableName, 0, strpos($tableName, 'core_website'));
|
| 48 |
+
|
| 49 |
+
// Get database connection
|
| 50 |
+
$this->_dbConnection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// Apply prefix to table names in the query
|
| 54 |
+
private function _applyTablePrefix($query) {
|
| 55 |
+
return str_replace('ChannelPilotSolutions_ChannelPilot_', $this->_tablePrefix, $query);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// Run the main application and call the appropriate function
|
| 59 |
+
// depending on the command.
|
| 60 |
+
public function _runMain() {
|
| 61 |
+
if (isset($_GET['store']) AND $_GET['store'] != '') {
|
| 62 |
+
$this->_storeId = $_GET['store'];
|
| 63 |
+
} else {
|
| 64 |
+
$this->_storeId = Mage::app()->getStore()->getId();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
// Validate store and get information
|
| 68 |
+
$this->_getStoreInformation();
|
| 69 |
+
|
| 70 |
+
// Run extraction
|
| 71 |
+
return $this->_extractFromMySQL();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
private function getCategory($key) {
|
| 75 |
+
$return = 0;
|
| 76 |
+
if (strpos($key, '/') != false) {
|
| 77 |
+
$tmpKey = substr($key, 0, strpos($key, strrchr($key, '/')));
|
| 78 |
+
if (isset($this->_allCat[$tmpKey])) {
|
| 79 |
+
$return = $this->_allCat[$tmpKey];
|
| 80 |
+
} else {
|
| 81 |
+
$return = $this->getCategory($tmpKey);
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
return $return;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// Extract natively directly from the database
|
| 88 |
+
private function _extractFromMySQL() {
|
| 89 |
+
$selectLimit = 100;
|
| 90 |
+
|
| 91 |
+
// Increase maximium length for group_concat (for additional image URLs field)
|
| 92 |
+
$query = "SET SESSION group_concat_max_len = 1000000;";
|
| 93 |
+
$this->_dbConnection->query($query);
|
| 94 |
+
|
| 95 |
+
// Get category information
|
| 96 |
+
$query = '';
|
| 97 |
+
if (substr(Mage::getVersion(), 2, 3) >= 6) {
|
| 98 |
+
$query = "
|
| 99 |
+
SELECT DISTINCT fs.entity_id, fs.path, fs.name
|
| 100 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
|
| 101 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
|
| 102 |
+
ON pi.category_id = fs.entity_id
|
| 103 |
+
ORDER BY fs.path ASC
|
| 104 |
+
";
|
| 105 |
+
} else {
|
| 106 |
+
$query = "
|
| 107 |
+
SELECT DISTINCT ev.entity_id, ce.path, ev.value
|
| 108 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_entity_varchar AS ev
|
| 109 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON ev.entity_id = ce.entity_id
|
| 110 |
+
WHERE ev.attribute_id = (
|
| 111 |
+
SELECT attribute_id
|
| 112 |
+
FROM ChannelPilotSolutions_ChannelPilot_eav_attribute as att
|
| 113 |
+
WHERE att.entity_type_id = ev.entity_type_id AND att.attribute_code='name'
|
| 114 |
+
)
|
| 115 |
+
ORDER BY ce.path ASC
|
| 116 |
+
";
|
| 117 |
+
}
|
| 118 |
+
$query = $this->_applyTablePrefix($query);
|
| 119 |
+
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 120 |
+
|
| 121 |
+
$categoriesTable = $this->_dbConnection->fetchAll($query);
|
| 122 |
+
|
| 123 |
+
$this->_allCat = array();
|
| 124 |
+
$oldCatPath = 'initialize';
|
| 125 |
+
$oldCatTree = '';
|
| 126 |
+
|
| 127 |
+
foreach ($categoriesTable as $categorie) {
|
| 128 |
+
if (strpos($categorie[1], $oldCatPath) !== 0) {
|
| 129 |
+
// Start tree
|
| 130 |
+
$path = $this->getCategory($categorie[1]);
|
| 131 |
+
if ($path !== 0) {
|
| 132 |
+
$this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $path . '>' . $categorie[2]);
|
| 133 |
+
$oldCatTree = $path . '>' . $categorie[2];
|
| 134 |
+
} else {
|
| 135 |
+
$this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $categorie[2]);
|
| 136 |
+
$oldCatTree = $categorie[2];
|
| 137 |
+
}
|
| 138 |
+
} else {
|
| 139 |
+
// continue tree
|
| 140 |
+
$this->_allCat[$categorie[1]] = str_replace('Root Catalog', 'Home', $oldCatTree . '>' . $categorie[2]);
|
| 141 |
+
$oldCatTree = $this->_allCat[$categorie[1]];
|
| 142 |
+
}
|
| 143 |
+
$oldCatPath = $categorie[1];
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// print_r($this->_allCat);
|
| 147 |
+
// exit();
|
| 148 |
+
// By default, set media gallery attribute id to 703
|
| 149 |
+
// Look it up later
|
| 150 |
+
$MEDIA_GALLERY_ATTRIBUTE_ID = 703;
|
| 151 |
+
|
| 152 |
+
// Get the entity type for products
|
| 153 |
+
$query = "SELECT entity_type_id FROM ChannelPilotSolutions_ChannelPilot_eav_entity_type WHERE entity_type_code = 'catalog_product'";
|
| 154 |
+
$query = $this->_applyTablePrefix($query);
|
| 155 |
+
$PRODUCT_ENTITY_TYPE_ID = $this->_dbConnection->fetchOne($query);
|
| 156 |
+
|
| 157 |
+
// Get attribute codes and types
|
| 158 |
+
$query = "SELECT attribute_id, attribute_code, backend_type, frontend_input
|
| 159 |
+
FROM ChannelPilotSolutions_ChannelPilot_eav_attribute
|
| 160 |
+
WHERE entity_type_id = $PRODUCT_ENTITY_TYPE_ID
|
| 161 |
+
";
|
| 162 |
+
$query = $this->_applyTablePrefix($query);
|
| 163 |
+
$attributes = $this->_dbConnection->FetchAssoc($query);
|
| 164 |
+
$attributeCodes = array();
|
| 165 |
+
$blankProduct = array();
|
| 166 |
+
$blankProduct['entity_id'] = '';
|
| 167 |
+
$blankProduct['sku'] = '';
|
| 168 |
+
$blankProduct['parent_id'] = '';
|
| 169 |
+
$blankProduct['variationTheme'] = '';
|
| 170 |
+
$blankProduct['name'] = '';
|
| 171 |
+
$blankProduct['description'] = '';
|
| 172 |
+
$blankProduct['price'] = '';
|
| 173 |
+
$blankProduct['categories'] = '';
|
| 174 |
+
$blankProduct['manufacturer'] = '';
|
| 175 |
+
$blankProduct['cp_product_url'] = '';
|
| 176 |
+
$blankProduct['cp_image_url'] = '';
|
| 177 |
+
$blankProduct['color'] = '';
|
| 178 |
+
$blankProduct['weight'] = '';
|
| 179 |
+
for($i = 1; $i <= Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_imagenumber'); $i++) {
|
| 180 |
+
$blankProduct['cp_additional_image_'.$i] = '';
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
$special_export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_specialexportfields'));
|
| 184 |
+
if (!empty($special_export_fields)) {
|
| 185 |
+
foreach ($special_export_fields as $element) {
|
| 186 |
+
if (!empty($element['name'])) {
|
| 187 |
+
$blankProduct[preg_replace('/\W/', '', $element['name'])] = $element['value'];
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
foreach ($attributes as $row) {
|
| 193 |
+
// Save attribute ID for media gallery
|
| 194 |
+
if ($row['attribute_code'] == 'media_gallery') {
|
| 195 |
+
$MEDIA_GALLERY_ATTRIBUTE_ID = $row['attribute_id'];
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
switch ($row['backend_type']) {
|
| 199 |
+
case 'datetime':
|
| 200 |
+
case 'decimal':
|
| 201 |
+
case 'int':
|
| 202 |
+
case 'text':
|
| 203 |
+
case 'varchar':
|
| 204 |
+
$attributeCodes[$row['attribute_id']] = $row['attribute_code'];
|
| 205 |
+
//$blankProduct[$row['attribute_code']] = '';
|
| 206 |
+
break;
|
| 207 |
+
case 'static':
|
| 208 |
+
// ignore columns in entity table
|
| 209 |
+
// print("Skipping static attribute: ".$row['attribute_code']."\n");
|
| 210 |
+
break;
|
| 211 |
+
default:
|
| 212 |
+
// print("Unsupported backend_type: ".$row['backend_type']."\n");
|
| 213 |
+
break;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
// If the type is multiple choice, cache the option values
|
| 217 |
+
// in a lookup array for performance (avoids several joins/aggregations)
|
| 218 |
+
if ($row['frontend_input'] == 'select' || $row['frontend_input'] == 'multiselect') {
|
| 219 |
+
// Get the option_id => value from the attribute options
|
| 220 |
+
$query = "
|
| 221 |
+
SELECT
|
| 222 |
+
CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.option_id) ELSE
|
| 223 |
+
MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.option_id ELSE NULL END)
|
| 224 |
+
END AS 'option_id'
|
| 225 |
+
,CASE WHEN SUM(aov.store_id) = 0 THEN MAX(aov.value) ELSE
|
| 226 |
+
MAX(CASE WHEN aov.store_id = " . $this->_storeId . " THEN aov.value ELSE NULL END)
|
| 227 |
+
END AS 'value'
|
| 228 |
+
FROM ChannelPilotSolutions_ChannelPilot_eav_attribute_option AS ao
|
| 229 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute_option_value AS aov
|
| 230 |
+
ON ao.option_id = aov.option_id
|
| 231 |
+
WHERE aov.store_id IN (" . $this->_storeId . ", 0)
|
| 232 |
+
AND ao.attribute_id = " . $row['attribute_id'] . "
|
| 233 |
+
GROUP BY aov.option_id
|
| 234 |
+
";
|
| 235 |
+
$query = $this->_applyTablePrefix($query);
|
| 236 |
+
$result = $this->_dbConnection->fetchPairs($query);
|
| 237 |
+
|
| 238 |
+
// If found, then save the lookup table in the attributeOptions array
|
| 239 |
+
if (is_array($result)) {
|
| 240 |
+
$attributeOptions[$row['attribute_id']] = $result;
|
| 241 |
+
} else {
|
| 242 |
+
// Otherwise, leave a blank array
|
| 243 |
+
$attributeOptions[$row['attribute_id']] = array();
|
| 244 |
+
}
|
| 245 |
+
$result = null;
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
$export_data_fields_codes = '';
|
| 250 |
+
$export_data_fields_ids = '';
|
| 251 |
+
foreach (array_keys($blankProduct) as $key) {
|
| 252 |
+
$export_data_fields_codes = $export_data_fields_codes . "'" . $key . "',";
|
| 253 |
+
$tmpid = array_search($key, $attributeCodes);
|
| 254 |
+
if (!empty($tmpid)) {
|
| 255 |
+
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
$export_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_exportfields'));
|
| 260 |
+
if (!empty($export_fields)) {
|
| 261 |
+
foreach ($export_fields as $element) {
|
| 262 |
+
if (!empty($element['productattribute'])) {
|
| 263 |
+
$blankProduct[preg_replace('/\W/', '', $element['productattribute'])] = '';
|
| 264 |
+
$export_data_fields_codes = $export_data_fields_codes . "'" . $element['productattribute'] . "',";
|
| 265 |
+
$tmpid = array_search($element['productattribute'], $attributeCodes);
|
| 266 |
+
if (!empty($tmpid)) {
|
| 267 |
+
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
$tmpid = array_search('status', $attributeCodes);
|
| 274 |
+
if (!empty($tmpid)) {
|
| 275 |
+
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 276 |
+
}
|
| 277 |
+
$tmpid = array_search('url_path', $attributeCodes);
|
| 278 |
+
if (!empty($tmpid)) {
|
| 279 |
+
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 280 |
+
}
|
| 281 |
+
$tmpid = array_search('image', $attributeCodes);
|
| 282 |
+
if (!empty($tmpid)) {
|
| 283 |
+
$export_data_fields_ids = $export_data_fields_ids . "'" . $tmpid . "',";
|
| 284 |
+
}
|
| 285 |
+
$export_data_fields_ids = rtrim($export_data_fields_ids, ',');
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
// Build queries for each attribute type
|
| 290 |
+
$backendTypes = array(
|
| 291 |
+
'datetime',
|
| 292 |
+
'decimal',
|
| 293 |
+
'int',
|
| 294 |
+
'text',
|
| 295 |
+
'varchar',
|
| 296 |
+
);
|
| 297 |
+
$queries = array();
|
| 298 |
+
foreach ($backendTypes as $backendType) {
|
| 299 |
+
// Get store value if there is one, otherwise, global value
|
| 300 |
+
$queries[] = "
|
| 301 |
+
SELECT CASE WHEN SUM(ev.store_id) = 0 THEN MAX(ev.value) ELSE
|
| 302 |
+
MAX(CASE WHEN ev.store_id = " . $this->_storeId . " THEN ev.value ELSE NULL END)
|
| 303 |
+
END AS 'value', ev.attribute_id
|
| 304 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity
|
| 305 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_$backendType AS ev
|
| 306 |
+
ON ChannelPilotSolutions_ChannelPilot_catalog_product_entity.entity_id = ev.entity_id
|
| 307 |
+
WHERE ev.store_id IN (" . $this->_storeId . ", 0)
|
| 308 |
+
AND ev.entity_type_id = $PRODUCT_ENTITY_TYPE_ID
|
| 309 |
+
AND ev.entity_id = @ENTITY_ID AND ev.attribute_id IN (" . $export_data_fields_ids . ")
|
| 310 |
+
GROUP BY ev.attribute_id, ev.entity_id
|
| 311 |
+
";
|
| 312 |
+
}
|
| 313 |
+
$query = implode(" UNION ALL ", $queries);
|
| 314 |
+
$MasterProductQuery = $query;
|
| 315 |
+
|
| 316 |
+
$count = 0;
|
| 317 |
+
$query = "
|
| 318 |
+
SELECT count(*)
|
| 319 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
|
| 320 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
|
| 321 |
+
ON cpw.product_id = cpe.entity_id
|
| 322 |
+
WHERE cpw.website_id = " . $this->_siteId . "
|
| 323 |
+
AND IFNULL(cpe.sku, '') != ''
|
| 324 |
+
";
|
| 325 |
+
$query = $this->_applyTablePrefix($query);
|
| 326 |
+
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 327 |
+
$count = $this->_dbConnection->fetchAll($query);
|
| 328 |
+
|
| 329 |
+
$counter = 0;
|
| 330 |
+
|
| 331 |
+
$border = (int) $count[0][0] - $selectLimit;
|
| 332 |
+
if ($border < $count[0][0]) {
|
| 333 |
+
$border = $count[0][0];
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
$parentProductArray = array();
|
| 337 |
+
$replace_fields = unserialize(Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_replacefields'));
|
| 338 |
+
|
| 339 |
+
$variationThemes = array();
|
| 340 |
+
while ($counter <= $border) {
|
| 341 |
+
// Get all entity_ids for all products in the selected store
|
| 342 |
+
$query = "
|
| 343 |
+
SELECT cpe.entity_id, cpe.sku,
|
| 344 |
+
(SELECT parent_id FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE product_id=cpe.entity_id LIMIT 1) as parent,
|
| 345 |
+
(SELECT count(*) FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_link WHERE parent_id=cpe.entity_id LIMIT 1) as is_parent,
|
| 346 |
+
(SELECT qty FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as qty,
|
| 347 |
+
(SELECT stock_status FROM ChannelPilotSolutions_ChannelPilot_cataloginventory_stock_status WHERE product_id=cpe.entity_id AND website_id=" . $this->_siteId . " AND stock_id = 1 LIMIT 1) as stock_status,
|
| 348 |
+
(SELECT crpp.rule_price FROM ChannelPilotSolutions_ChannelPilot_catalogrule_product_price AS crpp WHERE crpp.rule_date = CURDATE() AND crpp.product_id =cpe.entity_id AND crpp.customer_group_id = 1 AND crpp.website_id = " . $this->_siteId . ") as cat_price
|
| 349 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity AS cpe
|
| 350 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_website as cpw
|
| 351 |
+
ON cpw.product_id = cpe.entity_id
|
| 352 |
+
WHERE cpw.website_id = " . $this->_siteId . "
|
| 353 |
+
AND IFNULL(cpe.sku, '') != ''
|
| 354 |
+
ORDER BY is_parent DESC, entity_id DESC
|
| 355 |
+
LIMIT " . $counter . ", " . $selectLimit . "
|
| 356 |
+
";
|
| 357 |
+
$query = $this->_applyTablePrefix($query);
|
| 358 |
+
// Set fetch mode to numeric to save memory
|
| 359 |
+
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 360 |
+
$EntityIds = $this->_dbConnection->fetchAll($query);
|
| 361 |
+
// Loop through each product and output the data
|
| 362 |
+
foreach ($EntityIds as $entity) {
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
// Fill the master query with the entity ID
|
| 367 |
+
// $entity[0] = entity_id
|
| 368 |
+
// $entity[1] = sku
|
| 369 |
+
$query = str_replace('@ENTITY_ID', $entity[0], $MasterProductQuery);
|
| 370 |
+
$query = $this->_applyTablePrefix($query);
|
| 371 |
+
$result = $this->_dbConnection->query($query);
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
// Create a new product record
|
| 375 |
+
$product = $blankProduct;
|
| 376 |
+
|
| 377 |
+
if (intval($entity[3]) > 0) {
|
| 378 |
+
$varQuery = "SELECT ea.attribute_code FROM ChannelPilotSolutions_ChannelPilot_catalog_product_super_attribute cpsa
|
| 379 |
+
LEFT JOIN ChannelPilotSolutions_ChannelPilot_eav_attribute ea ON ea.attribute_id = cpsa.attribute_id
|
| 380 |
+
WHERE cpsa.product_id = '$entity[0]' ORDER BY ea.attribute_id; ";
|
| 381 |
+
$varQuery = $this->_applyTablePrefix($varQuery);
|
| 382 |
+
$varresults = $this->_dbConnection->fetchAll($varQuery);
|
| 383 |
+
$variationTheme = "";
|
| 384 |
+
foreach ($varresults as $varresult) {
|
| 385 |
+
$variationTheme = $variationTheme . "|" . $varresult[0];
|
| 386 |
+
}
|
| 387 |
+
$product['variationTheme'] = ltrim($variationTheme, "|");
|
| 388 |
+
$variationThemes[$entity[0]] = ltrim($variationTheme, "|");
|
| 389 |
+
} else {
|
| 390 |
+
if (empty($entity[2]) != true) {
|
| 391 |
+
$product['variationTheme'] = $variationThemes[$entity[2]];
|
| 392 |
+
}
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
// Initialize basic product data
|
| 400 |
+
$product['entity_id'] = $entity[0];
|
| 401 |
+
$product['sku'] = $entity[1];
|
| 402 |
+
|
| 403 |
+
// Escape the SKU (it may contain double-quotes)
|
| 404 |
+
$product['sku'] = str_replace('"', '""', $product['sku']);
|
| 405 |
+
|
| 406 |
+
$product_status;
|
| 407 |
+
$product_url;
|
| 408 |
+
$product_image;
|
| 409 |
+
// Loop through each field in the row and get the value
|
| 410 |
+
while (true) {
|
| 411 |
+
// Get next column
|
| 412 |
+
// $column[0] = value
|
| 413 |
+
// $column[1] = attribute_id
|
| 414 |
+
$column = $result->fetch(Zend_Db::FETCH_NUM);
|
| 415 |
+
// Break if no more rows
|
| 416 |
+
if (empty($column)) {
|
| 417 |
+
break;
|
| 418 |
+
}
|
| 419 |
+
// Skip attributes that don't exist in eav_attribute
|
| 420 |
+
if (!isset($attributeCodes[$column[1]])) {
|
| 421 |
+
continue;
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
// Translate the option option_id to a value.
|
| 425 |
+
if (isset($attributeOptions[$column[1]]) == true) {
|
| 426 |
+
// Convert all option values
|
| 427 |
+
$optionValues = explode(',', $column[0]);
|
| 428 |
+
$convertedOptionValues = array();
|
| 429 |
+
foreach ($optionValues as $optionValue) {
|
| 430 |
+
if (isset($attributeOptions[$column[1]][$optionValue]) == true) {
|
| 431 |
+
// If a option_id is found, translate it
|
| 432 |
+
$convertedOptionValues[] = $attributeOptions[$column[1]][$optionValue];
|
| 433 |
+
}
|
| 434 |
+
}
|
| 435 |
+
// Erase values that are set to zero
|
| 436 |
+
if ($column[0] == '0') {
|
| 437 |
+
$column[0] = '';
|
| 438 |
+
} elseif (empty($convertedOptionValues) == false) {
|
| 439 |
+
// Use convert values if any conversions exist
|
| 440 |
+
$column[0] = implode(',', $convertedOptionValues);
|
| 441 |
+
}
|
| 442 |
+
// Otherwise, leave value as-is
|
| 443 |
+
}
|
| 444 |
+
if (strpos($export_data_fields_codes, "'" . $attributeCodes[$column[1]] . "'") != false) {
|
| 445 |
+
$product[$attributeCodes[$column[1]]] = str_replace('"', '""', $column[0]);
|
| 446 |
+
}
|
| 447 |
+
if ($attributeCodes[$column[1]] == 'status') {
|
| 448 |
+
$product_status = $column[0];
|
| 449 |
+
}
|
| 450 |
+
if ($attributeCodes[$column[1]] == 'url_path') {
|
| 451 |
+
$product_url = $column[0];
|
| 452 |
+
}
|
| 453 |
+
if ($attributeCodes[$column[1]] == 'image') {
|
| 454 |
+
$product_image = $column[0];
|
| 455 |
+
}
|
| 456 |
+
}
|
| 457 |
+
$result = null;
|
| 458 |
+
|
| 459 |
+
// Skip product that are disabled or have no status
|
| 460 |
+
if (empty($product_status) || $product_status == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
|
| 461 |
+
continue;
|
| 462 |
+
}
|
| 463 |
+
// Get category information
|
| 464 |
+
$query = '';
|
| 465 |
+
if (substr(Mage::getVersion(), 2, 3) >= 6) {
|
| 466 |
+
$query = "
|
| 467 |
+
SELECT DISTINCT fs.entity_id, fs.path, fs.name
|
| 468 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
|
| 469 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_flat_store_" . $this->_storeId . " AS fs
|
| 470 |
+
ON pi.category_id = fs.entity_id
|
| 471 |
+
WHERE pi.product_id = " . $entity[0] . " ORDER BY fs.path ASC
|
| 472 |
+
";
|
| 473 |
+
} else {
|
| 474 |
+
$query = "
|
| 475 |
+
SELECT pi.category_id, ce.path
|
| 476 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_category_product_index AS pi
|
| 477 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_category_entity AS ce ON pi.category_id = ce.entity_id
|
| 478 |
+
WHERE pi.product_id = " . $entity[0] . " AND pi.is_parent = 1 AND pi.store_id = " . $this->_storeId . " ORDER BY ce.path ASC
|
| 479 |
+
";
|
| 480 |
+
}
|
| 481 |
+
$query = $this->_applyTablePrefix($query);
|
| 482 |
+
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 483 |
+
|
| 484 |
+
$categoriesTable = $this->_dbConnection->fetchAll($query);
|
| 485 |
+
$product['categories'] = '';
|
| 486 |
+
$categorieField = '';
|
| 487 |
+
$this->oldCatPath = '';
|
| 488 |
+
foreach ($categoriesTable as $categorie) {
|
| 489 |
+
if (($this->oldCatPath == '') || (strpos($categorie[1], $this->oldCatPath) !== 0)) {
|
| 490 |
+
// Start tree
|
| 491 |
+
if ($this->oldCatPath !== '') {
|
| 492 |
+
if ($categorieField !== '') {
|
| 493 |
+
$categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
|
| 494 |
+
} else {
|
| 495 |
+
$categorieField = $this->_allCat[$this->oldCatPath];
|
| 496 |
+
}
|
| 497 |
+
}
|
| 498 |
+
$this->oldCatPath = $categorie[1];
|
| 499 |
+
} else {
|
| 500 |
+
// Add to tree
|
| 501 |
+
$this->oldCatPath = $categorie[1];
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
if ($categorieField !== '') {
|
| 505 |
+
$categorieField = $categorieField . ', ' . $this->_allCat[$this->oldCatPath];
|
| 506 |
+
} else {
|
| 507 |
+
if ($this->oldCatPath !== '') {
|
| 508 |
+
$categorieField = $this->_allCat[$this->oldCatPath];
|
| 509 |
+
}
|
| 510 |
+
}
|
| 511 |
+
$product['categories'] = $categorieField;
|
| 512 |
+
|
| 513 |
+
// Get stock quantity
|
| 514 |
+
// NOTE: stock_id = 1 is the 'Default' stock
|
| 515 |
+
if (strpos($export_data_fields_codes, "'qty'") != false) {
|
| 516 |
+
if (empty($entity[4]) == true) {
|
| 517 |
+
$product['qty'] = '0';
|
| 518 |
+
} else {
|
| 519 |
+
$product['qty'] = $entity[4];
|
| 520 |
+
}
|
| 521 |
+
}
|
| 522 |
+
if (strpos($export_data_fields_codes, "'stock_status'") != false) {
|
| 523 |
+
if (empty($entity[5]) == true) {
|
| 524 |
+
$product['stock_status'] = '';
|
| 525 |
+
} else {
|
| 526 |
+
$product['stock_status'] = $entity[5];
|
| 527 |
+
}
|
| 528 |
+
}
|
| 529 |
+
$stockInfoResult = null;
|
| 530 |
+
|
| 531 |
+
// Get additional image URLs
|
| 532 |
+
$galleryImagePrefix = $this->_dbConnection->quote($this->_mediaUrl . 'catalog/product');
|
| 533 |
+
$query = "
|
| 534 |
+
SELECT
|
| 535 |
+
GROUP_CONCAT(gallery.value_id SEPARATOR ',') AS value_id
|
| 536 |
+
,GROUP_CONCAT(CONCAT(" . $galleryImagePrefix . ", gallery.value) SEPARATOR ',') AS value
|
| 537 |
+
FROM ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery AS gallery
|
| 538 |
+
INNER JOIN ChannelPilotSolutions_ChannelPilot_catalog_product_entity_media_gallery_value AS gallery_value
|
| 539 |
+
ON gallery.value_id = gallery_value.value_id
|
| 540 |
+
WHERE gallery_value.store_id IN (" . $this->_storeId . ", 0)
|
| 541 |
+
AND gallery_value.disabled = 0
|
| 542 |
+
AND gallery.entity_id=" . $entity[0] . "
|
| 543 |
+
AND gallery.attribute_id = " . $MEDIA_GALLERY_ATTRIBUTE_ID . "
|
| 544 |
+
ORDER BY gallery_value.position ASC";
|
| 545 |
+
$query = $this->_applyTablePrefix($query);
|
| 546 |
+
$this->_dbConnection->setFetchMode(ZEND_DB::FETCH_NUM);
|
| 547 |
+
$galleryValues = $this->_dbConnection->fetchAll($query);
|
| 548 |
+
if (empty($galleryValues) != true) {
|
| 549 |
+
$additional_images = explode(',', $galleryValues[0][1]);
|
| 550 |
+
for($i = 1; $i <= Mage::getStoreConfig('channelpilot_export/channelpilot_productfeed/channelpilot_imagenumber'); $i++) {
|
| 551 |
+
if (isset($additional_images[$i])) {
|
| 552 |
+
$product['cp_additional_image_' . ($i + 1)] = $additional_images[$i];
|
| 553 |
+
}
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
// Get parent ID
|
| 558 |
+
if (empty($entity[2]) != true && strpos($export_data_fields_codes, "'parent_id'") != false) {
|
| 559 |
+
$product['parent_id'] = $entity[2];
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
// Override price with catalog price rule, if found
|
| 563 |
+
if (empty($entity[6]) != true) {
|
| 564 |
+
// Override price with catalog rule price
|
| 565 |
+
$product['price'] = $entity[6];
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Calculate image and product URLs
|
| 569 |
+
if (empty($product_url) == false) {
|
| 570 |
+
$product['cp_product_url'] = $this->_urlPathJoin($this->_webUrl, $product_url);
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
if (empty($product_image) == false) {
|
| 574 |
+
$product['cp_image_url'] = $this->_urlPathJoin($this->_mediaUrl, 'catalog/product');
|
| 575 |
+
$product['cp_image_url'] = $this->_urlPathJoin($product['cp_image_url'], $product_image);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
if (!empty($replace_fields)) {
|
| 579 |
+
// PARENT
|
| 580 |
+
if ($entity[3] > 0) {
|
| 581 |
+
foreach ($replace_fields as $element) {
|
| 582 |
+
if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
|
| 583 |
+
$parentProductArray[$product['entity_id']][$element['productattribute']] = $product[$element['productattribute']];
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
} else {
|
| 587 |
+
// CHILD
|
| 588 |
+
if ($entity[2] != null) {
|
| 589 |
+
foreach ($replace_fields as $element) {
|
| 590 |
+
if (!empty($element['productattribute']) && array_key_exists($element['productattribute'], $product)) {
|
| 591 |
+
$product[$element['productattribute']] = $parentProductArray[$entity[2]][$element['productattribute']];
|
| 592 |
+
}
|
| 593 |
+
}
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
$this->xml = new SimpleXMLElement("<product></product>");
|
| 598 |
+
echo str_replace('<?xml version="1.0"?>', '', $this->toXML($product));
|
| 599 |
+
$this->xml = null;
|
| 600 |
+
}
|
| 601 |
+
$counter = $counter + $selectLimit;
|
| 602 |
+
}
|
| 603 |
+
return;
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
// Join two URL paths and handle forward slashes
|
| 607 |
+
private function _urlPathJoin($part1, $part2) {
|
| 608 |
+
return rtrim($part1, '/') . '/' . ltrim($part2, '/');
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
// Die if the storeId is invalid
|
| 612 |
+
private function _getStoreInformation() {
|
| 613 |
+
try {
|
| 614 |
+
// Get the store object
|
| 615 |
+
$store = Mage::app()->getStore($this->_storeId);
|
| 616 |
+
|
| 617 |
+
// Load the store information
|
| 618 |
+
$this->_siteId = $store->getWebsiteId();
|
| 619 |
+
$this->_webUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
| 620 |
+
$this->_mediaUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 621 |
+
} catch (Exception $e) {
|
| 622 |
+
die('Store=' . $this->_storeId . " probably does not exist.");
|
| 623 |
+
}
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
private function toXML($array) {
|
| 627 |
+
$this->iterate($array, $this->xml);
|
| 628 |
+
return $this->xml->asXML();
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
private function iterate($element, $xmlNode) {
|
| 632 |
+
if (is_array($element)) {
|
| 633 |
+
foreach ($element as $name => $value) {
|
| 634 |
+
if (is_string($value) || is_numeric($value) || is_bool($value)) {
|
| 635 |
+
$xmlNode->$name = $value;
|
| 636 |
+
} else {
|
| 637 |
+
$xmlNode->$name = null;
|
| 638 |
+
$this->iterate($value, $xmlNode->$name);
|
| 639 |
+
}
|
| 640 |
+
}
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
?>
|
app/code/community/Channelpilotsolutions/Channelpilot/Helper/api/1_0/ChannelPilotSellerAPI_v1_0.php
CHANGED
|
@@ -1,184 +1,184 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
// include the stub-classes
|
| 4 |
-
require_once 'thin/CPAuth.php';
|
| 5 |
-
require_once 'thin/CPResponseHeader.php';
|
| 6 |
-
require_once 'thin/CPArticleUpdate.php';
|
| 7 |
-
require_once 'thin/CPAddress.php';
|
| 8 |
-
require_once 'thin/CPArticle.php';
|
| 9 |
-
require_once 'thin/CPCancellation.php';
|
| 10 |
-
require_once 'thin/CPDiscount.php';
|
| 11 |
-
require_once 'thin/CPManagedArticlePrice.php';
|
| 12 |
-
require_once 'thin/CPMoney.php';
|
| 13 |
-
require_once 'thin/CPPayment.php';
|
| 14 |
-
require_once 'thin/CPCustomer.php';
|
| 15 |
-
require_once 'thin/CPOrderItem.php';
|
| 16 |
-
require_once 'thin/CPShipping.php';
|
| 17 |
-
require_once 'thin/CPOrderStatus.php';
|
| 18 |
-
require_once 'thin/CPOrderHeader.php';
|
| 19 |
-
require_once 'thin/CPOrder.php';
|
| 20 |
-
require_once 'thin/CPOrderSummary.php';
|
| 21 |
-
|
| 22 |
-
// request-classes
|
| 23 |
-
// response-classes
|
| 24 |
-
require_once 'responses/Response.php';
|
| 25 |
-
require_once 'responses/GetServerTimeResponse.php';
|
| 26 |
-
require_once 'responses/UpdateArticlesResponse.php';
|
| 27 |
-
require_once 'responses/UpdateArticleResult.php';
|
| 28 |
-
require_once 'responses/UpdateOrdersResponse.php';
|
| 29 |
-
require_once 'responses/UpdateOrderResult.php';
|
| 30 |
-
require_once 'responses/GetNewMarketplaceOrdersResponse.php';
|
| 31 |
-
require_once 'responses/GetManagedArticlePricesResponse.php';
|
| 32 |
-
|
| 33 |
-
/**
|
| 34 |
-
* Main API-Class
|
| 35 |
-
* @author Channel Pilot Solutions GmbH <api@channelpilot.com>
|
| 36 |
-
* @version 1.0
|
| 37 |
-
*/
|
| 38 |
-
class ChannelPilotSellerAPI_v1_0 extends SoapClient {
|
| 39 |
-
|
| 40 |
-
private $auth;
|
| 41 |
-
private $wsdlUrl = 'https://seller.api.channelpilot.com/1_0?wsdl';
|
| 42 |
-
private $soapOptions = array(
|
| 43 |
-
'connection_timeout' => 20,
|
| 44 |
-
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
|
| 45 |
-
);
|
| 46 |
-
private $classmap = array(
|
| 47 |
-
'CPAuth' => 'CPAuth',
|
| 48 |
-
'CPResponseHeader' => 'CPResponseHeader',
|
| 49 |
-
'AbstractResponse' => 'AbstractResponse',
|
| 50 |
-
'GetServerTimeResponse' => 'GetServerTimeResponse',
|
| 51 |
-
'CPArticleUpdate' => 'CPArticleUpdate',
|
| 52 |
-
'UpdateArticlesResponse' => 'UpdateArticlesResponse',
|
| 53 |
-
'UpdateArticleResult' => 'UpdateArticleResult',
|
| 54 |
-
'UpdateOrdersResponse' => 'UpdateOrdersResponse',
|
| 55 |
-
'UpdateOrderResult' => 'UpdateOrderResult',
|
| 56 |
-
'CPAddress' => 'CPAddress',
|
| 57 |
-
'CPArticle' => 'CPArticle',
|
| 58 |
-
'CPDiscount' => 'CPDiscount',
|
| 59 |
-
'CPManagedArticlePrice' => 'CPManagedArticlePrice',
|
| 60 |
-
'CPMoney' => 'CPMoney',
|
| 61 |
-
'CPPayment' => 'CPPayment',
|
| 62 |
-
'CPCustomer' => 'CPCustomer',
|
| 63 |
-
'CPOrderItem' => 'CPOrderItem',
|
| 64 |
-
'CPShipping' => 'CPShipping',
|
| 65 |
-
'CPOrderStatus' => 'CPOrderStatus',
|
| 66 |
-
'CPOrderHeader' => 'CPOrderHeader',
|
| 67 |
-
'CPOrder' => 'CPOrder',
|
| 68 |
-
'CPOrderSummary' => 'CPOrderSummary',
|
| 69 |
-
'GetNewMarketplaceOrdersResponse' => 'GetNewMarketplaceOrdersResponse'
|
| 70 |
-
);
|
| 71 |
-
|
| 72 |
-
public function ChannelPilotSellerAPI_v1_0($merchantId, $shopToken) {
|
| 73 |
-
$this->auth = new CPAuth($merchantId, $shopToken);
|
| 74 |
-
|
| 75 |
-
foreach ($this->classmap as $key => $value) {
|
| 76 |
-
if (!isset($this->soapOptions['classmap'][$key])) {
|
| 77 |
-
$this->soapOptions['classmap'][$key] = $value;
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
parent::__construct($this->wsdlUrl, $this->soapOptions);
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
/**
|
| 84 |
-
* Receives the acutal server time. Can be used to test the connection.
|
| 85 |
-
* @return GetServerTimeResponse
|
| 86 |
-
*/
|
| 87 |
-
public function getServerTime() {
|
| 88 |
-
return $this->__call(
|
| 89 |
-
'getServerTime',
|
| 90 |
-
array(
|
| 91 |
-
new SoapParam($this->auth, 'auth')
|
| 92 |
-
)
|
| 93 |
-
);
|
| 94 |
-
}
|
| 95 |
-
|
| 96 |
-
/**
|
| 97 |
-
* updates an array of articles in batch
|
| 98 |
-
* @return UpdateArticlesResponse
|
| 99 |
-
*/
|
| 100 |
-
public function updateArticles(array $articles) {
|
| 101 |
-
return $this->__call(
|
| 102 |
-
'updateArticles',
|
| 103 |
-
array(
|
| 104 |
-
new SoapParam($this->auth, 'auth'),
|
| 105 |
-
new SoapParam($articles, 'articles')
|
| 106 |
-
)
|
| 107 |
-
);
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/**
|
| 111 |
-
* retrieves new marketplace orders
|
| 112 |
-
* @return GetNewMarketplaceOrdersResponse
|
| 113 |
-
*/
|
| 114 |
-
public function getNewMarketplaceOrders() {
|
| 115 |
-
return $this->__call(
|
| 116 |
-
'getNewMarketplaceOrders',
|
| 117 |
-
array(
|
| 118 |
-
new SoapParam($this->auth, 'auth')
|
| 119 |
-
)
|
| 120 |
-
);
|
| 121 |
-
}
|
| 122 |
-
|
| 123 |
-
/**
|
| 124 |
-
* update orders in ChannelPilot to "imported", generates the matching between externalOrderId and the shop-internal orderId
|
| 125 |
-
* q
|
| 126 |
-
* @return GetNewMarketplaceOrdersResponse
|
| 127 |
-
*/
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
/**
|
| 131 |
-
* update orders in ChannelPilot to "imported", generates the matching between externalOrderId and the shop-internal orderId
|
| 132 |
-
* @param array $orders array of CPOrders
|
| 133 |
-
* @param type $mapOrderItemIds boolean, if channelPilot should map your internal orderItemIds
|
| 134 |
-
* @return type
|
| 135 |
-
*/
|
| 136 |
-
public function setImportedOrders(array $orders, $mapOrderItemIds) {
|
| 137 |
-
return $this->__call(
|
| 138 |
-
'setImportedOrders',
|
| 139 |
-
array(
|
| 140 |
-
new SoapParam($this->auth, 'auth'),
|
| 141 |
-
new SoapParam($orders, 'importedOrders'),
|
| 142 |
-
new SoapParam($mapOrderItemIds, 'mapOrderItemIds'),
|
| 143 |
-
)
|
| 144 |
-
);
|
| 145 |
-
}
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
public function registerDeliveries(array $deliveries) {
|
| 149 |
-
return $this->__call(
|
| 150 |
-
'registerDeliveries',
|
| 151 |
-
array(
|
| 152 |
-
new SoapParam($this->auth, 'auth'),
|
| 153 |
-
new SoapParam($deliveries, 'deliveries')
|
| 154 |
-
)
|
| 155 |
-
);
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
public function registerCancellations(array $cancellations) {
|
| 159 |
-
return $this->__call(
|
| 160 |
-
'registerCancellations',
|
| 161 |
-
array(
|
| 162 |
-
new SoapParam($this->auth, 'auth'),
|
| 163 |
-
new SoapParam($cancellations, 'cancellations')
|
| 164 |
-
)
|
| 165 |
-
);
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
public function getDynamicArticlePrices($priceId, $method, $filterArticles, $filterFrom) {
|
| 169 |
-
return $this->__call(
|
| 170 |
-
'getDynamicArticlePrices',
|
| 171 |
-
array(
|
| 172 |
-
new SoapParam($this->auth, 'auth'),
|
| 173 |
-
new SoapParam($priceId, 'priceId'),
|
| 174 |
-
new SoapParam(null, 'pagination'),
|
| 175 |
-
new SoapParam($method, 'method'),
|
| 176 |
-
new SoapParam($filterArticles, 'filterArticles'),
|
| 177 |
-
new SoapParam($filterFrom, 'filterFrom')
|
| 178 |
-
)
|
| 179 |
-
);
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
?>
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
// include the stub-classes
|
| 4 |
+
require_once 'thin/CPAuth.php';
|
| 5 |
+
require_once 'thin/CPResponseHeader.php';
|
| 6 |
+
require_once 'thin/CPArticleUpdate.php';
|
| 7 |
+
require_once 'thin/CPAddress.php';
|
| 8 |
+
require_once 'thin/CPArticle.php';
|
| 9 |
+
require_once 'thin/CPCancellation.php';
|
| 10 |
+
require_once 'thin/CPDiscount.php';
|
| 11 |
+
require_once 'thin/CPManagedArticlePrice.php';
|
| 12 |
+
require_once 'thin/CPMoney.php';
|
| 13 |
+
require_once 'thin/CPPayment.php';
|
| 14 |
+
require_once 'thin/CPCustomer.php';
|
| 15 |
+
require_once 'thin/CPOrderItem.php';
|
| 16 |
+
require_once 'thin/CPShipping.php';
|
| 17 |
+
require_once 'thin/CPOrderStatus.php';
|
| 18 |
+
require_once 'thin/CPOrderHeader.php';
|
| 19 |
+
require_once 'thin/CPOrder.php';
|
| 20 |
+
require_once 'thin/CPOrderSummary.php';
|
| 21 |
+
|
| 22 |
+
// request-classes
|
| 23 |
+
// response-classes
|
| 24 |
+
require_once 'responses/Response.php';
|
| 25 |
+
require_once 'responses/GetServerTimeResponse.php';
|
| 26 |
+
require_once 'responses/UpdateArticlesResponse.php';
|
| 27 |
+
require_once 'responses/UpdateArticleResult.php';
|
| 28 |
+
require_once 'responses/UpdateOrdersResponse.php';
|
| 29 |
+
require_once 'responses/UpdateOrderResult.php';
|
| 30 |
+
require_once 'responses/GetNewMarketplaceOrdersResponse.php';
|
| 31 |
+
require_once 'responses/GetManagedArticlePricesResponse.php';
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Main API-Class
|
| 35 |
+
* @author Channel Pilot Solutions GmbH <api@channelpilot.com>
|
| 36 |
+
* @version 1.0
|
| 37 |
+
*/
|
| 38 |
+
class ChannelPilotSellerAPI_v1_0 extends SoapClient {
|
| 39 |
+
|
| 40 |
+
private $auth;
|
| 41 |
+
private $wsdlUrl = 'https://seller.api.channelpilot.com/1_0?wsdl';
|
| 42 |
+
private $soapOptions = array(
|
| 43 |
+
'connection_timeout' => 20,
|
| 44 |
+
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
|
| 45 |
+
);
|
| 46 |
+
private $classmap = array(
|
| 47 |
+
'CPAuth' => 'CPAuth',
|
| 48 |
+
'CPResponseHeader' => 'CPResponseHeader',
|
| 49 |
+
'AbstractResponse' => 'AbstractResponse',
|
| 50 |
+
'GetServerTimeResponse' => 'GetServerTimeResponse',
|
| 51 |
+
'CPArticleUpdate' => 'CPArticleUpdate',
|
| 52 |
+
'UpdateArticlesResponse' => 'UpdateArticlesResponse',
|
| 53 |
+
'UpdateArticleResult' => 'UpdateArticleResult',
|
| 54 |
+
'UpdateOrdersResponse' => 'UpdateOrdersResponse',
|
| 55 |
+
'UpdateOrderResult' => 'UpdateOrderResult',
|
| 56 |
+
'CPAddress' => 'CPAddress',
|
| 57 |
+
'CPArticle' => 'CPArticle',
|
| 58 |
+
'CPDiscount' => 'CPDiscount',
|
| 59 |
+
'CPManagedArticlePrice' => 'CPManagedArticlePrice',
|
| 60 |
+
'CPMoney' => 'CPMoney',
|
| 61 |
+
'CPPayment' => 'CPPayment',
|
| 62 |
+
'CPCustomer' => 'CPCustomer',
|
| 63 |
+
'CPOrderItem' => 'CPOrderItem',
|
| 64 |
+
'CPShipping' => 'CPShipping',
|
| 65 |
+
'CPOrderStatus' => 'CPOrderStatus',
|
| 66 |
+
'CPOrderHeader' => 'CPOrderHeader',
|
| 67 |
+
'CPOrder' => 'CPOrder',
|
| 68 |
+
'CPOrderSummary' => 'CPOrderSummary',
|
| 69 |
+
'GetNewMarketplaceOrdersResponse' => 'GetNewMarketplaceOrdersResponse'
|
| 70 |
+
);
|
| 71 |
+
|
| 72 |
+
public function ChannelPilotSellerAPI_v1_0($merchantId, $shopToken) {
|
| 73 |
+
$this->auth = new CPAuth($merchantId, $shopToken);
|
| 74 |
+
|
| 75 |
+
foreach ($this->classmap as $key => $value) {
|
| 76 |
+
if (!isset($this->soapOptions['classmap'][$key])) {
|
| 77 |
+
$this->soapOptions['classmap'][$key] = $value;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
parent::__construct($this->wsdlUrl, $this->soapOptions);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Receives the acutal server time. Can be used to test the connection.
|
| 85 |
+
* @return GetServerTimeResponse
|
| 86 |
+
*/
|
| 87 |
+
public function getServerTime() {
|
| 88 |
+
return $this->__call(
|
| 89 |
+
'getServerTime',
|
| 90 |
+
array(
|
| 91 |
+
new SoapParam($this->auth, 'auth')
|
| 92 |
+
)
|
| 93 |
+
);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/**
|
| 97 |
+
* updates an array of articles in batch
|
| 98 |
+
* @return UpdateArticlesResponse
|
| 99 |
+
*/
|
| 100 |
+
public function updateArticles(array $articles) {
|
| 101 |
+
return $this->__call(
|
| 102 |
+
'updateArticles',
|
| 103 |
+
array(
|
| 104 |
+
new SoapParam($this->auth, 'auth'),
|
| 105 |
+
new SoapParam($articles, 'articles')
|
| 106 |
+
)
|
| 107 |
+
);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* retrieves new marketplace orders
|
| 112 |
+
* @return GetNewMarketplaceOrdersResponse
|
| 113 |
+
*/
|
| 114 |
+
public function getNewMarketplaceOrders() {
|
| 115 |
+
return $this->__call(
|
| 116 |
+
'getNewMarketplaceOrders',
|
| 117 |
+
array(
|
| 118 |
+
new SoapParam($this->auth, 'auth')
|
| 119 |
+
)
|
| 120 |
+
);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* update orders in ChannelPilot to "imported", generates the matching between externalOrderId and the shop-internal orderId
|
| 125 |
+
* q
|
| 126 |
+
* @return GetNewMarketplaceOrdersResponse
|
| 127 |
+
*/
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* update orders in ChannelPilot to "imported", generates the matching between externalOrderId and the shop-internal orderId
|
| 132 |
+
* @param array $orders array of CPOrders
|
| 133 |
+
* @param type $mapOrderItemIds boolean, if channelPilot should map your internal orderItemIds
|
| 134 |
+
* @return type
|
| 135 |
+
*/
|
| 136 |
+
public function setImportedOrders(array $orders, $mapOrderItemIds) {
|
| 137 |
+
return $this->__call(
|
| 138 |
+
'setImportedOrders',
|
| 139 |
+
array(
|
| 140 |
+
new SoapParam($this->auth, 'auth'),
|
| 141 |
+
new SoapParam($orders, 'importedOrders'),
|
| 142 |
+
new SoapParam($mapOrderItemIds, 'mapOrderItemIds'),
|
| 143 |
+
)
|
| 144 |
+
);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
public function registerDeliveries(array $deliveries) {
|
| 149 |
+
return $this->__call(
|
| 150 |
+
'registerDeliveries',
|
| 151 |
+
array(
|
| 152 |
+
new SoapParam($this->auth, 'auth'),
|
| 153 |
+
new SoapParam($deliveries, 'deliveries')
|
| 154 |
+
)
|
| 155 |
+
);
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
public function registerCancellations(array $cancellations) {
|
| 159 |
+
return $this->__call(
|
| 160 |
+
'registerCancellations',
|
| 161 |
+
array(
|
| 162 |
+
new SoapParam($this->auth, 'auth'),
|
| 163 |
+
new SoapParam($cancellations, 'cancellations')
|
| 164 |
+
)
|
| 165 |
+
);
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
public function getDynamicArticlePrices($priceId, $method, $filterArticles, $filterFrom) {
|
| 169 |
+
return $this->__call(
|
| 170 |
+
'getDynamicArticlePrices',
|
| 171 |
+
array(
|
| 172 |
+
new SoapParam($this->auth, 'auth'),
|
| 173 |
+
new SoapParam($priceId, 'priceId'),
|
| 174 |
+
new SoapParam(null, 'pagination'),
|
| 175 |
+
new SoapParam($method, 'method'),
|
| 176 |
+
new SoapParam($filterArticles, 'filterArticles'),
|
| 177 |
+
new SoapParam($filterFrom, 'filterFrom')
|
| 178 |
+
)
|
| 179 |
+
);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
?>
|
app/code/community/Channelpilotsolutions/Channelpilot/Helper/handler/CPExportHandler.php
CHANGED
|
@@ -24,7 +24,7 @@ class CPExportHandler extends CPAbstractHandler {
|
|
| 24 |
*
|
| 25 |
*/
|
| 26 |
public function handle() {
|
| 27 |
-
if (isset($_GET['shopId'])) {
|
| 28 |
$this->limit = $_GET['limit'];
|
| 29 |
$this->last = $_GET['last'];
|
| 30 |
$this->_storeId = $_GET['shopId'];
|
| 24 |
*
|
| 25 |
*/
|
| 26 |
public function handle() {
|
| 27 |
+
if (isset($_GET['limit']) && isset($_GET['shopId'])) {
|
| 28 |
$this->limit = $_GET['limit'];
|
| 29 |
$this->last = $_GET['last'];
|
| 30 |
$this->_storeId = $_GET['shopId'];
|
app/code/community/Channelpilotsolutions/Channelpilot/Model/PaymentTypes.php
CHANGED
|
@@ -1,11 +1,5 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
/*
|
| 4 |
-
* To change this license header, choose License Headers in Project Properties.
|
| 5 |
-
* To change this template file, choose Tools | Templates
|
| 6 |
-
* and open the template in the editor.
|
| 7 |
-
*/
|
| 8 |
-
|
| 9 |
class Channelpilotsolutions_Channelpilot_Model_Paymenttypes {
|
| 10 |
|
| 11 |
public function toOptionArray() {
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class Channelpilotsolutions_Channelpilot_Model_Paymenttypes {
|
| 4 |
|
| 5 |
public function toOptionArray() {
|
app/code/community/Channelpilotsolutions/Channelpilot/etc/config.xml
CHANGED
|
@@ -24,7 +24,7 @@
|
|
| 24 |
<config>
|
| 25 |
<modules>
|
| 26 |
<Channelpilotsolutions_Channelpilot>
|
| 27 |
-
<version>2.1.
|
| 28 |
</Channelpilotsolutions_Channelpilot>
|
| 29 |
</modules>
|
| 30 |
<global>
|
| 24 |
<config>
|
| 25 |
<modules>
|
| 26 |
<Channelpilotsolutions_Channelpilot>
|
| 27 |
+
<version>2.1.3</version>
|
| 28 |
</Channelpilotsolutions_Channelpilot>
|
| 29 |
</modules>
|
| 30 |
<global>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Channelpilotsolutions_Channelpilot</name>
|
| 4 |
-
<version>2.1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -26,11 +26,11 @@
|
|
| 26 |
<li><b>ChannelPilot Multi-Platform:</b> Access ChannelPilot on any device (e.g. computer, tablet or smartphone) and keep a firm hold on your online marketing- wherever you are!</li>
|
| 27 |
</ul>
|
| 28 |
Just get more information about ChannelPilot: <a href="http://www.channelpilot.com">www.channelpilot.com</a></description>
|
| 29 |
-
<notes>-
|
| 30 |
<authors><author><name>ChannelPilot Solutions GmbH</name><user>auto-converted</user><email>info@channelpilot.com</email></author></authors>
|
| 31 |
-
<date>2015-
|
| 32 |
-
<time>
|
| 33 |
-
<contents><target name="magecommunity"><dir name="Channelpilotsolutions"><dir name="Channelpilot"><dir name="Adminhtml"><dir name="Model"><dir name="Articlenumber"><file name="Values.php" hash="f2744ef8301e25e096318f34eb97c2bf"/></dir><dir name="Cookiemode"><file name="Values.php" hash="1ec39f85bb7562c1b6a4614f759d9124"/></dir><dir name="Grossnet"><file name="Values.php" hash="11eaf553b0ec34299524ec6d5a9f1e13"/></dir><dir name="Imagenumber"><file name="Values.php" hash="010dbb2ec946627f338bc500d3d8d747"/></dir><dir name="Pricefield"><file name="Values.php" hash="6b02dfa3fa93daafa8325d66a986b4ac"/></dir><dir name="Truefalse"><file name="Values.php" hash="e07f105d7d8dc9881690f162cd23472d"/></dir><dir name="Truefalsesecurity"><file name="Values.php" hash="509b5e1cc7cabbe179373bc0ed490499"/></dir></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="Field"><file name="Exportfields.php" hash="ca3e562dff7272ed6e72592d65d2466f"/><file name="Replacefields.php" hash="998c731b9e0419271f5ef13237405ad0"/><file name="Specialfields.php" hash="617a423f8632d0bee669bab5a463ce74"/><file name="Trackingkeys.php" hash="383c5112824ccb2998c74dbc3fe10da1"/></dir><file name="Hintlogo.php" hash="be78974a79e7cc59601254a8df0dc48b"/></dir></dir><dir name="Helper"><dir name="api"><dir name="1_0"><dir name="responses"><file name="GetManagedArticlePricesResponse.php" hash="9ad5adee1952b9408b442449791a1f34"/><file name="GetNewMarketplaceOrdersResponse.php" hash="cd5db953a84759b93a35a360956c4624"/><file name="GetServerTimeResponse.php" hash="07d157639b5bf715aa3f93b0d9e4b736"/><file name="Response.php" hash="c76ce62707a862e1c59346c668055b5d"/><file name="UpdateArticleResult.php" hash="a014c60be447fbb9cf48c947c8e9822f"/><file name="UpdateArticlesResponse.php" hash="338619d50391d91defb5c9d41370022f"/><file name="UpdateOrderResult.php" hash="0fbd88371624270a8cb2c4209a89cfac"/><file name="UpdateOrdersResponse.php" hash="b0ad5828da633b05e654da393b15526a"/></dir><dir name="thin"><file name="CPAddress.php" hash="885fb4517335421fbd8cbc882ae336b1"/><file name="CPArticle.php" hash="1adce1ce33acdd0185dee06010040b18"/><file name="CPArticleUpdate.php" hash="45f514823895c754010f8f11a1ff683a"/><file name="CPAuth.php" hash="cf5fe570dbd98e3e6339b20cec826b7b"/><file name="CPCancellation.php" hash="9bf808e265e09d166466313405a167fc"/><file name="CPCustomer.php" hash="62babdf11e9b4d80ae0afbbf96ba329d"/><file name="CPDelivery.php" hash="c8c54883370efd519249a9a9551668d0"/><file name="CPDiscount.php" hash="5d6f2766869134a86761c12230dc32d1"/><file name="CPManagedArticlePrice.php" hash="65c4c0df04b7c8d20294874de11640d6"/><file name="CPMoney.php" hash="952131eccc8470e107c78e15c94b6495"/><file name="CPOrder.php" hash="32623885f664e9b5871fc48b6ba0c801"/><file name="CPOrderHeader.php" hash="828377182e8197c304f230a783606993"/><file name="CPOrderItem.php" hash="dfe2440a08e3d0f13e638fc4090e6c52"/><file name="CPOrderStatus.php" hash="e0e767388dd9a1ab8be5a990f1ab1259"/><file name="CPOrderSummary.php" hash="fceaa6a79b5fc892062681f518fd0243"/><file name="CPPayment.php" hash="446ffde1318d001c213de2b80855af07"/><file name="CPResponseHeader.php" hash="53930210d68046183e3be306996ea9b9"/><file name="CPShipping.php" hash="eaddceace28cdc6ba72434a6321d8c47"/></dir><file name="CPResultCodes.php" hash="955180ee33f14b4afa93f6eb1b5df53f"/><file name="ChannelPilotSellerAPI_v1_0.php" hash="
|
| 34 |
<compatible/>
|
| 35 |
<dependencies/>
|
| 36 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Channelpilotsolutions_Channelpilot</name>
|
| 4 |
+
<version>2.1.3</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
|
| 7 |
<channel>community</channel>
|
| 26 |
<li><b>ChannelPilot Multi-Platform:</b> Access ChannelPilot on any device (e.g. computer, tablet or smartphone) and keep a firm hold on your online marketing- wherever you are!</li>
|
| 27 |
</ul>
|
| 28 |
Just get more information about ChannelPilot: <a href="http://www.channelpilot.com">www.channelpilot.com</a></description>
|
| 29 |
+
<notes>- fixed bug in module activation</notes>
|
| 30 |
<authors><author><name>ChannelPilot Solutions GmbH</name><user>auto-converted</user><email>info@channelpilot.com</email></author></authors>
|
| 31 |
+
<date>2015-05-12</date>
|
| 32 |
+
<time>12:28:52</time>
|
| 33 |
+
<contents><target name="magecommunity"><dir name="Channelpilotsolutions"><dir name="Channelpilot"><dir name="Adminhtml"><dir name="Model"><dir name="Articlenumber"><file name="Values.php" hash="f2744ef8301e25e096318f34eb97c2bf"/></dir><dir name="Cookiemode"><file name="Values.php" hash="1ec39f85bb7562c1b6a4614f759d9124"/></dir><dir name="Grossnet"><file name="Values.php" hash="11eaf553b0ec34299524ec6d5a9f1e13"/></dir><dir name="Imagenumber"><file name="Values.php" hash="010dbb2ec946627f338bc500d3d8d747"/></dir><dir name="Pricefield"><file name="Values.php" hash="6b02dfa3fa93daafa8325d66a986b4ac"/></dir><dir name="Truefalse"><file name="Values.php" hash="e07f105d7d8dc9881690f162cd23472d"/></dir><dir name="Truefalsesecurity"><file name="Values.php" hash="509b5e1cc7cabbe179373bc0ed490499"/></dir></dir></dir><dir name="Block"><dir name="Adminhtml"><dir name="Field"><file name="Exportfields.php" hash="ca3e562dff7272ed6e72592d65d2466f"/><file name="Replacefields.php" hash="998c731b9e0419271f5ef13237405ad0"/><file name="Specialfields.php" hash="617a423f8632d0bee669bab5a463ce74"/><file name="Trackingkeys.php" hash="383c5112824ccb2998c74dbc3fe10da1"/></dir><file name="Hintlogo.php" hash="be78974a79e7cc59601254a8df0dc48b"/></dir></dir><dir name="Helper"><dir name="api"><dir name="1_0"><dir name="responses"><file name="GetManagedArticlePricesResponse.php" hash="9ad5adee1952b9408b442449791a1f34"/><file name="GetNewMarketplaceOrdersResponse.php" hash="cd5db953a84759b93a35a360956c4624"/><file name="GetServerTimeResponse.php" hash="07d157639b5bf715aa3f93b0d9e4b736"/><file name="Response.php" hash="c76ce62707a862e1c59346c668055b5d"/><file name="UpdateArticleResult.php" hash="a014c60be447fbb9cf48c947c8e9822f"/><file name="UpdateArticlesResponse.php" hash="338619d50391d91defb5c9d41370022f"/><file name="UpdateOrderResult.php" hash="0fbd88371624270a8cb2c4209a89cfac"/><file name="UpdateOrdersResponse.php" hash="b0ad5828da633b05e654da393b15526a"/></dir><dir name="thin"><file name="CPAddress.php" hash="885fb4517335421fbd8cbc882ae336b1"/><file name="CPArticle.php" hash="1adce1ce33acdd0185dee06010040b18"/><file name="CPArticleUpdate.php" hash="45f514823895c754010f8f11a1ff683a"/><file name="CPAuth.php" hash="cf5fe570dbd98e3e6339b20cec826b7b"/><file name="CPCancellation.php" hash="9bf808e265e09d166466313405a167fc"/><file name="CPCustomer.php" hash="62babdf11e9b4d80ae0afbbf96ba329d"/><file name="CPDelivery.php" hash="c8c54883370efd519249a9a9551668d0"/><file name="CPDiscount.php" hash="5d6f2766869134a86761c12230dc32d1"/><file name="CPManagedArticlePrice.php" hash="65c4c0df04b7c8d20294874de11640d6"/><file name="CPMoney.php" hash="952131eccc8470e107c78e15c94b6495"/><file name="CPOrder.php" hash="32623885f664e9b5871fc48b6ba0c801"/><file name="CPOrderHeader.php" hash="828377182e8197c304f230a783606993"/><file name="CPOrderItem.php" hash="dfe2440a08e3d0f13e638fc4090e6c52"/><file name="CPOrderStatus.php" hash="e0e767388dd9a1ab8be5a990f1ab1259"/><file name="CPOrderSummary.php" hash="fceaa6a79b5fc892062681f518fd0243"/><file name="CPPayment.php" hash="446ffde1318d001c213de2b80855af07"/><file name="CPResponseHeader.php" hash="53930210d68046183e3be306996ea9b9"/><file name="CPShipping.php" hash="eaddceace28cdc6ba72434a6321d8c47"/></dir><file name="CPResultCodes.php" hash="955180ee33f14b4afa93f6eb1b5df53f"/><file name="ChannelPilotSellerAPI_v1_0.php" hash="2eab31345c3628f38c71364e81aad905"/></dir></dir><dir name="handler"><file name="CPAbstractHandler.php" hash="3ff636f82a10e452f8b76e0747d64644"/><file name="CPCancellationHandler.php" hash="9b77706089a26ae42ad2e00c303b66ae"/><file name="CPDebugHandler.php" hash="43f2e8da6e44adfb20d7ec813ca54cad"/><file name="CPDeliveryHandler.php" hash="a392ca48d781dd0db4e6fb9bdd863b7e"/><file name="CPErrorHandler.php" hash="5d728c064c068fdf8354fa87882e4dba"/><file name="CPExportHandler.php" hash="d36ae63a30e587245e8be62e01cebdcb"/><file name="CPNewPriceHandler.php" hash="749093369d0c3fefe1782c5c77774f9f"/><file name="CPNewsHandler.php" hash="4975a6271baf09af3b2f007f13bb587c"/><file name="CPOrderHandler.php" hash="b605bf698acd1803bb6d3be8a65dd27c"/><file name="CPRegisterHandler.php" hash="43a7baff372b472049dc0e52deb2549f"/><file name="CPStatusHandler.php" hash="713feca664739aeacda6260318f5c26a"/><file name="todoCPPaymentHandler.php" hash="34ea64beda7c8bc5309ebea280146c32"/></dir><dir name="responses"><file name="CPGetStatusHookResponse.php" hash="672609ebcaa23aa0de85aed04c7662d8"/><file name="CPHookResponse.php" hash="9acdda5838cae8b6022af2f4e0a9314b"/><file name="CPRegisterHookResponse.php" hash="206de6433d0795ebdabff98129cc2fb7"/></dir><dir name="special"><file name="CustomerFunctions.php" hash="0d343d3c9c3cb87232c833e0772f730e"/></dir><file name="CPErrors.php" hash="3659c38a1ed3be4aa4ec03d93e68a84e"/><file name="Data.php" hash="7caa8da971acdff24ed04f928fef0cef"/><file name="ExportData.php" hash="4b7c911c4889cfde9d1e2976db856336"/></dir><dir name="Model"><file name="Abstract.php" hash="0e9349f1023527a77e59742dfdb21308"/><file name="Payment.php" hash="5160ffe0422a9a46dc2bd7a79e512b8b"/><file name="PaymentTypes.php" hash="b217cdabf427beadb8d74acff069af4d"/><file name="Paymenttypes.php" hash="b217cdabf427beadb8d74acff069af4d"/></dir><dir name="controllers"><file name="IndexController.php" hash="36e391b61d1914f8669cd48207dd06da"/></dir><dir name="etc"><file name="adminhtml.xml" hash="62fad9ef0e77e858b74d2a7bdd6a6879"/><file name="config.xml" hash="3ad65547173f2c1d9144ceb9267be37e"/><file name="system.xml" hash="33d311ca704780d078533f62381895b1"/></dir><dir name="sql"><dir name="channelpilot_setup"><file name="mysql4-install-2.0.0.php" hash="8910b9b0507d1b38c8b8465845fb3849"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Channelpilotsolutions_Channelpilot.xml" hash="4cc80daa0c7f8dda239e41a6b17321bf"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="Channelpilotsolutions"><file name="channelpilot.xml" hash="732f1d98851f3c1bf0cb9e655a4a0359"/></dir></dir><dir name="template"><dir name="Channelpilotsolutions"><file name="channelpilot.phtml" hash="ac42e9777d28910dddc50d7d82ded4c2"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="channelpilotsolutions"><file name="array_dropdown.phtml" hash="cb1230cd8a92ce0a0961f71b396736ec"/><file name="config_hint.phtml" hash="bab45579386a99fe4ccbfb1972ed08fc"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Channelpilotsolutions_Channelpilot.csv" hash="57d54b69d4c7cb28373764403069eb6d"/></dir><dir name="de_CH"><file name="Channelpilotsolutions_Channelpilot.csv" hash="c5c7fd72d8a8778b5f1228c356111695"/></dir><dir name="de_AT"><file name="Channelpilotsolutions_Channelpilot.csv" hash="c5c7fd72d8a8778b5f1228c356111695"/></dir><dir name="fr_FR"><file name="Channelpilotsolutions_Channelpilot.csv" hash="9a49d3ba87895fb14b234cfa838b9fab"/></dir><dir name="fr_CA"><file name="Channelpilotsolutions_Channelpilot.csv" hash="9a49d3ba87895fb14b234cfa838b9fab"/></dir><dir name="en_AU"><file name="Channelpilotsolutions_Channelpilot.csv" hash="023babc42d9f9fd4488c6badcee01032"/></dir><dir name="en_CA"><file name="Channelpilotsolutions_Channelpilot.csv" hash="023babc42d9f9fd4488c6badcee01032"/></dir><dir name="en_GB"><file name="Channelpilotsolutions_Channelpilot.csv" hash="023babc42d9f9fd4488c6badcee01032"/></dir><dir name="en_IE"><file name="Channelpilotsolutions_Channelpilot.csv" hash="023babc42d9f9fd4488c6badcee01032"/></dir><dir name="en_NZ"><file name="Channelpilotsolutions_Channelpilot.csv" hash="023babc42d9f9fd4488c6badcee01032"/></dir><dir name="en_US"><file name="Channelpilotsolutions_Channelpilot.csv" hash="023babc42d9f9fd4488c6badcee01032"/></dir><dir name="es_AR"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_CL"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_CO"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_CR"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_ES"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_MX"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_PA"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_PE"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir><dir name="es_VE"><file name="Channelpilotsolutions_Channelpilot.csv" hash="eb81767885d7b76c7e89f9f3c0900fc3"/></dir></target></contents>
|
| 34 |
<compatible/>
|
| 35 |
<dependencies/>
|
| 36 |
</package>
|
