Version Notes
Please contact our support desk if you have any problems.
Download this release
Release Info
| Developer | catalogondemand |
| Extension | Mage_Codi |
| Version | 4.3.0 |
| Comparing to | |
| See all releases | |
Code changes from version 4.2.8 to 4.3.0
app/code/community/Mage/CodiScript/Model/Files.php
CHANGED
|
@@ -1,40 +1,59 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
public $optionIds = array();
|
| 5 |
public $line = NULL;
|
|
|
|
| 6 |
}
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
public $id = NULL;
|
| 9 |
public $title = NULL;
|
| 10 |
public $type = NULL;
|
| 11 |
public $required = NULL;
|
| 12 |
public $values = array();
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
}
|
|
|
|
| 16 |
}
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
public $title = NULL;
|
| 19 |
public $sku = NULL;
|
| 20 |
public $rprice = NULL;
|
| 21 |
public $sprice = NULL;
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
}
|
|
|
|
| 25 |
}
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
public $optionId = NULL;
|
| 28 |
public $coValues = array();
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
return $out;
|
| 34 |
}
|
|
|
|
| 35 |
}
|
|
|
|
| 36 |
class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
|
|
|
|
| 37 |
public $version = __VERSION__;
|
|
|
|
| 38 |
public $Store;
|
| 39 |
public $StoreId;
|
| 40 |
public $reviewsModel;
|
|
@@ -75,278 +94,329 @@ class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
|
|
| 75 |
public $catpathmap;
|
| 76 |
public $catmap;
|
| 77 |
public $catpositions = FALSE;
|
|
|
|
| 78 |
public $_DEBUG;
|
|
|
|
| 79 |
const TAG_P_CLOSE = '</p>';
|
| 80 |
const TAG_P = '<p>';
|
| 81 |
const SCRIPTNAME = __SCRIPTNAME__;
|
| 82 |
|
| 83 |
public function _construct() {
|
| 84 |
parent::_construct();
|
| 85 |
-
$this->_init(
|
| 86 |
-
Mage::app()->setCurrentStore(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
// Class=DataFile
|
| 90 |
-
public function renderDataFile(){
|
| 91 |
-
if(
|
| 92 |
-
|
| 93 |
-
";
|
| 94 |
-
foreach(
|
| 95 |
-
"
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
$this->productTypeConfigurableModel = Mage::getModel('catalog/product_type_configurable');
|
| 98 |
$this->productTypeGroupedModel = Mage::getModel('catalog/product_type_grouped');
|
| 99 |
-
$this->reviewsModel = Mage::getModel('review/review')->setStoreId(
|
| 100 |
-
$this->catalogInventoryModel = Mage::getModel('cataloginventory/stock_item')->setStoreId(
|
| 101 |
-
$this->mediaurl = Mage::getBaseUrl(
|
| 102 |
-
$this->prodmediaurl = $this->mediaurl."catalog/product";
|
| 103 |
$this->mageVersionArray = Mage::getVersionInfo();
|
| 104 |
-
if(
|
| 105 |
-
|
| 106 |
-
";
|
| 107 |
-
|
|
|
|
| 108 |
$this->customerGroups = array();
|
| 109 |
$customerGroups = Mage::getModel('customer/group')->getCollection();
|
| 110 |
-
foreach(
|
| 111 |
$this->customerGroups[$cg->_data['customer_group_id']] = $cg->_data['customer_group_code'];
|
| 112 |
-
if(
|
| 113 |
-
"
|
|
|
|
|
|
|
| 114 |
}
|
| 115 |
}
|
| 116 |
-
$products = Mage::getModel('catalog/product')->setStoreId(
|
| 117 |
-
$products->addAttributeToFilter('status', 1)
|
| 118 |
-
$products->addAttributeToFilter('visibility', 4)
|
| 119 |
$prodIds = $products->getAllIds();
|
| 120 |
-
if(
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
"
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
$count = 0;
|
| 128 |
$index = 0;
|
| 129 |
$lastLine = "==EOF==
|
| 130 |
";
|
| 131 |
-
foreach(
|
| 132 |
-
if(
|
| 133 |
$lastLine = "==MORE==
|
| 134 |
";
|
| 135 |
break;
|
| 136 |
}
|
| 137 |
-
if(
|
| 138 |
$index++;
|
| 139 |
continue;
|
| 140 |
}
|
| 141 |
$index++;
|
| 142 |
-
$product = Mage::getModel('catalog/product')->setStoreId(
|
| 143 |
-
if(
|
| 144 |
-
"
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
|
|
|
| 154 |
}
|
| 155 |
} else {
|
| 156 |
-
|
| 157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
}
|
| 159 |
-
else
|
| 160 |
-
echo $this->ProducttoStringSimple( $product );
|
| 161 |
-
unset( $product );
|
| 162 |
-
if( $this->_DEBUG ) echo "#".$count.": memory_get_usage ".memory_get_usage()." / ".memory_get_usage( TRUE )."
|
| 163 |
-
";
|
| 164 |
$count++;
|
| 165 |
}
|
| 166 |
-
|
| 167 |
}
|
| 168 |
|
| 169 |
-
private function ProducttoStringGrouped(
|
| 170 |
$ProducttoString = "";
|
| 171 |
-
$AssociatedProductIds = $this->productTypeGroupedModel->getAssociatedProductIds(
|
| 172 |
$ProductDescription = "";
|
| 173 |
$shortDescription = "";
|
| 174 |
-
if(
|
| 175 |
$shortDescription = $product->getShortDescription();
|
| 176 |
-
if(
|
| 177 |
-
$shortDescription = $this->_cleanStr(
|
| 178 |
-
if(
|
| 179 |
-
$new = strlen(
|
| 180 |
-
$pos = strrpos(
|
| 181 |
-
if(
|
| 182 |
-
$shortDescription = substr(
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
| 189 |
$longDescription = $product->getDescription();
|
| 190 |
-
if(
|
| 191 |
-
$longDescription = $this->_cleanStr(
|
| 192 |
-
if(
|
| 193 |
-
$new = strlen(
|
| 194 |
-
$pos = strrpos(
|
| 195 |
-
if(
|
| 196 |
-
$longDescription = substr(
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
}
|
| 202 |
$attributes = $product->getAttributes();
|
| 203 |
$Manufacturer = "";
|
| 204 |
$ProductAttributes = "";
|
| 205 |
-
foreach(
|
| 206 |
-
$attribute->setStoreId(
|
| 207 |
-
if(
|
| 208 |
$hasData = $product->getData($attribute->getAttributeCode()) ? TRUE : FALSE;
|
| 209 |
-
|
| 210 |
-
";
|
| 211 |
}
|
| 212 |
-
if(
|
| 213 |
-
if(
|
| 214 |
-
$Manufacturer = $attribute->getFrontend()->getValue(
|
| 215 |
-
else
|
| 216 |
$Manufacturer = "";
|
|
|
|
| 217 |
continue;
|
| 218 |
}
|
| 219 |
-
if(
|
| 220 |
-
|
| 221 |
-
$value = $attribute->getFrontend()->getValue(
|
| 222 |
-
if(
|
| 223 |
-
$hasData = $product->getData(
|
| 224 |
-
if(
|
| 225 |
$value = "";
|
|
|
|
| 226 |
}
|
| 227 |
-
if(
|
| 228 |
-
if(
|
| 229 |
$ProductAttributes .= "|";
|
|
|
|
| 230 |
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
|
| 231 |
}
|
| 232 |
}
|
| 233 |
}
|
| 234 |
-
if(
|
| 235 |
-
$TierPriceAttributes = $this->_getTierPrices(
|
| 236 |
-
$sp = ( empty(
|
| 237 |
-
$ProductAttributes .= $sp
|
| 238 |
}
|
| 239 |
-
if(
|
| 240 |
-
$optionsAsAttributes = $this->_getCustomOptionsAsAttributes(
|
| 241 |
-
if(
|
| 242 |
-
if(
|
| 243 |
$ProductAttributes .= "|";
|
|
|
|
| 244 |
$ProductAttributes .= $optionsAsAttributes;
|
| 245 |
}
|
| 246 |
}
|
| 247 |
-
if(
|
| 248 |
-
$ProductAttributes = $this->_cleanStr(
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
"
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
|
|
|
|
|
|
|
|
|
| 256 |
$firstImageFile = FALSE;
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
| 267 |
continue;
|
| 268 |
-
|
|
|
|
| 269 |
continue;
|
| 270 |
-
|
|
|
|
| 271 |
}
|
| 272 |
}
|
| 273 |
-
$prodImages = implode(
|
| 274 |
$ProductURL = $product->getProductUrl();
|
| 275 |
-
if(
|
| 276 |
-
$ProductURL = $this->_correctProdUrlStr(
|
|
|
|
| 277 |
$productName = $product->getName();
|
| 278 |
-
$productName = $product->getId().'#$#'
|
| 279 |
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
| 280 |
-
if(
|
| 281 |
-
$Reviews = $this->_cleanStr(
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
";
|
|
|
|
|
|
|
|
|
|
| 287 |
}
|
| 288 |
$sequence = 1;
|
| 289 |
$UsedProducts = array();
|
| 290 |
-
foreach(
|
| 291 |
-
$UsedProduct = Mage::getModel('catalog/product')->setStoreId(
|
| 292 |
-
if(
|
| 293 |
$UsedProducts[] = $UsedProduct;
|
| 294 |
} else {
|
| 295 |
-
if(
|
| 296 |
-
"
|
| 297 |
-
|
|
|
|
|
|
|
| 298 |
}
|
| 299 |
}
|
| 300 |
$renderSPrice = FALSE;
|
| 301 |
-
if(
|
| 302 |
-
foreach(
|
| 303 |
$SPrice = $UsedProduct->getSpecialPrice();
|
| 304 |
-
if(
|
| 305 |
$renderSPrice = TRUE;
|
| 306 |
break;
|
| 307 |
}
|
| 308 |
}
|
| 309 |
}
|
| 310 |
-
foreach(
|
| 311 |
-
if(
|
| 312 |
-
$inventory = $this->catalogInventoryModel->loadByProduct(
|
| 313 |
$qty = $inventory->getQty();
|
| 314 |
$minQty = $inventory->getMinQty();
|
| 315 |
-
if(
|
| 316 |
-
if(
|
| 317 |
-
"
|
|
|
|
|
|
|
| 318 |
continue;
|
| 319 |
}
|
| 320 |
}
|
| 321 |
-
if(
|
| 322 |
-
"
|
| 323 |
-
|
|
|
|
|
|
|
| 324 |
$ProdRPrice = $UsedProduct->getData('price');
|
| 325 |
$ProdSPrice = $UsedProduct->getSpecialPrice();
|
| 326 |
$ProdSFromDate = $UsedProduct->getSpecialFromDate();
|
| 327 |
$ProdSToDate = $UsedProduct->getSpecialToDate();
|
| 328 |
$ProdGroupPrices = FALSE;
|
| 329 |
-
if(
|
| 330 |
$ProdGroupPrices = $UsedProduct->getData('group_price');
|
| 331 |
-
if(
|
| 332 |
-
"
|
|
|
|
|
|
|
| 333 |
}
|
| 334 |
$ProdSpecGroupPrices = FALSE;
|
| 335 |
-
if(
|
| 336 |
$ProdSpecGroupPrices = array();
|
| 337 |
-
foreach(
|
| 338 |
-
if(
|
| 339 |
-
$notLoggedInPrice = 0.0 + $groupPrice[
|
| 340 |
-
if(
|
| 341 |
-
$ProdSPrice = $groupPrice[
|
| 342 |
$ProdSFromDate = FALSE;
|
| 343 |
$ProdSToDate = FALSE;
|
| 344 |
}
|
| 345 |
-
} else
|
| 346 |
$ProdSpecGroupPrices[] = $groupPrice;
|
|
|
|
| 347 |
}
|
| 348 |
}
|
| 349 |
-
if(
|
| 350 |
$ProdSPrice = -1;
|
| 351 |
$ProdSFromDate = FALSE;
|
| 352 |
$ProdSToDate = FALSE;
|
|
@@ -354,269 +424,305 @@ thumbnail: ".$product->getThumbnail()."
|
|
| 354 |
$SFromDate = $ProdSFromDate;
|
| 355 |
$SToDate = $ProdSToDate;
|
| 356 |
$RPrice = $ProdRPrice;
|
| 357 |
-
if(
|
| 358 |
-
$RPrice = $this->taxhelper->getPrice(
|
|
|
|
| 359 |
$SPrice = $ProdSPrice;
|
| 360 |
-
if(
|
| 361 |
-
$SPrice = $this->taxhelper->getPrice(
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
$itemImages = array();
|
| 371 |
-
$firstImageFile = trim(
|
| 372 |
-
if(
|
| 373 |
$firstImageFile = FALSE;
|
| 374 |
-
|
| 375 |
-
|
|
|
|
|
|
|
| 376 |
$itemImageArray = $UsedProduct->getMediaGallery('images');
|
| 377 |
-
if(
|
| 378 |
-
foreach(
|
| 379 |
-
$imageFile = trim(
|
| 380 |
-
|
| 381 |
-
//";
|
| 382 |
-
if( !$imageFile || $imageFile == $firstImageFile )
|
| 383 |
continue;
|
| 384 |
-
|
|
|
|
| 385 |
continue;
|
| 386 |
-
|
|
|
|
| 387 |
}
|
| 388 |
}
|
| 389 |
-
$itemImages = implode(
|
| 390 |
}
|
| 391 |
$attributes = $UsedProduct->getAttributes();
|
| 392 |
$ItemAttributes = "";
|
| 393 |
-
foreach(
|
| 394 |
-
$attribute->setStoreId(
|
| 395 |
-
if(
|
| 396 |
$hasData = $UsedProduct->getData($attribute->getAttributeCode()) ? "YES" : "NO";
|
| 397 |
-
|
| 398 |
-
";
|
| 399 |
}
|
| 400 |
-
if(
|
| 401 |
-
if(
|
| 402 |
-
$Manufacturer = $attribute->getFrontend()->getValue(
|
|
|
|
| 403 |
continue;
|
| 404 |
}
|
| 405 |
-
if(
|
| 406 |
-
|
| 407 |
-
$value = $attribute->getFrontend()->getValue(
|
| 408 |
-
if(
|
| 409 |
-
$hasData = $UsedProduct->getData(
|
| 410 |
-
if(
|
| 411 |
$value = "";
|
|
|
|
| 412 |
}
|
| 413 |
-
if(
|
| 414 |
$ItemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|";
|
|
|
|
| 415 |
}
|
| 416 |
}
|
| 417 |
-
$ItemAttributes = substr(
|
| 418 |
-
if(
|
| 419 |
-
if(
|
| 420 |
$ItemAttributes .= "|";
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
$
|
| 426 |
-
$ItemAttributes
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
|
|
|
| 433 |
$ItemAttributes .= "|";
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
|
|
|
| 437 |
$ItemAttributes .= "|";
|
|
|
|
| 438 |
$ItemAttributes .= "Special Price=";
|
| 439 |
}
|
| 440 |
}
|
| 441 |
-
if(
|
| 442 |
-
if(
|
| 443 |
-
if(
|
| 444 |
$ItemAttributes .= "|";
|
| 445 |
-
|
|
|
|
| 446 |
}
|
| 447 |
}
|
| 448 |
-
if(
|
| 449 |
-
if(
|
| 450 |
-
if(
|
| 451 |
$ItemAttributes .= "|";
|
| 452 |
-
|
|
|
|
| 453 |
}
|
| 454 |
}
|
| 455 |
-
if(
|
| 456 |
-
foreach(
|
| 457 |
-
$price = 0.0 + $groupPrice[
|
| 458 |
-
if(
|
| 459 |
-
$price = $this->taxhelper->getPrice(
|
| 460 |
-
|
|
|
|
| 461 |
$ItemAttributes .= "|";
|
| 462 |
-
|
|
|
|
| 463 |
}
|
| 464 |
}
|
| 465 |
$itemID = $UsedProduct->getSku();
|
| 466 |
-
$ProducttoString .= $this->_cleanStr(
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
unset(
|
| 486 |
$sequence++;
|
| 487 |
}
|
| 488 |
-
unset(
|
| 489 |
-
unset(
|
| 490 |
return $ProducttoString;
|
| 491 |
}
|
| 492 |
|
| 493 |
-
private function ProducttoStringConfigurable(
|
| 494 |
$UsedProductIds = $this->productTypeConfigurableModel->getUsedProductIds($product);
|
| 495 |
$ProductDescription = "";
|
| 496 |
$shortDescription = "";
|
| 497 |
-
if(
|
| 498 |
$shortDescription = $product->getShortDescription();
|
| 499 |
-
if(
|
| 500 |
-
$shortDescription = $this->_cleanStr(
|
| 501 |
-
if(
|
| 502 |
-
$new = strlen(
|
| 503 |
-
$pos = strrpos(
|
| 504 |
-
if(
|
| 505 |
-
$shortDescription = substr(
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
|
|
|
|
|
|
| 512 |
$longDescription = $product->getDescription();
|
| 513 |
-
if(
|
| 514 |
-
$longDescription = $this->_cleanStr(
|
| 515 |
-
if(
|
| 516 |
-
$new = strlen(
|
| 517 |
-
$pos = strrpos(
|
| 518 |
-
if(
|
| 519 |
-
$longDescription = substr(
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
|
|
|
|
|
|
| 523 |
}
|
| 524 |
}
|
| 525 |
$attributes = $product->getAttributes();
|
| 526 |
$Manufacturer = "";
|
| 527 |
$ProductAttributes = "";
|
| 528 |
-
foreach(
|
| 529 |
-
$attribute->setStoreId(
|
| 530 |
-
if(
|
| 531 |
-
if(
|
| 532 |
-
$Manufacturer = $attribute->getFrontend()->getValue(
|
| 533 |
-
else
|
| 534 |
$Manufacturer = "";
|
|
|
|
| 535 |
continue;
|
| 536 |
}
|
| 537 |
-
if(
|
| 538 |
-
|
| 539 |
-
$value = $attribute->getFrontend()->getValue(
|
| 540 |
-
if(
|
| 541 |
-
$hasData = $product->getData(
|
| 542 |
-
if(
|
| 543 |
$value = "";
|
|
|
|
| 544 |
}
|
| 545 |
-
if(
|
| 546 |
-
if(
|
| 547 |
$ProductAttributes .= "|";
|
|
|
|
| 548 |
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
|
| 549 |
}
|
| 550 |
}
|
| 551 |
}
|
| 552 |
-
if(
|
| 553 |
$TierPriceAttributes = $this->_getTierPrices($product);
|
| 554 |
-
$sp = ( empty(
|
| 555 |
-
$ProductAttributes.= $sp
|
| 556 |
}
|
| 557 |
-
if(
|
| 558 |
-
$optionsAsAttributes = $this->_getCustomOptionsAsAttributes(
|
| 559 |
-
if(
|
| 560 |
-
if(
|
| 561 |
$ProductAttributes .= "|";
|
|
|
|
| 562 |
$ProductAttributes .= $optionsAsAttributes;
|
| 563 |
}
|
| 564 |
}
|
| 565 |
-
if(
|
| 566 |
-
$ProductAttributes = $this->_cleanStr(
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
"
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
|
|
|
|
|
|
|
|
|
| 574 |
$firstImageFile = FALSE;
|
| 575 |
-
|
| 576 |
-
|
|
|
|
|
|
|
| 577 |
$prodImageArray = $product->getMediaGallery('images');
|
| 578 |
-
if(
|
| 579 |
-
foreach(
|
| 580 |
-
$imageFile = trim(
|
| 581 |
-
if(
|
| 582 |
-
"
|
| 583 |
-
|
|
|
|
|
|
|
| 584 |
continue;
|
| 585 |
-
|
|
|
|
| 586 |
continue;
|
| 587 |
-
|
|
|
|
| 588 |
}
|
| 589 |
}
|
| 590 |
-
$prodImages = implode(
|
| 591 |
$ProductURL = $product->getProductUrl();
|
| 592 |
-
if(
|
| 593 |
-
$ProductURL = $this->_correctProdUrlStr(
|
|
|
|
| 594 |
$productName = $product->getName();
|
| 595 |
-
$productName = $product->getId().'#$#'
|
| 596 |
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
| 597 |
-
if(
|
| 598 |
-
$Reviews = $this->_cleanStr(
|
| 599 |
-
|
|
|
|
| 600 |
$ProdRPrice = $product->getData('price');
|
| 601 |
$ProdSPrice = $product->getSpecialPrice();
|
| 602 |
$ProdSFromDate = $product->getSpecialFromDate();
|
| 603 |
$ProdSToDate = $product->getSpecialToDate();
|
| 604 |
-
if(
|
| 605 |
-
"
|
|
|
|
|
|
|
| 606 |
$ProdGroupPrices = FALSE;
|
| 607 |
-
if(
|
| 608 |
$ProdGroupPrices = $product->getData('group_price');
|
| 609 |
-
if(
|
| 610 |
-
"
|
|
|
|
|
|
|
| 611 |
}
|
| 612 |
$ProdSpecGroupPrices = FALSE;
|
| 613 |
-
if(
|
| 614 |
$ProdSpecGroupPrices = array();
|
| 615 |
-
foreach(
|
| 616 |
-
if(
|
| 617 |
-
$notLoggedInPrice = 0.0 + $groupPrice[
|
| 618 |
-
if(
|
| 619 |
-
$ProdSPrice = $groupPrice[
|
| 620 |
$ProdSFromDate = FALSE;
|
| 621 |
$ProdSToDate = FALSE;
|
| 622 |
}
|
|
@@ -625,129 +731,142 @@ thumbnail: ".$product->getThumbnail()."
|
|
| 625 |
}
|
| 626 |
}
|
| 627 |
}
|
| 628 |
-
if(
|
| 629 |
$ProdSPrice = -1;
|
| 630 |
$ProdSFromDate = FALSE;
|
| 631 |
$ProdSToDate = FALSE;
|
| 632 |
}
|
| 633 |
} // ! $this->getpricefromchild
|
| 634 |
-
if(
|
| 635 |
-
|
| 636 |
-
foreach(
|
| 637 |
-
|
| 638 |
-
|
|
|
|
|
|
|
| 639 |
}
|
| 640 |
$usedConfigurableAttributes = FALSE;
|
| 641 |
-
if(
|
| 642 |
$usedConfigurableAttributes = array();
|
| 643 |
}
|
| 644 |
-
$ConfigurableAttributes = $product->getTypeInstance(
|
| 645 |
-
foreach(
|
| 646 |
-
if(
|
| 647 |
-
|
| 648 |
-
";
|
| 649 |
}
|
| 650 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
| 651 |
-
if(
|
| 652 |
$label = $attribute->getLabel();
|
| 653 |
-
|
| 654 |
-
";
|
| 655 |
continue;
|
| 656 |
}
|
| 657 |
-
$configurableProdAttribute->setStoreId(
|
| 658 |
-
if(
|
| 659 |
-
|
| 660 |
-
";
|
| 661 |
}
|
| 662 |
$AttributeLabel = $attribute->getLabel();
|
| 663 |
-
if(
|
| 664 |
$AttributeLabel = $configurableProdAttribute->getFrontend()->getLabel();
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
"
|
|
|
|
| 670 |
}
|
| 671 |
}
|
| 672 |
-
foreach(
|
| 673 |
-
if(
|
| 674 |
-
|
| 675 |
-
";
|
| 676 |
}
|
| 677 |
-
if(
|
| 678 |
-
$usedConfigurableAttributes[
|
| 679 |
-
if(
|
| 680 |
-
|
| 681 |
-
";
|
| 682 |
}
|
| 683 |
-
}
|
| 684 |
}
|
| 685 |
}
|
| 686 |
$UsedProducts = array();
|
| 687 |
-
foreach(
|
| 688 |
-
$UsedProduct = Mage::getModel('catalog/product')->setStoreId(
|
| 689 |
-
if(
|
| 690 |
-
$UsedProducts[
|
| 691 |
} else {
|
| 692 |
-
if(
|
| 693 |
-
"
|
| 694 |
-
|
|
|
|
|
|
|
| 695 |
}
|
| 696 |
}
|
| 697 |
$cpLines = array();
|
| 698 |
-
foreach(
|
| 699 |
$cpLine = new ConfiguredProductLine();
|
| 700 |
-
if(
|
| 701 |
-
$inventory = $this->catalogInventoryModel->loadByProduct(
|
| 702 |
$qty = $inventory->getQty();
|
| 703 |
$minQty = $inventory->getMinQty();
|
| 704 |
-
if(
|
| 705 |
-
if(
|
| 706 |
-
"
|
|
|
|
|
|
|
| 707 |
continue;
|
| 708 |
}
|
| 709 |
}
|
| 710 |
-
if(
|
| 711 |
$RPrice = $ProdRPrice;
|
| 712 |
$SPrice = $ProdSPrice;
|
| 713 |
$RPrice0 = $ProdRPrice;
|
| 714 |
$SPrice0 = $ProdSPrice;
|
| 715 |
-
$SFromDate = !empty(
|
| 716 |
-
$SToDate = !empty(
|
| 717 |
$SpecGroupPrices = FALSE;
|
| 718 |
$SpecGroupPrices0 = FALSE;
|
| 719 |
-
if(
|
| 720 |
$SpecGroupPrices = array();
|
| 721 |
$SpecGroupPrices0 = array();
|
| 722 |
-
foreach(
|
| 723 |
-
$SpecGroupPrices[
|
| 724 |
-
$SpecGroupPrices0[
|
| 725 |
}
|
| 726 |
}
|
| 727 |
} else { // $this->getpricefromchild
|
| 728 |
-
if(
|
| 729 |
-
"
|
|
|
|
|
|
|
| 730 |
$RPrice = $UsedProduct->getData('price');
|
| 731 |
$SPrice = $UsedProduct->getSpecialPrice();
|
| 732 |
$SFromDate = $UsedProduct->getSpecialFromDate();
|
| 733 |
$SToDate = $UsedProduct->getSpecialToDate();
|
| 734 |
-
if(
|
| 735 |
-
"
|
|
|
|
|
|
|
| 736 |
$ProdGroupPrices = FALSE;
|
| 737 |
-
if(
|
| 738 |
$ProdGroupPrices = $UsedProduct->getData('group_price');
|
| 739 |
-
if(
|
| 740 |
-
"
|
|
|
|
|
|
|
| 741 |
}
|
| 742 |
$SpecGroupPrices = FALSE;
|
| 743 |
$SpecGroupPrices0 = FALSE;
|
| 744 |
-
if(
|
| 745 |
$SpecGroupPrices = array();
|
| 746 |
-
foreach(
|
| 747 |
-
if(
|
| 748 |
-
$notLoggedInPrice = 0.0 + $groupPrice[
|
| 749 |
-
if(
|
| 750 |
-
$SPrice = $groupPrice[
|
| 751 |
$SFromDate = FALSE;
|
| 752 |
$SToDate = FALSE;
|
| 753 |
}
|
|
@@ -756,172 +875,198 @@ thumbnail: ".$product->getThumbnail()."
|
|
| 756 |
}
|
| 757 |
}
|
| 758 |
}
|
| 759 |
-
if(
|
| 760 |
$SPrice = -1;
|
| 761 |
$SFromDate = FALSE;
|
| 762 |
$SToDate = FALSE;
|
| 763 |
}
|
| 764 |
}
|
| 765 |
$ItemAttributes = "";
|
| 766 |
-
foreach(
|
| 767 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
| 768 |
-
if(
|
| 769 |
$label = $attribute->getLabel();
|
| 770 |
-
|
| 771 |
-
";
|
| 772 |
$cpLine->optionIds[] = 0;
|
| 773 |
continue;
|
| 774 |
}
|
| 775 |
$AttributeCode = $configurableProdAttribute->getAttributeCode();
|
| 776 |
$AttributeLabel = $attribute->getLabel();
|
| 777 |
-
if(
|
| 778 |
$AttributeLabel = $configurableProdAttribute->getFrontend()->getLabel();
|
|
|
|
| 779 |
$AttribId = $UsedProduct->getData($AttributeCode);
|
| 780 |
-
$cpLine->optionIds[] = intVal(
|
| 781 |
$AttributeValue = "";
|
| 782 |
-
foreach(
|
| 783 |
-
if(
|
| 784 |
$AttributeValue = $option['label'];
|
| 785 |
break;
|
| 786 |
}
|
| 787 |
}
|
| 788 |
-
if(
|
| 789 |
-
$usedConfigurableAttributes[
|
| 790 |
-
}
|
| 791 |
-
if(
|
| 792 |
-
"
|
| 793 |
-
|
|
|
|
|
|
|
| 794 |
$ItemAttributes .= "|";
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
|
|
|
|
|
|
| 806 |
}
|
| 807 |
-
}
|
| 808 |
} else {
|
| 809 |
$RPrice += $addedPrice['pricing_value'];
|
| 810 |
-
if(
|
| 811 |
$SPrice += $addedPrice['pricing_value'];
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
|
|
|
|
|
|
| 816 |
}
|
| 817 |
}
|
| 818 |
}
|
| 819 |
} // ! $this->getpricefromchild
|
| 820 |
}
|
| 821 |
-
if(
|
| 822 |
-
$RPrice = $this->taxhelper->getPrice(
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
|
|
|
|
|
|
| 827 |
$ItemAttributes .= "|";
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
|
|
|
|
|
|
|
|
|
| 837 |
$ItemAttributes .= "|";
|
| 838 |
-
|
|
|
|
| 839 |
}
|
| 840 |
}
|
| 841 |
-
if(
|
| 842 |
-
if(
|
| 843 |
-
if(
|
| 844 |
$ItemAttributes .= "|";
|
| 845 |
-
|
|
|
|
| 846 |
}
|
| 847 |
}
|
| 848 |
-
if(
|
| 849 |
-
if(
|
| 850 |
-
if(
|
| 851 |
$ItemAttributes .= "|";
|
| 852 |
-
|
|
|
|
| 853 |
}
|
| 854 |
}
|
| 855 |
-
if(
|
| 856 |
-
foreach(
|
| 857 |
-
if(
|
| 858 |
-
$price = $this->taxhelper->getPrice(
|
| 859 |
-
|
|
|
|
| 860 |
$ItemAttributes .= "|";
|
| 861 |
-
|
|
|
|
| 862 |
}
|
| 863 |
}
|
| 864 |
-
if(
|
| 865 |
-
if(
|
| 866 |
$TierPriceAttributes = $this->_getTierPrices($UsedProduct);
|
| 867 |
-
$sp = ( empty(
|
| 868 |
-
$ItemAttributes.= $sp
|
| 869 |
}
|
| 870 |
} // ! $this->getpricefromchild
|
| 871 |
-
if(
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
"
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
|
|
|
|
|
|
|
|
|
| 880 |
$firstImageFile = FALSE;
|
| 881 |
-
|
| 882 |
-
|
|
|
|
|
|
|
| 883 |
$itemImageArray = $UsedProduct->getMediaGallery('images');
|
| 884 |
-
if(
|
| 885 |
-
foreach(
|
| 886 |
-
$imageFile = trim(
|
| 887 |
-
if(
|
| 888 |
-
"
|
| 889 |
-
|
|
|
|
|
|
|
| 890 |
continue;
|
| 891 |
-
|
|
|
|
| 892 |
continue;
|
| 893 |
-
|
|
|
|
| 894 |
}
|
| 895 |
}
|
| 896 |
-
$itemImages = implode(
|
| 897 |
}
|
| 898 |
$itemID = $UsedProduct->getSku();
|
| 899 |
-
$cpLine->line = $this->_cleanStr(
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
$cpLines[] = $cpLine;
|
| 908 |
-
unset(
|
| 909 |
}
|
| 910 |
-
unset(
|
| 911 |
-
unset(
|
| 912 |
$optionIds = array();
|
| 913 |
$attrNumber = 0;
|
| 914 |
$optNumbers = array();
|
| 915 |
$optCounters = array();
|
| 916 |
-
foreach(
|
| 917 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
| 918 |
-
if(
|
| 919 |
continue;
|
| 920 |
}
|
| 921 |
$optionIdList = array();
|
| 922 |
$optionNo = 0;
|
| 923 |
-
foreach(
|
| 924 |
-
$optionIdList[] = trim(
|
| 925 |
$optionNo++;
|
| 926 |
}
|
| 927 |
$optionIds[] = $optionIdList;
|
|
@@ -929,318 +1074,370 @@ thumbnail: ".$UsedProduct->getThumbnail()."
|
|
| 929 |
$optNumbers[] = 0;
|
| 930 |
$attrNumber++;
|
| 931 |
}
|
| 932 |
-
// if( $this->_DEBUG ) foreach( $optionIds as $key => $optionIdList ) echo "optionIds[".$key."]: ".var_export( $optionIdList, true )."
|
| 933 |
-
//";
|
| 934 |
// supplement prod attrs
|
| 935 |
-
if(
|
| 936 |
-
foreach(
|
| 937 |
-
if(
|
| 938 |
$ProductAttributes .= "|";
|
| 939 |
-
|
|
|
|
| 940 |
$valCount = 0;
|
| 941 |
-
foreach(
|
| 942 |
-
if(
|
| 943 |
-
if(
|
| 944 |
$ProductAttributes .= "<br />";
|
|
|
|
| 945 |
$ProductAttributes .= $attrValue;
|
| 946 |
$valCount++;
|
| 947 |
}
|
| 948 |
}
|
| 949 |
}
|
| 950 |
-
}
|
| 951 |
// build prod part
|
| 952 |
-
$this->prodLine = "\t"
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
// build cplines matrix
|
| 963 |
$cpLinesMatrix = array();
|
| 964 |
-
foreach(
|
| 965 |
-
$optionId = $cpLine->optionIds[
|
| 966 |
-
if(
|
| 967 |
-
if(
|
| 968 |
-
$cpLinesMatrix[
|
| 969 |
-
|
|
|
|
| 970 |
} else {
|
| 971 |
-
if(
|
| 972 |
-
$cpLinesMatrix[
|
|
|
|
| 973 |
}
|
| 974 |
}
|
| 975 |
$this->configItemSequence = 1;
|
| 976 |
$this->configProducttoString = "";
|
| 977 |
-
$this->_fillConfigProdItems(
|
| 978 |
-
unset(
|
| 979 |
-
foreach(
|
| 980 |
-
if(
|
| 981 |
-
"
|
|
|
|
|
|
|
| 982 |
}
|
| 983 |
-
unset(
|
| 984 |
return $this->configProducttoString;
|
| 985 |
}
|
| 986 |
-
|
| 987 |
-
private function ProducttoStringSimple(
|
| 988 |
$ProductDescription = "";
|
| 989 |
$shortDescription = "";
|
| 990 |
-
if(
|
| 991 |
$shortDescription = $product->getShortDescription();
|
| 992 |
-
if(
|
| 993 |
-
$shortDescription = $this->_cleanStr(
|
| 994 |
-
if(
|
| 995 |
-
$new = strlen(
|
| 996 |
-
$pos = strrpos(
|
| 997 |
-
if(
|
| 998 |
-
$shortDescription = substr(
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
|
|
|
|
|
|
|
| 1005 |
$longDescription = $product->getDescription();
|
| 1006 |
-
if(
|
| 1007 |
-
$longDescription = $this->_cleanStr(
|
| 1008 |
-
if(
|
| 1009 |
-
$new = strlen(
|
| 1010 |
-
$pos = strrpos(
|
| 1011 |
-
if(
|
| 1012 |
-
$longDescription = substr(
|
| 1013 |
-
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
| 1017 |
-
|
| 1018 |
-
|
| 1019 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
"
|
| 1023 |
-
|
| 1024 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1025 |
$firstImageFile = FALSE;
|
| 1026 |
-
|
| 1027 |
-
|
|
|
|
|
|
|
| 1028 |
$prodImageArray = $product->getMediaGallery('images');
|
| 1029 |
-
if(
|
| 1030 |
-
foreach(
|
| 1031 |
-
$imageFile = trim(
|
| 1032 |
-
if(
|
| 1033 |
-
"
|
| 1034 |
-
|
|
|
|
|
|
|
| 1035 |
continue;
|
| 1036 |
-
|
|
|
|
| 1037 |
continue;
|
| 1038 |
-
|
|
|
|
| 1039 |
}
|
| 1040 |
}
|
| 1041 |
-
$prodImages = implode(
|
| 1042 |
$URL = $product->getProductUrl();
|
| 1043 |
-
if(
|
| 1044 |
-
"
|
| 1045 |
-
|
| 1046 |
-
|
|
|
|
|
|
|
|
|
|
| 1047 |
$attributes = $product->getAttributes();
|
| 1048 |
$Manufacturer = "";
|
| 1049 |
$ProductAttributes = "";
|
| 1050 |
-
foreach(
|
| 1051 |
-
$attribute->setStoreId(
|
| 1052 |
-
if(
|
| 1053 |
$hasData = $product->getData($attribute->getAttributeCode()) ? "YES" : "NO";
|
| 1054 |
$vof = $attribute->getIsVisibleOnFront() ? "YES" : "NO";
|
| 1055 |
-
|
| 1056 |
-
";
|
| 1057 |
}
|
| 1058 |
-
if(
|
| 1059 |
-
if(
|
| 1060 |
-
$Manufacturer = $attribute->getFrontend()->getValue(
|
| 1061 |
-
else
|
| 1062 |
$Manufacturer = "";
|
|
|
|
| 1063 |
continue;
|
| 1064 |
}
|
| 1065 |
-
if(
|
| 1066 |
-
|
| 1067 |
-
$value = $attribute->getFrontend()->getValue(
|
| 1068 |
-
if(
|
| 1069 |
-
$hasData = $product->getData(
|
| 1070 |
-
if(
|
| 1071 |
$value = "";
|
|
|
|
| 1072 |
}
|
| 1073 |
-
if(
|
| 1074 |
-
if(
|
| 1075 |
$ProductAttributes .= "|";
|
|
|
|
| 1076 |
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
|
| 1077 |
} else {
|
| 1078 |
-
if(
|
| 1079 |
-
"
|
|
|
|
|
|
|
| 1080 |
}
|
| 1081 |
}
|
| 1082 |
}
|
| 1083 |
-
if(
|
| 1084 |
-
$TierPriceAttributes = $this->_getTierPrices(
|
| 1085 |
-
$sp = ( empty(
|
| 1086 |
-
$ProductAttributes.= $sp
|
| 1087 |
}
|
| 1088 |
-
if(
|
| 1089 |
-
$optionsAsAttributes = $this->_getCustomOptionsAsAttributes(
|
| 1090 |
-
if(
|
| 1091 |
-
if(
|
| 1092 |
$ProductAttributes .= "|";
|
|
|
|
| 1093 |
$ProductAttributes .= $optionsAsAttributes;
|
| 1094 |
}
|
| 1095 |
}
|
| 1096 |
-
if(
|
| 1097 |
-
$ProductAttributes = $this->_cleanStr(
|
|
|
|
| 1098 |
$ProdRPrice = $product->getData('price');
|
| 1099 |
$ProdSPrice = $product->getSpecialPrice();
|
| 1100 |
$ProdSFromDate = $product->getSpecialFromDate();
|
| 1101 |
$ProdSToDate = $product->getSpecialToDate();
|
| 1102 |
-
if(
|
| 1103 |
-
$inventory = $this->catalogInventoryModel->loadByProduct(
|
| 1104 |
$qty = $inventory->getQty();
|
| 1105 |
$minQty = $inventory->getMinQty();
|
| 1106 |
-
if(
|
| 1107 |
-
"
|
| 1108 |
-
|
|
|
|
|
|
|
| 1109 |
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1110 |
}
|
| 1111 |
-
if( $this->_DEBUG ) echo "sku=".$product->getSku()." prices: Regular=".$ProdRPrice." Special=".$ProdSPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
|
| 1112 |
-
";
|
| 1113 |
$ProdGroupPrices = FALSE;
|
| 1114 |
-
if(
|
| 1115 |
$ProdGroupPrices = $product->getData('group_price');
|
| 1116 |
-
if(
|
| 1117 |
-
"
|
|
|
|
|
|
|
| 1118 |
}
|
| 1119 |
$ProdSpecGroupPrices = FALSE;
|
| 1120 |
-
if(
|
| 1121 |
$ProdSpecGroupPrices = array();
|
| 1122 |
-
foreach(
|
| 1123 |
-
if(
|
| 1124 |
-
$notLoggedInPrice = 0.0 + $groupPrice[
|
| 1125 |
-
if(
|
| 1126 |
-
$ProdSPrice = $groupPrice[
|
| 1127 |
$ProdSFromDate = FALSE;
|
| 1128 |
$ProdSToDate = FALSE;
|
| 1129 |
}
|
| 1130 |
-
} else
|
| 1131 |
$ProdSpecGroupPrices[] = $groupPrice;
|
|
|
|
| 1132 |
}
|
| 1133 |
}
|
| 1134 |
-
if(
|
| 1135 |
$ProdSPrice = -1;
|
| 1136 |
$ProdSFromDate = FALSE;
|
| 1137 |
$ProdSToDate = FALSE;
|
| 1138 |
}
|
| 1139 |
-
if(
|
| 1140 |
$priceModel = $product->getPriceModel();
|
| 1141 |
-
$options = Mage::getSingleton('core/layout')->createBlock('bundle/catalog_product_view_type_bundle')->setProduct(
|
| 1142 |
$ProdRPrice = 0;
|
| 1143 |
-
foreach(
|
| 1144 |
$selection = $option->getDefaultSelection();
|
| 1145 |
$MinSelPrice = 0;
|
| 1146 |
-
if(
|
| 1147 |
-
$MinSelPrice = $priceModel->getSelectionPreFinalPrice(
|
| 1148 |
-
else if(
|
| 1149 |
-
foreach(
|
| 1150 |
-
$SelPrice = $priceModel->getSelectionPreFinalPrice(
|
| 1151 |
-
if
|
| 1152 |
$MinSelPrice = $SelPrice;
|
|
|
|
| 1153 |
}
|
| 1154 |
}
|
| 1155 |
-
if(
|
| 1156 |
continue;
|
| 1157 |
-
|
| 1158 |
-
|
|
|
|
|
|
|
|
|
|
| 1159 |
$ProdRPrice += $MinSelPrice;
|
| 1160 |
}
|
| 1161 |
-
if(
|
| 1162 |
-
"
|
|
|
|
|
|
|
| 1163 |
}
|
| 1164 |
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
| 1165 |
-
if(
|
| 1166 |
-
$Reviews = $this->_cleanStr(
|
|
|
|
| 1167 |
$prodSku = $product->getSku();
|
| 1168 |
-
$prodSku = $this->_cleanStr(
|
| 1169 |
-
$cleanProdName = $this->_cleanStr(
|
| 1170 |
$prodName = $product->getName();
|
| 1171 |
-
$cleanProdName = $this->_cleanStr(
|
| 1172 |
-
$prodName = $product->getId().'#$#'
|
| 1173 |
$skusAdded = false;
|
| 1174 |
-
if(
|
| 1175 |
$this->configItemSequence = 1;
|
| 1176 |
$this->configProducttoString = "";
|
| 1177 |
$customOptions = $product->getOptions();
|
| 1178 |
-
if(
|
| 1179 |
-
if(
|
| 1180 |
-
|
| 1181 |
-
"
|
|
|
|
|
|
|
| 1182 |
$max_sort_order = 0;
|
| 1183 |
-
foreach(
|
| 1184 |
-
if(
|
| 1185 |
$max_sort_order = $option->getSortOrder();
|
| 1186 |
-
} else if(
|
| 1187 |
-
$option->setSortOrder(
|
| 1188 |
}
|
| 1189 |
}
|
| 1190 |
$orderedOptionValues = array();
|
| 1191 |
$orderedCustomOptions = array();
|
| 1192 |
-
for(
|
| 1193 |
foreach ($customOptions as $option) {
|
| 1194 |
-
if(
|
|
|
|
|
|
|
| 1195 |
$orderedCustomOptions[] = $option;
|
| 1196 |
$optionValues = array();
|
| 1197 |
-
if(
|
| 1198 |
$max_v_sort_order = 0;
|
| 1199 |
-
foreach(
|
| 1200 |
-
if(
|
| 1201 |
$max_v_sort_order = $_value->getSortOrder();
|
| 1202 |
-
} else if(
|
| 1203 |
-
$_value->setSortOrder(
|
| 1204 |
}
|
| 1205 |
}
|
| 1206 |
-
for(
|
| 1207 |
-
foreach(
|
| 1208 |
-
if(
|
| 1209 |
-
|
|
|
|
|
|
|
| 1210 |
}
|
| 1211 |
}
|
| 1212 |
}
|
| 1213 |
-
$orderedOptionValues[
|
| 1214 |
}
|
| 1215 |
}
|
| 1216 |
$customOptions = array();
|
| 1217 |
$customOptionsById = array();
|
| 1218 |
-
foreach(
|
| 1219 |
-
if(
|
| 1220 |
-
|
| 1221 |
-
";
|
| 1222 |
-
if(
|
| 1223 |
-
|
| 1224 |
-
|
| 1225 |
-
|
| 1226 |
-
|
| 1227 |
-
|
| 1228 |
-
";
|
|
|
|
| 1229 |
}
|
| 1230 |
$customOption = new COption();
|
| 1231 |
$customOption->id = $option->getOptionId();
|
| 1232 |
$customOption->title = $option->getStoreTitle();
|
| 1233 |
-
if(
|
| 1234 |
$customOption->title = $option->getTitle();
|
| 1235 |
-
|
| 1236 |
-
|
|
|
|
|
|
|
| 1237 |
$customOption->type = $option->getType();
|
| 1238 |
$customOption->required = $option->getIsRequire();
|
| 1239 |
-
if(
|
| 1240 |
-
"
|
| 1241 |
-
|
|
|
|
|
|
|
| 1242 |
$isMultiple = ( $option->getType() == "multiple" || $option->getType() == "checkbox" );
|
| 1243 |
-
if(
|
| 1244 |
$coValue = new COValue();
|
| 1245 |
$coValue->title = FALSE;
|
| 1246 |
$coValue->sku = FALSE;
|
|
@@ -1248,202 +1445,240 @@ ProdRPrice=".$ProdRPrice." ProdSPrice=".$ProdSPrice."
|
|
| 1248 |
$coValue->pvalue = 0;
|
| 1249 |
$coValue->rprice = 0;
|
| 1250 |
$coValue->sprice = 0;
|
| 1251 |
-
if(
|
| 1252 |
-
"
|
|
|
|
|
|
|
| 1253 |
$customOption->values[] = $coValue;
|
| 1254 |
}
|
| 1255 |
-
if(
|
| 1256 |
-
|
| 1257 |
-
|
| 1258 |
-
|
| 1259 |
-
|
| 1260 |
-
if(
|
| 1261 |
$coValue = new COValue();
|
| 1262 |
$coValue->title = "Provided";
|
| 1263 |
$coValue->sku = $option->getSku();
|
| 1264 |
$coValue->ifpercent = FALSE;
|
| 1265 |
$coValue->pvalue = $option->getPrice();
|
| 1266 |
-
if(
|
| 1267 |
$coValue->ifpercent = TRUE;
|
| 1268 |
-
$coValue->rprice = round(
|
| 1269 |
-
$coValue->sprice = $ProdSPrice > -1 ? round(
|
| 1270 |
} else {
|
| 1271 |
$coValue->rprice = $option->getPrice();
|
| 1272 |
$coValue->sprice = $ProdSPrice > -1 ? $option->getPrice() : -1;
|
| 1273 |
}
|
| 1274 |
-
if(
|
| 1275 |
-
"
|
|
|
|
|
|
|
| 1276 |
$customOption->values[] = $coValue;
|
| 1277 |
}
|
| 1278 |
} else {
|
| 1279 |
-
foreach(
|
| 1280 |
-
if(
|
| 1281 |
-
"
|
| 1282 |
-
|
|
|
|
|
|
|
| 1283 |
$coValue = new COValue();
|
| 1284 |
$coValue->title = $optionValue->getStoreTitle();
|
| 1285 |
-
if(
|
| 1286 |
$coValue->title = $optionValue->getTitle();
|
| 1287 |
-
|
|
|
|
| 1288 |
$coValue->title = "Option value";
|
|
|
|
| 1289 |
$coValue->sku = $optionValue->getSku();
|
| 1290 |
$coValue->ifpercent = FALSE;
|
| 1291 |
$coValue->pvalue = $optionValue->getPrice();
|
| 1292 |
-
if(
|
| 1293 |
$coValue->ifpercent = TRUE;
|
| 1294 |
-
$coValue->rprice = round(
|
| 1295 |
-
$coValue->sprice = $ProdSPrice > -1 ? round(
|
| 1296 |
} else {
|
| 1297 |
$coValue->rprice = $optionValue->getPrice();
|
| 1298 |
$coValue->sprice = $ProdSPrice > -1 ? $optionValue->getPrice() : -1;
|
| 1299 |
}
|
| 1300 |
-
if(
|
| 1301 |
-
"
|
|
|
|
|
|
|
| 1302 |
$customOption->values[] = $coValue;
|
| 1303 |
}
|
| 1304 |
}
|
| 1305 |
}
|
| 1306 |
-
if(
|
| 1307 |
-
$customOption->values = array_reverse(
|
| 1308 |
-
|
| 1309 |
-
|
| 1310 |
-
|
|
|
|
|
|
|
| 1311 |
$customOptions[] = $customOption;
|
|
|
|
| 1312 |
} else {
|
| 1313 |
$customOptions[] = $customOption;
|
| 1314 |
}
|
| 1315 |
-
$customOptionsById[
|
| 1316 |
}
|
| 1317 |
-
if(
|
| 1318 |
-
|
| 1319 |
-
";
|
| 1320 |
-
foreach(
|
| 1321 |
-
|
| 1322 |
-
";
|
| 1323 |
-
foreach(
|
| 1324 |
-
"
|
|
|
|
|
|
|
| 1325 |
}
|
| 1326 |
}
|
| 1327 |
-
if(
|
| 1328 |
$coValueSetSequences = array();
|
| 1329 |
$coValueSetSequence = array();
|
| 1330 |
-
$this->_buildCOValueSets(
|
| 1331 |
$index = 1;
|
| 1332 |
-
foreach(
|
| 1333 |
-
if(
|
| 1334 |
-
|
| 1335 |
-
";
|
| 1336 |
-
foreach(
|
| 1337 |
-
"
|
|
|
|
|
|
|
| 1338 |
}
|
| 1339 |
$ItemNumber = $prodSku;
|
| 1340 |
$RPrice = $ProdRPrice;
|
| 1341 |
$SPrice = $ProdSPrice;
|
| 1342 |
$ItemAttributes = "";
|
| 1343 |
-
if(
|
| 1344 |
-
if(
|
| 1345 |
$ItemAttributes .= "|";
|
| 1346 |
-
|
|
|
|
| 1347 |
}
|
| 1348 |
-
foreach(
|
| 1349 |
-
$cOption = $customOptionsById[
|
| 1350 |
-
if(
|
| 1351 |
$ItemAttributes .= "|";
|
| 1352 |
-
|
|
|
|
| 1353 |
$vcount = 0;
|
| 1354 |
-
foreach(
|
| 1355 |
-
if(
|
| 1356 |
-
if(
|
|
|
|
|
|
|
| 1357 |
$ItemNumber .= $value->sku;
|
| 1358 |
$RPrice += $value->rprice;
|
| 1359 |
-
if(
|
| 1360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1361 |
$ItemAttributes .= $value->title;
|
| 1362 |
$vcount++;
|
| 1363 |
}
|
| 1364 |
}
|
| 1365 |
}
|
| 1366 |
-
if(
|
| 1367 |
-
if(
|
| 1368 |
-
"
|
|
|
|
|
|
|
| 1369 |
continue;
|
| 1370 |
}
|
| 1371 |
-
if(
|
| 1372 |
-
$RPrice = $this->taxhelper->getPrice(
|
| 1373 |
-
|
| 1374 |
-
|
| 1375 |
-
|
| 1376 |
-
|
| 1377 |
-
|
| 1378 |
-
|
| 1379 |
-
|
| 1380 |
-
|
| 1381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1382 |
$ItemAttributes .= "|";
|
| 1383 |
-
|
|
|
|
| 1384 |
}
|
| 1385 |
}
|
| 1386 |
-
if(
|
| 1387 |
-
if(
|
| 1388 |
-
if(
|
| 1389 |
$ItemAttributes .= "|";
|
| 1390 |
-
|
|
|
|
| 1391 |
}
|
| 1392 |
}
|
| 1393 |
-
if(
|
| 1394 |
-
if(
|
| 1395 |
-
if(
|
| 1396 |
$ItemAttributes .= "|";
|
| 1397 |
-
|
|
|
|
| 1398 |
}
|
| 1399 |
}
|
| 1400 |
-
if(
|
| 1401 |
-
foreach(
|
| 1402 |
-
$price = 0.0 + $groupPrice[
|
| 1403 |
$price0 = $price;
|
| 1404 |
-
foreach(
|
| 1405 |
-
foreach(
|
| 1406 |
-
if(
|
| 1407 |
-
if(
|
| 1408 |
-
$price = $price + round(
|
| 1409 |
} else {
|
| 1410 |
$price = $price + $value->pvalue;
|
| 1411 |
}
|
| 1412 |
}
|
| 1413 |
}
|
| 1414 |
}
|
| 1415 |
-
if(
|
| 1416 |
-
$price = $this->taxhelper->getPrice(
|
| 1417 |
-
|
|
|
|
| 1418 |
$ItemAttributes .= "|";
|
| 1419 |
-
|
|
|
|
| 1420 |
}
|
| 1421 |
}
|
| 1422 |
-
if(
|
| 1423 |
-
"
|
|
|
|
|
|
|
| 1424 |
$ProducttoString .= $ItemNumber //ItemID
|
| 1425 |
-
|
| 1426 |
-
|
| 1427 |
-
|
| 1428 |
-
|
| 1429 |
-
|
| 1430 |
-
|
| 1431 |
-
|
| 1432 |
-
|
| 1433 |
-
|
| 1434 |
-
|
| 1435 |
-
|
| 1436 |
-
|
| 1437 |
-
|
| 1438 |
-
|
| 1439 |
-
|
| 1440 |
-
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
$skusAdded = TRUE;
|
| 1444 |
// https://objectpublisher.basecamphq.com/projects/257020-odp/posts/87233819/comments#comment_312388129
|
| 1445 |
-
if(
|
| 1446 |
-
$ProducttoString .= "REPORTWARNING: Not all options were converted to items for the product #"
|
| 1447 |
";
|
| 1448 |
break;
|
| 1449 |
}
|
|
@@ -1452,70 +1687,80 @@ ProdRPrice=".$ProdRPrice." ProdSPrice=".$ProdSPrice."
|
|
| 1452 |
}
|
| 1453 |
}
|
| 1454 |
}
|
| 1455 |
-
if(
|
| 1456 |
$RPrice = $ProdRPrice;
|
| 1457 |
-
if(
|
| 1458 |
-
$RPrice = $this->taxhelper->getPrice(
|
|
|
|
| 1459 |
$SPrice = $ProdSPrice;
|
| 1460 |
-
if(
|
| 1461 |
-
$SPrice = $this->taxhelper->getPrice(
|
| 1462 |
-
|
| 1463 |
-
|
|
|
|
|
|
|
|
|
|
| 1464 |
$ItemAttributes = "";
|
| 1465 |
-
if(
|
| 1466 |
-
$ItemAttributes = "Inventory="
|
| 1467 |
-
|
| 1468 |
-
|
| 1469 |
-
|
| 1470 |
-
|
| 1471 |
-
|
|
|
|
| 1472 |
$ItemAttributes .= "|";
|
| 1473 |
-
|
|
|
|
| 1474 |
}
|
| 1475 |
}
|
| 1476 |
-
if(
|
| 1477 |
-
if(
|
| 1478 |
-
if(
|
| 1479 |
$ItemAttributes .= "|";
|
| 1480 |
-
|
|
|
|
| 1481 |
}
|
| 1482 |
}
|
| 1483 |
-
if(
|
| 1484 |
-
if(
|
| 1485 |
-
if(
|
| 1486 |
$ItemAttributes .= "|";
|
| 1487 |
-
|
|
|
|
| 1488 |
}
|
| 1489 |
}
|
| 1490 |
-
if(
|
| 1491 |
-
foreach(
|
| 1492 |
-
$price = 0.0 + $groupPrice[
|
| 1493 |
-
if(
|
| 1494 |
-
$price = $this->taxhelper->getPrice(
|
| 1495 |
-
|
|
|
|
| 1496 |
$ItemAttributes .= "|";
|
| 1497 |
-
|
|
|
|
| 1498 |
}
|
| 1499 |
}
|
| 1500 |
$ProducttoString = $prodSku //ItemID
|
| 1501 |
-
|
| 1502 |
-
|
| 1503 |
-
|
| 1504 |
-
|
| 1505 |
-
|
| 1506 |
-
|
| 1507 |
-
|
| 1508 |
-
|
| 1509 |
-
|
| 1510 |
-
|
| 1511 |
-
|
| 1512 |
-
|
| 1513 |
-
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
| 1517 |
-
|
| 1518 |
-
|
| 1519 |
}
|
| 1520 |
return $ProducttoString;
|
| 1521 |
}
|
|
@@ -1524,33 +1769,35 @@ ProdRPrice=".$ProdRPrice." ProdSPrice=".$ProdSPrice."
|
|
| 1524 |
private $configItemSequence = 0;
|
| 1525 |
private $configProducttoString = "";
|
| 1526 |
|
| 1527 |
-
private function _fillCPLinesMatrix(
|
| 1528 |
-
$optionId = $cpLine->optionIds[
|
| 1529 |
-
if(
|
| 1530 |
-
if(
|
| 1531 |
-
$cpLinesMatrix[
|
| 1532 |
-
|
|
|
|
| 1533 |
} else {
|
| 1534 |
-
if(
|
| 1535 |
-
$cpLinesMatrix[
|
|
|
|
| 1536 |
}
|
| 1537 |
}
|
| 1538 |
|
| 1539 |
-
private function _fillConfigProdItems(
|
| 1540 |
$optNumber = 0;
|
| 1541 |
-
$optionIdNo = $optCounters[
|
| 1542 |
-
while(
|
| 1543 |
-
$optionID = $optionIds[
|
| 1544 |
-
if(
|
| 1545 |
-
if(
|
| 1546 |
-
$optNumbers[
|
| 1547 |
-
$this->_fillConfigProdItems(
|
| 1548 |
} else {
|
| 1549 |
-
$cpLine = $cpLinesMatrix[
|
| 1550 |
$this->configProducttoString .= $cpLine->line
|
| 1551 |
-
|
| 1552 |
-
|
| 1553 |
-
."\n";
|
| 1554 |
$cpLine->line = FALSE;
|
| 1555 |
$this->configItemSequence++;
|
| 1556 |
}
|
|
@@ -1558,107 +1805,124 @@ ProdRPrice=".$ProdRPrice." ProdSPrice=".$ProdSPrice."
|
|
| 1558 |
$optNumber++;
|
| 1559 |
}
|
| 1560 |
}
|
| 1561 |
-
|
| 1562 |
-
private function _getCustomOptionsAsAttributes(
|
| 1563 |
$attributes = "";
|
| 1564 |
$customOptions = $product->getOptions();
|
| 1565 |
-
if(
|
| 1566 |
//We should support all 4 selects: dropdown, radio buttons, checkbox, and multiple select.
|
| 1567 |
//\app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php
|
| 1568 |
-
if(
|
| 1569 |
-
"
|
|
|
|
|
|
|
| 1570 |
$max_sort_order = 0;
|
| 1571 |
-
foreach(
|
| 1572 |
-
if(
|
| 1573 |
$max_sort_order = $option->getSortOrder();
|
| 1574 |
-
} else if(
|
| 1575 |
-
$option->setSortOrder(
|
| 1576 |
}
|
| 1577 |
}
|
| 1578 |
-
if(
|
| 1579 |
-
for(
|
| 1580 |
foreach ($customOptions as $option) {
|
| 1581 |
-
if(
|
| 1582 |
-
|
| 1583 |
-
|
| 1584 |
-
|
|
|
|
|
|
|
| 1585 |
$max_v_sort_order = 0;
|
| 1586 |
foreach ($option->getValues() as $_value) {
|
| 1587 |
-
if(
|
| 1588 |
$max_v_sort_order = $_value->getSortOrder();
|
| 1589 |
-
} else if(
|
| 1590 |
-
$_value->setSortOrder(
|
| 1591 |
}
|
| 1592 |
}
|
| 1593 |
-
for(
|
| 1594 |
-
if(
|
|
|
|
|
|
|
| 1595 |
foreach ($option->getValues() as $_value) {
|
| 1596 |
-
|
| 1597 |
-
";
|
| 1598 |
}
|
| 1599 |
}
|
| 1600 |
}
|
| 1601 |
}
|
| 1602 |
}
|
| 1603 |
}
|
| 1604 |
-
for(
|
| 1605 |
foreach ($customOptions as $option) {
|
| 1606 |
-
if(
|
| 1607 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1608 |
$optionTitle = $option->getStoreTitle();
|
| 1609 |
-
if(
|
| 1610 |
$optionTitle = $option->getTitle();
|
|
|
|
| 1611 |
$optionValues = "";
|
| 1612 |
-
if(
|
| 1613 |
$max_v_sort_order = 0;
|
| 1614 |
-
foreach(
|
| 1615 |
-
if(
|
| 1616 |
$max_v_sort_order = $_value->getSortOrder();
|
| 1617 |
-
} else if(
|
| 1618 |
-
$_value->setSortOrder(
|
| 1619 |
}
|
| 1620 |
}
|
| 1621 |
-
for(
|
| 1622 |
-
foreach(
|
| 1623 |
-
if(
|
| 1624 |
-
|
|
|
|
|
|
|
| 1625 |
$optionValues .= "<br/>";
|
|
|
|
| 1626 |
$valueTitle = $_value->getStoreTitle();
|
| 1627 |
-
if(
|
| 1628 |
$valueTitle = $_value->getTitle();
|
|
|
|
| 1629 |
$optionValues .= $valueTitle;
|
| 1630 |
}
|
| 1631 |
}
|
| 1632 |
}
|
| 1633 |
-
if(
|
| 1634 |
$attributes .= "|";
|
|
|
|
| 1635 |
$attributes .= $optionTitle . "=" . $optionValues;
|
| 1636 |
}
|
| 1637 |
}
|
| 1638 |
}
|
| 1639 |
return $attributes;
|
| 1640 |
}
|
| 1641 |
-
|
| 1642 |
-
private function _buildCOValueSets(
|
| 1643 |
-
$cOption = $customOptions[
|
| 1644 |
-
$customOptionCount = count(
|
| 1645 |
$coValueSetList = array();
|
| 1646 |
-
if(
|
| 1647 |
// all combinations + empty if not required
|
| 1648 |
-
$valuesCount = count(
|
| 1649 |
$indexList = array();
|
| 1650 |
$indices = array();
|
| 1651 |
-
$this->_buildCOValueIndices(
|
| 1652 |
-
foreach(
|
| 1653 |
$coValueSet = new COValueSet();
|
| 1654 |
$coValueSet->optionId = $cOption->id;
|
| 1655 |
$valueIndexNo = 0;
|
| 1656 |
-
foreach(
|
| 1657 |
-
if(
|
| 1658 |
-
$coValueSet->coValues[] = $cOption->values[
|
|
|
|
| 1659 |
$valueIndexNo++;
|
| 1660 |
}
|
| 1661 |
-
if(
|
| 1662 |
$coValue = new COValue();
|
| 1663 |
$coValue->title = FALSE;
|
| 1664 |
$coValue->sku = FALSE;
|
|
@@ -1666,539 +1930,689 @@ ProdRPrice=".$ProdRPrice." ProdSPrice=".$ProdSPrice."
|
|
| 1666 |
$coValue->sprice = 0;
|
| 1667 |
$coValueSet->coValues[] = $coValue;
|
| 1668 |
}
|
| 1669 |
-
if(
|
| 1670 |
continue;
|
| 1671 |
-
|
| 1672 |
-
|
|
|
|
|
|
|
| 1673 |
$coValueSetList[] = $coValueSet;
|
| 1674 |
}
|
| 1675 |
} else {
|
| 1676 |
-
foreach(
|
| 1677 |
$coValueSet = new COValueSet();
|
| 1678 |
$coValueSet->optionId = $cOption->id;
|
| 1679 |
$coValueSet->coValues[] = $optionValue;
|
| 1680 |
$coValueSetList[] = $coValueSet;
|
| 1681 |
}
|
| 1682 |
}
|
| 1683 |
-
$coValueSetListCount =
|
| 1684 |
-
foreach(
|
| 1685 |
-
$coValueSetSequence[
|
| 1686 |
-
if(
|
| 1687 |
$coValueSetSequences[] = $coValueSetSequence;
|
| 1688 |
else
|
| 1689 |
-
$this->_buildCOValueSets(
|
| 1690 |
}
|
| 1691 |
}
|
| 1692 |
|
| 1693 |
-
private function _buildCOValueIndices(
|
| 1694 |
-
for(
|
| 1695 |
-
$indices[
|
| 1696 |
-
if(
|
| 1697 |
$indexList[] = $indices;
|
| 1698 |
-
else
|
| 1699 |
-
$this->_buildCOValueIndices(
|
|
|
|
| 1700 |
}
|
| 1701 |
}
|
| 1702 |
|
| 1703 |
-
private function _cleanStr(
|
| 1704 |
-
return str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $str
|
| 1705 |
}
|
| 1706 |
|
| 1707 |
-
private function _correctProdUrlStr(
|
| 1708 |
-
$str =
|
| 1709 |
-
$pos = strpos(
|
| 1710 |
-
if(
|
| 1711 |
return $str;
|
| 1712 |
-
else if(
|
| 1713 |
-
return substr(
|
| 1714 |
-
else
|
|
|
|
|
|
|
| 1715 |
}
|
| 1716 |
|
| 1717 |
-
private function _getReviews(
|
| 1718 |
$reviewsCollection = $this->reviewsModel->getCollection()
|
| 1719 |
-
|
| 1720 |
-
|
| 1721 |
-
|
| 1722 |
-
|
| 1723 |
$Reviews = "";
|
| 1724 |
-
foreach(
|
| 1725 |
-
$Reviews .= "<p><b>"
|
| 1726 |
-
|
|
|
|
| 1727 |
return $Reviews;
|
| 1728 |
}
|
| 1729 |
|
| 1730 |
-
private function _formatPrice(
|
| 1731 |
-
$v = 0.0;
|
| 1732 |
-
if(
|
| 1733 |
-
$rv = str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $Price
|
| 1734 |
-
if(
|
| 1735 |
-
return "";
|
| 1736 |
-
|
| 1737 |
-
|
| 1738 |
-
|
|
|
|
| 1739 |
} else {
|
| 1740 |
-
$v = floatval(
|
| 1741 |
}
|
| 1742 |
-
if(
|
| 1743 |
-
return "";
|
| 1744 |
}
|
| 1745 |
$v100 = $v * 100;
|
| 1746 |
-
$iv100 = intval(
|
| 1747 |
-
if(
|
| 1748 |
$iv100 = $iv100 + 1;
|
| 1749 |
-
|
| 1750 |
-
$
|
| 1751 |
-
|
| 1752 |
-
|
| 1753 |
-
|
| 1754 |
-
|
| 1755 |
-
|
| 1756 |
-
|
| 1757 |
-
|
| 1758 |
-
|
|
|
|
|
|
|
| 1759 |
return $rv;
|
| 1760 |
}
|
| 1761 |
|
| 1762 |
-
private function _formatQty(
|
| 1763 |
-
$tail = strrchr(
|
| 1764 |
-
if(
|
| 1765 |
-
$qty = substr(
|
|
|
|
| 1766 |
return $qty;
|
| 1767 |
}
|
| 1768 |
-
|
| 1769 |
-
private function _formatImageURL(
|
| 1770 |
-
if(
|
| 1771 |
-
$str = "/"
|
|
|
|
| 1772 |
return $str;
|
| 1773 |
}
|
| 1774 |
-
|
| 1775 |
-
private function _getTierPrices(
|
| 1776 |
-
$res="";
|
| 1777 |
$prices = $product->getFormatedTierPrice();
|
| 1778 |
-
if(
|
| 1779 |
-
"
|
|
|
|
|
|
|
| 1780 |
$rightstr = "";
|
| 1781 |
-
if(
|
| 1782 |
-
$count = count(
|
| 1783 |
-
if(
|
| 1784 |
$prodFinalPrice = $this->includetaxes ?
|
| 1785 |
-
|
| 1786 |
-
|
| 1787 |
-
if(
|
| 1788 |
-
"
|
| 1789 |
-
|
| 1790 |
-
|
| 1791 |
-
|
|
|
|
|
|
|
| 1792 |
$price['price_qty'] = $price['price_qty'] * 1;
|
| 1793 |
$tierPrice = $this->includetaxes ?
|
| 1794 |
-
|
| 1795 |
-
|
| 1796 |
-
if(
|
| 1797 |
-
$tierPrice = $this->_formatPrice(
|
| 1798 |
-
$rightstr .= $price['price_qty'].'#$#';
|
| 1799 |
-
$rightstr.=$tierPrice.'#$#';
|
| 1800 |
-
if(
|
| 1801 |
-
$rightstr .= ceil(100 - (( 100
|
| 1802 |
-
else
|
| 1803 |
-
$rightstr .= ceil(100 - (( 100
|
|
|
|
| 1804 |
}
|
| 1805 |
$i++;
|
| 1806 |
}
|
| 1807 |
}
|
| 1808 |
-
if(
|
| 1809 |
-
$res="";
|
| 1810 |
}
|
| 1811 |
}
|
| 1812 |
-
unset(
|
| 1813 |
-
if(
|
| 1814 |
$pairs = array();
|
| 1815 |
-
if(
|
| 1816 |
-
$pairs[] = $res
|
| 1817 |
}
|
| 1818 |
$prices = $product->getData('tier_price');
|
| 1819 |
-
if(
|
| 1820 |
-
"
|
| 1821 |
-
|
| 1822 |
-
|
| 1823 |
-
|
| 1824 |
-
if(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1825 |
continue;
|
| 1826 |
}
|
| 1827 |
-
$res="";
|
| 1828 |
$rightstr = "";
|
| 1829 |
$gprices = array();
|
| 1830 |
-
foreach(
|
| 1831 |
-
if(
|
| 1832 |
$gprices[] = $price;
|
| 1833 |
}
|
| 1834 |
}
|
| 1835 |
-
$count = count(
|
| 1836 |
-
if(
|
| 1837 |
-
if(
|
| 1838 |
$prodFinalPrice = $this->includetaxes ?
|
| 1839 |
-
|
| 1840 |
-
|
| 1841 |
-
if(
|
| 1842 |
-
"
|
|
|
|
|
|
|
| 1843 |
}
|
| 1844 |
-
$res='[TierPriceTable_'
|
| 1845 |
-
$i = 1;
|
| 1846 |
-
foreach(
|
| 1847 |
$price['price_qty'] = $price['price_qty'] * 1;
|
| 1848 |
$tierPrice = $this->includetaxes ?
|
| 1849 |
-
|
| 1850 |
-
|
| 1851 |
-
if(
|
| 1852 |
-
$tierPrice = $this->_formatPrice(
|
| 1853 |
-
$rightstr .= $price['price_qty'].'#$#';
|
| 1854 |
-
$rightstr.=$tierPrice.'#$#';
|
| 1855 |
-
if(
|
| 1856 |
-
$rightstr .= ceil(100 - (( 100
|
| 1857 |
-
else
|
| 1858 |
-
$rightstr .= ceil(100 - (( 100
|
|
|
|
| 1859 |
}
|
| 1860 |
$i++;
|
| 1861 |
}
|
| 1862 |
}
|
| 1863 |
-
if(
|
| 1864 |
-
$pairs[] = $res
|
| 1865 |
}
|
| 1866 |
}
|
| 1867 |
-
return count
|
| 1868 |
-
} else
|
|
|
|
| 1869 |
}
|
| 1870 |
|
| 1871 |
// Class=CatalogSection
|
| 1872 |
-
public function renderCatalogSection(){
|
| 1873 |
$categories = Mage::getModel('catalog/category')
|
| 1874 |
-
|
| 1875 |
-
|
| 1876 |
-
|
| 1877 |
-
|
| 1878 |
-
|
| 1879 |
-
|
| 1880 |
-
$i = 1;
|
| 1881 |
-
$count = count(
|
| 1882 |
-
if(
|
| 1883 |
-
"
|
| 1884 |
-
|
| 1885 |
-
|
| 1886 |
-
|
| 1887 |
-
|
|
|
|
|
|
|
| 1888 |
$children = $topcategory->getCollection();
|
| 1889 |
-
$children->setStoreId(
|
| 1890 |
->addAttributeToSelect('name')
|
| 1891 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 1892 |
->addAttributeToSort('position', 'asc')
|
| 1893 |
->addIdFilter($topcategory->getChildren())
|
| 1894 |
-
->load();
|
| 1895 |
-
foreach(
|
| 1896 |
$name = $category->getName();
|
| 1897 |
$id = $category->getId();
|
| 1898 |
-
|
| 1899 |
$i++;
|
| 1900 |
}
|
| 1901 |
}
|
| 1902 |
-
}else{
|
| 1903 |
-
foreach(
|
| 1904 |
$name = $category->getName();
|
| 1905 |
$id = $category->getId();
|
| 1906 |
-
|
| 1907 |
$i++;
|
| 1908 |
}
|
| 1909 |
}
|
| 1910 |
}
|
| 1911 |
$lastId = $i;
|
| 1912 |
-
|
| 1913 |
-
";
|
| 1914 |
-
|
| 1915 |
}
|
| 1916 |
|
| 1917 |
-
private function _drawCategory(
|
| 1918 |
$html = "";
|
| 1919 |
$children = $category->getCollection();
|
| 1920 |
-
$children->setStoreId(
|
| 1921 |
->addAttributeToSelect('name')
|
| 1922 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 1923 |
->addAttributeToSort('position', 'asc')
|
| 1924 |
->addIdFilter($category->getChildren())
|
| 1925 |
-
->load();
|
| 1926 |
-
$id = $category->getId();
|
| 1927 |
$sec_path = "";
|
| 1928 |
-
if(
|
| 1929 |
$path .= '-' . $j;
|
| 1930 |
-
$hpath = $hpath.'#$#'
|
| 1931 |
-
$sec_path .= str_replace(
|
| 1932 |
-
$seq = $i
|
| 1933 |
-
}else{
|
| 1934 |
$hpath = $category->getName(); //.' '.$i;
|
| 1935 |
$seq = $i;
|
| 1936 |
}
|
| 1937 |
-
$html = "General\t"
|
| 1938 |
$htmlChildren = "";
|
| 1939 |
-
if(
|
| 1940 |
$j = 1;
|
| 1941 |
-
foreach(
|
| 1942 |
-
$htmlChildren .= $this->_drawCategory(
|
| 1943 |
$j++;
|
| 1944 |
}
|
| 1945 |
}
|
| 1946 |
-
unset(
|
| 1947 |
return $html .= $htmlChildren;
|
| 1948 |
}
|
| 1949 |
|
| 1950 |
// Class=CatalogProject
|
| 1951 |
-
public function renderCatalogProject(){
|
| 1952 |
-
if(
|
| 1953 |
$this->productTypeGroupedModel = Mage::getModel('catalog/product_type_grouped');
|
| 1954 |
}
|
| 1955 |
$this->productTypeConfigurableModel = Mage::getModel('catalog/product_type_configurable');
|
|
|
|
| 1956 |
$categories = Mage::getModel('catalog/category')
|
| 1957 |
-
|
| 1958 |
-
|
| 1959 |
-
|
| 1960 |
-
|
| 1961 |
-
|
| 1962 |
-
|
| 1963 |
-
|
| 1964 |
-
|
| 1965 |
-
|
| 1966 |
-
|
|
|
|
|
|
|
|
|
|
| 1967 |
$hpath = "";
|
| 1968 |
-
if(
|
| 1969 |
-
foreach(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1970 |
$children = $topcategory->getCollection();
|
| 1971 |
-
$children->setStoreId(
|
| 1972 |
->addAttributeToSelect('name')
|
|
|
|
| 1973 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 1974 |
->addAttributeToSort('position', 'asc')
|
| 1975 |
->addIdFilter($topcategory->getChildren())
|
| 1976 |
-
->load();
|
| 1977 |
-
foreach(
|
| 1978 |
-
$this->
|
| 1979 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1980 |
}
|
| 1981 |
}
|
| 1982 |
-
}else{
|
| 1983 |
-
foreach(
|
| 1984 |
-
$this->
|
| 1985 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1986 |
}
|
| 1987 |
}
|
| 1988 |
}
|
| 1989 |
$this->unCatPosition = 1;
|
| 1990 |
-
if(
|
| 1991 |
-
"
|
| 1992 |
-
|
| 1993 |
-
|
| 1994 |
-
$products
|
| 1995 |
-
$
|
| 1996 |
-
|
| 1997 |
-
|
| 1998 |
-
|
|
|
|
|
|
|
|
|
|
| 1999 |
$count = 0;
|
| 2000 |
$index = 0;
|
| 2001 |
$lastLine = "==EOF==
|
| 2002 |
";
|
| 2003 |
-
foreach(
|
| 2004 |
-
if(
|
| 2005 |
$lastLine = "==MORE==
|
| 2006 |
";
|
| 2007 |
break;
|
| 2008 |
}
|
| 2009 |
-
if(
|
| 2010 |
$index++;
|
| 2011 |
continue;
|
| 2012 |
}
|
| 2013 |
$index++;
|
| 2014 |
-
$product = Mage::getModel('catalog/product')->setStoreId(
|
| 2015 |
-
if(
|
| 2016 |
-
|
| 2017 |
-
} else if(
|
| 2018 |
-
|
| 2019 |
} else {
|
| 2020 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2021 |
}
|
| 2022 |
-
unset( $product );
|
| 2023 |
-
if( $this->_DEBUG ) echo "#".$count.": memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
| 2024 |
-
";
|
| 2025 |
$count++;
|
| 2026 |
}
|
| 2027 |
-
|
| 2028 |
}
|
| 2029 |
|
| 2030 |
-
private function _processCategory(
|
| 2031 |
-
$hpath = $level != 1 ? $hpath.'#$#'
|
| 2032 |
-
$this->catpathmap[
|
| 2033 |
-
if(
|
| 2034 |
-
"
|
|
|
|
|
|
|
| 2035 |
$children = $category->getCollection();
|
| 2036 |
-
$children->setStoreId(
|
| 2037 |
->addAttributeToSelect('name')
|
|
|
|
| 2038 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2039 |
->addAttributeToSort('position', 'asc')
|
| 2040 |
->addIdFilter($category->getChildren())
|
| 2041 |
-
->load();
|
| 2042 |
$htmlChildren = "";
|
| 2043 |
-
if(
|
| 2044 |
-
$
|
| 2045 |
-
|
| 2046 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2047 |
}
|
| 2048 |
|
| 2049 |
-
private function CatalogProjectStringGroupedOrSimple(
|
| 2050 |
$ProducttoString = "";
|
| 2051 |
$categoryIds = $product->getCategoryIds();
|
| 2052 |
$listed = FALSE;
|
| 2053 |
-
if(
|
| 2054 |
-
foreach(
|
| 2055 |
-
if(
|
| 2056 |
-
if(
|
| 2057 |
-
"
|
|
|
|
|
|
|
| 2058 |
continue;
|
| 2059 |
}
|
| 2060 |
-
$category = $this->catmap[
|
| 2061 |
-
$hpath = $this->catpathmap[
|
| 2062 |
$position = "";
|
| 2063 |
$positions = $category->getProductsPosition();
|
| 2064 |
-
if(
|
| 2065 |
-
$position = $positions[
|
| 2066 |
-
|
| 2067 |
-
$
|
| 2068 |
-
|
| 2069 |
-
|
| 2070 |
-
.
|
| 2071 |
-
|
| 2072 |
-
|
| 2073 |
-
|
| 2074 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2075 |
$listed = TRUE;
|
| 2076 |
}
|
| 2077 |
}
|
| 2078 |
-
if(
|
| 2079 |
-
$productName = $product->getName();
|
| 2080 |
-
$
|
| 2081 |
-
|
| 2082 |
-
|
| 2083 |
-
|
| 2084 |
-
|
| 2085 |
-
|
| 2086 |
-
|
| 2087 |
-
|
|
|
|
| 2088 |
$this->unCatPosition++;
|
| 2089 |
}
|
| 2090 |
return $ProducttoString;
|
| 2091 |
}
|
| 2092 |
|
| 2093 |
-
private function CatalogProjectStringGroupedAsSimple(
|
| 2094 |
-
$
|
| 2095 |
-
$
|
| 2096 |
-
$
|
| 2097 |
-
|
| 2098 |
-
$
|
| 2099 |
-
|
| 2100 |
-
|
| 2101 |
-
|
| 2102 |
-
|
| 2103 |
-
|
| 2104 |
-
$prodNames[] = $UsedProduct->getId().'#$#'.$this->_cleanStr( $prodName );
|
| 2105 |
-
} else {
|
| 2106 |
-
if( $this->_DEBUG ) echo "sku=".$UsedProduct->getSku()." enabled=".$UsedProduct->getStatus()." - bypassed.
|
| 2107 |
-
";
|
| 2108 |
}
|
| 2109 |
-
unset(
|
| 2110 |
}
|
| 2111 |
-
|
| 2112 |
-
|
| 2113 |
-
|
| 2114 |
-
|
| 2115 |
-
|
| 2116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2117 |
continue;
|
| 2118 |
}
|
| 2119 |
-
$category = $this->catmap[
|
| 2120 |
-
$hpath = $this->catpathmap[
|
| 2121 |
$position = "";
|
| 2122 |
$positions = $category->getProductsPosition();
|
| 2123 |
-
if(
|
| 2124 |
-
$position = $positions[
|
| 2125 |
-
|
| 2126 |
-
|
| 2127 |
-
|
| 2128 |
-
|
| 2129 |
-
|
| 2130 |
-
.
|
| 2131 |
-
|
| 2132 |
-
|
| 2133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2134 |
$position += 0.001;
|
| 2135 |
}
|
| 2136 |
$listed = TRUE;
|
| 2137 |
}
|
| 2138 |
}
|
| 2139 |
-
if(
|
| 2140 |
-
foreach(
|
| 2141 |
-
$
|
| 2142 |
-
|
| 2143 |
-
.
|
| 2144 |
-
|
| 2145 |
-
|
| 2146 |
-
|
| 2147 |
-
|
| 2148 |
-
|
|
|
|
|
|
|
| 2149 |
$this->unCatPosition++;
|
| 2150 |
}
|
| 2151 |
}
|
|
|
|
|
|
|
|
|
|
| 2152 |
return $ProducttoString;
|
| 2153 |
}
|
| 2154 |
|
| 2155 |
-
private function CatalogProjectStringConfigurable(
|
| 2156 |
$UsedProductIds = $this->productTypeConfigurableModel->getUsedProductIds($product);
|
| 2157 |
-
$countUsedProductIds = count(
|
| 2158 |
-
if(
|
| 2159 |
$listed = FALSE;
|
| 2160 |
$ProducttoString = "";
|
| 2161 |
$categoryIds = $product->getCategoryIds();
|
| 2162 |
-
if(
|
| 2163 |
-
foreach(
|
| 2164 |
-
if(
|
| 2165 |
-
if(
|
| 2166 |
-
"
|
|
|
|
|
|
|
| 2167 |
continue;
|
| 2168 |
}
|
| 2169 |
-
$category = $this->catmap[
|
| 2170 |
-
$hpath = $this->catpathmap[
|
| 2171 |
$position = "";
|
| 2172 |
$positions = $category->getProductsPosition();
|
| 2173 |
-
if(
|
| 2174 |
-
$position = $positions[
|
| 2175 |
-
|
| 2176 |
-
$
|
| 2177 |
-
|
| 2178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2179 |
. "\tGeneral" //Proj Name
|
| 2180 |
-
. "\
|
| 2181 |
-
. "\t" //Proj Flag
|
| 2182 |
-
. "\t" //Proj Prod layout
|
| 2183 |
. "\n";
|
| 2184 |
-
$listed = TRUE;
|
| 2185 |
-
}
|
| 2186 |
-
}
|
| 2187 |
-
if( !$listed ){
|
| 2188 |
-
$productName = $product->getName();
|
| 2189 |
-
$ProducttoString .= $product->getId().'#$#'.$this->_cleanStr( $productName ) //ProductKey
|
| 2190 |
-
. "\t" . $product->getId().'#$#'.$this->_cleanStr( $productName ) //Product Name
|
| 2191 |
-
. "\t" . $this->unCatPosition //Prod Sequence
|
| 2192 |
-
. "\tGeneral" //Proj Name
|
| 2193 |
-
. "\tUncategorized" //Hirarachi Path
|
| 2194 |
-
. "\t" //Proj Flag
|
| 2195 |
-
. "\t" //Proj Prod layout
|
| 2196 |
-
. "\n";
|
| 2197 |
$this->unCatPosition++;
|
| 2198 |
-
}
|
| 2199 |
-
} else
|
| 2200 |
$ProducttoString = "";
|
| 2201 |
-
|
|
|
|
| 2202 |
return $ProducttoString;
|
| 2203 |
}
|
| 2204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
<?php
|
| 2 |
+
|
| 3 |
+
// 2016-05-30
|
| 4 |
+
class ConfiguredProductLine {
|
| 5 |
+
|
| 6 |
public $optionIds = array();
|
| 7 |
public $line = NULL;
|
| 8 |
+
|
| 9 |
}
|
| 10 |
+
|
| 11 |
+
class COption {
|
| 12 |
+
|
| 13 |
public $id = NULL;
|
| 14 |
public $title = NULL;
|
| 15 |
public $type = NULL;
|
| 16 |
public $required = NULL;
|
| 17 |
public $values = array();
|
| 18 |
+
|
| 19 |
+
public function toString() {
|
| 20 |
+
return "COption #" . $this->id . " title=" . $this->title . " type=" . $this->type . " required=" . $this->required . " values=" . count($this->values);
|
| 21 |
}
|
| 22 |
+
|
| 23 |
}
|
| 24 |
+
|
| 25 |
+
class COValue {
|
| 26 |
+
|
| 27 |
public $title = NULL;
|
| 28 |
public $sku = NULL;
|
| 29 |
public $rprice = NULL;
|
| 30 |
public $sprice = NULL;
|
| 31 |
+
|
| 32 |
+
public function toString() {
|
| 33 |
+
return "COValue " . $this->title . " sku=" . $this->sku . " rprice=" . $this->rprice . " sprice=" . $this->sprice;
|
| 34 |
}
|
| 35 |
+
|
| 36 |
}
|
| 37 |
+
|
| 38 |
+
class COValueSet {
|
| 39 |
+
|
| 40 |
public $optionId = NULL;
|
| 41 |
public $coValues = array();
|
| 42 |
+
|
| 43 |
+
public function toString() {
|
| 44 |
+
$out = "COValueSet #" . $this->optionId . " ";
|
| 45 |
+
foreach ($this->coValues as $value) {
|
| 46 |
+
$out .= $value->sku ? "-" . $value->sku : "-...";
|
| 47 |
+
}
|
| 48 |
return $out;
|
| 49 |
}
|
| 50 |
+
|
| 51 |
}
|
| 52 |
+
|
| 53 |
class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
|
| 54 |
+
|
| 55 |
public $version = __VERSION__;
|
| 56 |
+
public $controller;
|
| 57 |
public $Store;
|
| 58 |
public $StoreId;
|
| 59 |
public $reviewsModel;
|
| 94 |
public $catpathmap;
|
| 95 |
public $catmap;
|
| 96 |
public $catpositions = FALSE;
|
| 97 |
+
public $storeSorting = "position";
|
| 98 |
public $_DEBUG;
|
| 99 |
+
|
| 100 |
const TAG_P_CLOSE = '</p>';
|
| 101 |
const TAG_P = '<p>';
|
| 102 |
const SCRIPTNAME = __SCRIPTNAME__;
|
| 103 |
|
| 104 |
public function _construct() {
|
| 105 |
parent::_construct();
|
| 106 |
+
$this->_init('codi/codi2');
|
| 107 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
// Class=Settings
|
| 111 |
+
public function renderConfiguration() {
|
| 112 |
+
$this->controller->getResponse()->appendBody("Configuration: start
|
| 113 |
+
ProductListDefaultSortBy: " . Mage::getSingleton('catalog/config')->getProductListDefaultSortBy($this->StoreId) . "
|
| 114 |
+
Configuration: end
|
| 115 |
+
");
|
| 116 |
}
|
| 117 |
|
| 118 |
// Class=DataFile
|
| 119 |
+
public function renderDataFile() {
|
| 120 |
+
if ($this->_DEBUG) {
|
| 121 |
+
$this->controller->getResponse()->appendBody("memory_get_usage real: " . memory_get_usage(TRUE) . " allocated: " . memory_get_usage() . "
|
| 122 |
+
");
|
| 123 |
+
foreach (Mage::app()->getStores() as $store) {
|
| 124 |
+
$this->controller->getResponse()->appendBody("store: " . $store->getId() . " code=" . $store->getCode() . " isActive=" . $store->getIsActive() . "
|
| 125 |
+
");
|
| 126 |
+
}
|
| 127 |
}
|
| 128 |
$this->productTypeConfigurableModel = Mage::getModel('catalog/product_type_configurable');
|
| 129 |
$this->productTypeGroupedModel = Mage::getModel('catalog/product_type_grouped');
|
| 130 |
+
$this->reviewsModel = Mage::getModel('review/review')->setStoreId($this->StoreId);
|
| 131 |
+
$this->catalogInventoryModel = Mage::getModel('cataloginventory/stock_item')->setStoreId($this->StoreId);
|
| 132 |
+
$this->mediaurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
| 133 |
+
$this->prodmediaurl = $this->mediaurl . "catalog/product";
|
| 134 |
$this->mageVersionArray = Mage::getVersionInfo();
|
| 135 |
+
if ($this->_DEBUG) {
|
| 136 |
+
$this->controller->getResponse()->appendBody("mageVersionArray: major " . $this->mageVersionArray['major'] . " minor " . $this->mageVersionArray['minor'] . "
|
| 137 |
+
");
|
| 138 |
+
}
|
| 139 |
+
if ($this->publishtieredpricing || $this->getgroupprices) {
|
| 140 |
$this->customerGroups = array();
|
| 141 |
$customerGroups = Mage::getModel('customer/group')->getCollection();
|
| 142 |
+
foreach ($customerGroups as $cg) {
|
| 143 |
$this->customerGroups[$cg->_data['customer_group_id']] = $cg->_data['customer_group_code'];
|
| 144 |
+
if ($this->_DEBUG) {
|
| 145 |
+
$this->controller->getResponse()->appendBody("customer group #" . $cg->_data['customer_group_id'] . "-" . $cg->_data['customer_group_code'] . "
|
| 146 |
+
");
|
| 147 |
+
}
|
| 148 |
}
|
| 149 |
}
|
| 150 |
+
$products = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->getCollection();
|
| 151 |
+
$products->addAttributeToFilter('status', 1); //enabled
|
| 152 |
+
$products->addAttributeToFilter('visibility', 4); //catalog, search
|
| 153 |
$prodIds = $products->getAllIds();
|
| 154 |
+
if ($this->_DEBUG) {
|
| 155 |
+
$this->controller->getResponse()->appendBody("StoreId: " . $this->StoreId . "
|
| 156 |
+
Products: " . count($prodIds) . "
|
| 157 |
+
Media URL: " . $this->mediaurl . "
|
| 158 |
+
memory_get_usage " . memory_get_usage() . " / " . memory_get_usage(TRUE) . "
|
| 159 |
+
");
|
| 160 |
+
}
|
| 161 |
+
if ($this->start == 0) {
|
| 162 |
+
$this->controller->getResponse()->appendBody("itemNumber\titemQty\titemUom\titemPrice\titemDescription\titemLink\titemAttributes\titemGraphic\tproductName\tproductDescription\tproductGraphic\tproductLink\tproductAttributes\tManufacturer\tCategory\tReviews\tSupplementalInfo\titemSequence
|
| 163 |
+
");
|
| 164 |
+
}
|
| 165 |
$count = 0;
|
| 166 |
$index = 0;
|
| 167 |
$lastLine = "==EOF==
|
| 168 |
";
|
| 169 |
+
foreach ($prodIds as $productId) {
|
| 170 |
+
if ($count == $this->pageSize) {
|
| 171 |
$lastLine = "==MORE==
|
| 172 |
";
|
| 173 |
break;
|
| 174 |
}
|
| 175 |
+
if ($index < $this->start) {
|
| 176 |
$index++;
|
| 177 |
continue;
|
| 178 |
}
|
| 179 |
$index++;
|
| 180 |
+
$product = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->load($productId);
|
| 181 |
+
if ($this->_DEBUG) {
|
| 182 |
+
$this->controller->getResponse()->appendBody("== PRODUCT: " . $product->getTypeId() . " == " . $product->getId() . "-" . $product->getName() . " ==
|
| 183 |
+
");
|
| 184 |
+
}
|
| 185 |
+
if ($product->isConfigurable()) {
|
| 186 |
+
$this->controller->getResponse()->appendBody($this->ProducttoStringConfigurable($product));
|
| 187 |
+
} else if ($product->isGrouped()) {
|
| 188 |
+
if ($this->splitgroupedproducts) {
|
| 189 |
+
$AssociatedProductIds = $this->productTypeGroupedModel->getAssociatedProductIds($product);
|
| 190 |
+
foreach ($AssociatedProductIds as $UsedProductid) {
|
| 191 |
+
$_product = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->load($UsedProductid);
|
| 192 |
+
$this->controller->getResponse()->appendBody($this->ProducttoStringSimple($_product));
|
| 193 |
}
|
| 194 |
} else {
|
| 195 |
+
$this->controller->getResponse()->appendBody($this->ProducttoStringGrouped($product));
|
| 196 |
}
|
| 197 |
+
} else {
|
| 198 |
+
$this->controller->getResponse()->appendBody($this->ProducttoStringSimple($product));
|
| 199 |
+
}
|
| 200 |
+
unset($product);
|
| 201 |
+
if ($this->_DEBUG) {
|
| 202 |
+
$this->controller->getResponse()->appendBody("#" . $count . ": memory_get_usage " . memory_get_usage() . " / " . memory_get_usage(TRUE) . "
|
| 203 |
+
");
|
| 204 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
$count++;
|
| 206 |
}
|
| 207 |
+
$this->controller->getResponse()->appendBody($lastLine);
|
| 208 |
}
|
| 209 |
|
| 210 |
+
private function ProducttoStringGrouped(&$product) {
|
| 211 |
$ProducttoString = "";
|
| 212 |
+
$AssociatedProductIds = $this->productTypeGroupedModel->getAssociatedProductIds($product);
|
| 213 |
$ProductDescription = "";
|
| 214 |
$shortDescription = "";
|
| 215 |
+
if ($this->includeshortdescription) {
|
| 216 |
$shortDescription = $product->getShortDescription();
|
| 217 |
+
if (!empty($shortDescription)) {
|
| 218 |
+
$shortDescription = $this->_cleanStr($shortDescription);
|
| 219 |
+
if (strpos($shortDescription, self::TAG_P) !== false) {
|
| 220 |
+
$new = strlen($shortDescription);
|
| 221 |
+
$pos = strrpos($shortDescription, self::TAG_P_CLOSE) + 4;
|
| 222 |
+
if ($new != $pos) {
|
| 223 |
+
$shortDescription = substr($shortDescription, 0, $pos) . self::TAG_P . substr($shortDescription, $pos) . self::TAG_P_CLOSE;
|
| 224 |
+
}
|
| 225 |
+
} else {
|
| 226 |
+
$shortDescription = self::TAG_P . $shortDescription . self::TAG_P_CLOSE;
|
| 227 |
+
}
|
| 228 |
+
$ProductDescription = $shortDescription;
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
if ($this->includelongdescription) {
|
| 232 |
$longDescription = $product->getDescription();
|
| 233 |
+
if (!empty($longDescription)) {
|
| 234 |
+
$longDescription = $this->_cleanStr($longDescription);
|
| 235 |
+
if (strpos($longDescription, self::TAG_P) !== false) {
|
| 236 |
+
$new = strlen($longDescription);
|
| 237 |
+
$pos = strrpos($longDescription, self::TAG_P_CLOSE) + 4;
|
| 238 |
+
if ($new != $pos) {
|
| 239 |
+
$longDescription = substr($longDescription, 0, $pos) . self::TAG_P . substr($longDescription, $pos) . self::TAG_P_CLOSE;
|
| 240 |
+
}
|
| 241 |
+
} else {
|
| 242 |
+
$longDescription = self::TAG_P . $longDescription . self::TAG_P_CLOSE;
|
| 243 |
+
}
|
| 244 |
+
$ProductDescription .= $longDescription;
|
| 245 |
}
|
| 246 |
}
|
| 247 |
$attributes = $product->getAttributes();
|
| 248 |
$Manufacturer = "";
|
| 249 |
$ProductAttributes = "";
|
| 250 |
+
foreach ($attributes as $attribute) {
|
| 251 |
+
$attribute->setStoreId($this->StoreId);
|
| 252 |
+
if ($this->_DEBUG && ( $attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect" )) {
|
| 253 |
$hasData = $product->getData($attribute->getAttributeCode()) ? TRUE : FALSE;
|
| 254 |
+
$this->controller->getResponse()->appendBody("grouped prod attr: " . $attribute->getFrontend()->getLabel() . "=" . $attribute->getFrontend()->getValue($product) . " input=" . $attribute->getFrontendInput() . " data=" . $product->getData($attribute->getAttributeCode()) . " hasData=" . $hasData . "
|
| 255 |
+
");
|
| 256 |
}
|
| 257 |
+
if ($attribute->getAttributeCode() == "manufacturer") {
|
| 258 |
+
if ($product->getData($attribute->getAttributeCode())) {
|
| 259 |
+
$Manufacturer = $attribute->getFrontend()->getValue($product);
|
| 260 |
+
} else {
|
| 261 |
$Manufacturer = "";
|
| 262 |
+
}
|
| 263 |
continue;
|
| 264 |
}
|
| 265 |
+
if ($attribute->getIsVisibleOnFront() ||
|
| 266 |
+
( $this->includecustomfields && array_key_exists(strtolower($attribute->getAttributeCode()), $this->includecustomfields) )) {
|
| 267 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 268 |
+
if ($attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect") {
|
| 269 |
+
$hasData = $product->getData($attribute->getAttributeCode()) ? TRUE : FALSE;
|
| 270 |
+
if (!$hasData) {
|
| 271 |
$value = "";
|
| 272 |
+
}
|
| 273 |
}
|
| 274 |
+
if (is_string($value) && strlen($value)) {
|
| 275 |
+
if (!empty($ProductAttributes)) {
|
| 276 |
$ProductAttributes .= "|";
|
| 277 |
+
}
|
| 278 |
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
|
| 279 |
}
|
| 280 |
}
|
| 281 |
}
|
| 282 |
+
if ($this->publishtieredpricing == "1") {
|
| 283 |
+
$TierPriceAttributes = $this->_getTierPrices($product);
|
| 284 |
+
$sp = ( empty($ProductAttributes) || empty($TierPriceAttributes) ) ? "" : "|";
|
| 285 |
+
$ProductAttributes .= $sp . $TierPriceAttributes;
|
| 286 |
}
|
| 287 |
+
if ($this->importoptionsasattributes) {
|
| 288 |
+
$optionsAsAttributes = $this->_getCustomOptionsAsAttributes($product);
|
| 289 |
+
if (!empty($optionsAsAttributes)) {
|
| 290 |
+
if (!empty($ProductAttributes)) {
|
| 291 |
$ProductAttributes .= "|";
|
| 292 |
+
}
|
| 293 |
$ProductAttributes .= $optionsAsAttributes;
|
| 294 |
}
|
| 295 |
}
|
| 296 |
+
if (!empty($ProductAttributes)) {
|
| 297 |
+
$ProductAttributes = $this->_cleanStr($ProductAttributes);
|
| 298 |
+
}
|
| 299 |
+
if ($this->_DEBUG) {
|
| 300 |
+
$this->controller->getResponse()->appendBody("product image: " . $product->getImage() . "
|
| 301 |
+
small image: " . $product->getSmallImage() . "
|
| 302 |
+
thumbnail: " . $product->getThumbnail() . "
|
| 303 |
+
");
|
| 304 |
+
}
|
| 305 |
+
$prodImages = array();
|
| 306 |
+
$firstImageFile = trim($product->getImage());
|
| 307 |
+
if ($firstImageFile == "no_selection") {
|
| 308 |
$firstImageFile = FALSE;
|
| 309 |
+
}
|
| 310 |
+
if ($firstImageFile) {
|
| 311 |
+
$prodImages[] = "MagentoBase#=#" . $this->prodmediaurl . $this->_formatImageURL($firstImageFile);
|
| 312 |
+
}
|
| 313 |
+
$prodImageArray = $product->getMediaGallery('images');
|
| 314 |
+
if (is_array($prodImageArray)) {
|
| 315 |
+
foreach ($prodImageArray as $image) {
|
| 316 |
+
$imageFile = trim($image['file']);
|
| 317 |
+
if ($this->_DEBUG) {
|
| 318 |
+
$this->controller->getResponse()->appendBody("gallery image: " . $imageFile . " disabled=" . $image['disabled'] . "
|
| 319 |
+
");
|
| 320 |
+
}
|
| 321 |
+
if (!$imageFile || $imageFile == $firstImageFile) {
|
| 322 |
continue;
|
| 323 |
+
}
|
| 324 |
+
if ($this->ignoreexcludedimages && $image['disabled']) {
|
| 325 |
continue;
|
| 326 |
+
}
|
| 327 |
+
$prodImages[] = "Print#=#" . $this->prodmediaurl . $this->_formatImageURL($imageFile);
|
| 328 |
}
|
| 329 |
}
|
| 330 |
+
$prodImages = implode("#|#", $prodImages);
|
| 331 |
$ProductURL = $product->getProductUrl();
|
| 332 |
+
if (!empty($ProductURL)) {
|
| 333 |
+
$ProductURL = $this->_correctProdUrlStr($ProductURL);
|
| 334 |
+
}
|
| 335 |
$productName = $product->getName();
|
| 336 |
+
$productName = $product->getId() . '#$#' . $this->_cleanStr($productName);
|
| 337 |
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
| 338 |
+
if (!empty($Reviews)) {
|
| 339 |
+
$Reviews = $this->_cleanStr($Reviews);
|
| 340 |
+
}
|
| 341 |
+
if ($this->_DEBUG) {
|
| 342 |
+
$this->controller->getResponse()->appendBody("associated IDs: ");
|
| 343 |
+
foreach ($AssociatedProductIds as $UsedProductid) {
|
| 344 |
+
$this->controller->getResponse()->appendBody("" . $UsedProductid . " ");
|
| 345 |
+
}
|
| 346 |
+
$this->controller->getResponse()->appendBody("
|
| 347 |
+
");
|
| 348 |
}
|
| 349 |
$sequence = 1;
|
| 350 |
$UsedProducts = array();
|
| 351 |
+
foreach ($AssociatedProductIds as $UsedProductid) {
|
| 352 |
+
$UsedProduct = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->load($UsedProductid);
|
| 353 |
+
if ($UsedProduct->getStatus() == 1) {
|
| 354 |
$UsedProducts[] = $UsedProduct;
|
| 355 |
} else {
|
| 356 |
+
if ($this->_DEBUG) {
|
| 357 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " enabled=" . $UsedProduct->getStatus() . " - bypassed.
|
| 358 |
+
");
|
| 359 |
+
}
|
| 360 |
+
unset($UsedProduct);
|
| 361 |
}
|
| 362 |
}
|
| 363 |
$renderSPrice = FALSE;
|
| 364 |
+
if ($this->includespecialprice) {
|
| 365 |
+
foreach ($UsedProducts as $UsedProduct) {
|
| 366 |
$SPrice = $UsedProduct->getSpecialPrice();
|
| 367 |
+
if (trim($SPrice) != "") {
|
| 368 |
$renderSPrice = TRUE;
|
| 369 |
break;
|
| 370 |
}
|
| 371 |
}
|
| 372 |
}
|
| 373 |
+
foreach ($UsedProducts as $UsedProduct) {
|
| 374 |
+
if ($this->instockonly) {
|
| 375 |
+
$inventory = $this->catalogInventoryModel->loadByProduct($UsedProduct);
|
| 376 |
$qty = $inventory->getQty();
|
| 377 |
$minQty = $inventory->getMinQty();
|
| 378 |
+
if ($qty <= $minQty) {
|
| 379 |
+
if ($this->_DEBUG) {
|
| 380 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " enabled=" . $UsedProduct->getStatus() . " qty=" . $qty . " minQty=" . $minQty . " - bypassing.
|
| 381 |
+
");
|
| 382 |
+
}
|
| 383 |
continue;
|
| 384 |
}
|
| 385 |
}
|
| 386 |
+
if ($this->_DEBUG) {
|
| 387 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " enabled=" . $UsedProduct->getStatus() . " prices: Regular=" . $UsedProduct->getData('price') . " Final=" . $UsedProduct->getFinalPrice() . " Special=" . $UsedProduct->getSpecialPrice() . " FromDate=" . $UsedProduct->getSpecialFromDate() . " ToDate=" . $UsedProduct->getSpecialToDate() . "
|
| 388 |
+
");
|
| 389 |
+
}
|
| 390 |
+
$ItemName = $UsedProduct->getName();
|
| 391 |
$ProdRPrice = $UsedProduct->getData('price');
|
| 392 |
$ProdSPrice = $UsedProduct->getSpecialPrice();
|
| 393 |
$ProdSFromDate = $UsedProduct->getSpecialFromDate();
|
| 394 |
$ProdSToDate = $UsedProduct->getSpecialToDate();
|
| 395 |
$ProdGroupPrices = FALSE;
|
| 396 |
+
if ($this->mageVersionArray['major'] > 1 || $this->mageVersionArray['minor'] > 6) {
|
| 397 |
$ProdGroupPrices = $UsedProduct->getData('group_price');
|
| 398 |
+
if ($this->_DEBUG && count($ProdGroupPrices) > 0) {
|
| 399 |
+
$this->controller->getResponse()->appendBody("group_price: " . var_export($ProdGroupPrices, true) . "
|
| 400 |
+
");
|
| 401 |
+
}
|
| 402 |
}
|
| 403 |
$ProdSpecGroupPrices = FALSE;
|
| 404 |
+
if ($ProdGroupPrices) {
|
| 405 |
$ProdSpecGroupPrices = array();
|
| 406 |
+
foreach ($ProdGroupPrices as $groupPrice) {
|
| 407 |
+
if ($groupPrice['cust_group'] == '0') {
|
| 408 |
+
$notLoggedInPrice = 0.0 + $groupPrice['price'];
|
| 409 |
+
if (trim($ProdSPrice) == "" || $notLoggedInPrice < 0.0 + $ProdSPrice) {
|
| 410 |
+
$ProdSPrice = $groupPrice['price'];
|
| 411 |
$ProdSFromDate = FALSE;
|
| 412 |
$ProdSToDate = FALSE;
|
| 413 |
}
|
| 414 |
+
} else {
|
| 415 |
$ProdSpecGroupPrices[] = $groupPrice;
|
| 416 |
+
}
|
| 417 |
}
|
| 418 |
}
|
| 419 |
+
if (trim($ProdSPrice) == "") {
|
| 420 |
$ProdSPrice = -1;
|
| 421 |
$ProdSFromDate = FALSE;
|
| 422 |
$ProdSToDate = FALSE;
|
| 424 |
$SFromDate = $ProdSFromDate;
|
| 425 |
$SToDate = $ProdSToDate;
|
| 426 |
$RPrice = $ProdRPrice;
|
| 427 |
+
if (!empty($RPrice) && $this->includetaxes) {
|
| 428 |
+
$RPrice = $this->taxhelper->getPrice($UsedProduct, $RPrice, true, null, null, null, $this->StoreId);
|
| 429 |
+
}
|
| 430 |
$SPrice = $ProdSPrice;
|
| 431 |
+
if ($SPrice >= 0 && $this->includetaxes) {
|
| 432 |
+
$SPrice = $this->taxhelper->getPrice($UsedProduct, $SPrice, true, null, null, null, $this->StoreId);
|
| 433 |
+
}
|
| 434 |
+
if ($this->_DEBUG) {
|
| 435 |
+
$this->controller->getResponse()->appendBody("resulting prices: Regular=" . $RPrice . " Special=" . $SPrice . " FromDate=" . $SFromDate . " ToDate=" . $SToDate . "
|
| 436 |
+
");
|
| 437 |
+
}
|
| 438 |
+
if ($this->ignoreassprodimages) {
|
| 439 |
+
$itemImages = "";
|
| 440 |
+
} else {
|
| 441 |
+
$itemImages = array();
|
| 442 |
+
$firstImageFile = trim($UsedProduct->getImage());
|
| 443 |
+
if ($firstImageFile == "no_selection") {
|
| 444 |
$firstImageFile = FALSE;
|
| 445 |
+
}
|
| 446 |
+
if ($firstImageFile) {
|
| 447 |
+
$itemImages[] = "MagentoBase#=#" . $this->prodmediaurl . $this->_formatImageURL($firstImageFile);
|
| 448 |
+
}
|
| 449 |
$itemImageArray = $UsedProduct->getMediaGallery('images');
|
| 450 |
+
if (is_array($itemImageArray)) {
|
| 451 |
+
foreach ($itemImageArray as $image) {
|
| 452 |
+
$imageFile = trim($image['file']);
|
| 453 |
+
if (!$imageFile || $imageFile == $firstImageFile) {
|
|
|
|
|
|
|
| 454 |
continue;
|
| 455 |
+
}
|
| 456 |
+
if ($this->ignoreexcludedimages && $image['disabled']) {
|
| 457 |
continue;
|
| 458 |
+
}
|
| 459 |
+
$itemImages[] = "Print#=#" . $this->prodmediaurl . $this->_formatImageURL($imageFile);
|
| 460 |
}
|
| 461 |
}
|
| 462 |
+
$itemImages = implode("#|#", $itemImages);
|
| 463 |
}
|
| 464 |
$attributes = $UsedProduct->getAttributes();
|
| 465 |
$ItemAttributes = "";
|
| 466 |
+
foreach ($attributes as $attribute) {
|
| 467 |
+
$attribute->setStoreId($this->StoreId);
|
| 468 |
+
if ($this->_DEBUG && ( $attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect" )) {
|
| 469 |
$hasData = $UsedProduct->getData($attribute->getAttributeCode()) ? "YES" : "NO";
|
| 470 |
+
$this->controller->getResponse()->appendBody("grouped prod attr: " . $attribute->getFrontend()->getLabel() . "=" . $attribute->getFrontend()->getValue($UsedProduct) . " input=" . $attribute->getFrontendInput() . " data=" . $UsedProduct->getData($attribute->getAttributeCode()) . " hasData=" . $hasData . "
|
| 471 |
+
");
|
| 472 |
}
|
| 473 |
+
if ($attribute->getAttributeCode() == "manufacturer") {
|
| 474 |
+
if ($UsedProduct->getData($attribute->getAttributeCode())) {
|
| 475 |
+
$Manufacturer = $attribute->getFrontend()->getValue($UsedProduct);
|
| 476 |
+
}
|
| 477 |
continue;
|
| 478 |
}
|
| 479 |
+
if ($attribute->getIsVisibleOnFront() ||
|
| 480 |
+
( $this->includecustomfields && array_key_exists(strtolower($attribute->getAttributeCode()), $this->includecustomfields) )) {
|
| 481 |
+
$value = $attribute->getFrontend()->getValue($UsedProduct);
|
| 482 |
+
if ($attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect") {
|
| 483 |
+
$hasData = $UsedProduct->getData($attribute->getAttributeCode()) ? TRUE : FALSE;
|
| 484 |
+
if (!$hasData) {
|
| 485 |
$value = "";
|
| 486 |
+
}
|
| 487 |
}
|
| 488 |
+
if (is_string($value) && strlen($value)) {
|
| 489 |
$ItemAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value . "|";
|
| 490 |
+
}
|
| 491 |
}
|
| 492 |
}
|
| 493 |
+
$ItemAttributes = substr($ItemAttributes, 0, strlen($ItemAttributes) - 1);
|
| 494 |
+
if ($this->includeinvqty) {
|
| 495 |
+
if (!empty($ItemAttributes)) {
|
| 496 |
$ItemAttributes .= "|";
|
| 497 |
+
}
|
| 498 |
+
$ItemAttributes .= "Inventory=" . $this->_formatQty("" . $this->catalogInventoryModel->loadByProduct($UsedProduct)->getQty());
|
| 499 |
+
}
|
| 500 |
+
if ($this->publishtieredpricing == "1") {
|
| 501 |
+
$TierPriceAttributes = $this->_getTierPrices($UsedProduct);
|
| 502 |
+
$sp = ( empty($ItemAttributes) || empty($TierPriceAttributes) ) ? "" : "|";
|
| 503 |
+
$ItemAttributes .= $sp . $TierPriceAttributes;
|
| 504 |
+
}
|
| 505 |
+
$RPrice = $this->_formatPrice($RPrice);
|
| 506 |
+
if ($this->includespecialprice) {
|
| 507 |
+
if ($SPrice >= 0) {
|
| 508 |
+
$SPrice = $this->_formatPrice($SPrice);
|
| 509 |
+
if (!empty($ItemAttributes)) {
|
| 510 |
$ItemAttributes .= "|";
|
| 511 |
+
}
|
| 512 |
+
$ItemAttributes .= "Special Price=" . $SPrice;
|
| 513 |
+
} else if ($renderSPrice) {
|
| 514 |
+
if (!empty($ItemAttributes)) {
|
| 515 |
$ItemAttributes .= "|";
|
| 516 |
+
}
|
| 517 |
$ItemAttributes .= "Special Price=";
|
| 518 |
}
|
| 519 |
}
|
| 520 |
+
if ($this->includespecialpricedatefrom) {
|
| 521 |
+
if (!empty($SFromDate)) {
|
| 522 |
+
if (!empty($ItemAttributes)) {
|
| 523 |
$ItemAttributes .= "|";
|
| 524 |
+
}
|
| 525 |
+
$ItemAttributes .= "Special Price From Date=" . substr($SFromDate, 0, 10);
|
| 526 |
}
|
| 527 |
}
|
| 528 |
+
if ($this->includespecialpricedateto) {
|
| 529 |
+
if (!empty($SToDate)) {
|
| 530 |
+
if (!empty($ItemAttributes)) {
|
| 531 |
$ItemAttributes .= "|";
|
| 532 |
+
}
|
| 533 |
+
$ItemAttributes .= "Special Price To Date=" . substr($SToDate, 0, 10);
|
| 534 |
}
|
| 535 |
}
|
| 536 |
+
if ($this->getgroupprices && $ProdSpecGroupPrices) {
|
| 537 |
+
foreach ($ProdSpecGroupPrices as $groupPrice) {
|
| 538 |
+
$price = 0.0 + $groupPrice['price'];
|
| 539 |
+
if ($price >= 0 && $this->includetaxes) {
|
| 540 |
+
$price = $this->taxhelper->getPrice($UsedProduct, $price, true, null, null, null, $this->StoreId);
|
| 541 |
+
}
|
| 542 |
+
if (!empty($ItemAttributes)) {
|
| 543 |
$ItemAttributes .= "|";
|
| 544 |
+
}
|
| 545 |
+
$ItemAttributes .= "price_" . $this->customerGroups[$groupPrice['cust_group']] . "=" . $this->_formatPrice($price);
|
| 546 |
}
|
| 547 |
}
|
| 548 |
$itemID = $UsedProduct->getSku();
|
| 549 |
+
$ProducttoString .= $this->_cleanStr($itemID) //ItemID
|
| 550 |
+
. "\t" //ItemQty
|
| 551 |
+
. "\t" //ItemUom
|
| 552 |
+
. "\t" . $RPrice //ItemPrice
|
| 553 |
+
. "\t" . $this->_cleanStr($ItemName) //ItemDescription
|
| 554 |
+
. "\t" //ItemLink
|
| 555 |
+
. "\t" . $this->_cleanStr($ItemAttributes) //ItemAttributes
|
| 556 |
+
. "\t" . $itemImages //ItemGraphic
|
| 557 |
+
. "\t" . $productName //ProductName
|
| 558 |
+
. "\t" . $ProductDescription
|
| 559 |
+
. "\t" . $prodImages //ProductGraphic
|
| 560 |
+
. "\t" . $ProductURL //ProductLink
|
| 561 |
+
. "\t" . $ProductAttributes //ProductAttributes
|
| 562 |
+
. "\t" . $Manufacturer //Manufacturer
|
| 563 |
+
. "\t" //Category
|
| 564 |
+
. "\t" . $Reviews //Reviews
|
| 565 |
+
. "\t" . $shortDescription
|
| 566 |
+
. "\t" . $sequence
|
| 567 |
+
. "\n";
|
| 568 |
+
unset($UsedProduct);
|
| 569 |
$sequence++;
|
| 570 |
}
|
| 571 |
+
unset($UsedProducts);
|
| 572 |
+
unset($AssociatedProductIds);
|
| 573 |
return $ProducttoString;
|
| 574 |
}
|
| 575 |
|
| 576 |
+
private function ProducttoStringConfigurable(&$product) {
|
| 577 |
$UsedProductIds = $this->productTypeConfigurableModel->getUsedProductIds($product);
|
| 578 |
$ProductDescription = "";
|
| 579 |
$shortDescription = "";
|
| 580 |
+
if ($this->includeshortdescription) {
|
| 581 |
$shortDescription = $product->getShortDescription();
|
| 582 |
+
if (!empty($shortDescription)) {
|
| 583 |
+
$shortDescription = $this->_cleanStr($shortDescription);
|
| 584 |
+
if (strpos($shortDescription, self::TAG_P) !== false) {
|
| 585 |
+
$new = strlen($shortDescription);
|
| 586 |
+
$pos = strrpos($shortDescription, self::TAG_P_CLOSE) + 4;
|
| 587 |
+
if ($new != $pos) {
|
| 588 |
+
$shortDescription = substr($shortDescription, 0, $pos) . self::TAG_P . substr($shortDescription, $pos) . self::TAG_P_CLOSE;
|
| 589 |
+
}
|
| 590 |
+
} else {
|
| 591 |
+
$shortDescription = self::TAG_P . $shortDescription . self::TAG_P_CLOSE;
|
| 592 |
+
}
|
| 593 |
+
$ProductDescription = $shortDescription;
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
if ($this->includelongdescription) {
|
| 597 |
$longDescription = $product->getDescription();
|
| 598 |
+
if (!empty($longDescription)) {
|
| 599 |
+
$longDescription = $this->_cleanStr($longDescription);
|
| 600 |
+
if (strpos($longDescription, self::TAG_P) !== false) {
|
| 601 |
+
$new = strlen($longDescription);
|
| 602 |
+
$pos = strrpos($longDescription, self::TAG_P_CLOSE) + 4;
|
| 603 |
+
if ($new != $pos) {
|
| 604 |
+
$longDescription = substr($longDescription, 0, $pos) . self::TAG_P . substr($longDescription, $pos) . self::TAG_P_CLOSE;
|
| 605 |
+
}
|
| 606 |
+
} else {
|
| 607 |
+
$longDescription = self::TAG_P . $longDescription . self::TAG_P_CLOSE;
|
| 608 |
+
}
|
| 609 |
+
$ProductDescription .= $longDescription;
|
| 610 |
}
|
| 611 |
}
|
| 612 |
$attributes = $product->getAttributes();
|
| 613 |
$Manufacturer = "";
|
| 614 |
$ProductAttributes = "";
|
| 615 |
+
foreach ($attributes as $attribute) {
|
| 616 |
+
$attribute->setStoreId($this->StoreId);
|
| 617 |
+
if ($attribute->getAttributeCode() == "manufacturer") {
|
| 618 |
+
if ($product->getData($attribute->getAttributeCode())) {
|
| 619 |
+
$Manufacturer = $attribute->getFrontend()->getValue($product);
|
| 620 |
+
} else {
|
| 621 |
$Manufacturer = "";
|
| 622 |
+
}
|
| 623 |
continue;
|
| 624 |
}
|
| 625 |
+
if ($attribute->getIsVisibleOnFront() ||
|
| 626 |
+
( $this->includecustomfields && array_key_exists(strtolower($attribute->getAttributeCode()), $this->includecustomfields) )) {
|
| 627 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 628 |
+
if ($attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect") {
|
| 629 |
+
$hasData = $product->getData($attribute->getAttributeCode()) ? TRUE : FALSE;
|
| 630 |
+
if (!$hasData) {
|
| 631 |
$value = "";
|
| 632 |
+
}
|
| 633 |
}
|
| 634 |
+
if (is_string($value) && strlen($value)) {
|
| 635 |
+
if (!empty($ProductAttributes)) {
|
| 636 |
$ProductAttributes .= "|";
|
| 637 |
+
}
|
| 638 |
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
|
| 639 |
}
|
| 640 |
}
|
| 641 |
}
|
| 642 |
+
if ($this->publishtieredpricing == "1") {
|
| 643 |
$TierPriceAttributes = $this->_getTierPrices($product);
|
| 644 |
+
$sp = ( empty($ProductAttributes) || empty($TierPriceAttributes) ) ? "" : "|";
|
| 645 |
+
$ProductAttributes.= $sp . $TierPriceAttributes;
|
| 646 |
}
|
| 647 |
+
if ($this->importoptionsasattributes) {
|
| 648 |
+
$optionsAsAttributes = $this->_getCustomOptionsAsAttributes($product);
|
| 649 |
+
if (!empty($optionsAsAttributes)) {
|
| 650 |
+
if (!empty($ProductAttributes)) {
|
| 651 |
$ProductAttributes .= "|";
|
| 652 |
+
}
|
| 653 |
$ProductAttributes .= $optionsAsAttributes;
|
| 654 |
}
|
| 655 |
}
|
| 656 |
+
if (!empty($ProductAttributes)) {
|
| 657 |
+
$ProductAttributes = $this->_cleanStr($ProductAttributes);
|
| 658 |
+
}
|
| 659 |
+
if ($this->_DEBUG) {
|
| 660 |
+
$this->controller->getResponse()->appendBody("product image: " . $product->getImage() . "
|
| 661 |
+
small image: " . $product->getSmallImage() . "
|
| 662 |
+
thumbnail: " . $product->getThumbnail() . "
|
| 663 |
+
");
|
| 664 |
+
}
|
| 665 |
+
$prodImages = array();
|
| 666 |
+
$firstImageFile = trim($product->getImage());
|
| 667 |
+
if ($firstImageFile == "no_selection") {
|
| 668 |
$firstImageFile = FALSE;
|
| 669 |
+
}
|
| 670 |
+
if ($firstImageFile) {
|
| 671 |
+
$prodImages[] = "MagentoBase#=#" . $this->prodmediaurl . $this->_formatImageURL($firstImageFile);
|
| 672 |
+
}
|
| 673 |
$prodImageArray = $product->getMediaGallery('images');
|
| 674 |
+
if (is_array($prodImageArray)) {
|
| 675 |
+
foreach ($prodImageArray as $image) {
|
| 676 |
+
$imageFile = trim($image['file']);
|
| 677 |
+
if ($this->_DEBUG) {
|
| 678 |
+
$this->controller->getResponse()->appendBody("gallery image: " . $imageFile . " disabled=" . $image['disabled'] . "
|
| 679 |
+
");
|
| 680 |
+
}
|
| 681 |
+
if (!$imageFile || $imageFile == $firstImageFile) {
|
| 682 |
continue;
|
| 683 |
+
}
|
| 684 |
+
if ($this->ignoreexcludedimages && $image['disabled']) {
|
| 685 |
continue;
|
| 686 |
+
}
|
| 687 |
+
$prodImages[] = "Print#=#" . $this->prodmediaurl . $this->_formatImageURL($imageFile);
|
| 688 |
}
|
| 689 |
}
|
| 690 |
+
$prodImages = implode("#|#", $prodImages);
|
| 691 |
$ProductURL = $product->getProductUrl();
|
| 692 |
+
if (!empty($ProductURL)) {
|
| 693 |
+
$ProductURL = $this->_correctProdUrlStr($ProductURL);
|
| 694 |
+
}
|
| 695 |
$productName = $product->getName();
|
| 696 |
+
$productName = $product->getId() . '#$#' . $this->_cleanStr($productName);
|
| 697 |
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
| 698 |
+
if (!empty($Reviews)) {
|
| 699 |
+
$Reviews = $this->_cleanStr($Reviews);
|
| 700 |
+
}
|
| 701 |
+
if (!$this->getpricefromchild) {
|
| 702 |
$ProdRPrice = $product->getData('price');
|
| 703 |
$ProdSPrice = $product->getSpecialPrice();
|
| 704 |
$ProdSFromDate = $product->getSpecialFromDate();
|
| 705 |
$ProdSToDate = $product->getSpecialToDate();
|
| 706 |
+
if ($this->_DEBUG) {
|
| 707 |
+
$this->controller->getResponse()->appendBody("prod prices: Regular=" . $ProdRPrice . " Special=" . $ProdSPrice . " FromDate=" . $ProdSFromDate . " ToDate=" . $ProdSToDate . "
|
| 708 |
+
");
|
| 709 |
+
}
|
| 710 |
$ProdGroupPrices = FALSE;
|
| 711 |
+
if ($this->mageVersionArray['major'] > 1 || $this->mageVersionArray['minor'] > 6) {
|
| 712 |
$ProdGroupPrices = $product->getData('group_price');
|
| 713 |
+
if ($this->_DEBUG && count($ProdGroupPrices) > 0) {
|
| 714 |
+
$this->controller->getResponse()->appendBody("group_price: " . var_export($ProdGroupPrices, true) . "
|
| 715 |
+
");
|
| 716 |
+
}
|
| 717 |
}
|
| 718 |
$ProdSpecGroupPrices = FALSE;
|
| 719 |
+
if ($ProdGroupPrices) {
|
| 720 |
$ProdSpecGroupPrices = array();
|
| 721 |
+
foreach ($ProdGroupPrices as $groupPrice) {
|
| 722 |
+
if ($groupPrice['cust_group'] == '0') {
|
| 723 |
+
$notLoggedInPrice = 0.0 + $groupPrice['price'];
|
| 724 |
+
if (trim($ProdSPrice) == "" || $notLoggedInPrice < 0.0 + $ProdSPrice) {
|
| 725 |
+
$ProdSPrice = $groupPrice['price'];
|
| 726 |
$ProdSFromDate = FALSE;
|
| 727 |
$ProdSToDate = FALSE;
|
| 728 |
}
|
| 731 |
}
|
| 732 |
}
|
| 733 |
}
|
| 734 |
+
if (trim($ProdSPrice) == "") {
|
| 735 |
$ProdSPrice = -1;
|
| 736 |
$ProdSFromDate = FALSE;
|
| 737 |
$ProdSToDate = FALSE;
|
| 738 |
}
|
| 739 |
} // ! $this->getpricefromchild
|
| 740 |
+
if ($this->_DEBUG) {
|
| 741 |
+
$this->controller->getResponse()->appendBody("used product IDs: ");
|
| 742 |
+
foreach ($UsedProductIds as $UsedProductid) {
|
| 743 |
+
$this->controller->getResponse()->appendBody("" . $UsedProductid . " ");
|
| 744 |
+
}
|
| 745 |
+
$this->controller->getResponse()->appendBody("
|
| 746 |
+
");
|
| 747 |
}
|
| 748 |
$usedConfigurableAttributes = FALSE;
|
| 749 |
+
if ($this->importoptionsasattributes) {
|
| 750 |
$usedConfigurableAttributes = array();
|
| 751 |
}
|
| 752 |
+
$ConfigurableAttributes = $product->getTypeInstance(true)->getConfigurableAttributes($product);
|
| 753 |
+
foreach ($ConfigurableAttributes as $attribute) {
|
| 754 |
+
if ($this->_DEBUG) {
|
| 755 |
+
$this->controller->getResponse()->appendBody("configurable attr: " . $attribute->getLabel() . "
|
| 756 |
+
");
|
| 757 |
}
|
| 758 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
| 759 |
+
if (empty($configurableProdAttribute)) {
|
| 760 |
$label = $attribute->getLabel();
|
| 761 |
+
$this->controller->getResponse()->appendBody("WARNING: no product attribute for configurable attribute " . $label . "
|
| 762 |
+
");
|
| 763 |
continue;
|
| 764 |
}
|
| 765 |
+
$configurableProdAttribute->setStoreId($this->StoreId);
|
| 766 |
+
if ($this->_DEBUG) {
|
| 767 |
+
$this->controller->getResponse()->appendBody("configurable prod attr: " . $configurableProdAttribute->getFrontend()->getLabel() . "
|
| 768 |
+
");
|
| 769 |
}
|
| 770 |
$AttributeLabel = $attribute->getLabel();
|
| 771 |
+
if (!$AttributeLabel) {
|
| 772 |
$AttributeLabel = $configurableProdAttribute->getFrontend()->getLabel();
|
| 773 |
+
}
|
| 774 |
+
if ($this->importoptionsasattributes) {
|
| 775 |
+
$usedConfigurableAttributes[$AttributeLabel] = array();
|
| 776 |
+
if ($this->_DEBUG) {
|
| 777 |
+
$this->controller->getResponse()->appendBody("created usedConfigurableAttributes array for \"" . $AttributeLabel . "\"
|
| 778 |
+
");
|
| 779 |
}
|
| 780 |
}
|
| 781 |
+
foreach ($configurableProdAttribute->getSource()->getAllOptions() as $option) {
|
| 782 |
+
if ($this->_DEBUG) {
|
| 783 |
+
$this->controller->getResponse()->appendBody("variation option: " . $option['value'] . "=>" . $option['label'] . "
|
| 784 |
+
");
|
| 785 |
}
|
| 786 |
+
if ($this->importoptionsasattributes) {
|
| 787 |
+
$usedConfigurableAttributes[$AttributeLabel][$option['label']] = FALSE;
|
| 788 |
+
if ($this->_DEBUG) {
|
| 789 |
+
$this->controller->getResponse()->appendBody("created usedConfigurableAttributes label \"" . $option['label'] . "\"
|
| 790 |
+
");
|
| 791 |
}
|
| 792 |
+
}
|
| 793 |
}
|
| 794 |
}
|
| 795 |
$UsedProducts = array();
|
| 796 |
+
foreach ($UsedProductIds as $UsedProductid) {
|
| 797 |
+
$UsedProduct = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->load($UsedProductid);
|
| 798 |
+
if ($UsedProduct->getStatus() == 1) {
|
| 799 |
+
$UsedProducts[$UsedProductid] = $UsedProduct;
|
| 800 |
} else {
|
| 801 |
+
if ($this->_DEBUG) {
|
| 802 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " enabled=" . $UsedProduct->getStatus() . " - bypassed.
|
| 803 |
+
");
|
| 804 |
+
}
|
| 805 |
+
unset($UsedProduct);
|
| 806 |
}
|
| 807 |
}
|
| 808 |
$cpLines = array();
|
| 809 |
+
foreach ($UsedProducts as $UsedProductid => $UsedProduct) {
|
| 810 |
$cpLine = new ConfiguredProductLine();
|
| 811 |
+
if ($this->instockonly) {
|
| 812 |
+
$inventory = $this->catalogInventoryModel->loadByProduct($UsedProduct);
|
| 813 |
$qty = $inventory->getQty();
|
| 814 |
$minQty = $inventory->getMinQty();
|
| 815 |
+
if ($qty <= $minQty) {
|
| 816 |
+
if ($this->_DEBUG) {
|
| 817 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " qty=" . $qty . " minQty=" . $minQty . " - bypassing.
|
| 818 |
+
");
|
| 819 |
+
}
|
| 820 |
continue;
|
| 821 |
}
|
| 822 |
}
|
| 823 |
+
if (!$this->getpricefromchild) {
|
| 824 |
$RPrice = $ProdRPrice;
|
| 825 |
$SPrice = $ProdSPrice;
|
| 826 |
$RPrice0 = $ProdRPrice;
|
| 827 |
$SPrice0 = $ProdSPrice;
|
| 828 |
+
$SFromDate = !empty($SPrice) ? $ProdSFromDate : FALSE;
|
| 829 |
+
$SToDate = !empty($SPrice) ? $ProdSToDate : FALSE;
|
| 830 |
$SpecGroupPrices = FALSE;
|
| 831 |
$SpecGroupPrices0 = FALSE;
|
| 832 |
+
if ($ProdSpecGroupPrices) {
|
| 833 |
$SpecGroupPrices = array();
|
| 834 |
$SpecGroupPrices0 = array();
|
| 835 |
+
foreach ($ProdSpecGroupPrices as $prodGroupPrice) {
|
| 836 |
+
$SpecGroupPrices[$prodGroupPrice['cust_group']] = 0.0 + $prodGroupPrice['price'];
|
| 837 |
+
$SpecGroupPrices0[$prodGroupPrice['cust_group']] = 0.0 + $prodGroupPrice['price'];
|
| 838 |
}
|
| 839 |
}
|
| 840 |
} else { // $this->getpricefromchild
|
| 841 |
+
if ($this->_DEBUG) {
|
| 842 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " prices: Regular=" . $UsedProduct->getData('price') . " Final=" . $UsedProduct->getFinalPrice() . " Special=" . $UsedProduct->getSpecialPrice() . " FromDate=" . $UsedProduct->getSpecialFromDate() . " ToDate=" . $UsedProduct->getSpecialToDate() . "
|
| 843 |
+
");
|
| 844 |
+
}
|
| 845 |
$RPrice = $UsedProduct->getData('price');
|
| 846 |
$SPrice = $UsedProduct->getSpecialPrice();
|
| 847 |
$SFromDate = $UsedProduct->getSpecialFromDate();
|
| 848 |
$SToDate = $UsedProduct->getSpecialToDate();
|
| 849 |
+
if ($this->_DEBUG) {
|
| 850 |
+
$this->controller->getResponse()->appendBody("prod prices: Regular=" . $RPrice . " Special=" . $SPrice . " FromDate=" . $SFromDate . " ToDate=" . $SToDate . "
|
| 851 |
+
");
|
| 852 |
+
}
|
| 853 |
$ProdGroupPrices = FALSE;
|
| 854 |
+
if ($this->mageVersionArray['major'] > 1 || $this->mageVersionArray['minor'] > 6) {
|
| 855 |
$ProdGroupPrices = $UsedProduct->getData('group_price');
|
| 856 |
+
if ($this->_DEBUG && count($ProdGroupPrices) > 0) {
|
| 857 |
+
$this->controller->getResponse()->appendBody("group_price: " . var_export($ProdGroupPrices, true) . "
|
| 858 |
+
");
|
| 859 |
+
}
|
| 860 |
}
|
| 861 |
$SpecGroupPrices = FALSE;
|
| 862 |
$SpecGroupPrices0 = FALSE;
|
| 863 |
+
if ($ProdGroupPrices) {
|
| 864 |
$SpecGroupPrices = array();
|
| 865 |
+
foreach ($ProdGroupPrices as $groupPrice) {
|
| 866 |
+
if ($groupPrice['cust_group'] == '0') {
|
| 867 |
+
$notLoggedInPrice = 0.0 + $groupPrice['price'];
|
| 868 |
+
if (trim($SPrice) == "" || $notLoggedInPrice < 0.0 + $SPrice) {
|
| 869 |
+
$SPrice = $groupPrice['price'];
|
| 870 |
$SFromDate = FALSE;
|
| 871 |
$SToDate = FALSE;
|
| 872 |
}
|
| 875 |
}
|
| 876 |
}
|
| 877 |
}
|
| 878 |
+
if (trim($SPrice) == "") {
|
| 879 |
$SPrice = -1;
|
| 880 |
$SFromDate = FALSE;
|
| 881 |
$SToDate = FALSE;
|
| 882 |
}
|
| 883 |
}
|
| 884 |
$ItemAttributes = "";
|
| 885 |
+
foreach ($ConfigurableAttributes as $attribute) {
|
| 886 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
| 887 |
+
if (empty($configurableProdAttribute)) {
|
| 888 |
$label = $attribute->getLabel();
|
| 889 |
+
$this->controller->getResponse()->appendBody("WARNING: no product attribute for configurable attribute " . $label . "
|
| 890 |
+
");
|
| 891 |
$cpLine->optionIds[] = 0;
|
| 892 |
continue;
|
| 893 |
}
|
| 894 |
$AttributeCode = $configurableProdAttribute->getAttributeCode();
|
| 895 |
$AttributeLabel = $attribute->getLabel();
|
| 896 |
+
if (!$AttributeLabel) {
|
| 897 |
$AttributeLabel = $configurableProdAttribute->getFrontend()->getLabel();
|
| 898 |
+
}
|
| 899 |
$AttribId = $UsedProduct->getData($AttributeCode);
|
| 900 |
+
$cpLine->optionIds[] = intVal($AttribId);
|
| 901 |
$AttributeValue = "";
|
| 902 |
+
foreach ($configurableProdAttribute->getSource()->getAllOptions() as $option) {
|
| 903 |
+
if ($option['value'] == $AttribId) {
|
| 904 |
$AttributeValue = $option['label'];
|
| 905 |
break;
|
| 906 |
}
|
| 907 |
}
|
| 908 |
+
if ($this->importoptionsasattributes && trim($AttributeValue)) {
|
| 909 |
+
$usedConfigurableAttributes[$AttributeLabel][$AttributeValue] = TRUE;
|
| 910 |
+
}
|
| 911 |
+
if ($this->_DEBUG) {
|
| 912 |
+
$this->controller->getResponse()->appendBody("config attr code=" . $AttributeCode . " label=" . $AttributeLabel . " id=" . $AttribId . " value=" . $AttributeValue . "
|
| 913 |
+
");
|
| 914 |
+
}
|
| 915 |
+
if (!empty($ItemAttributes)) {
|
| 916 |
$ItemAttributes .= "|";
|
| 917 |
+
}
|
| 918 |
+
$ItemAttributes .= $AttributeLabel . "=" . $AttributeValue;
|
| 919 |
+
if (!$this->getpricefromchild) {
|
| 920 |
+
foreach ($attribute->getPrices() as $addedPrice) {
|
| 921 |
+
if ($AttributeValue == $addedPrice['label']) {
|
| 922 |
+
if ($addedPrice['is_percent']) {
|
| 923 |
+
$RPrice += round($RPrice0 * $addedPrice['pricing_value'] / 100, 2);
|
| 924 |
+
if ($SPrice >= 0) {
|
| 925 |
+
$SPrice += round($SPrice0 * $addedPrice['pricing_value'] / 100, 2);
|
| 926 |
+
}
|
| 927 |
+
if ($SpecGroupPrices) {
|
| 928 |
+
foreach ($SpecGroupPrices0 as $key => $value) {
|
| 929 |
+
$SpecGroupPrices[$key] += round($value * $addedPrice['pricing_value'] / 100, 2);
|
| 930 |
}
|
| 931 |
+
}
|
| 932 |
} else {
|
| 933 |
$RPrice += $addedPrice['pricing_value'];
|
| 934 |
+
if ($SPrice >= 0) {
|
| 935 |
$SPrice += $addedPrice['pricing_value'];
|
| 936 |
+
}
|
| 937 |
+
if ($SpecGroupPrices) {
|
| 938 |
+
foreach ($SpecGroupPrices0 as $key => $value) {
|
| 939 |
+
$SpecGroupPrices[$key] += $addedPrice['pricing_value'];
|
| 940 |
+
}
|
| 941 |
+
}
|
| 942 |
}
|
| 943 |
}
|
| 944 |
}
|
| 945 |
} // ! $this->getpricefromchild
|
| 946 |
}
|
| 947 |
+
if (!empty($RPrice) && $this->includetaxes) {
|
| 948 |
+
$RPrice = $this->taxhelper->getPrice($UsedProduct, $RPrice, true, null, null, null, $this->StoreId);
|
| 949 |
+
}
|
| 950 |
+
if (!empty($SPrice) && $this->includetaxes) {
|
| 951 |
+
$SPrice = $this->taxhelper->getPrice($UsedProduct, $SPrice, true, null, null, null, $this->StoreId);
|
| 952 |
+
}
|
| 953 |
+
if ($this->includeinvqty) {
|
| 954 |
+
if (!empty($ItemAttributes)) {
|
| 955 |
$ItemAttributes .= "|";
|
| 956 |
+
}
|
| 957 |
+
$ItemAttributes .= "Inventory=" . $this->_formatQty("" . $this->catalogInventoryModel->loadByProduct($UsedProduct)->getQty());
|
| 958 |
+
}
|
| 959 |
+
if ($this->_DEBUG) {
|
| 960 |
+
$this->controller->getResponse()->appendBody("resulting prices: Regular=" . $RPrice . " Special=" . $SPrice . " FromDate=" . $SFromDate . " ToDate=" . $SToDate . "
|
| 961 |
+
");
|
| 962 |
+
}
|
| 963 |
+
$RPrice = $this->_formatPrice($RPrice);
|
| 964 |
+
if ($this->includespecialprice) {
|
| 965 |
+
if ($SPrice >= 0) {
|
| 966 |
+
$SPrice = $this->_formatPrice($SPrice);
|
| 967 |
+
if (!empty($ItemAttributes)) {
|
| 968 |
$ItemAttributes .= "|";
|
| 969 |
+
}
|
| 970 |
+
$ItemAttributes .= "Special Price=" . $SPrice;
|
| 971 |
}
|
| 972 |
}
|
| 973 |
+
if ($this->includespecialpricedatefrom) {
|
| 974 |
+
if (!empty($SFromDate)) {
|
| 975 |
+
if (!empty($ItemAttributes)) {
|
| 976 |
$ItemAttributes .= "|";
|
| 977 |
+
}
|
| 978 |
+
$ItemAttributes .= "Special Price From Date=" . substr($SFromDate, 0, 10);
|
| 979 |
}
|
| 980 |
}
|
| 981 |
+
if ($this->includespecialpricedateto) {
|
| 982 |
+
if (!empty($SToDate)) {
|
| 983 |
+
if (!empty($ItemAttributes)) {
|
| 984 |
$ItemAttributes .= "|";
|
| 985 |
+
}
|
| 986 |
+
$ItemAttributes .= "Special Price To Date=" . substr($SToDate, 0, 10);
|
| 987 |
}
|
| 988 |
}
|
| 989 |
+
if ($this->getgroupprices && $SpecGroupPrices) {
|
| 990 |
+
foreach ($SpecGroupPrices as $groupID => $price) {
|
| 991 |
+
if ($price >= 0 && $this->includetaxes) {
|
| 992 |
+
$price = $this->taxhelper->getPrice($UsedProduct, $price, true, null, null, null, $this->StoreId);
|
| 993 |
+
}
|
| 994 |
+
if (!empty($ItemAttributes)) {
|
| 995 |
$ItemAttributes .= "|";
|
| 996 |
+
}
|
| 997 |
+
$ItemAttributes .= "price_" . $this->customerGroups[$groupID] . "=" . $this->_formatPrice($price);
|
| 998 |
}
|
| 999 |
}
|
| 1000 |
+
if (!$this->getpricefromchild) {
|
| 1001 |
+
if ($this->publishtieredpricing == "1") {
|
| 1002 |
$TierPriceAttributes = $this->_getTierPrices($UsedProduct);
|
| 1003 |
+
$sp = ( empty($ItemAttributes) || empty($TierPriceAttributes) ) ? "" : "|";
|
| 1004 |
+
$ItemAttributes.= $sp . $TierPriceAttributes;
|
| 1005 |
}
|
| 1006 |
} // ! $this->getpricefromchild
|
| 1007 |
+
if ($this->ignoreassprodimages) {
|
| 1008 |
+
$itemImages = "";
|
| 1009 |
+
} else {
|
| 1010 |
+
if ($this->_DEBUG) {
|
| 1011 |
+
$this->controller->getResponse()->appendBody("config item image: " . $UsedProduct->getImage() . "
|
| 1012 |
+
small image: " . $UsedProduct->getSmallImage() . "
|
| 1013 |
+
thumbnail: " . $UsedProduct->getThumbnail() . "
|
| 1014 |
+
");
|
| 1015 |
+
}
|
| 1016 |
+
$itemImages = array();
|
| 1017 |
+
$firstImageFile = trim($UsedProduct->getImage());
|
| 1018 |
+
if ($firstImageFile == "no_selection") {
|
| 1019 |
$firstImageFile = FALSE;
|
| 1020 |
+
}
|
| 1021 |
+
if ($firstImageFile) {
|
| 1022 |
+
$itemImages[] = "MagentoBase#=#" . $this->prodmediaurl . $this->_formatImageURL($firstImageFile);
|
| 1023 |
+
}
|
| 1024 |
$itemImageArray = $UsedProduct->getMediaGallery('images');
|
| 1025 |
+
if (is_array($itemImageArray)) {
|
| 1026 |
+
foreach ($itemImageArray as $image) {
|
| 1027 |
+
$imageFile = trim($image['file']);
|
| 1028 |
+
if ($this->_DEBUG) {
|
| 1029 |
+
$this->controller->getResponse()->appendBody("gallery image: " . $imageFile . " disabled=" . $image['disabled'] . "
|
| 1030 |
+
");
|
| 1031 |
+
}
|
| 1032 |
+
if (!$imageFile || $imageFile == $firstImageFile) {
|
| 1033 |
continue;
|
| 1034 |
+
}
|
| 1035 |
+
if ($this->ignoreexcludedimages && $image['disabled']) {
|
| 1036 |
continue;
|
| 1037 |
+
}
|
| 1038 |
+
$itemImages[] = "Print#=#" . $this->prodmediaurl . $this->_formatImageURL($imageFile);
|
| 1039 |
}
|
| 1040 |
}
|
| 1041 |
+
$itemImages = implode("#|#", $itemImages);
|
| 1042 |
}
|
| 1043 |
$itemID = $UsedProduct->getSku();
|
| 1044 |
+
$cpLine->line = $this->_cleanStr($itemID) //ItemID
|
| 1045 |
+
. "\t" //ItemQty
|
| 1046 |
+
. "\t" //ItemUom
|
| 1047 |
+
. "\t" . $RPrice //ItemPrice
|
| 1048 |
+
. "\t" //ItemDescription
|
| 1049 |
+
. "\t" //ItemLink
|
| 1050 |
+
. "\t" . $this->_cleanStr($ItemAttributes) //ItemAttributes
|
| 1051 |
+
. "\t" . $itemImages; //ItemitemGraphic
|
| 1052 |
$cpLines[] = $cpLine;
|
| 1053 |
+
unset($UsedProduct);
|
| 1054 |
}
|
| 1055 |
+
unset($UsedProducts);
|
| 1056 |
+
unset($UsedProductIds);
|
| 1057 |
$optionIds = array();
|
| 1058 |
$attrNumber = 0;
|
| 1059 |
$optNumbers = array();
|
| 1060 |
$optCounters = array();
|
| 1061 |
+
foreach ($ConfigurableAttributes as $attribute) {
|
| 1062 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
| 1063 |
+
if (empty($configurableProdAttribute)) {
|
| 1064 |
continue;
|
| 1065 |
}
|
| 1066 |
$optionIdList = array();
|
| 1067 |
$optionNo = 0;
|
| 1068 |
+
foreach ($configurableProdAttribute->getSource()->getAllOptions() as $option) {
|
| 1069 |
+
$optionIdList[] = trim($option['value']) == "" ? 0 : intVal($option['value']);
|
| 1070 |
$optionNo++;
|
| 1071 |
}
|
| 1072 |
$optionIds[] = $optionIdList;
|
| 1074 |
$optNumbers[] = 0;
|
| 1075 |
$attrNumber++;
|
| 1076 |
}
|
|
|
|
|
|
|
| 1077 |
// supplement prod attrs
|
| 1078 |
+
if ($this->importoptionsasattributes) {
|
| 1079 |
+
foreach ($usedConfigurableAttributes as $attrName => $attrValues) {
|
| 1080 |
+
if (!empty($ProductAttributes)) {
|
| 1081 |
$ProductAttributes .= "|";
|
| 1082 |
+
}
|
| 1083 |
+
$ProductAttributes .= $attrName . "=";
|
| 1084 |
$valCount = 0;
|
| 1085 |
+
foreach ($attrValues as $attrValue => $used) {
|
| 1086 |
+
if ($used) {
|
| 1087 |
+
if ($valCount > 0) {
|
| 1088 |
$ProductAttributes .= "<br />";
|
| 1089 |
+
}
|
| 1090 |
$ProductAttributes .= $attrValue;
|
| 1091 |
$valCount++;
|
| 1092 |
}
|
| 1093 |
}
|
| 1094 |
}
|
| 1095 |
+
}
|
| 1096 |
// build prod part
|
| 1097 |
+
$this->prodLine = "\t" . $productName //ProductName
|
| 1098 |
+
. "\t" . $ProductDescription
|
| 1099 |
+
. "\t" . $prodImages //ProductGraphic
|
| 1100 |
+
. "\t" . $ProductURL //ProductLink
|
| 1101 |
+
. "\t" . $ProductAttributes //ProductAttributes
|
| 1102 |
+
. "\t" . $Manufacturer //Manufacturer
|
| 1103 |
+
. "\t" //Category
|
| 1104 |
+
. "\t" . $Reviews //Reviews
|
| 1105 |
+
. "\t" . $shortDescription
|
| 1106 |
+
. "\t";
|
| 1107 |
// build cplines matrix
|
| 1108 |
$cpLinesMatrix = array();
|
| 1109 |
+
foreach ($cpLines as $cpLine) {
|
| 1110 |
+
$optionId = $cpLine->optionIds[0];
|
| 1111 |
+
if ($attrNumber > 1) {
|
| 1112 |
+
if (!isset($cpLinesMatrix[$optionId])) {
|
| 1113 |
+
$cpLinesMatrix[$optionId] = array();
|
| 1114 |
+
}
|
| 1115 |
+
$this->_fillCPLinesMatrix(1, $attrNumber, $cpLine, $cpLinesMatrix[$optionId]);
|
| 1116 |
} else {
|
| 1117 |
+
if (!isset($cpLinesMatrix[$optionId])) {
|
| 1118 |
+
$cpLinesMatrix[$optionId] = $cpLine;
|
| 1119 |
+
}
|
| 1120 |
}
|
| 1121 |
}
|
| 1122 |
$this->configItemSequence = 1;
|
| 1123 |
$this->configProducttoString = "";
|
| 1124 |
+
$this->_fillConfigProdItems(0, $attrNumber, $optNumbers, $optionIds, $optCounters, $cpLinesMatrix);
|
| 1125 |
+
unset($optionIds);
|
| 1126 |
+
foreach ($cpLines as $cpLine) {
|
| 1127 |
+
if ($cpLine->line) {
|
| 1128 |
+
$this->controller->getResponse()->appendBody("WARNING: not rendered config line: " . var_export($cpLine->optionIds, true) . "
|
| 1129 |
+
");
|
| 1130 |
+
}
|
| 1131 |
}
|
| 1132 |
+
unset($cpLines);
|
| 1133 |
return $this->configProducttoString;
|
| 1134 |
}
|
| 1135 |
+
|
| 1136 |
+
private function ProducttoStringSimple(&$product) {
|
| 1137 |
$ProductDescription = "";
|
| 1138 |
$shortDescription = "";
|
| 1139 |
+
if ($this->includeshortdescription) {
|
| 1140 |
$shortDescription = $product->getShortDescription();
|
| 1141 |
+
if (!empty($shortDescription)) {
|
| 1142 |
+
$shortDescription = $this->_cleanStr($shortDescription);
|
| 1143 |
+
if (strpos($shortDescription, self::TAG_P) !== false) {
|
| 1144 |
+
$new = strlen($shortDescription);
|
| 1145 |
+
$pos = strrpos($shortDescription, self::TAG_P_CLOSE) + 4;
|
| 1146 |
+
if ($new != $pos) {
|
| 1147 |
+
$shortDescription = substr($shortDescription, 0, $pos) . self::TAG_P . substr($shortDescription, $pos) . self::TAG_P_CLOSE;
|
| 1148 |
+
}
|
| 1149 |
+
} else {
|
| 1150 |
+
$shortDescription = self::TAG_P . $shortDescription . self::TAG_P_CLOSE;
|
| 1151 |
+
}
|
| 1152 |
+
$ProductDescription = $shortDescription;
|
| 1153 |
+
}
|
| 1154 |
+
}
|
| 1155 |
+
if ($this->includelongdescription) {
|
| 1156 |
$longDescription = $product->getDescription();
|
| 1157 |
+
if (!empty($longDescription)) {
|
| 1158 |
+
$longDescription = $this->_cleanStr($longDescription);
|
| 1159 |
+
if (strpos($longDescription, self::TAG_P) !== false) {
|
| 1160 |
+
$new = strlen($longDescription);
|
| 1161 |
+
$pos = strrpos($longDescription, self::TAG_P_CLOSE) + 4;
|
| 1162 |
+
if ($new != $pos) {
|
| 1163 |
+
$longDescription = substr($longDescription, 0, $pos) . self::TAG_P . substr($longDescription, $pos) . self::TAG_P_CLOSE;
|
| 1164 |
+
}
|
| 1165 |
+
} else {
|
| 1166 |
+
$longDescription = self::TAG_P . $longDescription . self::TAG_P_CLOSE;
|
| 1167 |
+
}
|
| 1168 |
+
$ProductDescription .= $longDescription;
|
| 1169 |
+
}
|
| 1170 |
+
}
|
| 1171 |
+
$prodImages = array();
|
| 1172 |
+
if ($this->_DEBUG) {
|
| 1173 |
+
$this->controller->getResponse()->appendBody("product image: " . $product->getImage() . "
|
| 1174 |
+
small image: " . $product->getSmallImage() . "
|
| 1175 |
+
thumbnail: " . $product->getThumbnail() . "
|
| 1176 |
+
");
|
| 1177 |
+
}
|
| 1178 |
+
$firstImageFile = trim($product->getImage());
|
| 1179 |
+
if ($firstImageFile == "no_selection") {
|
| 1180 |
$firstImageFile = FALSE;
|
| 1181 |
+
}
|
| 1182 |
+
if ($firstImageFile) {
|
| 1183 |
+
$prodImages[] = "MagentoBase#=#" . $this->prodmediaurl . $this->_formatImageURL($firstImageFile);
|
| 1184 |
+
}
|
| 1185 |
$prodImageArray = $product->getMediaGallery('images');
|
| 1186 |
+
if (is_array($prodImageArray)) {
|
| 1187 |
+
foreach ($prodImageArray as $image) {
|
| 1188 |
+
$imageFile = trim($image['file']);
|
| 1189 |
+
if ($this->_DEBUG) {
|
| 1190 |
+
$this->controller->getResponse()->appendBody("gallery image: " . $imageFile . " disabled=" . $image['disabled'] . "
|
| 1191 |
+
");
|
| 1192 |
+
}
|
| 1193 |
+
if (!$imageFile || $imageFile == $firstImageFile) {
|
| 1194 |
continue;
|
| 1195 |
+
}
|
| 1196 |
+
if ($this->ignoreexcludedimages && $image['disabled']) {
|
| 1197 |
continue;
|
| 1198 |
+
}
|
| 1199 |
+
$prodImages[] = "Print#=#" . $this->prodmediaurl . $this->_formatImageURL($imageFile);
|
| 1200 |
}
|
| 1201 |
}
|
| 1202 |
+
$prodImages = implode("#|#", $prodImages);
|
| 1203 |
$URL = $product->getProductUrl();
|
| 1204 |
+
if ($this->_DEBUG) {
|
| 1205 |
+
$this->controller->getResponse()->appendBody("URL= " . $URL . "
|
| 1206 |
+
");
|
| 1207 |
+
}
|
| 1208 |
+
if (!empty($URL)) {
|
| 1209 |
+
$URL = $this->_correctProdUrlStr($URL);
|
| 1210 |
+
}
|
| 1211 |
$attributes = $product->getAttributes();
|
| 1212 |
$Manufacturer = "";
|
| 1213 |
$ProductAttributes = "";
|
| 1214 |
+
foreach ($attributes as $attribute) {
|
| 1215 |
+
$attribute->setStoreId($this->StoreId);
|
| 1216 |
+
if ($this->_DEBUG && ( $attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect" )) {
|
| 1217 |
$hasData = $product->getData($attribute->getAttributeCode()) ? "YES" : "NO";
|
| 1218 |
$vof = $attribute->getIsVisibleOnFront() ? "YES" : "NO";
|
| 1219 |
+
$this->controller->getResponse()->appendBody("simple prod attr: " . $attribute->getFrontend()->getLabel() . "=" . $attribute->getFrontend()->getValue($product) . " input=" . $attribute->getFrontendInput() . " data=" . $product->getData($attribute->getAttributeCode()) . " hasData=" . $hasData . " store=" . $product->_storeId . " vof=" . $vof . "
|
| 1220 |
+
");
|
| 1221 |
}
|
| 1222 |
+
if ($attribute->getAttributeCode() == "manufacturer") {
|
| 1223 |
+
if ($product->getData($attribute->getAttributeCode())) {
|
| 1224 |
+
$Manufacturer = $attribute->getFrontend()->getValue($product);
|
| 1225 |
+
} else {
|
| 1226 |
$Manufacturer = "";
|
| 1227 |
+
}
|
| 1228 |
continue;
|
| 1229 |
}
|
| 1230 |
+
if ($attribute->getIsVisibleOnFront() ||
|
| 1231 |
+
( $this->includecustomfields && array_key_exists(strtolower($attribute->getAttributeCode()), $this->includecustomfields) )) {
|
| 1232 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 1233 |
+
if ($attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect") {
|
| 1234 |
+
$hasData = $product->getData($attribute->getAttributeCode()) ? TRUE : FALSE;
|
| 1235 |
+
if (!$hasData) {
|
| 1236 |
$value = "";
|
| 1237 |
+
}
|
| 1238 |
}
|
| 1239 |
+
if (is_string($value) && strlen($value)) {
|
| 1240 |
+
if (!empty($ProductAttributes)) {
|
| 1241 |
$ProductAttributes .= "|";
|
| 1242 |
+
}
|
| 1243 |
$ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
|
| 1244 |
} else {
|
| 1245 |
+
if ($this->_DEBUG) {
|
| 1246 |
+
$this->controller->getResponse()->appendBody("not a string with length > 0
|
| 1247 |
+
");
|
| 1248 |
+
}
|
| 1249 |
}
|
| 1250 |
}
|
| 1251 |
}
|
| 1252 |
+
if ($this->publishtieredpricing == "1") {
|
| 1253 |
+
$TierPriceAttributes = $this->_getTierPrices($product);
|
| 1254 |
+
$sp = ( empty($ProductAttributes) || empty($TierPriceAttributes) ) ? "" : "|";
|
| 1255 |
+
$ProductAttributes.= $sp . $TierPriceAttributes;
|
| 1256 |
}
|
| 1257 |
+
if ($this->importoptionsasattributes) {
|
| 1258 |
+
$optionsAsAttributes = $this->_getCustomOptionsAsAttributes($product);
|
| 1259 |
+
if (!empty($optionsAsAttributes)) {
|
| 1260 |
+
if (!empty($ProductAttributes)) {
|
| 1261 |
$ProductAttributes .= "|";
|
| 1262 |
+
}
|
| 1263 |
$ProductAttributes .= $optionsAsAttributes;
|
| 1264 |
}
|
| 1265 |
}
|
| 1266 |
+
if (!empty($ProductAttributes)) {
|
| 1267 |
+
$ProductAttributes = $this->_cleanStr($ProductAttributes);
|
| 1268 |
+
}
|
| 1269 |
$ProdRPrice = $product->getData('price');
|
| 1270 |
$ProdSPrice = $product->getSpecialPrice();
|
| 1271 |
$ProdSFromDate = $product->getSpecialFromDate();
|
| 1272 |
$ProdSToDate = $product->getSpecialToDate();
|
| 1273 |
+
if ($this->instockonly) {
|
| 1274 |
+
$inventory = $this->catalogInventoryModel->loadByProduct($product);
|
| 1275 |
$qty = $inventory->getQty();
|
| 1276 |
$minQty = $inventory->getMinQty();
|
| 1277 |
+
if ($this->_DEBUG) {
|
| 1278 |
+
$this->controller->getResponse()->appendBody("sku=" . $product->getSku() . " qty=" . $qty . " minQty=" . $minQty . "
|
| 1279 |
+
");
|
| 1280 |
+
}
|
| 1281 |
+
if ($qty <= $minQty) {
|
| 1282 |
return;
|
| 1283 |
+
}
|
| 1284 |
+
}
|
| 1285 |
+
if ($this->_DEBUG) {
|
| 1286 |
+
$this->controller->getResponse()->appendBody("sku=" . $product->getSku() . " prices: Regular=" . $ProdRPrice . " Special=" . $ProdSPrice . " FromDate=" . $ProdSFromDate . " ToDate=" . $ProdSToDate . "
|
| 1287 |
+
");
|
| 1288 |
}
|
|
|
|
|
|
|
| 1289 |
$ProdGroupPrices = FALSE;
|
| 1290 |
+
if ($this->mageVersionArray['major'] > 1 || $this->mageVersionArray['minor'] > 6) {
|
| 1291 |
$ProdGroupPrices = $product->getData('group_price');
|
| 1292 |
+
if ($this->_DEBUG && count($ProdGroupPrices) > 0) {
|
| 1293 |
+
$this->controller->getResponse()->appendBody("group_price: " . var_export($ProdGroupPrices, true) . "
|
| 1294 |
+
");
|
| 1295 |
+
}
|
| 1296 |
}
|
| 1297 |
$ProdSpecGroupPrices = FALSE;
|
| 1298 |
+
if ($ProdGroupPrices) {
|
| 1299 |
$ProdSpecGroupPrices = array();
|
| 1300 |
+
foreach ($ProdGroupPrices as $groupPrice) {
|
| 1301 |
+
if ($groupPrice['cust_group'] == '0') {
|
| 1302 |
+
$notLoggedInPrice = 0.0 + $groupPrice['price'];
|
| 1303 |
+
if (trim($ProdSPrice) == "" || $notLoggedInPrice < 0.0 + $ProdSPrice) {
|
| 1304 |
+
$ProdSPrice = $groupPrice['price'];
|
| 1305 |
$ProdSFromDate = FALSE;
|
| 1306 |
$ProdSToDate = FALSE;
|
| 1307 |
}
|
| 1308 |
+
} else {
|
| 1309 |
$ProdSpecGroupPrices[] = $groupPrice;
|
| 1310 |
+
}
|
| 1311 |
}
|
| 1312 |
}
|
| 1313 |
+
if (trim($ProdSPrice) == "") {
|
| 1314 |
$ProdSPrice = -1;
|
| 1315 |
$ProdSFromDate = FALSE;
|
| 1316 |
$ProdSToDate = FALSE;
|
| 1317 |
}
|
| 1318 |
+
if (!$ProdRPrice && $product->getTypeId() == "bundle") {
|
| 1319 |
$priceModel = $product->getPriceModel();
|
| 1320 |
+
$options = Mage::getSingleton('core/layout')->createBlock('bundle/catalog_product_view_type_bundle')->setProduct($product)->getOptions();
|
| 1321 |
$ProdRPrice = 0;
|
| 1322 |
+
foreach ($options as $option) {
|
| 1323 |
$selection = $option->getDefaultSelection();
|
| 1324 |
$MinSelPrice = 0;
|
| 1325 |
+
if ($selection) {
|
| 1326 |
+
$MinSelPrice = $priceModel->getSelectionPreFinalPrice($product, $selection, $selection->getSelectionQty());
|
| 1327 |
+
} else if (!$selection && $option->_origData["required"] == "1") {
|
| 1328 |
+
foreach ($option->getSelections() as $selection) {
|
| 1329 |
+
$SelPrice = $priceModel->getSelectionPreFinalPrice($product, $selection, $selection->getSelectionQty());
|
| 1330 |
+
if (( $MinSelPrice == 0 && $SelPrice > 0 ) || ( $MinSelPrice > 0 && $SelPrice > 0 && $SelPrice < $MinSelPrice )) {
|
| 1331 |
$MinSelPrice = $SelPrice;
|
| 1332 |
+
}
|
| 1333 |
}
|
| 1334 |
}
|
| 1335 |
+
if ($MinSelPrice <= 0) {
|
| 1336 |
continue;
|
| 1337 |
+
}
|
| 1338 |
+
if ($this->_DEBUG) {
|
| 1339 |
+
$this->controller->getResponse()->appendBody("added " . $MinSelPrice . "
|
| 1340 |
+
");
|
| 1341 |
+
}
|
| 1342 |
$ProdRPrice += $MinSelPrice;
|
| 1343 |
}
|
| 1344 |
+
if ($this->_DEBUG) {
|
| 1345 |
+
$this->controller->getResponse()->appendBody("Bundle=" . $ProdRPrice . "
|
| 1346 |
+
");
|
| 1347 |
+
}
|
| 1348 |
}
|
| 1349 |
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
| 1350 |
+
if (!empty($Reviews)) {
|
| 1351 |
+
$Reviews = $this->_cleanStr($Reviews);
|
| 1352 |
+
}
|
| 1353 |
$prodSku = $product->getSku();
|
| 1354 |
+
$prodSku = $this->_cleanStr($prodSku);
|
| 1355 |
+
$cleanProdName = $this->_cleanStr($prodName);
|
| 1356 |
$prodName = $product->getName();
|
| 1357 |
+
$cleanProdName = $this->_cleanStr($prodName);
|
| 1358 |
+
$prodName = $product->getId() . '#$#' . $cleanProdName;
|
| 1359 |
$skusAdded = false;
|
| 1360 |
+
if ($this->importoptionsassku) {
|
| 1361 |
$this->configItemSequence = 1;
|
| 1362 |
$this->configProducttoString = "";
|
| 1363 |
$customOptions = $product->getOptions();
|
| 1364 |
+
if ($customOptions) {
|
| 1365 |
+
if ($this->_DEBUG) {
|
| 1366 |
+
$this->controller->getResponse()->appendBody("=== customOptions ===
|
| 1367 |
+
ProdRPrice=" . $ProdRPrice . " ProdSPrice=" . $ProdSPrice . "
|
| 1368 |
+
");
|
| 1369 |
+
}
|
| 1370 |
$max_sort_order = 0;
|
| 1371 |
+
foreach ($customOptions as $option) {
|
| 1372 |
+
if ($option->getSortOrder() > $max_sort_order) {
|
| 1373 |
$max_sort_order = $option->getSortOrder();
|
| 1374 |
+
} else if ($option->getSortOrder() < 0) {
|
| 1375 |
+
$option->setSortOrder(-1);
|
| 1376 |
}
|
| 1377 |
}
|
| 1378 |
$orderedOptionValues = array();
|
| 1379 |
$orderedCustomOptions = array();
|
| 1380 |
+
for ($sortorder = -1; $sortorder <= $max_sort_order; $sortorder++) {
|
| 1381 |
foreach ($customOptions as $option) {
|
| 1382 |
+
if ($option->getSortOrder() != $sortorder) {
|
| 1383 |
+
continue;
|
| 1384 |
+
}
|
| 1385 |
$orderedCustomOptions[] = $option;
|
| 1386 |
$optionValues = array();
|
| 1387 |
+
if ($option->getValues()) {
|
| 1388 |
$max_v_sort_order = 0;
|
| 1389 |
+
foreach ($option->getValues() as $_value) {
|
| 1390 |
+
if ($_value->getSortOrder() > $max_v_sort_order) {
|
| 1391 |
$max_v_sort_order = $_value->getSortOrder();
|
| 1392 |
+
} else if ($_value->getSortOrder() < 0) {
|
| 1393 |
+
$_value->setSortOrder(-1);
|
| 1394 |
}
|
| 1395 |
}
|
| 1396 |
+
for ($vsortorder = -1; $vsortorder <= $max_v_sort_order; $vsortorder++) {
|
| 1397 |
+
foreach ($option->getValues() as $_value) {
|
| 1398 |
+
if ($_value->getSortOrder() != $vsortorder) {
|
| 1399 |
+
continue;
|
| 1400 |
+
}
|
| 1401 |
+
$optionValues[] = $_value;
|
| 1402 |
}
|
| 1403 |
}
|
| 1404 |
}
|
| 1405 |
+
$orderedOptionValues[$option->getOptionId()] = $optionValues;
|
| 1406 |
}
|
| 1407 |
}
|
| 1408 |
$customOptions = array();
|
| 1409 |
$customOptionsById = array();
|
| 1410 |
+
foreach ($orderedCustomOptions as $option) {
|
| 1411 |
+
if ($this->_DEBUG) {
|
| 1412 |
+
$this->controller->getResponse()->appendBody("customOption #" . $option->getOptionId() . " title=" . $option->getTitle() . " storeTitle=" . $option->getStoreTitle() . " type=" . $option->getType() . " isRequire=" . $option->getIsRequire() . " sort_order" . $option->getSortOrder() . "
|
| 1413 |
+
");
|
| 1414 |
+
if ($option->getType() == "date" ||
|
| 1415 |
+
$option->getType() == "time" ||
|
| 1416 |
+
$option->getType() == "date_time" ||
|
| 1417 |
+
$option->getType() == "field" ||
|
| 1418 |
+
$option->getType() == "area") {
|
| 1419 |
+
$this->controller->getResponse()->appendBody(" price=" . $option->getPrice() . " price_type=" . $option->getPriceType() . " sku=" . $option->getSku() . "
|
| 1420 |
+
");
|
| 1421 |
+
}
|
| 1422 |
}
|
| 1423 |
$customOption = new COption();
|
| 1424 |
$customOption->id = $option->getOptionId();
|
| 1425 |
$customOption->title = $option->getStoreTitle();
|
| 1426 |
+
if (!$customOption->title) {
|
| 1427 |
$customOption->title = $option->getTitle();
|
| 1428 |
+
}
|
| 1429 |
+
if (!$customOption->title) {
|
| 1430 |
+
$customOption->title = "Option #" . $option->getOptionId();
|
| 1431 |
+
}
|
| 1432 |
$customOption->type = $option->getType();
|
| 1433 |
$customOption->required = $option->getIsRequire();
|
| 1434 |
+
if ($this->_DEBUG) {
|
| 1435 |
+
$this->controller->getResponse()->appendBody($customOption->toString() . "
|
| 1436 |
+
");
|
| 1437 |
+
}
|
| 1438 |
+
$optionValues = $orderedOptionValues[$option->getOptionId()];
|
| 1439 |
$isMultiple = ( $option->getType() == "multiple" || $option->getType() == "checkbox" );
|
| 1440 |
+
if (!$option->getIsRequire() && !$isMultiple) {
|
| 1441 |
$coValue = new COValue();
|
| 1442 |
$coValue->title = FALSE;
|
| 1443 |
$coValue->sku = FALSE;
|
| 1445 |
$coValue->pvalue = 0;
|
| 1446 |
$coValue->rprice = 0;
|
| 1447 |
$coValue->sprice = 0;
|
| 1448 |
+
if ($this->_DEBUG) {
|
| 1449 |
+
$this->controller->getResponse()->appendBody($coValue->toString() . "
|
| 1450 |
+
");
|
| 1451 |
+
}
|
| 1452 |
$customOption->values[] = $coValue;
|
| 1453 |
}
|
| 1454 |
+
if ($option->getType() == "date" ||
|
| 1455 |
+
$option->getType() == "time" ||
|
| 1456 |
+
$option->getType() == "date_time" ||
|
| 1457 |
+
$option->getType() == "field" ||
|
| 1458 |
+
$option->getType() == "area") {
|
| 1459 |
+
if ($option->getSku()) {
|
| 1460 |
$coValue = new COValue();
|
| 1461 |
$coValue->title = "Provided";
|
| 1462 |
$coValue->sku = $option->getSku();
|
| 1463 |
$coValue->ifpercent = FALSE;
|
| 1464 |
$coValue->pvalue = $option->getPrice();
|
| 1465 |
+
if ($option->getPriceType() == "percent") {
|
| 1466 |
$coValue->ifpercent = TRUE;
|
| 1467 |
+
$coValue->rprice = round($ProdRPrice * $option->getPrice() / 100, 2);
|
| 1468 |
+
$coValue->sprice = $ProdSPrice > -1 ? round($ProdSPrice * $option->getPrice() / 100, 2) : -1;
|
| 1469 |
} else {
|
| 1470 |
$coValue->rprice = $option->getPrice();
|
| 1471 |
$coValue->sprice = $ProdSPrice > -1 ? $option->getPrice() : -1;
|
| 1472 |
}
|
| 1473 |
+
if ($this->_DEBUG) {
|
| 1474 |
+
$this->controller->getResponse()->appendBody($coValue->toString() . "
|
| 1475 |
+
");
|
| 1476 |
+
}
|
| 1477 |
$customOption->values[] = $coValue;
|
| 1478 |
}
|
| 1479 |
} else {
|
| 1480 |
+
foreach ($optionValues as $optionValue) {
|
| 1481 |
+
if ($this->_DEBUG) {
|
| 1482 |
+
$this->controller->getResponse()->appendBody("value title=" . $optionValue->getTitle() . " storeTitle=" . $optionValue->getStoreTitle() . " price=" . $optionValue->getPrice() . " price_type=" . $optionValue->getPriceType() . " sku=" . $optionValue->getSku() . " sort_order=" . $optionValue->getSortOrder() . "
|
| 1483 |
+
");
|
| 1484 |
+
}
|
| 1485 |
+
if ($optionValue->getSku()) {
|
| 1486 |
$coValue = new COValue();
|
| 1487 |
$coValue->title = $optionValue->getStoreTitle();
|
| 1488 |
+
if (!$coValue->title) {
|
| 1489 |
$coValue->title = $optionValue->getTitle();
|
| 1490 |
+
}
|
| 1491 |
+
if (!$coValue->title) {
|
| 1492 |
$coValue->title = "Option value";
|
| 1493 |
+
}
|
| 1494 |
$coValue->sku = $optionValue->getSku();
|
| 1495 |
$coValue->ifpercent = FALSE;
|
| 1496 |
$coValue->pvalue = $optionValue->getPrice();
|
| 1497 |
+
if ($optionValue->getPriceType() == "percent") {
|
| 1498 |
$coValue->ifpercent = TRUE;
|
| 1499 |
+
$coValue->rprice = round($ProdRPrice * $optionValue->getPrice() / 100, 2);
|
| 1500 |
+
$coValue->sprice = $ProdSPrice > -1 ? round($ProdSPrice * $optionValue->getPrice() / 100, 2) : -1;
|
| 1501 |
} else {
|
| 1502 |
$coValue->rprice = $optionValue->getPrice();
|
| 1503 |
$coValue->sprice = $ProdSPrice > -1 ? $optionValue->getPrice() : -1;
|
| 1504 |
}
|
| 1505 |
+
if ($this->_DEBUG) {
|
| 1506 |
+
$this->controller->getResponse()->appendBody($coValue->toString() . "
|
| 1507 |
+
");
|
| 1508 |
+
}
|
| 1509 |
$customOption->values[] = $coValue;
|
| 1510 |
}
|
| 1511 |
}
|
| 1512 |
}
|
| 1513 |
+
if ($isMultiple && count($customOption->values) > 1) {
|
| 1514 |
+
$customOption->values = array_reverse($customOption->values);
|
| 1515 |
+
}
|
| 1516 |
+
if (count($customOption->values) == 0) {
|
| 1517 |
+
// OK
|
| 1518 |
+
} else if (count($customOption->values) == 1) {
|
| 1519 |
+
if ($customOption->values[0]->sku) {
|
| 1520 |
$customOptions[] = $customOption;
|
| 1521 |
+
}
|
| 1522 |
} else {
|
| 1523 |
$customOptions[] = $customOption;
|
| 1524 |
}
|
| 1525 |
+
$customOptionsById[$customOption->id] = $customOption;
|
| 1526 |
}
|
| 1527 |
+
if ($this->_DEBUG) {
|
| 1528 |
+
$this->controller->getResponse()->appendBody("Resulting options / values
|
| 1529 |
+
");
|
| 1530 |
+
foreach ($customOptions as $option) {
|
| 1531 |
+
$this->controller->getResponse()->appendBody($option->toString() . "
|
| 1532 |
+
");
|
| 1533 |
+
foreach ($option->values as $value) {
|
| 1534 |
+
$this->controller->getResponse()->appendBody($value->toString() . "
|
| 1535 |
+
");
|
| 1536 |
+
}
|
| 1537 |
}
|
| 1538 |
}
|
| 1539 |
+
if (count($customOptions) > 0) {
|
| 1540 |
$coValueSetSequences = array();
|
| 1541 |
$coValueSetSequence = array();
|
| 1542 |
+
$this->_buildCOValueSets($coValueSetSequences, $coValueSetSequence, 0, $customOptions);
|
| 1543 |
$index = 1;
|
| 1544 |
+
foreach ($coValueSetSequences as $coValueSetSequence) {
|
| 1545 |
+
if ($this->_DEBUG) {
|
| 1546 |
+
$this->controller->getResponse()->appendBody("coValueSetSequence #" . $index . "
|
| 1547 |
+
");
|
| 1548 |
+
foreach ($coValueSetSequence as $coValueSet) {
|
| 1549 |
+
$this->controller->getResponse()->appendBody($coValueSet->toString() . "
|
| 1550 |
+
");
|
| 1551 |
+
}
|
| 1552 |
}
|
| 1553 |
$ItemNumber = $prodSku;
|
| 1554 |
$RPrice = $ProdRPrice;
|
| 1555 |
$SPrice = $ProdSPrice;
|
| 1556 |
$ItemAttributes = "";
|
| 1557 |
+
if ($this->includeinvqty) {
|
| 1558 |
+
if (!empty($ItemAttributes)) {
|
| 1559 |
$ItemAttributes .= "|";
|
| 1560 |
+
}
|
| 1561 |
+
$ItemAttributes = "Inventory=" . $this->_formatQty("" . $this->catalogInventoryModel->loadByProduct($product)->getQty());
|
| 1562 |
}
|
| 1563 |
+
foreach ($coValueSetSequence as $coValueSet) {
|
| 1564 |
+
$cOption = $customOptionsById[$coValueSet->optionId];
|
| 1565 |
+
if (!empty($ItemAttributes)) {
|
| 1566 |
$ItemAttributes .= "|";
|
| 1567 |
+
}
|
| 1568 |
+
$ItemAttributes .= $cOption->title . "=";
|
| 1569 |
$vcount = 0;
|
| 1570 |
+
foreach ($coValueSet->coValues as $value) {
|
| 1571 |
+
if ($value->sku) {
|
| 1572 |
+
if ($ItemNumber) {
|
| 1573 |
+
$ItemNumber .= "-";
|
| 1574 |
+
}
|
| 1575 |
$ItemNumber .= $value->sku;
|
| 1576 |
$RPrice += $value->rprice;
|
| 1577 |
+
if ($SPrice >= 0) {
|
| 1578 |
+
$SPrice += $value->sprice;
|
| 1579 |
+
}
|
| 1580 |
+
if ($vcount > 0) {
|
| 1581 |
+
$ItemAttributes .= ", ";
|
| 1582 |
+
}
|
| 1583 |
$ItemAttributes .= $value->title;
|
| 1584 |
$vcount++;
|
| 1585 |
}
|
| 1586 |
}
|
| 1587 |
}
|
| 1588 |
+
if (empty($ItemNumber)) {
|
| 1589 |
+
if ($this->_DEBUG) {
|
| 1590 |
+
$this->controller->getResponse()->appendBody("NO ItemNumber
|
| 1591 |
+
");
|
| 1592 |
+
}
|
| 1593 |
continue;
|
| 1594 |
}
|
| 1595 |
+
if (!empty($RPrice) && $this->includetaxes) {
|
| 1596 |
+
$RPrice = $this->taxhelper->getPrice($product, $RPrice, true, null, null, null, $this->StoreId);
|
| 1597 |
+
}
|
| 1598 |
+
if ($SPrice >= 0 && $this->includetaxes) {
|
| 1599 |
+
$SPrice = $this->taxhelper->getPrice($product, $SPrice, true, null, null, null, $this->StoreId);
|
| 1600 |
+
}
|
| 1601 |
+
if ($this->_DEBUG) {
|
| 1602 |
+
$this->controller->getResponse()->appendBody("resulting prices: Regular=" . $RPrice . " Special=" . $SPrice . " FromDate=" . $ProdSFromDate . " ToDate=" . $ProdSToDate . "
|
| 1603 |
+
");
|
| 1604 |
+
}
|
| 1605 |
+
$RPrice = $this->_formatPrice($RPrice);
|
| 1606 |
+
if ($this->includespecialprice) {
|
| 1607 |
+
if ($SPrice >= 0) {
|
| 1608 |
+
$SPrice = $this->_formatPrice($SPrice);
|
| 1609 |
+
if (!empty($ItemAttributes)) {
|
| 1610 |
$ItemAttributes .= "|";
|
| 1611 |
+
}
|
| 1612 |
+
$ItemAttributes .= "Special Price=" . $SPrice;
|
| 1613 |
}
|
| 1614 |
}
|
| 1615 |
+
if ($this->includespecialpricedatefrom) {
|
| 1616 |
+
if (!empty($ProdSFromDate)) {
|
| 1617 |
+
if (!empty($ItemAttributes)) {
|
| 1618 |
$ItemAttributes .= "|";
|
| 1619 |
+
}
|
| 1620 |
+
$ItemAttributes .= "Special Price From Date=" . substr($ProdSFromDate, 0, 10);
|
| 1621 |
}
|
| 1622 |
}
|
| 1623 |
+
if ($this->includespecialpricedateto) {
|
| 1624 |
+
if (!empty($ProdSToDate)) {
|
| 1625 |
+
if (!empty($ItemAttributes)) {
|
| 1626 |
$ItemAttributes .= "|";
|
| 1627 |
+
}
|
| 1628 |
+
$ItemAttributes .= "Special Price To Date=" . substr($ProdSToDate, 0, 10);
|
| 1629 |
}
|
| 1630 |
}
|
| 1631 |
+
if ($this->getgroupprices && $ProdSpecGroupPrices) {
|
| 1632 |
+
foreach ($ProdSpecGroupPrices as $groupPrice) {
|
| 1633 |
+
$price = 0.0 + $groupPrice['price'];
|
| 1634 |
$price0 = $price;
|
| 1635 |
+
foreach ($coValueSetSequence as $coValueSet) {
|
| 1636 |
+
foreach ($coValueSet->coValues as $value) {
|
| 1637 |
+
if ($value->sku) {
|
| 1638 |
+
if ($value->ifpercent) {
|
| 1639 |
+
$price = $price + round($price0 * $value->pvalue / 100, 2);
|
| 1640 |
} else {
|
| 1641 |
$price = $price + $value->pvalue;
|
| 1642 |
}
|
| 1643 |
}
|
| 1644 |
}
|
| 1645 |
}
|
| 1646 |
+
if ($price >= 0 && $this->includetaxes) {
|
| 1647 |
+
$price = $this->taxhelper->getPrice($product, $price, true, null, null, null, $this->StoreId);
|
| 1648 |
+
}
|
| 1649 |
+
if (!empty($ItemAttributes)) {
|
| 1650 |
$ItemAttributes .= "|";
|
| 1651 |
+
}
|
| 1652 |
+
$ItemAttributes .= "price_" . $this->customerGroups[$groupPrice['cust_group']] . "=" . $this->_formatPrice($price);
|
| 1653 |
}
|
| 1654 |
}
|
| 1655 |
+
if ($this->_DEBUG) {
|
| 1656 |
+
$this->controller->getResponse()->appendBody("resulting attrs: " . $ItemAttributes . "
|
| 1657 |
+
");
|
| 1658 |
+
}
|
| 1659 |
$ProducttoString .= $ItemNumber //ItemID
|
| 1660 |
+
. "\t" //ItemQty
|
| 1661 |
+
. "\t" //ItemUom
|
| 1662 |
+
. "\t" . $RPrice //ItemPrice
|
| 1663 |
+
. "\t" //ItemDescription
|
| 1664 |
+
. "\t" //ItemLink
|
| 1665 |
+
. "\t" . $ItemAttributes //ItemAttributes
|
| 1666 |
+
. "\t" //ItemitemGraphic
|
| 1667 |
+
. "\t" . $prodName //ProductName
|
| 1668 |
+
. "\t" . $ProductDescription //ProductDescription
|
| 1669 |
+
. "\t" . $prodImages //ProductGraphic
|
| 1670 |
+
. "\t" . $URL //ProductLink
|
| 1671 |
+
. "\t" . $ProductAttributes //ProductAttributes
|
| 1672 |
+
. "\t" . $Manufacturer //Manufacturer
|
| 1673 |
+
. "\t" //Category
|
| 1674 |
+
. "\t" . $Reviews //Reviews
|
| 1675 |
+
. "\t" . $shortDescription
|
| 1676 |
+
. "\t" . $index
|
| 1677 |
+
. "\n";
|
| 1678 |
$skusAdded = TRUE;
|
| 1679 |
// https://objectpublisher.basecamphq.com/projects/257020-odp/posts/87233819/comments#comment_312388129
|
| 1680 |
+
if ($index >= 200) {
|
| 1681 |
+
$ProducttoString .= "REPORTWARNING: Not all options were converted to items for the product #" . $product->getId() . " - \"" . $cleanProdName . "\".
|
| 1682 |
";
|
| 1683 |
break;
|
| 1684 |
}
|
| 1687 |
}
|
| 1688 |
}
|
| 1689 |
}
|
| 1690 |
+
if (!$skusAdded) {
|
| 1691 |
$RPrice = $ProdRPrice;
|
| 1692 |
+
if (!empty($RPrice) && $this->includetaxes) {
|
| 1693 |
+
$RPrice = $this->taxhelper->getPrice($product, $RPrice, true, null, null, null, $this->StoreId);
|
| 1694 |
+
}
|
| 1695 |
$SPrice = $ProdSPrice;
|
| 1696 |
+
if ($SPrice >= 0 && $this->includetaxes) {
|
| 1697 |
+
$SPrice = $this->taxhelper->getPrice($product, $SPrice, true, null, null, null, $this->StoreId);
|
| 1698 |
+
}
|
| 1699 |
+
if ($this->_DEBUG) {
|
| 1700 |
+
$this->controller->getResponse()->appendBody("resulting prices: Regular=" . $RPrice . " Special=" . $SPrice . " FromDate=" . $ProdSFromDate . " ToDate=" . $ProdSToDate . "
|
| 1701 |
+
");
|
| 1702 |
+
}
|
| 1703 |
$ItemAttributes = "";
|
| 1704 |
+
if ($this->includeinvqty) {
|
| 1705 |
+
$ItemAttributes = "Inventory=" . $this->_formatQty("" . $this->catalogInventoryModel->loadByProduct($product)->getQty());
|
| 1706 |
+
}
|
| 1707 |
+
$RPrice = $this->_formatPrice($RPrice);
|
| 1708 |
+
if ($this->includespecialprice) {
|
| 1709 |
+
if ($SPrice >= 0) {
|
| 1710 |
+
$SPrice = $this->_formatPrice($SPrice);
|
| 1711 |
+
if (!empty($ItemAttributes)) {
|
| 1712 |
$ItemAttributes .= "|";
|
| 1713 |
+
}
|
| 1714 |
+
$ItemAttributes .= "Special Price=" . $SPrice;
|
| 1715 |
}
|
| 1716 |
}
|
| 1717 |
+
if ($this->includespecialpricedatefrom) {
|
| 1718 |
+
if (!empty($ProdSFromDate)) {
|
| 1719 |
+
if (!empty($ItemAttributes)) {
|
| 1720 |
$ItemAttributes .= "|";
|
| 1721 |
+
}
|
| 1722 |
+
$ItemAttributes .= "Special Price From Date=" . substr($ProdSFromDate, 0, 10);
|
| 1723 |
}
|
| 1724 |
}
|
| 1725 |
+
if ($this->includespecialpricedateto) {
|
| 1726 |
+
if (!empty($ProdSToDate)) {
|
| 1727 |
+
if (!empty($ItemAttributes)) {
|
| 1728 |
$ItemAttributes .= "|";
|
| 1729 |
+
}
|
| 1730 |
+
$ItemAttributes .= "Special Price To Date=" . substr($ProdSToDate, 0, 10);
|
| 1731 |
}
|
| 1732 |
}
|
| 1733 |
+
if ($this->getgroupprices && $ProdSpecGroupPrices) {
|
| 1734 |
+
foreach ($ProdSpecGroupPrices as $groupPrice) {
|
| 1735 |
+
$price = 0.0 + $groupPrice['price'];
|
| 1736 |
+
if ($price >= 0 && $this->includetaxes) {
|
| 1737 |
+
$price = $this->taxhelper->getPrice($product, $price, true, null, null, null, $this->StoreId);
|
| 1738 |
+
}
|
| 1739 |
+
if (!empty($ItemAttributes)) {
|
| 1740 |
$ItemAttributes .= "|";
|
| 1741 |
+
}
|
| 1742 |
+
$ItemAttributes .= "price_" . $this->customerGroups[$groupPrice['cust_group']] . "=" . $this->_formatPrice($price);
|
| 1743 |
}
|
| 1744 |
}
|
| 1745 |
$ProducttoString = $prodSku //ItemID
|
| 1746 |
+
. "\t" //ItemQty
|
| 1747 |
+
. "\t" //ItemUom
|
| 1748 |
+
. "\t" . $RPrice //ItemPrice
|
| 1749 |
+
. "\t" //ItemDescription
|
| 1750 |
+
. "\t" //ItemLink
|
| 1751 |
+
. "\t" . $ItemAttributes //ItemAttributes
|
| 1752 |
+
. "\t" //ItemitemGraphic
|
| 1753 |
+
. "\t" . $prodName //ProductName
|
| 1754 |
+
. "\t" . $ProductDescription //ProductDescription
|
| 1755 |
+
. "\t" . $prodImages //ProductGraphic
|
| 1756 |
+
. "\t" . $URL //ProductLink
|
| 1757 |
+
. "\t" . $ProductAttributes //ProductAttributes
|
| 1758 |
+
. "\t" . $Manufacturer //Manufacturer
|
| 1759 |
+
. "\t" //Category
|
| 1760 |
+
. "\t" . $Reviews //Reviews
|
| 1761 |
+
. "\t" . $shortDescription
|
| 1762 |
+
. "\t1"
|
| 1763 |
+
. "\n";
|
| 1764 |
}
|
| 1765 |
return $ProducttoString;
|
| 1766 |
}
|
| 1769 |
private $configItemSequence = 0;
|
| 1770 |
private $configProducttoString = "";
|
| 1771 |
|
| 1772 |
+
private function _fillCPLinesMatrix($attrNumber, $optNo, &$cpLine, &$cpLinesMatrix) {
|
| 1773 |
+
$optionId = $cpLine->optionIds[$attrNumber];
|
| 1774 |
+
if ($attrNumber < $optNo - 1) {
|
| 1775 |
+
if (!isset($cpLinesMatrix[$optionId])) {
|
| 1776 |
+
$cpLinesMatrix[$optionId] = array();
|
| 1777 |
+
}
|
| 1778 |
+
$this->_fillCPLinesMatrix($attrNumber + 1, $optNo, $cpLine, $cpLinesMatrix[$optionId]);
|
| 1779 |
} else {
|
| 1780 |
+
if (!isset($cpLinesMatrix[$optionId])) {
|
| 1781 |
+
$cpLinesMatrix[$optionId] = $cpLine;
|
| 1782 |
+
}
|
| 1783 |
}
|
| 1784 |
}
|
| 1785 |
|
| 1786 |
+
private function _fillConfigProdItems($attrNumber, $attrNo, &$optNumbers, &$optionIds, &$optCounters, &$cpLinesMatrix) {
|
| 1787 |
$optNumber = 0;
|
| 1788 |
+
$optionIdNo = $optCounters[$attrNumber];
|
| 1789 |
+
while ($optNumber < $optionIdNo) {
|
| 1790 |
+
$optionID = $optionIds[$attrNumber][$optNumber];
|
| 1791 |
+
if (isset($cpLinesMatrix[$optionID])) {
|
| 1792 |
+
if ($attrNumber < $attrNo - 1) {
|
| 1793 |
+
$optNumbers[$attrNumber] = $optNumber;
|
| 1794 |
+
$this->_fillConfigProdItems($attrNumber + 1, $attrNo, $optNumbers, $optionIds, $optCounters, $cpLinesMatrix[$optionID]);
|
| 1795 |
} else {
|
| 1796 |
+
$cpLine = $cpLinesMatrix[$optionID];
|
| 1797 |
$this->configProducttoString .= $cpLine->line
|
| 1798 |
+
. $this->prodLine
|
| 1799 |
+
. $this->configItemSequence
|
| 1800 |
+
. "\n";
|
| 1801 |
$cpLine->line = FALSE;
|
| 1802 |
$this->configItemSequence++;
|
| 1803 |
}
|
| 1805 |
$optNumber++;
|
| 1806 |
}
|
| 1807 |
}
|
| 1808 |
+
|
| 1809 |
+
private function _getCustomOptionsAsAttributes(&$product) {
|
| 1810 |
$attributes = "";
|
| 1811 |
$customOptions = $product->getOptions();
|
| 1812 |
+
if ($customOptions) {
|
| 1813 |
//We should support all 4 selects: dropdown, radio buttons, checkbox, and multiple select.
|
| 1814 |
//\app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php
|
| 1815 |
+
if ($this->_DEBUG) {
|
| 1816 |
+
$this->controller->getResponse()->appendBody("=== customOptions ===
|
| 1817 |
+
");
|
| 1818 |
+
}
|
| 1819 |
$max_sort_order = 0;
|
| 1820 |
+
foreach ($customOptions as $option) {
|
| 1821 |
+
if ($option->getSortOrder() > $max_sort_order) {
|
| 1822 |
$max_sort_order = $option->getSortOrder();
|
| 1823 |
+
} else if ($option->getSortOrder() < 0) {
|
| 1824 |
+
$option->setSortOrder(-1);
|
| 1825 |
}
|
| 1826 |
}
|
| 1827 |
+
if ($this->_DEBUG) {
|
| 1828 |
+
for ($sortorder = -1; $sortorder <= $max_sort_order; $sortorder++) {
|
| 1829 |
foreach ($customOptions as $option) {
|
| 1830 |
+
if ($option->getSortOrder() != $sortorder) {
|
| 1831 |
+
continue;
|
| 1832 |
+
}
|
| 1833 |
+
$this->controller->getResponse()->appendBody("customOption #" . $option->getOptionId() . " title=" . $option->getTitle() . " storeTitle=" . $option->getStoreTitle() . " type=" . $option->getType() . " sort_order" . $option->getSortOrder() . "
|
| 1834 |
+
");
|
| 1835 |
+
if ($option->getValues()) {
|
| 1836 |
$max_v_sort_order = 0;
|
| 1837 |
foreach ($option->getValues() as $_value) {
|
| 1838 |
+
if ($_value->getSortOrder() > $max_v_sort_order) {
|
| 1839 |
$max_v_sort_order = $_value->getSortOrder();
|
| 1840 |
+
} else if ($_value->getSortOrder() < 0) {
|
| 1841 |
+
$_value->setSortOrder(-1);
|
| 1842 |
}
|
| 1843 |
}
|
| 1844 |
+
for ($vsortorder = -1; $vsortorder <= $max_v_sort_order; $vsortorder++) {
|
| 1845 |
+
if ($_value->getSortOrder() != $vsortorder) {
|
| 1846 |
+
continue;
|
| 1847 |
+
}
|
| 1848 |
foreach ($option->getValues() as $_value) {
|
| 1849 |
+
$this->controller->getResponse()->appendBody("value title=" . $_value->getTitle() . " storeTitle=" . $option->getStoreTitle() . " price=" . $_value->getPrice() . " price_type=" . $_value->getPriceType() . " sku=" . $_value->getSku() . " sort_order=" . $_value->getSortOrder() . "
|
| 1850 |
+
");
|
| 1851 |
}
|
| 1852 |
}
|
| 1853 |
}
|
| 1854 |
}
|
| 1855 |
}
|
| 1856 |
}
|
| 1857 |
+
for ($sortorder = -1; $sortorder <= $max_sort_order; $sortorder++) {
|
| 1858 |
foreach ($customOptions as $option) {
|
| 1859 |
+
if ($option->getSortOrder() != $sortorder) {
|
| 1860 |
+
continue;
|
| 1861 |
+
}
|
| 1862 |
+
if ($option->getType() != "drop_down" && $option->getType() != "radio" && $option->getType() != "multiple" && $option->getType() != "checkbox") {
|
| 1863 |
+
continue;
|
| 1864 |
+
}
|
| 1865 |
$optionTitle = $option->getStoreTitle();
|
| 1866 |
+
if (empty($optionTitle)) {
|
| 1867 |
$optionTitle = $option->getTitle();
|
| 1868 |
+
}
|
| 1869 |
$optionValues = "";
|
| 1870 |
+
if ($option->getValues()) {
|
| 1871 |
$max_v_sort_order = 0;
|
| 1872 |
+
foreach ($option->getValues() as $_value) {
|
| 1873 |
+
if ($_value->getSortOrder() > $max_v_sort_order) {
|
| 1874 |
$max_v_sort_order = $_value->getSortOrder();
|
| 1875 |
+
} else if ($_value->getSortOrder() < 0) {
|
| 1876 |
+
$_value->setSortOrder(-1);
|
| 1877 |
}
|
| 1878 |
}
|
| 1879 |
+
for ($vsortorder = -1; $vsortorder <= $max_v_sort_order; $vsortorder++) {
|
| 1880 |
+
foreach ($option->getValues() as $_value) {
|
| 1881 |
+
if ($_value->getSortOrder() != $vsortorder) {
|
| 1882 |
+
continue;
|
| 1883 |
+
}
|
| 1884 |
+
if (!empty($optionValues)) {
|
| 1885 |
$optionValues .= "<br/>";
|
| 1886 |
+
}
|
| 1887 |
$valueTitle = $_value->getStoreTitle();
|
| 1888 |
+
if (empty($valueTitle)) {
|
| 1889 |
$valueTitle = $_value->getTitle();
|
| 1890 |
+
}
|
| 1891 |
$optionValues .= $valueTitle;
|
| 1892 |
}
|
| 1893 |
}
|
| 1894 |
}
|
| 1895 |
+
if (!empty($attributes)) {
|
| 1896 |
$attributes .= "|";
|
| 1897 |
+
}
|
| 1898 |
$attributes .= $optionTitle . "=" . $optionValues;
|
| 1899 |
}
|
| 1900 |
}
|
| 1901 |
}
|
| 1902 |
return $attributes;
|
| 1903 |
}
|
| 1904 |
+
|
| 1905 |
+
private function _buildCOValueSets(&$coValueSetSequences, $coValueSetSequence, $index, &$customOptions) {
|
| 1906 |
+
$cOption = $customOptions[$index];
|
| 1907 |
+
$customOptionCount = count($customOptions);
|
| 1908 |
$coValueSetList = array();
|
| 1909 |
+
if ($cOption->type == "multiple" || $cOption->type == "checkbox") {
|
| 1910 |
// all combinations + empty if not required
|
| 1911 |
+
$valuesCount = count($cOption->values);
|
| 1912 |
$indexList = array();
|
| 1913 |
$indices = array();
|
| 1914 |
+
$this->_buildCOValueIndices($indexList, $indices, $valuesCount - 1);
|
| 1915 |
+
foreach ($indexList as $indices) {
|
| 1916 |
$coValueSet = new COValueSet();
|
| 1917 |
$coValueSet->optionId = $cOption->id;
|
| 1918 |
$valueIndexNo = 0;
|
| 1919 |
+
foreach ($indices as $valueIndex) {
|
| 1920 |
+
if ($valueIndex == 1) {
|
| 1921 |
+
$coValueSet->coValues[] = $cOption->values[$valueIndexNo];
|
| 1922 |
+
}
|
| 1923 |
$valueIndexNo++;
|
| 1924 |
}
|
| 1925 |
+
if (!$cOption->required && count($coValueSet->coValues) == 0) {
|
| 1926 |
$coValue = new COValue();
|
| 1927 |
$coValue->title = FALSE;
|
| 1928 |
$coValue->sku = FALSE;
|
| 1930 |
$coValue->sprice = 0;
|
| 1931 |
$coValueSet->coValues[] = $coValue;
|
| 1932 |
}
|
| 1933 |
+
if (count($coValueSet->coValues) == 0) {
|
| 1934 |
continue;
|
| 1935 |
+
}
|
| 1936 |
+
if (count($coValueSet->coValues) > 1) {
|
| 1937 |
+
$coValueSet->coValues = array_reverse($coValueSet->coValues);
|
| 1938 |
+
}
|
| 1939 |
$coValueSetList[] = $coValueSet;
|
| 1940 |
}
|
| 1941 |
} else {
|
| 1942 |
+
foreach ($cOption->values as $optionValue) {
|
| 1943 |
$coValueSet = new COValueSet();
|
| 1944 |
$coValueSet->optionId = $cOption->id;
|
| 1945 |
$coValueSet->coValues[] = $optionValue;
|
| 1946 |
$coValueSetList[] = $coValueSet;
|
| 1947 |
}
|
| 1948 |
}
|
| 1949 |
+
$coValueSetListCount = count($coValueSetList);
|
| 1950 |
+
foreach ($coValueSetList as $coValueSet) {
|
| 1951 |
+
$coValueSetSequence[$index] = $coValueSet;
|
| 1952 |
+
if ($index == $customOptionCount - 1)
|
| 1953 |
$coValueSetSequences[] = $coValueSetSequence;
|
| 1954 |
else
|
| 1955 |
+
$this->_buildCOValueSets($coValueSetSequences, $coValueSetSequence, $index + 1, $customOptions);
|
| 1956 |
}
|
| 1957 |
}
|
| 1958 |
|
| 1959 |
+
private function _buildCOValueIndices(&$indexList, $indices, $index) {
|
| 1960 |
+
for ($i = 0; $i < 2; $i++) {
|
| 1961 |
+
$indices[$index] = $i;
|
| 1962 |
+
if ($index == 0) {
|
| 1963 |
$indexList[] = $indices;
|
| 1964 |
+
} else {
|
| 1965 |
+
$this->_buildCOValueIndices($indexList, $indices, $index - 1);
|
| 1966 |
+
}
|
| 1967 |
}
|
| 1968 |
}
|
| 1969 |
|
| 1970 |
+
private function _cleanStr(&$str) {
|
| 1971 |
+
return str_replace("\n", " ", str_replace("\r", " ", str_replace("\r\n", " ", str_replace("\t", " ", $str))));
|
| 1972 |
}
|
| 1973 |
|
| 1974 |
+
private function _correctProdUrlStr(&$str) {
|
| 1975 |
+
$str = str_replace(self::SCRIPTNAME, "index.php", $str);
|
| 1976 |
+
$pos = strpos($str, "?");
|
| 1977 |
+
if ($pos === false) {
|
| 1978 |
return $str;
|
| 1979 |
+
} else if (substr($str, $pos) == "?___store=default") {
|
| 1980 |
+
return substr($str, 0, $pos);
|
| 1981 |
+
} else {
|
| 1982 |
+
return $str;
|
| 1983 |
+
}
|
| 1984 |
}
|
| 1985 |
|
| 1986 |
+
private function _getReviews($productid) {
|
| 1987 |
$reviewsCollection = $this->reviewsModel->getCollection()
|
| 1988 |
+
->addStoreFilter($this->StoreId)
|
| 1989 |
+
->addStatusFilter('approved')
|
| 1990 |
+
->addEntityFilter('product', $productid)
|
| 1991 |
+
->setDateOrder();
|
| 1992 |
$Reviews = "";
|
| 1993 |
+
foreach ($reviewsCollection as $review) {
|
| 1994 |
+
$Reviews .= "<p><b>" . $review->getTitle() . "(" . $review->getNickname() . ")</b><br>" . $review->getDetail() . self::TAG_P_CLOSE;
|
| 1995 |
+
}
|
| 1996 |
+
unset($reviewsCollection);
|
| 1997 |
return $Reviews;
|
| 1998 |
}
|
| 1999 |
|
| 2000 |
+
private function _formatPrice($Price) {
|
| 2001 |
+
$v = 0.0;
|
| 2002 |
+
if (is_string($Price)) {
|
| 2003 |
+
$rv = str_replace("\n", " ", str_replace("\r", " ", str_replace("\r\n", " ", str_replace("\t", " ", $Price))));
|
| 2004 |
+
if (empty($rv) || $rv == "0") {
|
| 2005 |
+
return "";
|
| 2006 |
+
}
|
| 2007 |
+
$v = floatval($Price);
|
| 2008 |
+
} else if (is_float($Price)) {
|
| 2009 |
+
$v = $Price;
|
| 2010 |
} else {
|
| 2011 |
+
$v = floatval($Price);
|
| 2012 |
}
|
| 2013 |
+
if ($v <= 0) {
|
| 2014 |
+
return "";
|
| 2015 |
}
|
| 2016 |
$v100 = $v * 100;
|
| 2017 |
+
$iv100 = intval($v100);
|
| 2018 |
+
if ($v100 - $iv100 >= 0.5) {
|
| 2019 |
$iv100 = $iv100 + 1;
|
| 2020 |
+
}
|
| 2021 |
+
$rv = strval(floatval($iv100) / 100);
|
| 2022 |
+
$tail = strrchr($rv, ".");
|
| 2023 |
+
if (!empty($tail) && strlen($tail) > 3) {
|
| 2024 |
+
$rv = substr($rv, 0, strlen($rv) - ( strlen($tail) - 3 ));
|
| 2025 |
+
} else if (!empty($tail) && strlen($tail) == 2) {
|
| 2026 |
+
$rv = $rv . "0";
|
| 2027 |
+
} else if (!empty($tail) && strlen($tail) == 1) {
|
| 2028 |
+
$rv = $rv . "00";
|
| 2029 |
+
} else if (!$tail) {
|
| 2030 |
+
$rv = $rv . ".00";
|
| 2031 |
+
}
|
| 2032 |
return $rv;
|
| 2033 |
}
|
| 2034 |
|
| 2035 |
+
private function _formatQty($qty) {
|
| 2036 |
+
$tail = strrchr($qty, ".");
|
| 2037 |
+
if (!empty($tail)) {
|
| 2038 |
+
$qty = substr($qty, 0, strlen($qty) - strlen($tail));
|
| 2039 |
+
}
|
| 2040 |
return $qty;
|
| 2041 |
}
|
| 2042 |
+
|
| 2043 |
+
private function _formatImageURL($str) {
|
| 2044 |
+
if ($str[0] != '/') {
|
| 2045 |
+
$str = "/" . $str;
|
| 2046 |
+
}
|
| 2047 |
return $str;
|
| 2048 |
}
|
| 2049 |
+
|
| 2050 |
+
private function _getTierPrices(&$product) {
|
| 2051 |
+
$res = "";
|
| 2052 |
$prices = $product->getFormatedTierPrice();
|
| 2053 |
+
if ($this->_DEBUG && isset($prices)) {
|
| 2054 |
+
$this->controller->getResponse()->appendBody("public tier prices: " . var_export($prices, true) . "
|
| 2055 |
+
");
|
| 2056 |
+
}
|
| 2057 |
$rightstr = "";
|
| 2058 |
+
if (is_array($prices)) {
|
| 2059 |
+
$count = count($prices);
|
| 2060 |
+
if ($count > 0) {
|
| 2061 |
$prodFinalPrice = $this->includetaxes ?
|
| 2062 |
+
$this->taxhelper->getPrice($product, $product->getData('price'), true, null, null, null, $this->StoreId) :
|
| 2063 |
+
$product->getData('price');
|
| 2064 |
+
if ($this->_DEBUG) {
|
| 2065 |
+
$this->controller->getResponse()->appendBody("prodFinalPrice: " . $prodFinalPrice . "
|
| 2066 |
+
");
|
| 2067 |
+
}
|
| 2068 |
+
$res = '[TierPriceTable]#$$#' . $this->quantitylabel . '#$#' . $this->pricelabel . '#$#' . $this->savingslabel . "=";
|
| 2069 |
+
$i = 1;
|
| 2070 |
+
foreach ($prices as $price) {
|
| 2071 |
$price['price_qty'] = $price['price_qty'] * 1;
|
| 2072 |
$tierPrice = $this->includetaxes ?
|
| 2073 |
+
$this->taxhelper->getPrice($product, $price['price'], true, null, null, null, $this->StoreId) :
|
| 2074 |
+
$price['price'];
|
| 2075 |
+
if ($tierPrice < $prodFinalPrice) {
|
| 2076 |
+
$tierPrice = $this->_formatPrice("" . $tierPrice);
|
| 2077 |
+
$rightstr .= $price['price_qty'] . '#$#';
|
| 2078 |
+
$rightstr.=$tierPrice . '#$#';
|
| 2079 |
+
if ($i == $count) {
|
| 2080 |
+
$rightstr .= ceil(100 - (( 100 / $prodFinalPrice ) * $tierPrice )) . '%';
|
| 2081 |
+
} else {
|
| 2082 |
+
$rightstr .= ceil(100 - (( 100 / $prodFinalPrice ) * $tierPrice )) . '%#$$#';
|
| 2083 |
+
}
|
| 2084 |
}
|
| 2085 |
$i++;
|
| 2086 |
}
|
| 2087 |
}
|
| 2088 |
+
if (empty($rightstr)) {
|
| 2089 |
+
$res = "";
|
| 2090 |
}
|
| 2091 |
}
|
| 2092 |
+
unset($prices);
|
| 2093 |
+
if ($this->getgroupprices) {
|
| 2094 |
$pairs = array();
|
| 2095 |
+
if (!empty($res)) {
|
| 2096 |
+
$pairs[] = $res . $rightstr;
|
| 2097 |
}
|
| 2098 |
$prices = $product->getData('tier_price');
|
| 2099 |
+
if ($this->_DEBUG && isset($prices)) {
|
| 2100 |
+
$this->controller->getResponse()->appendBody("all tier prices: " . var_export($prices, true) . "
|
| 2101 |
+
");
|
| 2102 |
+
}
|
| 2103 |
+
foreach ($this->customerGroups as $gid => $gname) {
|
| 2104 |
+
if ($this->_DEBUG) {
|
| 2105 |
+
$this->controller->getResponse()->appendBody("group: " . $gid . "=>" . $gname . "
|
| 2106 |
+
");
|
| 2107 |
+
}
|
| 2108 |
+
if ($gid == 0) {
|
| 2109 |
continue;
|
| 2110 |
}
|
| 2111 |
+
$res = "";
|
| 2112 |
$rightstr = "";
|
| 2113 |
$gprices = array();
|
| 2114 |
+
foreach ($prices as $price) {
|
| 2115 |
+
if ($price['all_groups'] == '1' || $price['cust_group'] == $gid) {
|
| 2116 |
$gprices[] = $price;
|
| 2117 |
}
|
| 2118 |
}
|
| 2119 |
+
$count = count($gprices);
|
| 2120 |
+
if ($count > 0) {
|
| 2121 |
+
if (!isset($prodFinalPrice)) {
|
| 2122 |
$prodFinalPrice = $this->includetaxes ?
|
| 2123 |
+
$this->taxhelper->getPrice($product, $product->getData('price'), true, null, null, null, $this->StoreId) :
|
| 2124 |
+
$product->getData('price');
|
| 2125 |
+
if ($this->_DEBUG) {
|
| 2126 |
+
$this->controller->getResponse()->appendBody("prodFinalPrice: " . $prodFinalPrice . "
|
| 2127 |
+
");
|
| 2128 |
+
}
|
| 2129 |
}
|
| 2130 |
+
$res = '[TierPriceTable_' . $gname . ']#$$#' . $this->quantitylabel . '#$#' . $this->pricelabel . '#$#' . $this->savingslabel . "=";
|
| 2131 |
+
$i = 1;
|
| 2132 |
+
foreach ($gprices as $price) {
|
| 2133 |
$price['price_qty'] = $price['price_qty'] * 1;
|
| 2134 |
$tierPrice = $this->includetaxes ?
|
| 2135 |
+
$this->taxhelper->getPrice($product, $price['price'], true, null, null, null, $this->StoreId) :
|
| 2136 |
+
$price['price'];
|
| 2137 |
+
if ($tierPrice < $prodFinalPrice) {
|
| 2138 |
+
$tierPrice = $this->_formatPrice("" . $tierPrice);
|
| 2139 |
+
$rightstr .= $price['price_qty'] . '#$#';
|
| 2140 |
+
$rightstr.=$tierPrice . '#$#';
|
| 2141 |
+
if ($i == $count) {
|
| 2142 |
+
$rightstr .= ceil(100 - (( 100 / $prodFinalPrice ) * $tierPrice )) . '%';
|
| 2143 |
+
} else {
|
| 2144 |
+
$rightstr .= ceil(100 - (( 100 / $prodFinalPrice ) * $tierPrice )) . '%#$$#';
|
| 2145 |
+
}
|
| 2146 |
}
|
| 2147 |
$i++;
|
| 2148 |
}
|
| 2149 |
}
|
| 2150 |
+
if (!empty($rightstr)) {
|
| 2151 |
+
$pairs[] = $res . $rightstr;
|
| 2152 |
}
|
| 2153 |
}
|
| 2154 |
+
return count($pairs) > 0 ? implode("|", $pairs) : FALSE;
|
| 2155 |
+
} else
|
| 2156 |
+
return $res . $rightstr;
|
| 2157 |
}
|
| 2158 |
|
| 2159 |
// Class=CatalogSection
|
| 2160 |
+
public function renderCatalogSection() {
|
| 2161 |
$categories = Mage::getModel('catalog/category')
|
| 2162 |
+
->setStoreId($this->StoreId)
|
| 2163 |
+
->getCollection()
|
| 2164 |
+
->addAttributeToSelect('name')
|
| 2165 |
+
->addAttributeToFilter('level', array('eq' => 2))
|
| 2166 |
+
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2167 |
+
->addAttributeToSort('position', 'asc');
|
| 2168 |
+
$i = 1;
|
| 2169 |
+
$count = count($categories);
|
| 2170 |
+
if ($this->_DEBUG) {
|
| 2171 |
+
$this->controller->getResponse()->appendBody("StoreId: " . $this->StoreId . " Top categories: " . $count . "
|
| 2172 |
+
");
|
| 2173 |
+
}
|
| 2174 |
+
$this->controller->getResponse()->appendBody("sec_Project\tsec_Sequence\tsec_HierarchyPath\tsec_Flag\n");
|
| 2175 |
+
if ($count > 0) {
|
| 2176 |
+
if ($this->ignoretopcategory) {
|
| 2177 |
+
foreach ($categories as $topcategory) {
|
| 2178 |
$children = $topcategory->getCollection();
|
| 2179 |
+
$children->setStoreId($this->StoreId)
|
| 2180 |
->addAttributeToSelect('name')
|
| 2181 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2182 |
->addAttributeToSort('position', 'asc')
|
| 2183 |
->addIdFilter($topcategory->getChildren())
|
| 2184 |
+
->load();
|
| 2185 |
+
foreach ($children as $category) {
|
| 2186 |
$name = $category->getName();
|
| 2187 |
$id = $category->getId();
|
| 2188 |
+
$this->controller->getResponse()->appendBody($this->_drawCategory($category, 1, $name, $i));
|
| 2189 |
$i++;
|
| 2190 |
}
|
| 2191 |
}
|
| 2192 |
+
} else {
|
| 2193 |
+
foreach ($categories as $category) {
|
| 2194 |
$name = $category->getName();
|
| 2195 |
$id = $category->getId();
|
| 2196 |
+
$this->controller->getResponse()->appendBody($this->_drawCategory($category, 1, $name, $i));
|
| 2197 |
$i++;
|
| 2198 |
}
|
| 2199 |
}
|
| 2200 |
}
|
| 2201 |
$lastId = $i;
|
| 2202 |
+
$this->controller->getResponse()->appendBody("General\t" . $lastId . "\tUncategorized\t
|
| 2203 |
+
");
|
| 2204 |
+
$this->controller->getResponse()->appendBody("==EOF==");
|
| 2205 |
}
|
| 2206 |
|
| 2207 |
+
private function _drawCategory(&$category, $level = 0, $hpath = '', $i = 1, $j = 1, $path = '') {
|
| 2208 |
$html = "";
|
| 2209 |
$children = $category->getCollection();
|
| 2210 |
+
$children->setStoreId($this->StoreId)
|
| 2211 |
->addAttributeToSelect('name')
|
| 2212 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2213 |
->addAttributeToSort('position', 'asc')
|
| 2214 |
->addIdFilter($category->getChildren())
|
| 2215 |
+
->load();
|
|
|
|
| 2216 |
$sec_path = "";
|
| 2217 |
+
if ($level != 1) {
|
| 2218 |
$path .= '-' . $j;
|
| 2219 |
+
$hpath = $hpath . '#$#' . $category->getName(); //.' '.$i.$path;
|
| 2220 |
+
$sec_path .= str_replace("-", ",", $path);
|
| 2221 |
+
$seq = $i . $sec_path;
|
| 2222 |
+
} else {
|
| 2223 |
$hpath = $category->getName(); //.' '.$i;
|
| 2224 |
$seq = $i;
|
| 2225 |
}
|
| 2226 |
+
$html = "General\t" . $seq . "\t" . $hpath . "\t\n";
|
| 2227 |
$htmlChildren = "";
|
| 2228 |
+
if (count($children)) {
|
| 2229 |
$j = 1;
|
| 2230 |
+
foreach ($children as $cat) {
|
| 2231 |
+
$htmlChildren .= $this->_drawCategory($cat, $level + 1, $hpath, $i, $j, $path);
|
| 2232 |
$j++;
|
| 2233 |
}
|
| 2234 |
}
|
| 2235 |
+
unset($children);
|
| 2236 |
return $html .= $htmlChildren;
|
| 2237 |
}
|
| 2238 |
|
| 2239 |
// Class=CatalogProject
|
| 2240 |
+
public function renderCatalogProject() {
|
| 2241 |
+
if ($this->splitgroupedproducts) {
|
| 2242 |
$this->productTypeGroupedModel = Mage::getModel('catalog/product_type_grouped');
|
| 2243 |
}
|
| 2244 |
$this->productTypeConfigurableModel = Mage::getModel('catalog/product_type_configurable');
|
| 2245 |
+
$this->storeSorting = Mage::getSingleton('catalog/config')->getProductListDefaultSortBy($this->StoreId);
|
| 2246 |
$categories = Mage::getModel('catalog/category')
|
| 2247 |
+
->setStoreId($this->StoreId)
|
| 2248 |
+
->getCollection()
|
| 2249 |
+
->addAttributeToSelect('name')
|
| 2250 |
+
->addAttributeToSelect('default_sort_by')
|
| 2251 |
+
->addAttributeToFilter('level', array('eq' => 2))
|
| 2252 |
+
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2253 |
+
->addAttributeToSort('position', 'asc');
|
| 2254 |
+
$count = count($categories);
|
| 2255 |
+
if ($this->_DEBUG) {
|
| 2256 |
+
$this->controller->getResponse()->appendBody("StoreId: " . $this->StoreId . " Top categories: " . $count . "
|
| 2257 |
+
");
|
| 2258 |
+
}
|
| 2259 |
+
if ($count > 0) {
|
| 2260 |
$hpath = "";
|
| 2261 |
+
if ($this->ignoretopcategory) {
|
| 2262 |
+
foreach ($categories as $topcategory) {
|
| 2263 |
+
if ($this->_DEBUG) {
|
| 2264 |
+
$this->controller->getResponse()->appendBody("Category: " . $topcategory->getName() . "
|
| 2265 |
+
");
|
| 2266 |
+
$this->controller->getResponse()->appendBody("DefaultSortBy: " . $topcategory->getDefaultSortBy() . "
|
| 2267 |
+
");
|
| 2268 |
+
}
|
| 2269 |
$children = $topcategory->getCollection();
|
| 2270 |
+
$children->setStoreId($this->StoreId)
|
| 2271 |
->addAttributeToSelect('name')
|
| 2272 |
+
->addAttributeToSelect('default_sort_by')
|
| 2273 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2274 |
->addAttributeToSort('position', 'asc')
|
| 2275 |
->addIdFilter($topcategory->getChildren())
|
| 2276 |
+
->load();
|
| 2277 |
+
foreach ($children as $category) {
|
| 2278 |
+
if ($this->_DEBUG) {
|
| 2279 |
+
$this->controller->getResponse()->appendBody("Category: " . $category->getName()
|
| 2280 |
+
. " sortBy: " . $category->_getData('default_sort_by')
|
| 2281 |
+
. " storeSortBy: " . Mage::getSingleton('catalog/config')->getProductListDefaultSortBy($this->StoreId)
|
| 2282 |
+
. " resulting DefaultSortBy: " . $category->getDefaultSortBy()
|
| 2283 |
+
. "
|
| 2284 |
+
");
|
| 2285 |
+
}
|
| 2286 |
+
$this->catmap[$category->getId()] = $category;
|
| 2287 |
+
$this->_processCategory($category, 1, $hpath);
|
| 2288 |
}
|
| 2289 |
}
|
| 2290 |
+
} else {
|
| 2291 |
+
foreach ($categories as $category) {
|
| 2292 |
+
if ($this->_DEBUG) {
|
| 2293 |
+
$this->controller->getResponse()->appendBody("Category: " . $category->getName()
|
| 2294 |
+
. " sortBy: " . $category->_getData('default_sort_by')
|
| 2295 |
+
. " storeSortBy: " . Mage::getSingleton('catalog/config')->getProductListDefaultSortBy($this->StoreId)
|
| 2296 |
+
. " resulting DefaultSortBy: " . $category->getDefaultSortBy()
|
| 2297 |
+
. "
|
| 2298 |
+
");
|
| 2299 |
+
}
|
| 2300 |
+
$this->catmap[$category->getId()] = $category;
|
| 2301 |
+
$this->_processCategory($category, 1, $hpath);
|
| 2302 |
}
|
| 2303 |
}
|
| 2304 |
}
|
| 2305 |
$this->unCatPosition = 1;
|
| 2306 |
+
if ($this->start == 0) {
|
| 2307 |
+
$this->controller->getResponse()->appendBody("proj_Key\tproj_ProdName\tproj_Sequence\tproj_Name\tproj_HierarchyPath\tproj_Flag\tproj_ProdLayout
|
| 2308 |
+
");
|
| 2309 |
+
}
|
| 2310 |
+
$products = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->getCollection();
|
| 2311 |
+
$products->addAttributeToFilter('status', 1); //enabled
|
| 2312 |
+
$products->addAttributeToFilter('visibility', 4); //catalog, search
|
| 2313 |
+
$prodIds = $this->_DEBUG ? $products->getAllIds(1000, 0) : $products->getAllIds();
|
| 2314 |
+
if ($this->_DEBUG) {
|
| 2315 |
+
$this->controller->getResponse()->appendBody("StoreId: " . $this->StoreId . " Products: " . count($prodIds) . "
|
| 2316 |
+
");
|
| 2317 |
+
}
|
| 2318 |
$count = 0;
|
| 2319 |
$index = 0;
|
| 2320 |
$lastLine = "==EOF==
|
| 2321 |
";
|
| 2322 |
+
foreach ($prodIds as $productId) {
|
| 2323 |
+
if ($count == $this->pageSize) {
|
| 2324 |
$lastLine = "==MORE==
|
| 2325 |
";
|
| 2326 |
break;
|
| 2327 |
}
|
| 2328 |
+
if ($index < $this->start) {
|
| 2329 |
$index++;
|
| 2330 |
continue;
|
| 2331 |
}
|
| 2332 |
$index++;
|
| 2333 |
+
$product = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->load($productId);
|
| 2334 |
+
if ($product->isConfigurable()) {
|
| 2335 |
+
$this->controller->getResponse()->appendBody($this->CatalogProjectStringConfigurable($product));
|
| 2336 |
+
} else if ($product->isGrouped() && $this->splitgroupedproducts) {
|
| 2337 |
+
$this->controller->getResponse()->appendBody($this->CatalogProjectStringGroupedAsSimple($product));
|
| 2338 |
} else {
|
| 2339 |
+
$this->controller->getResponse()->appendBody($this->CatalogProjectStringGroupedOrSimple($product));
|
| 2340 |
+
}
|
| 2341 |
+
unset($product);
|
| 2342 |
+
if ($this->_DEBUG) {
|
| 2343 |
+
$this->controller->getResponse()->appendBody("#" . $count . ": memory_get_usage " . memory_get_usage() . " / " . memory_get_usage(TRUE) . "
|
| 2344 |
+
");
|
| 2345 |
}
|
|
|
|
|
|
|
|
|
|
| 2346 |
$count++;
|
| 2347 |
}
|
| 2348 |
+
$this->controller->getResponse()->appendBody($lastLine);
|
| 2349 |
}
|
| 2350 |
|
| 2351 |
+
private function _processCategory(&$category, $level = 0, $hpath = '', $path = '') {
|
| 2352 |
+
$hpath = $level != 1 ? $hpath . '#$#' . $category->getName() : $hpath = $category->getName();
|
| 2353 |
+
$this->catpathmap[$category->getId()] = $hpath;
|
| 2354 |
+
if ($this->_DEBUG) {
|
| 2355 |
+
$this->controller->getResponse()->appendBody("Category: " . $category->getId() . " path=" . $hpath . "
|
| 2356 |
+
");
|
| 2357 |
+
}
|
| 2358 |
$children = $category->getCollection();
|
| 2359 |
+
$children->setStoreId($this->StoreId)
|
| 2360 |
->addAttributeToSelect('name')
|
| 2361 |
+
->addAttributeToSelect('default_sort_by')
|
| 2362 |
->addAttributeToFilter('is_active', array('eq' => 1))
|
| 2363 |
->addAttributeToSort('position', 'asc')
|
| 2364 |
->addIdFilter($category->getChildren())
|
| 2365 |
+
->load();
|
| 2366 |
$htmlChildren = "";
|
| 2367 |
+
if (count($children)) {
|
| 2368 |
+
foreach ($children as $childcategory) {
|
| 2369 |
+
if ($this->_DEBUG) {
|
| 2370 |
+
$this->controller->getResponse()->appendBody("Category: " . $childcategory->getName()
|
| 2371 |
+
. " sortBy: " . $childcategory->_getData('default_sort_by')
|
| 2372 |
+
. " storeSortBy: " . Mage::getSingleton('catalog/config')->getProductListDefaultSortBy($this->StoreId)
|
| 2373 |
+
. " resulting DefaultSortBy: " . $childcategory->getDefaultSortBy()
|
| 2374 |
+
. "
|
| 2375 |
+
");
|
| 2376 |
+
}
|
| 2377 |
+
$this->catmap[$childcategory->getId()] = $childcategory;
|
| 2378 |
+
$htmlChildren .= $this->_processCategory($childcategory, $level + 1, $hpath, $path);
|
| 2379 |
+
}
|
| 2380 |
+
}
|
| 2381 |
}
|
| 2382 |
|
| 2383 |
+
private function CatalogProjectStringGroupedOrSimple(&$product) {
|
| 2384 |
$ProducttoString = "";
|
| 2385 |
$categoryIds = $product->getCategoryIds();
|
| 2386 |
$listed = FALSE;
|
| 2387 |
+
if ($categoryIds) {
|
| 2388 |
+
foreach ($categoryIds as $k => $category_id) {
|
| 2389 |
+
if (!isset($this->catmap[$category_id])) {
|
| 2390 |
+
if ($this->_DEBUG) {
|
| 2391 |
+
$this->controller->getResponse()->appendBody("No category: " . $category_id . "
|
| 2392 |
+
");
|
| 2393 |
+
}
|
| 2394 |
continue;
|
| 2395 |
}
|
| 2396 |
+
$category = $this->catmap[$category_id];
|
| 2397 |
+
$hpath = $this->catpathmap[$category_id];
|
| 2398 |
$position = "";
|
| 2399 |
$positions = $category->getProductsPosition();
|
| 2400 |
+
if (count($positions) > 0) {
|
| 2401 |
+
$position = $positions[$product->getId()];
|
| 2402 |
+
}
|
| 2403 |
+
$productName = $this->_cleanStr($product->getName());
|
| 2404 |
+
$categorySorting = $category->getDefaultSortBy();
|
| 2405 |
+
$productSortValue = $this->CatalogProjectSortValue($product, $productName, $categorySorting);
|
| 2406 |
+
$ProducttoString .= $product->getId() . '#$#' . $productName //ProductKey
|
| 2407 |
+
. "\t" . $product->getId() . '#$#' . $productName //Product Name
|
| 2408 |
+
. "\t" . $position //Prod Sequence
|
| 2409 |
+
. "\tGeneral" //Proj Name
|
| 2410 |
+
. "\t" . $hpath //Hirarachi Path
|
| 2411 |
+
. "\t" . $categorySorting //Proj Flag
|
| 2412 |
+
. "\t" . $productSortValue//Proj Prod layout
|
| 2413 |
+
. "\n";
|
| 2414 |
+
if ($this->_DEBUG) {
|
| 2415 |
+
$this->controller->getResponse()->appendBody("Product #" . $product->getId() . ": position=" . $position . " price=" . $product->getData('price') . "
|
| 2416 |
+
");
|
| 2417 |
+
}
|
| 2418 |
$listed = TRUE;
|
| 2419 |
}
|
| 2420 |
}
|
| 2421 |
+
if (!$listed) {
|
| 2422 |
+
$productName = $this->_cleanStr($product->getName());
|
| 2423 |
+
$productSortValue = $this->CatalogProjectSortValue($product, $productName, $this->storeSorting);
|
| 2424 |
+
$ProducttoString .= $product->getId() . '#$#' . $productName //ProductKey
|
| 2425 |
+
. "\t" . $product->getId() . '#$#' . $productName //Product Name
|
| 2426 |
+
. "\t" . $this->unCatPosition //Prod Sequence
|
| 2427 |
+
. "\tGeneral" //Proj Name
|
| 2428 |
+
. "\tUncategorized" //Hirarachi Path
|
| 2429 |
+
. "\t" . $this->storeSorting //Proj Flag
|
| 2430 |
+
. "\t" . $productSortValue//Proj Prod layout
|
| 2431 |
+
. "\n";
|
| 2432 |
$this->unCatPosition++;
|
| 2433 |
}
|
| 2434 |
return $ProducttoString;
|
| 2435 |
}
|
| 2436 |
|
| 2437 |
+
private function CatalogProjectStringGroupedAsSimple(&$product) {
|
| 2438 |
+
$AssociatedProductIds = $this->productTypeGroupedModel->getAssociatedProductIds($product);
|
| 2439 |
+
$AssociatedProducts = array();
|
| 2440 |
+
foreach ($AssociatedProductIds as $UsedProductid) {
|
| 2441 |
+
$UsedProduct = Mage::getModel('catalog/product')->setStoreId($this->StoreId)->load($UsedProductid);
|
| 2442 |
+
if ($UsedProduct->getStatus() == 1) {
|
| 2443 |
+
$AssociatedProducts[] = $UsedProduct;
|
| 2444 |
+
} else {
|
| 2445 |
+
if ($this->_DEBUG) {
|
| 2446 |
+
$this->controller->getResponse()->appendBody("sku=" . $UsedProduct->getSku() . " enabled=" . $UsedProduct->getStatus() . " - bypassed.
|
| 2447 |
+
");
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2448 |
}
|
| 2449 |
+
unset($UsedProduct);
|
| 2450 |
}
|
| 2451 |
+
}
|
| 2452 |
+
$ProducttoString = "";
|
| 2453 |
+
if (count($AssociatedProducts) == 0) {
|
| 2454 |
+
return $ProducttoString;
|
| 2455 |
+
}
|
| 2456 |
+
$listed = FALSE;
|
| 2457 |
+
$categoryIds = $product->getCategoryIds();
|
| 2458 |
+
if ($categoryIds) {
|
| 2459 |
+
foreach ($categoryIds as $k => $category_id) {
|
| 2460 |
+
if (!isset($this->catmap[$category_id])) {
|
| 2461 |
+
if ($this->_DEBUG) {
|
| 2462 |
+
$this->controller->getResponse()->appendBody("No category: " . $category_id . "
|
| 2463 |
+
");
|
| 2464 |
+
}
|
| 2465 |
continue;
|
| 2466 |
}
|
| 2467 |
+
$category = $this->catmap[$category_id];
|
| 2468 |
+
$hpath = $this->catpathmap[$category_id];
|
| 2469 |
$position = "";
|
| 2470 |
$positions = $category->getProductsPosition();
|
| 2471 |
+
if (count($positions) > 0) {
|
| 2472 |
+
$position = $positions[$product->getId()];
|
| 2473 |
+
}
|
| 2474 |
+
$categorySorting = $category->getDefaultSortBy();
|
| 2475 |
+
foreach ($AssociatedProducts as $UsedProduct) {
|
| 2476 |
+
$productName = $this->_cleanStr($UsedProduct->getName());
|
| 2477 |
+
$productSortValue = $this->CatalogProjectSortValue($UsedProduct, $productName, $categorySorting);
|
| 2478 |
+
$ProducttoString .= $UsedProduct->getId() . '#$#' . $productName //ProductKey
|
| 2479 |
+
. "\t" . $UsedProduct->getId() . '#$#' . $productName //Product Name
|
| 2480 |
+
. "\t" . $position //Prod Sequence
|
| 2481 |
+
. "\tGeneral" //Proj Name
|
| 2482 |
+
. "\t" . $hpath //Hirarachi Path
|
| 2483 |
+
. "\t" . $categorySorting //Proj Flag
|
| 2484 |
+
. "\t" . $productSortValue//Proj Prod layout
|
| 2485 |
+
. "\n";
|
| 2486 |
$position += 0.001;
|
| 2487 |
}
|
| 2488 |
$listed = TRUE;
|
| 2489 |
}
|
| 2490 |
}
|
| 2491 |
+
if (!$listed) {
|
| 2492 |
+
foreach ($AssociatedProducts as $UsedProduct) {
|
| 2493 |
+
$productName = $this->_cleanStr($UsedProduct->getName());
|
| 2494 |
+
$productSortValue = $this->CatalogProjectSortValue($UsedProduct, $productName, $this->storeSorting);
|
| 2495 |
+
$ProducttoString .= $UsedProduct->getId() . '#$#' . $productName //ProductKey
|
| 2496 |
+
. "\t" . $UsedProduct->getId() . '#$#' . $productName //Product Name
|
| 2497 |
+
. "\t" . $this->unCatPosition //Prod Sequence
|
| 2498 |
+
. "\tGeneral" //Proj Name
|
| 2499 |
+
. "\tUncategorized" //Hirarachi Path
|
| 2500 |
+
. "\t" . $this->storeSorting //Proj Flag
|
| 2501 |
+
. "\t" . $productSortValue //Proj Prod layout
|
| 2502 |
+
. "\n";
|
| 2503 |
$this->unCatPosition++;
|
| 2504 |
}
|
| 2505 |
}
|
| 2506 |
+
foreach ($AssociatedProducts as $UsedProduct) {
|
| 2507 |
+
unset($UsedProduct);
|
| 2508 |
+
}
|
| 2509 |
return $ProducttoString;
|
| 2510 |
}
|
| 2511 |
|
| 2512 |
+
private function CatalogProjectStringConfigurable(&$product) {
|
| 2513 |
$UsedProductIds = $this->productTypeConfigurableModel->getUsedProductIds($product);
|
| 2514 |
+
$countUsedProductIds = count($UsedProductIds);
|
| 2515 |
+
if ($countUsedProductIds > 0) {
|
| 2516 |
$listed = FALSE;
|
| 2517 |
$ProducttoString = "";
|
| 2518 |
$categoryIds = $product->getCategoryIds();
|
| 2519 |
+
if ($categoryIds) {
|
| 2520 |
+
foreach ($categoryIds as $k => $category_id) {
|
| 2521 |
+
if (!isset($this->catmap[$category_id])) {
|
| 2522 |
+
if ($this->_DEBUG) {
|
| 2523 |
+
$this->controller->getResponse()->appendBody("No category: " . $category_id . "
|
| 2524 |
+
");
|
| 2525 |
+
}
|
| 2526 |
continue;
|
| 2527 |
}
|
| 2528 |
+
$category = $this->catmap[$category_id];
|
| 2529 |
+
$hpath = $this->catpathmap[$category_id];
|
| 2530 |
$position = "";
|
| 2531 |
$positions = $category->getProductsPosition();
|
| 2532 |
+
if (count($positions) > 0) {
|
| 2533 |
+
$position = $positions[$product->getId()];
|
| 2534 |
+
}
|
| 2535 |
+
$productName = $this->_cleanStr($product->getName());
|
| 2536 |
+
$categorySorting = $category->getDefaultSortBy();
|
| 2537 |
+
$productSortValue = $this->CatalogProjectSortValue($product, $productName, $categorySorting);
|
| 2538 |
+
$ProducttoString .= $product->getId() . '#$#' . $productName //ProductKey
|
| 2539 |
+
. "\t" . $product->getId() . '#$#' . $productName //Product Name
|
| 2540 |
+
. "\t" . $position //Prod Sequence
|
| 2541 |
+
. "\tGeneral" //Proj Name
|
| 2542 |
+
. "\t" . $hpath //Hirarachi Path
|
| 2543 |
+
. "\t" . $categorySorting //Proj Flag
|
| 2544 |
+
. "\t" . $productSortValue//Proj Prod layout
|
| 2545 |
+
. "\n";
|
| 2546 |
+
$listed = TRUE;
|
| 2547 |
+
}
|
| 2548 |
+
}
|
| 2549 |
+
if (!$listed) {
|
| 2550 |
+
$productName = $this->_cleanStr($product->getName());
|
| 2551 |
+
$productSortValue = $this->CatalogProjectSortValue($product, $productName, $this->storeSorting);
|
| 2552 |
+
$ProducttoString .= $product->getId() . '#$#' . $productName //ProductKey
|
| 2553 |
+
. "\t" . $product->getId() . '#$#' . $productName //Product Name
|
| 2554 |
+
. "\t" . $this->unCatPosition //Prod Sequence
|
| 2555 |
. "\tGeneral" //Proj Name
|
| 2556 |
+
. "\tUncategorized" //Hirarachi Path
|
| 2557 |
+
. "\t" . $this->storeSorting //Proj Flag
|
| 2558 |
+
. "\t" . $productSortValue//Proj Prod layout
|
| 2559 |
. "\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2560 |
$this->unCatPosition++;
|
| 2561 |
+
}
|
| 2562 |
+
} else {
|
| 2563 |
$ProducttoString = "";
|
| 2564 |
+
}
|
| 2565 |
+
unset($UsedProductIds);
|
| 2566 |
return $ProducttoString;
|
| 2567 |
}
|
| 2568 |
+
|
| 2569 |
+
private function CatalogProjectSortValue(&$product, &$productName, &$categorySorting) {
|
| 2570 |
+
$productSortValue = false;
|
| 2571 |
+
if ("position" == $categorySorting) {
|
| 2572 |
+
$productSortValue = strtolower(trim($productName));
|
| 2573 |
+
} else if ("name" == $categorySorting) {
|
| 2574 |
+
$productSortValue = strtolower(trim($productName));
|
| 2575 |
+
} else if ("price" == $categorySorting) {
|
| 2576 |
+
$ProdRPrice = $product->getData('price');
|
| 2577 |
+
if (!$ProdRPrice && $product->getTypeId() == "bundle") {
|
| 2578 |
+
$priceModel = $product->getPriceModel();
|
| 2579 |
+
$options = Mage::getSingleton('core/layout')->createBlock('bundle/catalog_product_view_type_bundle')->setProduct($product)->getOptions();
|
| 2580 |
+
$ProdRPrice = 0;
|
| 2581 |
+
foreach ($options as $option) {
|
| 2582 |
+
$selection = $option->getDefaultSelection();
|
| 2583 |
+
$MinSelPrice = 0;
|
| 2584 |
+
if ($selection) {
|
| 2585 |
+
$MinSelPrice = $priceModel->getSelectionPreFinalPrice($product, $selection, $selection->getSelectionQty());
|
| 2586 |
+
} else if (!$selection && $option->_origData["required"] == "1") {
|
| 2587 |
+
foreach ($option->getSelections() as $selection) {
|
| 2588 |
+
$SelPrice = $priceModel->getSelectionPreFinalPrice($product, $selection, $selection->getSelectionQty());
|
| 2589 |
+
if (( $MinSelPrice == 0 && $SelPrice > 0 ) || ( $MinSelPrice > 0 && $SelPrice > 0 && $SelPrice < $MinSelPrice )) {
|
| 2590 |
+
$MinSelPrice = $SelPrice;
|
| 2591 |
+
}
|
| 2592 |
+
}
|
| 2593 |
+
}
|
| 2594 |
+
if ($MinSelPrice <= 0) {
|
| 2595 |
+
continue;
|
| 2596 |
+
}
|
| 2597 |
+
if ($this->_DEBUG) {
|
| 2598 |
+
$this->controller->getResponse()->appendBody("added " . $MinSelPrice . "
|
| 2599 |
+
");
|
| 2600 |
+
}
|
| 2601 |
+
$ProdRPrice += $MinSelPrice;
|
| 2602 |
+
}
|
| 2603 |
+
if ($this->_DEBUG) {
|
| 2604 |
+
$this->controller->getResponse()->appendBody("Bundle=" . $ProdRPrice . "
|
| 2605 |
+
");
|
| 2606 |
+
}
|
| 2607 |
+
}
|
| 2608 |
+
if (!$ProdRPrice) {
|
| 2609 |
+
$ProdRPrice = "0.0";
|
| 2610 |
+
}
|
| 2611 |
+
$productSortValue = $ProdRPrice;
|
| 2612 |
+
}
|
| 2613 |
+
return $productSortValue;
|
| 2614 |
+
}
|
| 2615 |
+
|
| 2616 |
+
}
|
| 2617 |
+
|
| 2618 |
+
// Mage_CodiScript_Model_Files
|
app/code/community/Mage/CodiScript/controllers/IndexController.php
CHANGED
|
@@ -1,365 +1,439 @@
|
|
| 1 |
<?php
|
| 2 |
-
define("__VERSION__","2015-07-09");
|
| 3 |
-
define("__SCRIPTNAME__",basename(__FILE__));
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
// Headers
|
| 14 |
-
$gmdate_mod = gmdate('D, d M Y H:i:s', time()).' GMT';
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
// Enable errors display / list versions
|
| 20 |
-
ini_set('display_errors', '1');
|
| 21 |
-
ini_set('error_reporting', E_ALL);
|
| 22 |
-
ini_set('html_errors', '0');
|
| 23 |
-
ini_set('xmlrpc_errors', '0');
|
| 24 |
-
ini_set('error_prepend_string', "");
|
| 25 |
-
ini_set('error_append_string', "");
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
"
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
// Set an error handler for warnings and notices.
|
| 32 |
-
set_error_handler('myErrorHandler');
|
| 33 |
-
if(
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
Magento version: ".Mage::getVersion()."
|
| 37 |
-
Script version: ".__VERSION__."
|
| 38 |
--------------------------------------------------------------------------------
|
| 39 |
-
";
|
| 40 |
-
}
|
| 41 |
-
if(
|
| 42 |
-
|
| 43 |
-
"
|
| 44 |
-
|
|
|
|
| 45 |
// Check if a password is defined
|
| 46 |
-
if(
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
// Check the password
|
| 49 |
-
if(
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
$includecustomfields
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
-
}
|
| 81 |
-
$importoptionsasattributes = ( isset( $_REQUEST["importoptionsasattributes"] ) && $_REQUEST["importoptionsasattributes"] == "1" );
|
| 82 |
-
$importoptionsassku = ( isset($_REQUEST["importoptionsassku"]) && $_REQUEST["importoptionsassku"] == "1" );
|
| 83 |
-
$instockonly = isset($_REQUEST["instockonly"])? trim( $_REQUEST["instockonly"] ) : FALSE;
|
| 84 |
-
$splitgroupedproducts = isset($_REQUEST["splitgroupedproducts"])? trim( $_REQUEST["splitgroupedproducts"] ) : FALSE;
|
| 85 |
-
$start = isset( $_REQUEST["start"] ) ? intval( $_REQUEST["start"] ) : 0;
|
| 86 |
-
$pageSize = isset( $_REQUEST["pageSize"] ) ? intval( $_REQUEST["pageSize"] ) : 1000000000;
|
| 87 |
-
if( $_DEBUG ) echo "enablereviews=".$enablereviews."
|
| 88 |
-
ignoretopcategory=".$ignoretopcategory."
|
| 89 |
-
includeshortdescription=".$includeshortdescription."
|
| 90 |
-
includelongdescription=".$includelongdescription."
|
| 91 |
-
getpricefromchild=".$getpricefromchild."
|
| 92 |
-
getgroupprices=".$getgroupprices."
|
| 93 |
-
publishtieredpricing=".$publishtieredpricing."
|
| 94 |
-
quantitylabel=".$quantitylabel."
|
| 95 |
-
pricelabel=".$pricelabel."
|
| 96 |
-
savingslabel=".$savingslabel."
|
| 97 |
-
includetaxes=".$includetaxes."
|
| 98 |
-
includeinvqty=".$includeinvqty."
|
| 99 |
-
includespecialprice=".$includespecialprice."
|
| 100 |
-
includespecialpricedatefrom=".$includespecialpricedatefrom."
|
| 101 |
-
includespecialpricedateto=".$includespecialpricedateto."
|
| 102 |
-
ignoreexcludedimages=".$ignoreexcludedimages."
|
| 103 |
-
ignoreassprodimages=".$ignoreassprodimages."
|
| 104 |
-
includecustomfields=".( $includecustomfields ? implode( ",", array_keys( $includecustomfields ) ) : $includecustomfields )."
|
| 105 |
-
importoptionsasattributes=".$importoptionsasattributes."
|
| 106 |
-
importoptionsassku=".$importoptionsassku."
|
| 107 |
-
instockonly=".$instockonly."
|
| 108 |
-
splitgroupedproducts=".$splitgroupedproducts."
|
| 109 |
-
start=".$start."
|
| 110 |
-
pageSize=".$pageSize."
|
| 111 |
-
";
|
| 112 |
-
} else if( $Class=="CatalogSection" ){
|
| 113 |
-
$ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
|
| 114 |
-
if($_DEBUG) echo "ignoretopcategory=".$ignoretopcategory."
|
| 115 |
-
";
|
| 116 |
-
} else if( $Class=="CatalogProject" ){
|
| 117 |
-
$ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
|
| 118 |
-
$instockonly = isset($_REQUEST["instockonly"])? trim( $_REQUEST["instockonly"] ) : FALSE;
|
| 119 |
-
$splitgroupedproducts = isset($_REQUEST["splitgroupedproducts"])? trim( $_REQUEST["splitgroupedproducts"] ) : FALSE;
|
| 120 |
-
$start = isset($_REQUEST["start"]) ? intval( $_REQUEST["start"] ) : 0;
|
| 121 |
-
$pageSize = isset($_REQUEST["pageSize"]) ? intval( $_REQUEST["pageSize"] ) : 1000000000;
|
| 122 |
-
if($_DEBUG) echo "ignoretopcategory=".$ignoretopcategory."
|
| 123 |
-
instockonly=".$instockonly."
|
| 124 |
-
start=".$start."
|
| 125 |
-
pageSize=".$pageSize."
|
| 126 |
-
";
|
| 127 |
-
}
|
| 128 |
// Increase memory limit to 1024M
|
| 129 |
-
ini_set('memory_limit','1024M');
|
| 130 |
// Increase maximum execution time to 6 hours
|
| 131 |
-
ini_set('max_execution_time',28800);
|
| 132 |
// Make sure GC is enabled
|
| 133 |
-
if(
|
| 134 |
-
|
| 135 |
-
else if($_DEBUG || $_INFO)
|
| 136 |
-
|
| 137 |
-
";
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
"
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
"
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
// Determine / check store
|
| 151 |
-
$StoreId = 0;
|
| 152 |
-
$Store = FALSE;
|
| 153 |
-
$Stores = Mage::app()->getStores(
|
| 154 |
-
if(
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
$count = 0;
|
| 163 |
-
foreach ( $Stores as $_Store )
|
| 164 |
-
if( $_Store->getIsActive() ){
|
| 165 |
-
$count++;
|
| 166 |
-
$Store = $_Store;
|
| 167 |
$StoreId = $Store->getId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
} else if(
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
$cfModel->
|
| 212 |
-
|
| 213 |
-
$cfModel->
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
"
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
"
|
| 227 |
-
|
| 228 |
-
"
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
"
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
"
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
*
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
}
|
|
|
|
| 365 |
}
|
| 1 |
<?php
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
define("__VERSION__", "2016-10-03");
|
| 4 |
+
define("__SCRIPTNAME__", basename(__FILE__));
|
| 5 |
+
|
| 6 |
+
class Mage_CodiScript_IndexController extends Mage_Core_Controller_Front_Action {
|
| 7 |
+
|
| 8 |
+
public function indexAction() {
|
| 9 |
+
//================== common code start ==================
|
| 10 |
+
//class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
|
| 11 |
+
// public function renderDataFile(){
|
| 12 |
+
// private function ProducttoStringGrouped( &$product ){
|
| 13 |
+
// private function ProducttoStringConfigurable( &$product ){
|
| 14 |
+
// private function ProducttoStringSimple( &$product ){
|
| 15 |
+
// private function _fillConfigProdItems
|
| 16 |
+
// private function _cleanStr( &$str ){
|
| 17 |
+
// private function _correctProdUrlStr( &$str ){
|
| 18 |
+
// private function _getReviews( $productid ){
|
| 19 |
+
// private function _formatPrice( $Price ){
|
| 20 |
+
// private function _formatQty( $qty ){
|
| 21 |
+
// private function _formatImageURL( $str ){
|
| 22 |
+
// private function _getTierPrices( &$product ){
|
| 23 |
+
// public function renderCatalogSection(){
|
| 24 |
+
// private function _drawCategory( &$category, $level=0, $hpath='', $i=1, $j=1, $path='' ){
|
| 25 |
+
// public function renderCatalogProject(){
|
| 26 |
+
// private function _processCategory( &$category, $level=0, $hpath='', $path='' ){
|
| 27 |
+
// private function CatalogProjectStringGroupedOrSimple(&$product) {
|
| 28 |
+
// private function CatalogProjectStringSimple( &$product ){
|
| 29 |
+
// private function CatalogProjectStringConfigurable( &$product ){
|
| 30 |
+
// private function CatalogProjectSortValue(&$product, &$productName, &$categorySorting) {$_DEBUG = $this->getRequest()->getParam("_DEBUG"]) ? $this->getRequest()->getParam("_DEBUG"] : "0";
|
| 31 |
+
$_DEBUG = $this->getRequest()->getParam("_DEBUG") ? $this->getRequest()->getParam("_DEBUG") : "0";
|
| 32 |
+
$_INFO = $this->getRequest()->getParam("_INFO") ? $this->getRequest()->getParam("_INFO") : "0";
|
| 33 |
+
$StoreCode = $this->getRequest()->getParam("Store") ? $this->getRequest()->getParam("Store") : FALSE;
|
| 34 |
+
$Class = $this->getRequest()->getParam("Class") ? $this->getRequest()->getParam("Class") : "";
|
| 35 |
+
$Password = $this->getRequest()->getParam("Password") ? $this->getRequest()->getParam("Password") : "";
|
| 36 |
// Headers
|
| 37 |
+
$gmdate_mod = gmdate('D, d M Y H:i:s', time()) . ' GMT';
|
| 38 |
+
$this->getResponse()->setHeader('Last-Modified: ' . $gmdate_mod);
|
| 39 |
+
$this->getResponse()->setHeader('Content-Type: text/plain; charset=UTF-8');
|
| 40 |
+
$this->getResponse()->setHeader('Content-Disposition: inline; filename="' . $Class . '.txt"');
|
| 41 |
+
$this->getResponse()->setHeader('X-CoDSoftware-Version: ' . __VERSION__);
|
| 42 |
// Enable errors display / list versions
|
| 43 |
+
ini_set('display_errors', '1');
|
| 44 |
+
ini_set('error_reporting', E_ALL);
|
| 45 |
+
ini_set('html_errors', '0');
|
| 46 |
+
ini_set('xmlrpc_errors', '0');
|
| 47 |
+
ini_set('error_prepend_string', "");
|
| 48 |
+
ini_set('error_append_string', "");
|
| 49 |
+
|
| 50 |
+
function myErrorHandler($errno, $errstr, $errfile, $errline) {
|
| 51 |
+
// $this->getResponse()->appendBody("WARNING: " . $errstr . " (line " . $errline . ")
|
| 52 |
+
//");
|
| 53 |
+
return true;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
// Set an error handler for warnings and notices.
|
| 57 |
+
set_error_handler('myErrorHandler');
|
| 58 |
+
if ($_DEBUG || $_INFO) {
|
| 59 |
+
$started_time = time();
|
| 60 |
+
$this->getResponse()->appendBody("PHP version: " . phpversion() . "
|
| 61 |
+
Magento version: " . Mage::getVersion() . "
|
| 62 |
+
Script version: " . __VERSION__ . "
|
| 63 |
--------------------------------------------------------------------------------
|
| 64 |
+
");
|
| 65 |
+
}
|
| 66 |
+
if ($_DEBUG)
|
| 67 |
+
$this->getResponse()->appendBody("Class=" . $Class . "
|
| 68 |
+
Password=" . $Password . "
|
| 69 |
+
");
|
| 70 |
+
$codiScriptPassword = Mage::helper('codiscript')->getCodiPassword();
|
| 71 |
// Check if a password is defined
|
| 72 |
+
if ($codiScriptPassword == '') {
|
| 73 |
+
$this->getResponse()->appendBody('ERROR: A blank password is not allowed. Edit the password at System > Configuration > Catalog-on-Demand Configuration.');
|
| 74 |
+
return;
|
| 75 |
+
}
|
| 76 |
// Check the password
|
| 77 |
+
if ($Password != $codiScriptPassword) {
|
| 78 |
+
$this->getResponse()->appendBody('ERROR: The specified password is invalid.');
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
if ($Class == "Configuration") {
|
| 82 |
+
// nothing special
|
| 83 |
+
} else if ($Class == "DataFile") {
|
| 84 |
+
$enablereviews = ( $this->getRequest()->getParam("enablereviews") && $this->getRequest()->getParam("enablereviews") == "1" );
|
| 85 |
+
$ignoretopcategory = ( $this->getRequest()->getParam("ignoretopcategory") && $this->getRequest()->getParam("ignoretopcategory") == "1" );
|
| 86 |
+
$includeshortdescription = ( $this->getRequest()->getParam("includeshortdescription") && $this->getRequest()->getParam("includeshortdescription") == "1" );
|
| 87 |
+
$includelongdescription = ( $this->getRequest()->getParam("includelongdescription") ? $this->getRequest()->getParam("includelongdescription") == "1" : TRUE );
|
| 88 |
+
$getpricefromchild = ( $this->getRequest()->getParam("getpricefromchild") ? $this->getRequest()->getParam("getpricefromchild") == "1" : TRUE );
|
| 89 |
+
$getgroupprices = ( $this->getRequest()->getParam("getgroupprices") && $this->getRequest()->getParam("getgroupprices") == "1" );
|
| 90 |
+
$publishtieredpricing = ( $this->getRequest()->getParam("publishtieredpricing") && $this->getRequest()->getParam("publishtieredpricing") == "1" );
|
| 91 |
+
$quantitylabel = $this->getRequest()->getParam("quantitylabel") ? $this->getRequest()->getParam("quantitylabel") : "Quantity";
|
| 92 |
+
$pricelabel = $this->getRequest()->getParam("pricelabel") ? $this->getRequest()->getParam("pricelabel") : "Price";
|
| 93 |
+
$savingslabel = $this->getRequest()->getParam("savingslabel") ? $this->getRequest()->getParam("savingslabel") : "Savings";
|
| 94 |
+
$includetaxes = ( $this->getRequest()->getParam("includetaxes") && $this->getRequest()->getParam("includetaxes") == "1" );
|
| 95 |
+
$includeinvqty = ( $this->getRequest()->getParam("includeinvqty") && $this->getRequest()->getParam("includeinvqty") == "1" );
|
| 96 |
+
$includespecialprice = ( $this->getRequest()->getParam("includespecialprice") && $this->getRequest()->getParam("includespecialprice") == "1" );
|
| 97 |
+
$includespecialpricedatefrom = ( $this->getRequest()->getParam("includespecialpricedatefrom") && $this->getRequest()->getParam("includespecialpricedatefrom") == "1" );
|
| 98 |
+
$includespecialpricedateto = ( $this->getRequest()->getParam("includespecialpricedateto") && $this->getRequest()->getParam("includespecialpricedateto") == "1" );
|
| 99 |
+
$ignoreexcludedimages = ( $this->getRequest()->getParam("ignoreexcludedimages") && $this->getRequest()->getParam("ignoreexcludedimages") == "1" );
|
| 100 |
+
$ignoreassprodimages = ( $this->getRequest()->getParam("ignoreassprodimages") && $this->getRequest()->getParam("ignoreassprodimages") == "1" );
|
| 101 |
+
$includecustomfields = $this->getRequest()->getParam("includecustomfields") ? trim($this->getRequest()->getParam("includecustomfields")) : FALSE;
|
| 102 |
+
if (empty($includecustomfields)) {
|
| 103 |
+
$includecustomfields = FALSE;
|
| 104 |
+
} else {
|
| 105 |
+
$arr = explode(",", $includecustomfields);
|
| 106 |
+
$includecustomfields = array();
|
| 107 |
+
foreach ($arr as $part) {
|
| 108 |
+
$part = trim($part);
|
| 109 |
+
if (!empty($part)) {
|
| 110 |
+
$includecustomfields[strtolower($part)] = TRUE;
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
$importoptionsasattributes = ( $this->getRequest()->getParam("importoptionsasattributes") && $this->getRequest()->getParam("importoptionsasattributes") == "1" );
|
| 115 |
+
$importoptionsassku = ( $this->getRequest()->getParam("importoptionsassku") && $this->getRequest()->getParam("importoptionsassku") == "1" );
|
| 116 |
+
$instockonly = ( $this->getRequest()->getParam("instockonly") && $this->getRequest()->getParam("instockonly") == "1" );
|
| 117 |
+
$splitgroupedproducts = ( $this->getRequest()->getParam("splitgroupedproducts") && $this->getRequest()->getParam("splitgroupedproducts") == "1");
|
| 118 |
+
$start = $this->getRequest()->getParam("start") ? intval($this->getRequest()->getParam("start")) : 0;
|
| 119 |
+
$pageSize = $this->getRequest()->getParam("pageSize") ? intval($this->getRequest()->getParam("pageSize")) : 1000000000;
|
| 120 |
+
if ($_DEBUG) {
|
| 121 |
+
$this->getResponse()->appendBody("enablereviews=" . $enablereviews . "
|
| 122 |
+
ignoretopcategory=" . $ignoretopcategory . "
|
| 123 |
+
includeshortdescription=" . $includeshortdescription . "
|
| 124 |
+
includelongdescription=" . $includelongdescription . "
|
| 125 |
+
getpricefromchild=" . $getpricefromchild . "
|
| 126 |
+
getgroupprices=" . $getgroupprices . "
|
| 127 |
+
publishtieredpricing=" . $publishtieredpricing . "
|
| 128 |
+
quantitylabel=" . $quantitylabel . "
|
| 129 |
+
pricelabel=" . $pricelabel . "
|
| 130 |
+
savingslabel=" . $savingslabel . "
|
| 131 |
+
includetaxes=" . $includetaxes . "
|
| 132 |
+
includeinvqty=" . $includeinvqty . "
|
| 133 |
+
includespecialprice=" . $includespecialprice . "
|
| 134 |
+
includespecialpricedatefrom=" . $includespecialpricedatefrom . "
|
| 135 |
+
includespecialpricedateto=" . $includespecialpricedateto . "
|
| 136 |
+
ignoreexcludedimages=" . $ignoreexcludedimages . "
|
| 137 |
+
ignoreassprodimages=" . $ignoreassprodimages . "
|
| 138 |
+
includecustomfields=" . ( $includecustomfields ? implode(",", array_keys($includecustomfields)) : $includecustomfields ) . "
|
| 139 |
+
importoptionsasattributes=" . $importoptionsasattributes . "
|
| 140 |
+
importoptionsassku=" . $importoptionsassku . "
|
| 141 |
+
instockonly=" . $instockonly . "
|
| 142 |
+
splitgroupedproducts=" . $splitgroupedproducts . "
|
| 143 |
+
start=" . $start . "
|
| 144 |
+
pageSize=" . $pageSize . "
|
| 145 |
+
");
|
| 146 |
+
}
|
| 147 |
+
} else if ($Class == "CatalogSection") {
|
| 148 |
+
$ignoretopcategory = ( $this->getRequest()->getParam("ignoretopcategory") && $this->getRequest()->getParam("ignoretopcategory") == "1" );
|
| 149 |
+
if ($_DEBUG) {
|
| 150 |
+
$this->getResponse()->appendBody("ignoretopcategory=" . $ignoretopcategory . "
|
| 151 |
+
");
|
| 152 |
+
}
|
| 153 |
+
} else if ($Class == "CatalogProject") {
|
| 154 |
+
$ignoretopcategory = ( $this->getRequest()->getParam("ignoretopcategory") && $this->getRequest()->getParam("ignoretopcategory") == "1" );
|
| 155 |
+
$instockonly = ( $this->getRequest()->getParam("instockonly") && $this->getRequest()->getParam("instockonly") == "1" );
|
| 156 |
+
$splitgroupedproducts = ( $this->getRequest()->getParam("splitgroupedproducts") && $this->getRequest()->getParam("splitgroupedproducts") == "1");
|
| 157 |
+
$start = $this->getRequest()->getParam("start") ? intval($this->getRequest()->getParam("start")) : 0;
|
| 158 |
+
$pageSize = $this->getRequest()->getParam("pageSize") ? intval($this->getRequest()->getParam("pageSize")) : 1000000000;
|
| 159 |
+
if ($_DEBUG) {
|
| 160 |
+
$this->getResponse()->appendBody("ignoretopcategory=" . $ignoretopcategory . "
|
| 161 |
+
instockonly=" . $instockonly . "
|
| 162 |
+
splitgroupedproducts=" . $splitgroupedproducts . "
|
| 163 |
+
start=" . $start . "
|
| 164 |
+
pageSize=" . $pageSize . "
|
| 165 |
+
");
|
| 166 |
+
}
|
| 167 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
// Increase memory limit to 1024M
|
| 169 |
+
ini_set('memory_limit', '1024M');
|
| 170 |
// Increase maximum execution time to 6 hours
|
| 171 |
+
ini_set('max_execution_time', 28800);
|
| 172 |
// Make sure GC is enabled
|
| 173 |
+
if (function_exists("gc_enable")) {
|
| 174 |
+
gc_enable();
|
| 175 |
+
} else if ($_DEBUG || $_INFO) {
|
| 176 |
+
$this->getResponse()->appendBody("gc_enable does not exist.
|
| 177 |
+
");
|
| 178 |
+
}
|
| 179 |
+
if ($_INFO) {
|
| 180 |
+
foreach (Mage::app()->getStores() as $store) {
|
| 181 |
+
$this->getResponse()->appendBody("store: " . $store->getId() . " code=" . $store->getCode() . " name=" . $store->getName() . " isActive=" . $store->getIsActive() . "
|
| 182 |
+
");
|
| 183 |
+
}
|
| 184 |
+
if (function_exists("gc_enabled")) {
|
| 185 |
+
$this->getResponse()->appendBody("gc_enabled=" . gc_enabled() . "
|
| 186 |
+
");
|
| 187 |
+
} else {
|
| 188 |
+
$this->getResponse()->appendBody("gc_enabled does not exist.
|
| 189 |
+
");
|
| 190 |
+
}
|
| 191 |
+
$this->getResponse()->appendBody("=========================================================================================================
|
| 192 |
+
");
|
| 193 |
+
return;
|
| 194 |
+
}
|
| 195 |
// Determine / check store
|
| 196 |
+
$StoreId = 0;
|
| 197 |
+
$Store = FALSE;
|
| 198 |
+
$Stores = Mage::app()->getStores(false, true);
|
| 199 |
+
if (!empty($StoreCode) && !$Stores[$StoreCode]) {
|
| 200 |
+
$this->getResponse()->appendBody("ERROR: Store \"" . $StoreCode . "\" not found.");
|
| 201 |
+
return;
|
| 202 |
+
} else if (!empty($StoreCode) && !$Stores[$StoreCode]->getIsActive()) {
|
| 203 |
+
$this->getResponse()->appendBody("ERROR: Store \"" . $StoreCode . "\" is inactive (disabled).");
|
| 204 |
+
return;
|
| 205 |
+
} else if (!empty($StoreCode)) {
|
| 206 |
+
$Store = $Stores[$StoreCode];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
$StoreId = $Store->getId();
|
| 208 |
+
} else {
|
| 209 |
+
$count = 0;
|
| 210 |
+
foreach ($Stores as $_Store) {
|
| 211 |
+
if ($_Store->getIsActive()) {
|
| 212 |
+
$count++;
|
| 213 |
+
$Store = $_Store;
|
| 214 |
+
$StoreId = $Store->getId();
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
if ($count > 1) {
|
| 218 |
+
$this->getResponse()->appendBody("ERROR: Store specification is required (there are more than 1 active / enabled stores).");
|
| 219 |
+
return;
|
| 220 |
+
}
|
| 221 |
+
if ($count < 1) {
|
| 222 |
+
$this->getResponse()->appendBody("ERROR: No active stores.");
|
| 223 |
+
return;
|
| 224 |
+
}
|
| 225 |
}
|
| 226 |
+
|
| 227 |
+
//================== common code end ==================
|
| 228 |
+
$cfModel = Mage::getModel('codiscript/files');
|
| 229 |
+
$cfModel->controller = $this;
|
| 230 |
+
//================== common code start ==================
|
| 231 |
+
if ($Class == "Configuration") {
|
| 232 |
+
// nothing special
|
| 233 |
+
} else if ($Class == "DataFile") {
|
| 234 |
+
$cfModel->enablereviews = $enablereviews;
|
| 235 |
+
$cfModel->ignoretopcategory = $ignoretopcategory;
|
| 236 |
+
$cfModel->includeshortdescription = $includeshortdescription;
|
| 237 |
+
$cfModel->includelongdescription = $includelongdescription;
|
| 238 |
+
$cfModel->getpricefromchild = $getpricefromchild;
|
| 239 |
+
$cfModel->getgroupprices = $getgroupprices;
|
| 240 |
+
$cfModel->publishtieredpricing = $publishtieredpricing;
|
| 241 |
+
$cfModel->quantitylabel = $quantitylabel;
|
| 242 |
+
$cfModel->pricelabel = $pricelabel;
|
| 243 |
+
$cfModel->savingslabel = $savingslabel;
|
| 244 |
+
$cfModel->includetaxes = $includetaxes;
|
| 245 |
+
$cfModel->includeinvqty = $includeinvqty;
|
| 246 |
+
$cfModel->includespecialprice = $includespecialprice;
|
| 247 |
+
$cfModel->includespecialpricedatefrom = $includespecialpricedatefrom;
|
| 248 |
+
$cfModel->includespecialpricedateto = $includespecialpricedateto;
|
| 249 |
+
$cfModel->ignoreexcludedimages = $ignoreexcludedimages;
|
| 250 |
+
$cfModel->ignoreassprodimages = $ignoreassprodimages;
|
| 251 |
+
$cfModel->includecustomfields = $includecustomfields;
|
| 252 |
+
$cfModel->importoptionsasattributes = $importoptionsasattributes;
|
| 253 |
+
$cfModel->importoptionsassku = $importoptionsassku;
|
| 254 |
+
$cfModel->instockonly = $instockonly;
|
| 255 |
+
$cfModel->splitgroupedproducts = $splitgroupedproducts;
|
| 256 |
+
$cfModel->start = $start;
|
| 257 |
+
$cfModel->pageSize = $pageSize;
|
| 258 |
+
if ($cfModel->includetaxes) {
|
| 259 |
+
$cfModel->taxhelper = Mage::helper('tax');
|
| 260 |
+
}
|
| 261 |
+
} else if ($Class == "CatalogSection") {
|
| 262 |
+
$cfModel->ignoretopcategory = $ignoretopcategory;
|
| 263 |
+
} else if ($Class == "CatalogProject") {
|
| 264 |
+
$cfModel->ignoretopcategory = $ignoretopcategory;
|
| 265 |
+
$cfModel->instockonly = $instockonly;
|
| 266 |
+
$cfModel->splitgroupedproducts = $splitgroupedproducts;
|
| 267 |
+
$cfModel->start = $start;
|
| 268 |
+
$cfModel->pageSize = $pageSize;
|
| 269 |
+
}
|
| 270 |
+
$cfModel->_DEBUG = $_DEBUG;
|
| 271 |
+
$cfModel->StoreId = $StoreId;
|
| 272 |
+
$cfModel->Store = $Store;
|
| 273 |
+
if ($Class == "Configuration") {
|
| 274 |
+
$cfModel->renderConfiguration();
|
| 275 |
+
} else if ($Class == "DataFile") {
|
| 276 |
+
$cfModel->renderDataFile();
|
| 277 |
+
} else if ($Class == "CatalogSection") {
|
| 278 |
+
$cfModel->renderCatalogSection();
|
| 279 |
+
} else if ($Class == "CatalogProject") {
|
| 280 |
+
$cfModel->renderCatalogProject();
|
| 281 |
+
} else if ($_DEBUG) {
|
| 282 |
+
foreach (Mage::app()->getStores() as $store) {
|
| 283 |
+
$this->getResponse()->appendBody("store: " . $store->getId() . " code=" . $store->getCode() . " name=" . $store->getName() . " isActive=" . $store->getIsActive() . "
|
| 284 |
+
website=" . $store->getWebsite() . "
|
| 285 |
+
base currency=" . $store->getBaseCurrency() . "
|
| 286 |
+
");
|
| 287 |
+
}
|
| 288 |
+
$this->getResponse()->appendBody("max_execution_time=" . ini_get("max_execution_time") . "
|
| 289 |
+
memory_limit=" . ini_get("memory_limit") . "
|
| 290 |
+
");
|
| 291 |
+
if (function_exists("gc_enabled")) {
|
| 292 |
+
$this->getResponse()->appendBody("gc_enabled=" . gc_enabled() . "
|
| 293 |
+
");
|
| 294 |
+
} else {
|
| 295 |
+
$this->getResponse()->appendBody("gc_enabled does not exist.
|
| 296 |
+
");
|
| 297 |
+
}
|
| 298 |
+
$this->getResponse()->appendBody("--------------------------------------------------------------------------------
|
| 299 |
+
");
|
| 300 |
+
phpinfo(INFO_GENERAL);
|
| 301 |
+
phpinfo(INFO_CONFIGURATION);
|
| 302 |
+
$this->getResponse()->appendBody("--------------------------------------------------------------------------------
|
| 303 |
+
");
|
| 304 |
+
} else {
|
| 305 |
+
$this->getResponse()->appendBody("==EOF==");
|
| 306 |
+
}
|
| 307 |
+
if ($_DEBUG) {
|
| 308 |
+
$this->getResponse()->appendBody("
|
| 309 |
+
executed in " . ( time() - $started_time ) . " sec.
|
| 310 |
+
");
|
| 311 |
+
}
|
| 312 |
+
return;
|
| 313 |
+
/* RELEASE NOTES
|
| 314 |
+
* 2016-05-30
|
| 315 |
+
* Added product sort options
|
| 316 |
+
*
|
| 317 |
+
* 2015-07-09
|
| 318 |
+
* Improved rendering of image URLs
|
| 319 |
+
*
|
| 320 |
+
* 2015-05-11
|
| 321 |
+
* Improved rendering of prices with store-dependent taxes
|
| 322 |
+
*
|
| 323 |
+
* 2015-05-08
|
| 324 |
+
* Added rendering of products associated with grouped prodict as separate products
|
| 325 |
+
*
|
| 326 |
+
* 2015-04-27
|
| 327 |
+
* Added rendering of group tier prices in case of "Get group prices" and "Publish tiered pricing" both checked
|
| 328 |
+
*
|
| 329 |
+
* 2015-04-23
|
| 330 |
+
* Minor fixes
|
| 331 |
+
*
|
| 332 |
+
* 2015-04-14
|
| 333 |
+
* Added import of custom simple product options into items, if the option contains a SKU number
|
| 334 |
+
*
|
| 335 |
+
* 2015-03-30
|
| 336 |
+
* Added retrieval of custom product options in case of importoptionsasattributes=true
|
| 337 |
+
*
|
| 338 |
+
* 2015-03-02
|
| 339 |
+
* Filtering out disabled products improved for associated products of configurable products
|
| 340 |
+
*
|
| 341 |
+
* 2015-02-17
|
| 342 |
+
* Fixed call-time pass-by-reference bug
|
| 343 |
+
*
|
| 344 |
+
* 2015-01-29
|
| 345 |
+
* Restored / reimplemented getpricefromchild
|
| 346 |
+
* - now forces getting individual associated product prices as item prices
|
| 347 |
+
*
|
| 348 |
+
* 2015-01-08
|
| 349 |
+
* 1. Optimized configurable product items ordering
|
| 350 |
+
*
|
| 351 |
+
* 2014-12-16
|
| 352 |
+
* 1. Fixed configurable attributes processing bug
|
| 353 |
+
*
|
| 354 |
+
* 2014-11-10
|
| 355 |
+
* 1. Added instockonly option and implemented import of only items that are in stock
|
| 356 |
+
*
|
| 357 |
+
* 2014-10-17
|
| 358 |
+
* 1. Improved configurable product item attribute export
|
| 359 |
+
*
|
| 360 |
+
* 2014-10-12
|
| 361 |
+
* 1. Improved price formatting (added proper "rounding half up")
|
| 362 |
+
*
|
| 363 |
+
* 2014-08-22
|
| 364 |
+
* 1. publishtieredpricing causes retrieval of tier prices for individual products within a group product
|
| 365 |
+
*
|
| 366 |
+
* 2014-08-06
|
| 367 |
+
* 1. Added importoptionsasattributes option / processing
|
| 368 |
+
*
|
| 369 |
+
* 2014-04-01
|
| 370 |
+
* 1. Group prices retrieval implemented (Magento 1.7+)
|
| 371 |
+
* 2. Obsoleted getpricefromchild option
|
| 372 |
+
*
|
| 373 |
+
* 2014-02-24
|
| 374 |
+
* 1. includecustomfields parameter added / implemented
|
| 375 |
+
* 2. Improved langiage-specific section rendering
|
| 376 |
+
*
|
| 377 |
+
* 2014-02-04
|
| 378 |
+
* 1. "MagentoBase" role introduced for base product images.
|
| 379 |
+
* 2. Improved product attributes import: excluded attributes of "select" / "muitiselect" type having no selection
|
| 380 |
+
*
|
| 381 |
+
* * 2014-01-18
|
| 382 |
+
* 1. Configurable products - pricing updates / fixes
|
| 383 |
+
* 2. Configurable products - items ordering updates
|
| 384 |
+
* 3. Bundled products -pricing updates
|
| 385 |
+
*
|
| 386 |
+
* 2014-01-16
|
| 387 |
+
* 1. Fixed sequencing issue for grouped products
|
| 388 |
+
*
|
| 389 |
+
* 2013-10-30
|
| 390 |
+
* 1. Added includespecialprice / includespecialpricedatefrom / includespecialpricedateto request parameter / processing
|
| 391 |
+
* (population of item attributes with special price / dates)
|
| 392 |
+
* 2. Added incremental CatalogSection / CatalogProject file retrieval
|
| 393 |
+
*
|
| 394 |
+
* 2013-10-15
|
| 395 |
+
* 1. Added includeinvqty request parameter / processing
|
| 396 |
+
*
|
| 397 |
+
* 2013-07-19
|
| 398 |
+
* 1. Added incremental data file retrieval
|
| 399 |
+
*
|
| 400 |
+
* 2013-06-05
|
| 401 |
+
* 1. "Ignore associated product images" feature expanded to configurable products
|
| 402 |
+
*
|
| 403 |
+
* 2013-05-31
|
| 404 |
+
* 1. Added "Ignore associated product images" feature
|
| 405 |
+
*
|
| 406 |
+
* 2013-02-04
|
| 407 |
+
* 1. Added includelongdescription request parameter / processing
|
| 408 |
+
*
|
| 409 |
+
* 2012-12-07
|
| 410 |
+
* 1. Improved error / warning / notice reporting
|
| 411 |
+
* 2. Fixed configurable attributes import error
|
| 412 |
+
*
|
| 413 |
+
* 2012-12-04
|
| 414 |
+
* 1. Updated tier prices import
|
| 415 |
+
*
|
| 416 |
+
* 2012-11-05
|
| 417 |
+
* 1. Updated multiple images import
|
| 418 |
+
* 2. Added "Ignore excluded images" option support
|
| 419 |
+
*
|
| 420 |
+
* 2012-11-01
|
| 421 |
+
* 1. Updated debugging outout
|
| 422 |
+
*
|
| 423 |
+
* 2012-10-30
|
| 424 |
+
* 1. Added "Include taxes" option support
|
| 425 |
+
* 2. Updated images import: all product images are imported, not only the base one
|
| 426 |
+
*
|
| 427 |
+
* 2012-10-22
|
| 428 |
+
* 1. Added "Ignore top category" option support
|
| 429 |
+
*
|
| 430 |
+
* 2012-07-26
|
| 431 |
+
* 1. Added store spefification
|
| 432 |
+
* 2. Minor performance improvements
|
| 433 |
+
*
|
| 434 |
+
* 2012-07-25
|
| 435 |
+
* Minor performance improvements
|
| 436 |
+
*///==============================================================================
|
| 437 |
}
|
| 438 |
+
|
| 439 |
}
|
app/locale/en_US/Mage_CodiScript.csv
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
"Use Valide Symbols","Allowed Characters A-Z a-z 0-9 <br/>Special Chars: ` ~ @ # % ^ & * ( ) – _ = + [ ] { } \ | ; : ' "" , . < > / ?"
|
|
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_Codi</name>
|
| 4 |
-
<version>4.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -9,10 +9,10 @@
|
|
| 9 |
<summary>Catalog-on-Demand</summary>
|
| 10 |
<description>Extension to connect to the Catalog-on-Demand service for making print catalogs, brochures, and flyers.</description>
|
| 11 |
<notes>Please contact our support desk if you have any problems.</notes>
|
| 12 |
-
<authors><author><name>catalogondemand</name><user>
|
| 13 |
-
<date>
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magecommunity"><dir name="Mage"><dir name="CodiScript"><dir name="Helper"><file name="Data.php" hash="3f99660cb06a9dc09f024b9993d43a3f"/></dir><dir name="Model"><file name="Files.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
-
<dependencies
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_Codi</name>
|
| 4 |
+
<version>4.3.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 9 |
<summary>Catalog-on-Demand</summary>
|
| 10 |
<description>Extension to connect to the Catalog-on-Demand service for making print catalogs, brochures, and flyers.</description>
|
| 11 |
<notes>Please contact our support desk if you have any problems.</notes>
|
| 12 |
+
<authors><author><name>catalogondemand</name><user>catalogondemand</user><email>timh@catalog-on-demand.com</email></author></authors>
|
| 13 |
+
<date>2016-10-11</date>
|
| 14 |
+
<time>00:43:11</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Mage"><dir name="CodiScript"><dir name="Helper"><file name="Data.php" hash="3f99660cb06a9dc09f024b9993d43a3f"/></dir><dir name="Model"><file name="Files.php" hash="b5d35239376f3672365faabe80120098"/></dir><dir name="controllers"><file name="IndexController.php" hash="69fd58379b9a1d5d9b6af5bea899e489"/></dir><dir name="etc"><file name="adminhtml.xml" hash="40ab0bd86928c5ba175988926a9f6aee"/><file name="config.xml" hash="b960e9bd106f0c94559baa2bc5761e18"/><file name="system.xml" hash="1b5e5b18bfdce6b85e304fb4ef877274"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_CodiScript.xml" hash="f0502cac7918fc798b3b02d3d4b7e7fd"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="codiscript.xml" hash="066f99333a6054e11943a75413f65ff0"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="codi"><file name="password_validation.js" hash="7223aeed118bb5774c73f951460ae0b0"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Mage_CodiScript.csv" hash=""/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
