Mage_Codi - Version 4.2.2

Version Notes

Please contact our support desk if you have any problems.

Download this release

Release Info

Developer Magento Core Team
Extension Mage_Codi
Version 4.2.2
Comparing to
See all releases


Code changes from version 4.2.1 to 4.2.2

app/code/community/Mage/CodiScript/Model/Files.php CHANGED
@@ -1,9 +1,38 @@
1
  <?php
2
- // 2015-03-30
3
  class ConfiguredProductLine{
4
  public $optionIds = array();
5
  public $line = NULL;
6
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
8
  public $version = __VERSION__;
9
  public $Store;
@@ -30,6 +59,7 @@ class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
30
  public $ignoreassprodimages = FALSE;
31
  public $includecustomfields = FALSE;
32
  public $importoptionsasattributes = FALSE;
 
33
  public $instockonly = FALSE;
34
  public $start = 0;
35
  public $pageSize = 1000000000;
@@ -1008,7 +1038,8 @@ thumbnail: ".$product->getThumbnail()."
1008
  $attribute->setStoreId( $this->StoreId );
1009
  if( $this->_DEBUG && ( $attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect" ) ){
1010
  $hasData = $product->getData($attribute->getAttributeCode()) ? "YES" : "NO";
1011
- echo "simple prod attr: ".$attribute->getFrontend()->getLabel()."=".$attribute->getFrontend()->getValue( $product )." input=".$attribute->getFrontendInput()." data=".$product->getData($attribute->getAttributeCode())." hasData=".$hasData." store=".$product->_storeId."
 
1012
  ";
1013
  }
1014
  if( $attribute->getAttributeCode()=="manufacturer" ){
@@ -1030,6 +1061,9 @@ thumbnail: ".$product->getThumbnail()."
1030
  if( !empty( $ProductAttributes ) )
1031
  $ProductAttributes .= "|";
1032
  $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
 
 
 
1033
  }
1034
  }
1035
  }
@@ -1114,74 +1148,362 @@ thumbnail: ".$product->getThumbnail()."
1114
  if( $this->_DEBUG ) echo "Bundle=".$ProdRPrice."
1115
  ";
1116
  }
1117
- $RPrice = $ProdRPrice;
1118
- if( !empty( $RPrice ) && $this->includetaxes )
1119
- $RPrice = $this->taxhelper->getPrice( $product, $RPrice, true );
1120
- $SPrice = $ProdSPrice;
1121
- if( $SPrice >= 0 && $this->includetaxes )
1122
- $SPrice = $this->taxhelper->getPrice( $product, $SPrice, true );
1123
- if( $this->_DEBUG ) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1124
  ";
1125
- $ItemAttributes = "";
1126
- if( $this->includeinvqty )
1127
- $ItemAttributes = "Inventory=".$this->_formatQty( "".$this->catalogInventoryModel->loadByProduct( $product )->getQty() );
1128
- $RPrice = $this->_formatPrice( $RPrice );
1129
- if( $this->includespecialprice ){
1130
- if( $SPrice >= 0 ){
1131
- $SPrice = $this->_formatPrice( $SPrice );
1132
- if( !empty( $ItemAttributes ) )
1133
- $ItemAttributes .= "|";
1134
- $ItemAttributes .= "Special Price=".$SPrice;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1135
  }
1136
  }
1137
- if( $this->includespecialpricedatefrom ){
1138
- if( !empty( $ProdSFromDate ) ){
1139
- if( !empty( $ItemAttributes ) )
1140
- $ItemAttributes .= "|";
1141
- $ItemAttributes .= "Special Price From Date=".substr( $ProdSFromDate, 0, 10 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1142
  }
1143
- }
1144
- if( $this->includespecialpricedateto ){
1145
- if( !empty( $ProdSToDate ) ){
1146
- if( !empty( $ItemAttributes ) )
1147
- $ItemAttributes .= "|";
1148
- $ItemAttributes .= "Special Price To Date=".substr( $ProdSToDate, 0, 10 );
1149
  }
1150
- }
1151
- if( $this->getgroupprices && $ProdSpecGroupPrices ){
1152
- foreach( $ProdSpecGroupPrices as $groupPrice ){
1153
- $price = 0.0 + $groupPrice[ 'price' ];
1154
- if( $price >= 0 && $this->includetaxes )
1155
- $price = $this->taxhelper->getPrice( $product, $price, true );
1156
- if( !empty( $ItemAttributes ) )
1157
- $ItemAttributes .= "|";
1158
- $ItemAttributes .= "price_".$this->customerGroups[ $groupPrice[ 'cust_group' ] ]."=".$this->_formatPrice( $price );
1159
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1160
  }
1161
- $Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
1162
- if( !empty( $Reviews ) )
1163
- $Reviews = $this->_cleanStr( $Reviews );
1164
- $prodSku = $product->getSku();
1165
- $prodName = $product->getName();
1166
- $ProducttoString = $this->_cleanStr( $prodSku ) //ItemID
1167
- ."\t" //ItemQty
1168
- ."\t" //ItemUom
1169
- ."\t" .$RPrice //ItemPrice
1170
- ."\t" //ItemDescription
1171
- ."\t" //ItemLink
1172
- ."\t" .$ItemAttributes //ItemAttributes
1173
- ."\t" //ItemitemGraphic
1174
- ."\t" .$product->getId().'#$#'.$this->_cleanStr( $prodName ) //ProductName
1175
- ."\t" .$ProductDescription //ProductDescription
1176
- ."\t" .$prodImages //ProductGraphic
1177
- ."\t" .$URL //ProductLink
1178
- ."\t" .$ProductAttributes //ProductAttributes
1179
- ."\t" .$Manufacturer //Manufacturer
1180
- ."\t" //Category
1181
- ."\t" .$Reviews //Reviews
1182
- ."\t" .$shortDescription
1183
- ."\t1"
1184
- ."\n";
1185
  return $ProducttoString;
1186
  }
1187
 
@@ -1212,8 +1534,6 @@ thumbnail: ".$product->getThumbnail()."
1212
  $this->_fillConfigProdItems( $attrNumber + 1, $attrNo, $optNumbers, $optionIds, $optCounters, $cpLinesMatrix[ $optionID ] );
1213
  } else {
1214
  $cpLine = $cpLinesMatrix[ $optionID ];
1215
- // if( $this->_DEBUG ) echo "_fillConfigProdItems option ids: ".var_export( $cpLine->optionIds, true )."
1216
- //";
1217
  $this->configProducttoString .= $cpLine->line
1218
  .$this->prodLine
1219
  .$this->configItemSequence
@@ -1226,7 +1546,7 @@ thumbnail: ".$product->getThumbnail()."
1226
  }
1227
  }
1228
 
1229
- private function _getCustomOptionsAsAttributes( $product ){
1230
  $attributes = "";
1231
  $customOptions = $product->getOptions();
1232
  if( $customOptions ){
@@ -1236,10 +1556,10 @@ thumbnail: ".$product->getThumbnail()."
1236
  ";
1237
  $max_sort_order = 0;
1238
  foreach( $customOptions as $option ){
1239
- if( $option->getSortOrder() > $max_sort_order ){
1240
- $max_sort_order = $option->getSortOrder();
1241
- } else if( $option->getSortOrder() < 0 ){
1242
- $option->setSortOrder( -1 );
1243
  }
1244
  }
1245
  if( $this->_DEBUG ){
@@ -1305,6 +1625,67 @@ thumbnail: ".$product->getThumbnail()."
1305
  }
1306
  return $attributes;
1307
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1308
 
1309
  private function _cleanStr( &$str ){
1310
  return str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $str ) ) ) );
1
  <?php
2
+ // 2015-04-14
3
  class ConfiguredProductLine{
4
  public $optionIds = array();
5
  public $line = NULL;
6
  }
7
+ class COption{
8
+ public $id = NULL;
9
+ public $title = NULL;
10
+ public $type = NULL;
11
+ public $required = NULL;
12
+ public $values = array();
13
+ public function toString(){
14
+ return "COption #".$this->id." title=".$this->title." type=".$this->type." required=".$this->required." values=".count( $this->values );
15
+ }
16
+ }
17
+ class COValue{
18
+ public $title = NULL;
19
+ public $sku = NULL;
20
+ public $rprice = NULL;
21
+ public $sprice = NULL;
22
+ public function toString(){
23
+ return "COValue ".$this->title." sku=".$this->sku." rprice=".$this->rprice." sprice=".$this->sprice;
24
+ }
25
+ }
26
+ class COValueSet{
27
+ public $optionId = NULL;
28
+ public $coValues = array();
29
+ public function toString(){
30
+ $out = "COValueSet #".$this->optionId." ";
31
+ foreach( $this->coValues as $value )
32
+ $out .= $value->sku ? "-".$value->sku : "-...";
33
+ return $out;
34
+ }
35
+ }
36
  class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
37
  public $version = __VERSION__;
38
  public $Store;
59
  public $ignoreassprodimages = FALSE;
60
  public $includecustomfields = FALSE;
61
  public $importoptionsasattributes = FALSE;
62
+ public $importoptionsassku = FALSE;
63
  public $instockonly = FALSE;
64
  public $start = 0;
65
  public $pageSize = 1000000000;
1038
  $attribute->setStoreId( $this->StoreId );
1039
  if( $this->_DEBUG && ( $attribute->getFrontendInput() == "select" || $attribute->getFrontendInput() == "multiselect" ) ){
1040
  $hasData = $product->getData($attribute->getAttributeCode()) ? "YES" : "NO";
1041
+ $vof = $attribute->getIsVisibleOnFront() ? "YES" : "NO";
1042
+ echo "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."
1043
  ";
1044
  }
1045
  if( $attribute->getAttributeCode()=="manufacturer" ){
1061
  if( !empty( $ProductAttributes ) )
1062
  $ProductAttributes .= "|";
1063
  $ProductAttributes .= $attribute->getFrontend()->getLabel() . "=" . $value;
1064
+ } else {
1065
+ if( $this->_DEBUG ) echo "not a string with length > 0
1066
+ ";
1067
  }
1068
  }
1069
  }
1148
  if( $this->_DEBUG ) echo "Bundle=".$ProdRPrice."
1149
  ";
1150
  }
1151
+ $Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
1152
+ if( !empty( $Reviews ) )
1153
+ $Reviews = $this->_cleanStr( $Reviews );
1154
+ $prodSku = $product->getSku();
1155
+ $prodSku = $this->_cleanStr( $prodSku );
1156
+ $cleanProdName = $this->_cleanStr( $prodName );
1157
+ $prodName = $product->getName();
1158
+ $cleanProdName = $this->_cleanStr( $prodName );
1159
+ $prodName = $product->getId().'#$#'.$cleanProdName;
1160
+ $skusAdded = false;
1161
+ if( $this->importoptionsassku ){
1162
+ $this->configItemSequence = 1;
1163
+ $this->configProducttoString = "";
1164
+ $customOptions = $product->getOptions();
1165
+ if( $customOptions ){
1166
+ if( $this->_DEBUG ) echo "=== customOptions ===
1167
+ ProdRPrice=".$ProdRPrice." ProdSPrice=".$ProdSPrice."
1168
+ ";
1169
+ $max_sort_order = 0;
1170
+ foreach( $customOptions as $option ){
1171
+ if( $option->getSortOrder() > $max_sort_order ){
1172
+ $max_sort_order = $option->getSortOrder();
1173
+ } else if( $option->getSortOrder() < 0 ){
1174
+ $option->setSortOrder( -1 );
1175
+ }
1176
+ }
1177
+ $orderedOptionValues = array();
1178
+ $orderedCustomOptions = array();
1179
+ for( $sortorder = -1; $sortorder <= $max_sort_order; $sortorder++ ){
1180
+ foreach ($customOptions as $option) {
1181
+ if( $option->getSortOrder() != $sortorder ) continue;
1182
+ $orderedCustomOptions[] = $option;
1183
+ $optionValues = array();
1184
+ if( $option->getValues() ){
1185
+ $max_v_sort_order = 0;
1186
+ foreach( $option->getValues() as $_value ){
1187
+ if( $_value->getSortOrder() > $max_v_sort_order ){
1188
+ $max_v_sort_order = $_value->getSortOrder();
1189
+ } else if( $_value->getSortOrder() < 0 ){
1190
+ $_value->setSortOrder( -1 );
1191
+ }
1192
+ }
1193
+ for( $vsortorder = -1; $vsortorder <= $max_v_sort_order; $vsortorder++ ){
1194
+ foreach( $option->getValues() as $_value ){
1195
+ if( $_value->getSortOrder() != $vsortorder ) continue;
1196
+ $optionValues[] = $_value;
1197
+ }
1198
+ }
1199
+ }
1200
+ $orderedOptionValues[ $option->getOptionId() ] = $optionValues;
1201
+ }
1202
+ }
1203
+ $customOptions = array();
1204
+ $customOptionsById = array();
1205
+ foreach( $orderedCustomOptions as $option ){
1206
+ if( $this->_DEBUG ){
1207
+ echo "customOption #".$option->getOptionId()." title=".$option->getTitle()." storeTitle=".$option->getStoreTitle()." type=".$option->getType()." isRequire=".$option->getIsRequire()." sort_order".$option->getSortOrder()."
1208
+ ";
1209
+ if( $option->getType() == "date" ||
1210
+ $option->getType() == "time" ||
1211
+ $option->getType() == "date_time" ||
1212
+ $option->getType() == "field" ||
1213
+ $option->getType() == "area" )
1214
+ echo " price=".$option->getPrice()." price_type=".$option->getPriceType()." sku=".$option->getSku()."
1215
  ";
1216
+ }
1217
+ $customOption = new COption();
1218
+ $customOption->id = $option->getOptionId();
1219
+ $customOption->title = $option->getStoreTitle();
1220
+ if( !$customOption->title )
1221
+ $customOption->title = $option->getTitle();
1222
+ if( !$customOption->title )
1223
+ $customOption->title = "Option #".$option->getOptionId();
1224
+ $customOption->type = $option->getType();
1225
+ $customOption->required = $option->getIsRequire();
1226
+ if( $this->_DEBUG ) echo $customOption->toString()."
1227
+ ";
1228
+ $optionValues = $orderedOptionValues[ $option->getOptionId() ];
1229
+ $isMultiple = ( $option->getType() == "multiple" || $option->getType() == "checkbox" );
1230
+ if( !$option->getIsRequire() && !$isMultiple ){
1231
+ $coValue = new COValue();
1232
+ $coValue->title = FALSE;
1233
+ $coValue->sku = FALSE;
1234
+ $coValue->ifpercent = FALSE;
1235
+ $coValue->pvalue = 0;
1236
+ $coValue->rprice = 0;
1237
+ $coValue->sprice = 0;
1238
+ if( $this->_DEBUG ) echo $coValue->toString()."
1239
+ ";
1240
+ $customOption->values[] = $coValue;
1241
+ }
1242
+ if( $option->getType() == "date" ||
1243
+ $option->getType() == "time" ||
1244
+ $option->getType() == "date_time" ||
1245
+ $option->getType() == "field" ||
1246
+ $option->getType() == "area" ){
1247
+ if( $option->getSku() ){
1248
+ $coValue = new COValue();
1249
+ $coValue->title = "Provided";
1250
+ $coValue->sku = $option->getSku();
1251
+ $coValue->ifpercent = FALSE;
1252
+ $coValue->pvalue = $option->getPrice();
1253
+ if( $option->getPriceType() == "percent" ){
1254
+ $coValue->ifpercent = TRUE;
1255
+ $coValue->rprice = round( $ProdRPrice * $option->getPrice() / 100, 2 );
1256
+ $coValue->sprice = $ProdSPrice > -1 ? round( $ProdSPrice * $option->getPrice() / 100, 2 ) : -1;
1257
+ } else {
1258
+ $coValue->rprice = $option->getPrice();
1259
+ $coValue->sprice = $ProdSPrice > -1 ? $option->getPrice() : -1;
1260
+ }
1261
+ if( $this->_DEBUG ) echo $coValue->toString()."
1262
+ ";
1263
+ $customOption->values[] = $coValue;
1264
+ }
1265
+ } else {
1266
+ foreach( $optionValues as $optionValue ){
1267
+ if( $this->_DEBUG ) echo "value title=".$optionValue->getTitle()." storeTitle=".$optionValue->getStoreTitle()." price=".$optionValue->getPrice()." price_type=".$optionValue->getPriceType()." sku=".$optionValue->getSku()." sort_order=".$optionValue->getSortOrder()."
1268
+ ";
1269
+ if( $optionValue->getSku() ){
1270
+ $coValue = new COValue();
1271
+ $coValue->title = $optionValue->getStoreTitle();
1272
+ if( !$coValue->title )
1273
+ $coValue->title = $optionValue->getTitle();
1274
+ if( !$coValue->title )
1275
+ $coValue->title = "Option value";
1276
+ $coValue->sku = $optionValue->getSku();
1277
+ $coValue->ifpercent = FALSE;
1278
+ $coValue->pvalue = $optionValue->getPrice();
1279
+ if( $optionValue->getPriceType() == "percent" ){
1280
+ $coValue->ifpercent = TRUE;
1281
+ $coValue->rprice = round( $ProdRPrice * $optionValue->getPrice() / 100, 2 );
1282
+ $coValue->sprice = $ProdSPrice > -1 ? round( $ProdSPrice * $optionValue->getPrice() / 100, 2 ) : -1;
1283
+ } else {
1284
+ $coValue->rprice = $optionValue->getPrice();
1285
+ $coValue->sprice = $ProdSPrice > -1 ? $optionValue->getPrice() : -1;
1286
+ }
1287
+ if( $this->_DEBUG ) echo $coValue->toString()."
1288
+ ";
1289
+ $customOption->values[] = $coValue;
1290
+ }
1291
+ }
1292
+ }
1293
+ if( $isMultiple && count( $customOption->values ) > 1 )
1294
+ $customOption->values = array_reverse( $customOption->values );
1295
+ if( count( $customOption->values ) == 0 ){
1296
+ } else if( count( $customOption->values ) == 1 ){
1297
+ if( $customOption->values[ 0 ]->sku )
1298
+ $customOptions[] = $customOption;
1299
+ } else {
1300
+ $customOptions[] = $customOption;
1301
+ }
1302
+ $customOptionsById[ $customOption->id ] = $customOption;
1303
+ }
1304
+ if( $this->_DEBUG ){
1305
+ echo "Resulting options / values
1306
+ ";
1307
+ foreach( $customOptions as $option ){
1308
+ echo $option->toString()."
1309
+ ";
1310
+ foreach( $option->values as $value ) echo $value->toString()."
1311
+ ";
1312
+ }
1313
+ }
1314
+ if( count( $customOptions ) > 0 ){
1315
+ $coValueSetSequences = array();
1316
+ $coValueSetSequence = array();
1317
+ $this->_buildCOValueSets( &$coValueSetSequences, $coValueSetSequence, 0, $customOptions );
1318
+ $index = 0;
1319
+ foreach( $coValueSetSequences as $coValueSetSequence ){
1320
+ if( $this->_DEBUG ){
1321
+ echo "coValueSetSequence #".$index."
1322
+ ";
1323
+ foreach( $coValueSetSequence as $coValueSet ) echo $coValueSet->toString()."
1324
+ ";
1325
+ }
1326
+ $ItemNumber = $prodSku;
1327
+ $RPrice = $ProdRPrice;
1328
+ $SPrice = $ProdSPrice;
1329
+ $ItemAttributes = "";
1330
+ if( $this->includeinvqty ){
1331
+ if( !empty( $ItemAttributes ) )
1332
+ $ItemAttributes .= "|";
1333
+ $ItemAttributes = "Inventory=".$this->_formatQty( "".$this->catalogInventoryModel->loadByProduct( $product )->getQty() );
1334
+ }
1335
+ foreach( $coValueSetSequence as $coValueSet ){
1336
+ $cOption = $customOptionsById[ $coValueSet->optionId ];
1337
+ if( !empty( $ItemAttributes ) )
1338
+ $ItemAttributes .= "|";
1339
+ $ItemAttributes .= $cOption->title."=";
1340
+ $vcount = 0;
1341
+ foreach( $coValueSet->coValues as $value ){
1342
+ if( $value->sku ){
1343
+ if( $ItemNumber ) $ItemNumber .= "-";
1344
+ $ItemNumber .= $value->sku;
1345
+ $RPrice += $value->rprice;
1346
+ if( $SPrice >= 0 ) $SPrice += $value->sprice;
1347
+ if( $vcount > 0 ) $ItemAttributes .= ", ";
1348
+ $ItemAttributes .= $value->title;
1349
+ $vcount++;
1350
+ }
1351
+ }
1352
+ }
1353
+ if( empty( $ItemNumber ) ){
1354
+ if( $this->_DEBUG ) echo "NO ItemNumber
1355
+ ";
1356
+ continue;
1357
+ }
1358
+ if( !empty( $RPrice ) && $this->includetaxes )
1359
+ $RPrice = $this->taxhelper->getPrice( $product, $RPrice, true );
1360
+ if( $SPrice >= 0 && $this->includetaxes )
1361
+ $SPrice = $this->taxhelper->getPrice( $product, $SPrice, true );
1362
+ if( $this->_DEBUG ) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
1363
+ ";
1364
+ $RPrice = $this->_formatPrice( $RPrice );
1365
+ if( $this->includespecialprice ){
1366
+ if( $SPrice >= 0 ){
1367
+ $SPrice = $this->_formatPrice( $SPrice );
1368
+ if( !empty( $ItemAttributes ) )
1369
+ $ItemAttributes .= "|";
1370
+ $ItemAttributes .= "Special Price=".$SPrice;
1371
+ }
1372
+ }
1373
+ if( $this->includespecialpricedatefrom ){
1374
+ if( !empty( $ProdSFromDate ) ){
1375
+ if( !empty( $ItemAttributes ) )
1376
+ $ItemAttributes .= "|";
1377
+ $ItemAttributes .= "Special Price From Date=".substr( $ProdSFromDate, 0, 10 );
1378
+ }
1379
+ }
1380
+ if( $this->includespecialpricedateto ){
1381
+ if( !empty( $ProdSToDate ) ){
1382
+ if( !empty( $ItemAttributes ) )
1383
+ $ItemAttributes .= "|";
1384
+ $ItemAttributes .= "Special Price To Date=".substr( $ProdSToDate, 0, 10 );
1385
+ }
1386
+ }
1387
+ if( $this->getgroupprices && $ProdSpecGroupPrices ){
1388
+ foreach( $ProdSpecGroupPrices as $groupPrice ){
1389
+ $price = 0.0 + $groupPrice[ 'price' ];
1390
+ $price0 = $price;
1391
+ foreach( $coValueSetSequence as $coValueSet ){
1392
+ foreach( $coValueSet->coValues as $value ){
1393
+ if( $value->sku ){
1394
+ if( $value->ifpercent ){
1395
+ $price = $price + round( $price0 * $value->pvalue / 100, 2 );
1396
+ } else {
1397
+ $price = $price + $value->pvalue;
1398
+ }
1399
+ }
1400
+ }
1401
+ }
1402
+ if( $price >= 0 && $this->includetaxes )
1403
+ $price = $this->taxhelper->getPrice( $product, $price, true );
1404
+ if( !empty( $ItemAttributes ) )
1405
+ $ItemAttributes .= "|";
1406
+ $ItemAttributes .= "price_".$this->customerGroups[ $groupPrice[ 'cust_group' ] ]."=".$this->_formatPrice( $price );
1407
+ }
1408
+ }
1409
+ if( $this->_DEBUG ) echo "resulting attrs: ".$ItemAttributes."
1410
+ ";
1411
+ $ProducttoString .= $ItemNumber //ItemID
1412
+ ."\t" //ItemQty
1413
+ ."\t" //ItemUom
1414
+ ."\t" .$RPrice //ItemPrice
1415
+ ."\t" //ItemDescription
1416
+ ."\t" //ItemLink
1417
+ ."\t" .$ItemAttributes //ItemAttributes
1418
+ ."\t" //ItemitemGraphic
1419
+ ."\t" .$prodName //ProductName
1420
+ ."\t" .$ProductDescription //ProductDescription
1421
+ ."\t" .$prodImages //ProductGraphic
1422
+ ."\t" .$URL //ProductLink
1423
+ ."\t" .$ProductAttributes //ProductAttributes
1424
+ ."\t" .$Manufacturer //Manufacturer
1425
+ ."\t" //Category
1426
+ ."\t" .$Reviews //Reviews
1427
+ ."\t" .$shortDescription
1428
+ ."\t1"
1429
+ ."\n";
1430
+ $skusAdded = TRUE;
1431
+ $index++;
1432
+ // https://objectpublisher.basecamphq.com/projects/257020-odp/posts/87233819/comments#comment_312388129
1433
+ if( $index >= 200 ){
1434
+ $ProducttoString .= "REPORTWARNING: Not all options were converted to items for the product #".$product->getId()." - \"".$cleanProdName."\".
1435
+ ";
1436
+ break;
1437
+ }
1438
+ }
1439
+ }
1440
  }
1441
  }
1442
+ if( !$skusAdded ){
1443
+ $RPrice = $ProdRPrice;
1444
+ if( !empty( $RPrice ) && $this->includetaxes )
1445
+ $RPrice = $this->taxhelper->getPrice( $product, $RPrice, true );
1446
+ $SPrice = $ProdSPrice;
1447
+ if( $SPrice >= 0 && $this->includetaxes )
1448
+ $SPrice = $this->taxhelper->getPrice( $product, $SPrice, true );
1449
+ if( $this->_DEBUG ) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
1450
+ ";
1451
+ $ItemAttributes = "";
1452
+ if( $this->includeinvqty )
1453
+ $ItemAttributes = "Inventory=".$this->_formatQty( "".$this->catalogInventoryModel->loadByProduct( $product )->getQty() );
1454
+ $RPrice = $this->_formatPrice( $RPrice );
1455
+ if( $this->includespecialprice ){
1456
+ if( $SPrice >= 0 ){
1457
+ $SPrice = $this->_formatPrice( $SPrice );
1458
+ if( !empty( $ItemAttributes ) )
1459
+ $ItemAttributes .= "|";
1460
+ $ItemAttributes .= "Special Price=".$SPrice;
1461
+ }
1462
  }
1463
+ if( $this->includespecialpricedatefrom ){
1464
+ if( !empty( $ProdSFromDate ) ){
1465
+ if( !empty( $ItemAttributes ) )
1466
+ $ItemAttributes .= "|";
1467
+ $ItemAttributes .= "Special Price From Date=".substr( $ProdSFromDate, 0, 10 );
1468
+ }
1469
  }
1470
+ if( $this->includespecialpricedateto ){
1471
+ if( !empty( $ProdSToDate ) ){
1472
+ if( !empty( $ItemAttributes ) )
1473
+ $ItemAttributes .= "|";
1474
+ $ItemAttributes .= "Special Price To Date=".substr( $ProdSToDate, 0, 10 );
1475
+ }
 
 
 
1476
  }
1477
+ if( $this->getgroupprices && $ProdSpecGroupPrices ){
1478
+ foreach( $ProdSpecGroupPrices as $groupPrice ){
1479
+ $price = 0.0 + $groupPrice[ 'price' ];
1480
+ if( $price >= 0 && $this->includetaxes )
1481
+ $price = $this->taxhelper->getPrice( $product, $price, true );
1482
+ if( !empty( $ItemAttributes ) )
1483
+ $ItemAttributes .= "|";
1484
+ $ItemAttributes .= "price_".$this->customerGroups[ $groupPrice[ 'cust_group' ] ]."=".$this->_formatPrice( $price );
1485
+ }
1486
+ }
1487
+ $ProducttoString = $prodSku //ItemID
1488
+ ."\t" //ItemQty
1489
+ ."\t" //ItemUom
1490
+ ."\t" .$RPrice //ItemPrice
1491
+ ."\t" //ItemDescription
1492
+ ."\t" //ItemLink
1493
+ ."\t" .$ItemAttributes //ItemAttributes
1494
+ ."\t" //ItemitemGraphic
1495
+ ."\t" .$prodName //ProductName
1496
+ ."\t" .$ProductDescription //ProductDescription
1497
+ ."\t" .$prodImages //ProductGraphic
1498
+ ."\t" .$URL //ProductLink
1499
+ ."\t" .$ProductAttributes //ProductAttributes
1500
+ ."\t" .$Manufacturer //Manufacturer
1501
+ ."\t" //Category
1502
+ ."\t" .$Reviews //Reviews
1503
+ ."\t" .$shortDescription
1504
+ ."\t1"
1505
+ ."\n";
1506
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1507
  return $ProducttoString;
1508
  }
1509
 
1534
  $this->_fillConfigProdItems( $attrNumber + 1, $attrNo, $optNumbers, $optionIds, $optCounters, $cpLinesMatrix[ $optionID ] );
1535
  } else {
1536
  $cpLine = $cpLinesMatrix[ $optionID ];
 
 
1537
  $this->configProducttoString .= $cpLine->line
1538
  .$this->prodLine
1539
  .$this->configItemSequence
1546
  }
1547
  }
1548
 
1549
+ private function _getCustomOptionsAsAttributes( &$product ){
1550
  $attributes = "";
1551
  $customOptions = $product->getOptions();
1552
  if( $customOptions ){
1556
  ";
1557
  $max_sort_order = 0;
1558
  foreach( $customOptions as $option ){
1559
+ if( $option->getSortOrder() > $max_sort_order ){
1560
+ $max_sort_order = $option->getSortOrder();
1561
+ } else if( $option->getSortOrder() < 0 ){
1562
+ $option->setSortOrder( -1 );
1563
  }
1564
  }
1565
  if( $this->_DEBUG ){
1625
  }
1626
  return $attributes;
1627
  }
1628
+
1629
+ private function _buildCOValueSets( &$coValueSetSequences, $coValueSetSequence, $index, &$customOptions ){
1630
+ $cOption = $customOptions[ $index ];
1631
+ $customOptionCount = count( $customOptions );
1632
+ $coValueSetList = array();
1633
+ if( $cOption->type == "multiple" || $cOption->type == "checkbox" ){
1634
+ // all combinations + empty if not required
1635
+ $valuesCount = count( $cOption->values );
1636
+ $indexList = array();
1637
+ $indices = array();
1638
+ $this->_buildCOValueIndices( $indexList, $indices, $valuesCount - 1 );
1639
+ foreach( $indexList as $indices ){
1640
+ $coValueSet = new COValueSet();
1641
+ $coValueSet->optionId = $cOption->id;
1642
+ $valueIndexNo = 0;
1643
+ foreach( $indices as $valueIndex ){
1644
+ if( $valueIndex == 1 )
1645
+ $coValueSet->coValues[] = $cOption->values[ $valueIndexNo ];
1646
+ $valueIndexNo++;
1647
+ }
1648
+ if( !$cOption->required && count( $coValueSet->coValues ) == 0 ){
1649
+ $coValue = new COValue();
1650
+ $coValue->title = FALSE;
1651
+ $coValue->sku = FALSE;
1652
+ $coValue->rprice = 0;
1653
+ $coValue->sprice = 0;
1654
+ $coValueSet->coValues[] = $coValue;
1655
+ }
1656
+ if( count( $coValueSet->coValues ) == 0 )
1657
+ continue;
1658
+ if( count( $coValueSet->coValues ) > 1 )
1659
+ $coValueSet->coValues = array_reverse( $coValueSet->coValues );
1660
+ $coValueSetList[] = $coValueSet;
1661
+ }
1662
+ } else {
1663
+ foreach( $cOption->values as $optionValue ){
1664
+ $coValueSet = new COValueSet();
1665
+ $coValueSet->optionId = $cOption->id;
1666
+ $coValueSet->coValues[] = $optionValue;
1667
+ $coValueSetList[] = $coValueSet;
1668
+ }
1669
+ }
1670
+ $coValueSetListCount = count( $coValueSetList );
1671
+ foreach( $coValueSetList as $coValueSet ){
1672
+ $coValueSetSequence[ $index ] = $coValueSet;
1673
+ if( $index == $customOptionCount - 1 )
1674
+ $coValueSetSequences[] = $coValueSetSequence;
1675
+ else
1676
+ $this->_buildCOValueSets( $coValueSetSequences, $coValueSetSequence, $index + 1, $customOptions );
1677
+ }
1678
+ }
1679
+
1680
+ private function _buildCOValueIndices( &$indexList, $indices, $index ){
1681
+ for( $i = 0; $i < 2; $i++ ){
1682
+ $indices[ $index ] = $i;
1683
+ if( $index == 0 )
1684
+ $indexList[] = $indices;
1685
+ else
1686
+ $this->_buildCOValueIndices( $indexList, $indices, $index - 1 );
1687
+ }
1688
+ }
1689
 
1690
  private function _cleanStr( &$str ){
1691
  return str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $str ) ) ) );
app/code/community/Mage/CodiScript/controllers/IndexController.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- define("__VERSION__","2015-03-30");
3
  define("__SCRIPTNAME__",basename(__FILE__));
4
 
5
  class Mage_CodiScript_IndexController extends Mage_Core_Controller_Front_Action{
@@ -79,6 +79,7 @@ if( $Class=="DataFile" ){
79
  }
80
  }
81
  $importoptionsasattributes = ( isset( $_REQUEST["importoptionsasattributes"] ) && $_REQUEST["importoptionsasattributes"] == "1" );
 
82
  $instockonly = isset($_REQUEST["instockonly"])? trim( $_REQUEST["instockonly"] ) : FALSE;
83
  $start = isset( $_REQUEST["start"] ) ? intval( $_REQUEST["start"] ) : 0;
84
  $pageSize = isset( $_REQUEST["pageSize"] ) ? intval( $_REQUEST["pageSize"] ) : 1000000000;
@@ -101,6 +102,7 @@ ignoreexcludedimages=".$ignoreexcludedimages."
101
  ignoreassprodimages=".$ignoreassprodimages."
102
  includecustomfields=".( $includecustomfields ? implode( ",", array_keys( $includecustomfields ) ) : $includecustomfields )."
103
  importoptionsasattributes=".$importoptionsasattributes."
 
104
  instockonly=".$instockonly."
105
  start=".$start."
106
  pageSize=".$pageSize."
@@ -187,6 +189,7 @@ if( $Class=="DataFile" ){
187
  $cfModel->ignoreassprodimages = $ignoreassprodimages;
188
  $cfModel->includecustomfields = $includecustomfields;
189
  $cfModel->importoptionsasattributes = $importoptionsasattributes;
 
190
  $cfModel->instockonly = $instockonly;
191
  $cfModel->start = $start;
192
  $cfModel->pageSize = $pageSize;
@@ -233,6 +236,9 @@ executed in ".( time() - $started_time )." sec.
233
  ";
234
  die();
235
  /* RELEASE NOTES
 
 
 
236
  * 2015-03-30
237
  * Added retrieval of custom product options in case of importoptionsasattributes=true
238
  *
1
  <?php
2
+ define("__VERSION__","2015-04-14");
3
  define("__SCRIPTNAME__",basename(__FILE__));
4
 
5
  class Mage_CodiScript_IndexController extends Mage_Core_Controller_Front_Action{
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
  $start = isset( $_REQUEST["start"] ) ? intval( $_REQUEST["start"] ) : 0;
85
  $pageSize = isset( $_REQUEST["pageSize"] ) ? intval( $_REQUEST["pageSize"] ) : 1000000000;
102
  ignoreassprodimages=".$ignoreassprodimages."
103
  includecustomfields=".( $includecustomfields ? implode( ",", array_keys( $includecustomfields ) ) : $includecustomfields )."
104
  importoptionsasattributes=".$importoptionsasattributes."
105
+ importoptionsassku=".$importoptionsassku."
106
  instockonly=".$instockonly."
107
  start=".$start."
108
  pageSize=".$pageSize."
189
  $cfModel->ignoreassprodimages = $ignoreassprodimages;
190
  $cfModel->includecustomfields = $includecustomfields;
191
  $cfModel->importoptionsasattributes = $importoptionsasattributes;
192
+ $cfModel->importoptionsassku = $importoptionsassku;
193
  $cfModel->instockonly = $instockonly;
194
  $cfModel->start = $start;
195
  $cfModel->pageSize = $pageSize;
236
  ";
237
  die();
238
  /* RELEASE NOTES
239
+ * 2015-04-14
240
+ * Added import of custom simple product options into items, if the option contains a SKU number
241
+ *
242
  * 2015-03-30
243
  * Added retrieval of custom product options in case of importoptionsasattributes=true
244
  *
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Codi</name>
4
- <version>4.2.1</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>
@@ -10,9 +10,9 @@
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>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
13
- <date>2015-03-31</date>
14
- <time>13:39:43</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="d714a47f138b57f074c25269f356b1e3"/></dir><dir name="controllers"><file name="IndexController.php" hash="1008449108e0e32c15c923430b37199e"/></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="183fc591065ced83f878a4c3e23f854c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Codi</name>
4
+ <version>4.2.2</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>
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>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
13
+ <date>2015-04-22</date>
14
+ <time>15:47:48</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="8bccee1630f30cbfe5300a2a9ebeff16"/></dir><dir name="controllers"><file name="IndexController.php" hash="7f2cd9a9979158580cd458d13ce4a33e"/></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="183fc591065ced83f878a4c3e23f854c"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>