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.1.3 |
Comparing to | |
See all releases |
Code changes from version 4.1.2 to 4.1.3
app/code/community/Mage/CodiScript/Model/Files.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
// 2014-
|
3 |
class ConfiguredProductLine{
|
4 |
public $optionIds = array();
|
5 |
public $line = NULL;
|
@@ -12,11 +12,12 @@ class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
|
|
12 |
public $catalogInventoryModel;
|
13 |
public $productTypeGroupedModel;
|
14 |
public $productTypeConfigurableModel;
|
|
|
15 |
public $enablereviews = FALSE;
|
16 |
public $ignoretopcategory = FALSE;
|
17 |
public $includeshortdescription = FALSE;
|
18 |
public $includelongdescription = TRUE;
|
19 |
-
public $
|
20 |
public $publishtieredpricing = FALSE;
|
21 |
public $includetaxes = FALSE;
|
22 |
public $includeinvqty = FALSE;
|
@@ -63,6 +64,15 @@ class Mage_CodiScript_Model_Files extends Mage_Core_Model_Abstract {
|
|
63 |
$this->catalogInventoryModel = Mage::getModel('cataloginventory/stock_item')->setStoreId( $this->StoreId );
|
64 |
$this->mediaurl = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_MEDIA );
|
65 |
$this->prodmediaurl = $this->mediaurl."catalog/product";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
$products = Mage::getModel('catalog/product')->setStoreId( $this->StoreId )->getCollection();
|
67 |
$products->addAttributeToFilter('status', 1);//enabled
|
68 |
$products->addAttributeToFilter('visibility', 4);//catalog, search
|
@@ -114,7 +124,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
114 |
if( $this->includeshortdescription ){
|
115 |
$shortDescription = $product->getShortDescription();
|
116 |
if( !empty( $shortDescription ) ){
|
117 |
-
$shortDescription = $this->
|
118 |
if( strpos( $shortDescription, self::TAG_P ) !== false ){
|
119 |
$new = strlen( $shortDescription );
|
120 |
$pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
|
@@ -128,7 +138,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
128 |
if( $this->includelongdescription ){
|
129 |
$longDescription = $product->getDescription();
|
130 |
if( !empty( $longDescription ) ){
|
131 |
-
$longDescription = $this->
|
132 |
if( strpos( $longDescription, self::TAG_P ) !== false ){
|
133 |
$new = strlen( $longDescription );
|
134 |
$pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
|
@@ -172,12 +182,12 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
172 |
}
|
173 |
}
|
174 |
if($this->publishtieredpricing == "1"){
|
175 |
-
$TierPriceAttributes = $this->
|
176 |
$sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
|
177 |
$ProductAttributes .= $sp.$TierPriceAttributes;
|
178 |
}
|
179 |
if( !empty( $ProductAttributes ) )
|
180 |
-
$ProductAttributes = $this->
|
181 |
// echo "product image: ".$product->getImage()."
|
182 |
//small image: ".$product->getSmallImage()."
|
183 |
//thumbnail: ".$product->getThumbnail()."
|
@@ -204,24 +214,12 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
204 |
$prodImages = implode( "#|#", $prodImages );
|
205 |
$ProductURL = $product->getProductUrl();
|
206 |
if( !empty( $ProductURL ) )
|
207 |
-
$ProductURL = $this->
|
208 |
$productName = $product->getName();
|
209 |
-
$productName = $product->getId().'#$#'.$this->
|
210 |
-
$Reviews = $this->enablereviews ? $this->
|
211 |
if( !empty( $Reviews ) )
|
212 |
-
$Reviews = $this->
|
213 |
-
$ProdRPrice = $product->getData('price');
|
214 |
-
$ProdFPrice = $product->getFinalPrice();
|
215 |
-
$ProdSPrice = $product->getSpecialPrice();
|
216 |
-
$ProdSFromDate = $product->getSpecialFromDate();
|
217 |
-
$ProdSToDate = $product->getSpecialToDate();
|
218 |
-
if($this->_DEBUG) echo "prod prices: Regular=".$ProdRPrice." Final=".$ProdFPrice." Special=".$ProdSPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
|
219 |
-
";
|
220 |
-
if( trim( $ProdSPrice ) == "" ){
|
221 |
-
$ProdSPrice = -1;
|
222 |
-
$ProdSFromDate = FALSE;
|
223 |
-
$ProdSToDate = FALSE;
|
224 |
-
}
|
225 |
if($this->_DEBUG){
|
226 |
echo "associated IDs: ";
|
227 |
foreach($AssociatedProductIds as $UsedProductid) echo "".$UsedProductid." ";
|
@@ -237,9 +235,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
237 |
$renderSPrice = FALSE;
|
238 |
if( $this->includespecialprice ){
|
239 |
foreach($UsedProducts as $UsedProduct){
|
240 |
-
$SPrice = $
|
241 |
-
if( $this->getpricefromchild )
|
242 |
-
$SPrice = $UsedProduct->getSpecialPrice();
|
243 |
if( trim( $SPrice ) != "" ){
|
244 |
$renderSPrice = TRUE;
|
245 |
break;
|
@@ -252,37 +248,48 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
252 |
if($this->_DEBUG) echo "".$UsedProduct->getSku()." prices: Regular=".$UsedProduct->getData('price')." Final=".$UsedProduct->getFinalPrice()." Special=".$UsedProduct->getSpecialPrice()." FromDate=".$UsedProduct->getSpecialFromDate()." ToDate=".$UsedProduct->getSpecialToDate()."
|
253 |
";
|
254 |
$ItemName= $UsedProduct->getName();
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
}
|
266 |
}
|
|
|
|
|
|
|
|
|
|
|
267 |
$SFromDate = $ProdSFromDate;
|
268 |
$SToDate = $ProdSToDate;
|
269 |
$RPrice = $ProdRPrice;
|
270 |
-
if( !empty( $RPrice ) && $this->includetaxes )
|
271 |
-
|
272 |
-
$RPrice = $this->taxhelper->getPrice( $UsedProduct, $RPrice, true );
|
273 |
-
else
|
274 |
-
$RPrice = $this->taxhelper->getPrice( $product, $RPrice, true );
|
275 |
-
}
|
276 |
$SPrice = $ProdSPrice;
|
277 |
-
if( $SPrice >= 0 && $this->includetaxes )
|
278 |
-
|
279 |
-
$SPrice = $this->taxhelper->getPrice( $UsedProduct, $SPrice, true );
|
280 |
-
else
|
281 |
-
$SPrice = $this->taxhelper->getPrice( $product, $SPrice, true );
|
282 |
-
}
|
283 |
if($this->_DEBUG) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$SFromDate." ToDate=".$SToDate."
|
284 |
";
|
285 |
-
if($this->ignoreassprodimages) $itemImages = "";
|
286 |
else{
|
287 |
// echo "grouped item image: ".$UsedProduct->getImage()."
|
288 |
//small image: ".$UsedProduct->getSmallImage()."
|
@@ -339,12 +346,12 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
339 |
if( $this->includeinvqty ){
|
340 |
if( !empty( $ItemAttributes ) )
|
341 |
$ItemAttributes .= "|";
|
342 |
-
$ItemAttributes .= "Inventory=".$this->
|
343 |
}
|
344 |
-
$RPrice = $this->
|
345 |
if( $this->includespecialprice ){
|
346 |
if( $SPrice >= 0 ){
|
347 |
-
$SPrice = $this->
|
348 |
if( !empty( $ItemAttributes ) )
|
349 |
$ItemAttributes .= "|";
|
350 |
$ItemAttributes .= "Special Price=".$SPrice;
|
@@ -368,14 +375,24 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
368 |
$ItemAttributes .= "Special Price To Date=".substr( $SToDate, 0, 10 );
|
369 |
}
|
370 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
$itemID = $UsedProduct->getSku();
|
372 |
-
$ProducttoString .= $this->
|
373 |
."\t" //ItemQty
|
374 |
."\t" //ItemUom
|
375 |
."\t" .$RPrice //ItemPrice
|
376 |
-
."\t" .$this->
|
377 |
."\t" //ItemLink
|
378 |
-
."\t" .$this->
|
379 |
."\t" .$itemImages //ItemGraphic
|
380 |
."\t" .$productName //ProductName
|
381 |
."\t" .$ProductDescription
|
@@ -403,7 +420,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
403 |
if( $this->includeshortdescription ){
|
404 |
$shortDescription = $product->getShortDescription();
|
405 |
if( !empty( $shortDescription ) ){
|
406 |
-
$shortDescription = $this->
|
407 |
if( strpos( $shortDescription, self::TAG_P ) !== false ){
|
408 |
$new = strlen( $shortDescription );
|
409 |
$pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
|
@@ -417,7 +434,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
417 |
if( $this->includelongdescription ){
|
418 |
$longDescription = $product->getDescription();
|
419 |
if( !empty( $longDescription ) ){
|
420 |
-
$longDescription = $this->
|
421 |
if( strpos( $longDescription, self::TAG_P ) !== false ){
|
422 |
$new = strlen( $longDescription );
|
423 |
$pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
|
@@ -456,12 +473,12 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
456 |
}
|
457 |
}
|
458 |
if($this->publishtieredpricing == "1"){
|
459 |
-
$TierPriceAttributes = $this->
|
460 |
$sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
|
461 |
$ProductAttributes.= $sp.$TierPriceAttributes;
|
462 |
}
|
463 |
if( !empty( $ProductAttributes ) )
|
464 |
-
$ProductAttributes = $this->
|
465 |
// echo "product image: ".$product->getImage()."
|
466 |
//small image: ".$product->getSmallImage()."
|
467 |
//thumbnail: ".$product->getThumbnail()."
|
@@ -488,19 +505,41 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
488 |
$prodImages = implode( "#|#", $prodImages );
|
489 |
$ProductURL = $product->getProductUrl();
|
490 |
if( !empty( $ProductURL ) )
|
491 |
-
$ProductURL = $this->
|
492 |
$productName = $product->getName();
|
493 |
-
$productName = $product->getId().'#$#'.$this->
|
494 |
-
$Reviews = $this->enablereviews ? $this->
|
495 |
if( !empty( $Reviews ) )
|
496 |
-
$Reviews = $this->
|
497 |
$ProdRPrice = $product->getData('price');
|
498 |
-
$ProdFPrice = $product->getFinalPrice();
|
499 |
$ProdSPrice = $product->getSpecialPrice();
|
500 |
$ProdSFromDate = $product->getSpecialFromDate();
|
501 |
$ProdSToDate = $product->getSpecialToDate();
|
502 |
-
if($this->_DEBUG) echo "prod prices: Regular=".$ProdRPrice."
|
503 |
";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
if( trim( $ProdSPrice ) == "" ){
|
505 |
$ProdSPrice = -1;
|
506 |
$ProdSFromDate = FALSE;
|
@@ -516,10 +555,9 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
516 |
if($this->_DEBUG){
|
517 |
foreach( $ConfigurableAttributes as $attribute ){
|
518 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
519 |
-
foreach ( $configurableProdAttribute->getSource()->getAllOptions() as $option )
|
520 |
-
echo "variation option: ".
|
521 |
";
|
522 |
-
}
|
523 |
}
|
524 |
}
|
525 |
$UsedProducts = array();
|
@@ -528,7 +566,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
528 |
$UsedProducts[ $UsedProductid ] = $UsedProduct;
|
529 |
}
|
530 |
$cpLines = array();
|
531 |
-
foreach( $UsedProducts as $
|
532 |
$cpLine = new ConfiguredProductLine();
|
533 |
if($this->_DEBUG) echo "".$UsedProduct->getSku()." prices: Regular=".$UsedProduct->getData('price')." Final=".$UsedProduct->getFinalPrice()." Special=".$UsedProduct->getSpecialPrice()." FromDate=".$UsedProduct->getSpecialFromDate()." ToDate=".$UsedProduct->getSpecialToDate()."
|
534 |
";
|
@@ -538,6 +576,16 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
538 |
$SPrice0 = $ProdSPrice;
|
539 |
$SFromDate = !empty($SPrice) ? $ProdSFromDate : FALSE;
|
540 |
$SToDate = !empty($SPrice) ? $ProdSToDate : FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
$attributes = $UsedProduct->getAttributes();
|
542 |
$ItemAttributes = "";
|
543 |
foreach( $ConfigurableAttributes as $attribute ){
|
@@ -566,44 +614,45 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
566 |
if( !empty( $ItemAttributes ) )
|
567 |
$ItemAttributes .= "|";
|
568 |
$ItemAttributes .= $AttributeLabel."=".$AttributeValue;
|
569 |
-
|
570 |
-
|
571 |
-
if( $
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
581 |
}
|
582 |
}
|
583 |
}
|
584 |
}
|
585 |
-
if( $this->
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
$SPrice = $this->taxhelper->getPrice( $UsedProduct, $SPrice, true );
|
590 |
-
} else {
|
591 |
-
if( !empty($RPrice) && $this->includetaxes )
|
592 |
-
$RPrice = $this->taxhelper->getPrice( $product, $RPrice, true );
|
593 |
-
if( !empty($SPrice) && $this->includetaxes )
|
594 |
-
$SPrice = $this->taxhelper->getPrice( $product, $SPrice, true );
|
595 |
-
}
|
596 |
if( $this->includeinvqty ){
|
597 |
if( !empty( $ItemAttributes ) )
|
598 |
$ItemAttributes .= "|";
|
599 |
-
$ItemAttributes .= "Inventory=".$this->
|
600 |
}
|
601 |
if($this->_DEBUG) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$SFromDate." ToDate=".$SToDate."
|
602 |
";
|
603 |
-
$RPrice = $this->
|
604 |
if( $this->includespecialprice ){
|
605 |
if( $SPrice >= 0 ){
|
606 |
-
$SPrice = $this->
|
607 |
if( !empty( $ItemAttributes ) )
|
608 |
$ItemAttributes .= "|";
|
609 |
$ItemAttributes .= "Special Price=".$SPrice;
|
@@ -623,6 +672,15 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
623 |
$ItemAttributes .= "Special Price To Date=".substr( $SToDate, 0, 10 );
|
624 |
}
|
625 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
if($this->ignoreassprodimages) $itemImages = "";
|
627 |
else{
|
628 |
// echo "config item image: ".$UsedProduct->getImage()."
|
@@ -651,13 +709,13 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
651 |
$itemImages = implode( "#|#", $itemImages );
|
652 |
}
|
653 |
$itemID = $UsedProduct->getSku();
|
654 |
-
$cpLine->line = $this->
|
655 |
."\t" //ItemQty
|
656 |
."\t" //ItemUom
|
657 |
."\t" .$RPrice //ItemPrice
|
658 |
."\t" //ItemDescription
|
659 |
."\t" //ItemLink
|
660 |
-
."\t" .$this->
|
661 |
."\t" .$itemImages //ItemitemGraphic
|
662 |
."\t" .$productName //ProductName
|
663 |
."\t" .$ProductDescription
|
@@ -736,7 +794,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
736 |
if( $this->includeshortdescription ){
|
737 |
$shortDescription = $product->getShortDescription();
|
738 |
if( !empty( $shortDescription ) ){
|
739 |
-
$shortDescription = $this->
|
740 |
if( strpos( $shortDescription, self::TAG_P ) !== false ){
|
741 |
$new = strlen( $shortDescription );
|
742 |
$pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
|
@@ -750,7 +808,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
750 |
if( $this->includelongdescription ){
|
751 |
$longDescription = $product->getDescription();
|
752 |
if( !empty( $longDescription ) ){
|
753 |
-
$longDescription = $this->
|
754 |
if( strpos( $longDescription, self::TAG_P ) !== false ){
|
755 |
$new = strlen( $longDescription );
|
756 |
$pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
|
@@ -789,7 +847,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
789 |
if( $this->_DEBUG ) echo "URL= ".$URL."
|
790 |
";
|
791 |
if( !empty( $URL ) )
|
792 |
-
$URL = $this->
|
793 |
$attributes = $product->getAttributes();
|
794 |
$Manufacturer = "";
|
795 |
$ProductAttributes = "";
|
@@ -823,19 +881,40 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
823 |
}
|
824 |
}
|
825 |
if($this->publishtieredpricing == "1"){
|
826 |
-
$TierPriceAttributes = $this->
|
827 |
$sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
|
828 |
$ProductAttributes.= $sp.$TierPriceAttributes;
|
829 |
}
|
830 |
if( !empty( $ProductAttributes ) )
|
831 |
-
$ProductAttributes = $this->
|
832 |
$ProdRPrice = $product->getData('price');
|
833 |
-
$ProdFPrice = $product->getFinalPrice();
|
834 |
$ProdSPrice = $product->getSpecialPrice();
|
835 |
$ProdSFromDate = $product->getSpecialFromDate();
|
836 |
$ProdSToDate = $product->getSpecialToDate();
|
837 |
-
if($this->_DEBUG) echo "prod prices: Regular=".$ProdRPrice."
|
838 |
";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
if( trim( $ProdSPrice ) == "" ){
|
840 |
$ProdSPrice = -1;
|
841 |
$ProdSFromDate = FALSE;
|
@@ -876,11 +955,11 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
876 |
";
|
877 |
$ItemAttributes = "";
|
878 |
if( $this->includeinvqty )
|
879 |
-
$ItemAttributes = "Inventory=".$this->
|
880 |
-
$RPrice = $this->
|
881 |
if( $this->includespecialprice ){
|
882 |
if( $SPrice >= 0 ){
|
883 |
-
$SPrice = $this->
|
884 |
if( !empty( $ItemAttributes ) )
|
885 |
$ItemAttributes .= "|";
|
886 |
$ItemAttributes .= "Special Price=".$SPrice;
|
@@ -900,12 +979,22 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
900 |
$ItemAttributes .= "Special Price To Date=".substr( $ProdSToDate, 0, 10 );
|
901 |
}
|
902 |
}
|
903 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
904 |
if( !empty( $Reviews ) )
|
905 |
-
$Reviews = $this->
|
906 |
$prodSku = $product->getSku();
|
907 |
$prodName = $product->getName();
|
908 |
-
$ProducttoString = $this->
|
909 |
."\t" //ItemQty
|
910 |
."\t" //ItemUom
|
911 |
."\t" .$RPrice //ItemPrice
|
@@ -913,7 +1002,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
913 |
."\t" //ItemLink
|
914 |
."\t" .$ItemAttributes //ItemAttributes
|
915 |
."\t" //ItemitemGraphic
|
916 |
-
."\t" .$product->getId().'#$#'.$this->
|
917 |
."\t" .$ProductDescription //ProductDescription
|
918 |
."\t" .$prodImages //ProductGraphic
|
919 |
."\t" .$URL //ProductLink
|
@@ -947,11 +1036,11 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
947 |
}
|
948 |
}
|
949 |
|
950 |
-
private function
|
951 |
return str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $str ) ) ) );
|
952 |
}
|
953 |
|
954 |
-
private function
|
955 |
$str = str_replace( self::SCRIPTNAME, "index.php", $str );
|
956 |
$pos = strpos( $str, "?" );
|
957 |
if( $pos === false )
|
@@ -960,7 +1049,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
960 |
return substr( $str, 0, $pos );
|
961 |
}
|
962 |
|
963 |
-
private function
|
964 |
$reviewsCollection = $this->reviewsModel->getCollection()
|
965 |
->addStoreFilter($this->StoreId)
|
966 |
->addStatusFilter('approved')
|
@@ -973,7 +1062,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
973 |
return $Reviews;
|
974 |
}
|
975 |
|
976 |
-
private function
|
977 |
$rv = str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $Price ) ) ) );
|
978 |
if( empty( $rv ) || $rv == "0" )
|
979 |
return "";
|
@@ -985,14 +1074,14 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
985 |
return $rv;
|
986 |
}
|
987 |
|
988 |
-
private function
|
989 |
$tail = strrchr( $qty, "." );
|
990 |
if( !empty( $tail ) )
|
991 |
$qty = substr( $qty, 0, strlen( $qty ) - strlen( $tail ) );
|
992 |
return $qty;
|
993 |
}
|
994 |
|
995 |
-
private function
|
996 |
$res="";
|
997 |
$prices = $product->getFormatedTierPrice();
|
998 |
$rightstr = "";
|
@@ -1010,7 +1099,7 @@ memory_get_usage ".memory_get_usage()." / ".memory_get_usage(TRUE)."
|
|
1010 |
$this->taxhelper->getPrice($product,$price['price'],true) :
|
1011 |
$price['price'];
|
1012 |
if( $tierPrice < $prodFinalPrice ){
|
1013 |
-
$tierPrice = $this->
|
1014 |
$rightstr .= $price['price_qty'].'#$#';
|
1015 |
$rightstr.=$tierPrice.'#$#';
|
1016 |
if( $i == $count )
|
@@ -1213,8 +1302,8 @@ Products: ".count( $prodIds )."
|
|
1213 |
if( count( $positions ) > 0 )
|
1214 |
$position = $positions[ $product->getId() ];
|
1215 |
$productName = $product->getName();
|
1216 |
-
$ProducttoString .= $product->getId().'#$#'.$this->
|
1217 |
-
. "\t" . $product->getId().'#$#'.$this->
|
1218 |
. "\t" . $position //Prod Sequence
|
1219 |
. "\tGeneral" //Proj Name
|
1220 |
. "\t" . $hpath //Hirarachi Path
|
@@ -1226,8 +1315,8 @@ Products: ".count( $prodIds )."
|
|
1226 |
}
|
1227 |
if( !$listed ){
|
1228 |
$productName = $product->getName();
|
1229 |
-
$ProducttoString .= $product->getId().'#$#'.$this->
|
1230 |
-
. "\t" . $product->getId().'#$#'.$this->
|
1231 |
. "\t" . $this->unCatPosition //Prod Sequence
|
1232 |
. "\tGeneral" //Proj Name
|
1233 |
. "\tUncategorized" //Hirarachi Path
|
@@ -1260,8 +1349,8 @@ Products: ".count( $prodIds )."
|
|
1260 |
if( count( $positions ) > 0 )
|
1261 |
$position = $positions[ $product->getId() ];
|
1262 |
$productName = $product->getName();
|
1263 |
-
$ProducttoString .= $product->getId().'#$#'. $this->
|
1264 |
-
. "\t" . $product->getId().'#$#'.$this->
|
1265 |
. "\t" . $position //Prod Sequence
|
1266 |
. "\tGeneral" //Proj Name
|
1267 |
. "\t" . $hpath //Hirarachi Path
|
@@ -1273,8 +1362,8 @@ Products: ".count( $prodIds )."
|
|
1273 |
}
|
1274 |
if( !$listed ){
|
1275 |
$productName = $product->getName();
|
1276 |
-
$ProducttoString .= $product->getId().'#$#'.$this->
|
1277 |
-
. "\t" . $product->getId().'#$#'.$this->
|
1278 |
. "\t" . $this->unCatPosition //Prod Sequence
|
1279 |
. "\tGeneral" //Proj Name
|
1280 |
. "\tUncategorized" //Hirarachi Path
|
1 |
<?php
|
2 |
+
// 2014-04-01
|
3 |
class ConfiguredProductLine{
|
4 |
public $optionIds = array();
|
5 |
public $line = NULL;
|
12 |
public $catalogInventoryModel;
|
13 |
public $productTypeGroupedModel;
|
14 |
public $productTypeConfigurableModel;
|
15 |
+
public $customerGroups = FALSE;
|
16 |
public $enablereviews = FALSE;
|
17 |
public $ignoretopcategory = FALSE;
|
18 |
public $includeshortdescription = FALSE;
|
19 |
public $includelongdescription = TRUE;
|
20 |
+
public $getgroupprices = FALSE;
|
21 |
public $publishtieredpricing = FALSE;
|
22 |
public $includetaxes = FALSE;
|
23 |
public $includeinvqty = FALSE;
|
64 |
$this->catalogInventoryModel = Mage::getModel('cataloginventory/stock_item')->setStoreId( $this->StoreId );
|
65 |
$this->mediaurl = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_MEDIA );
|
66 |
$this->prodmediaurl = $this->mediaurl."catalog/product";
|
67 |
+
if( $this->publishtieredpricing || $this->getgroupprices ){
|
68 |
+
$this->customerGroups = array();
|
69 |
+
$customerGroups = Mage::getModel('customer/group')->getCollection();
|
70 |
+
foreach( $customerGroups as $cg ){
|
71 |
+
$this->customerGroups[$cg->_data['customer_group_id']] = $cg->_data['customer_group_code'];
|
72 |
+
if($this->_DEBUG) echo "customer group #".$cg->_data['customer_group_id']."-".$cg->_data['customer_group_code']."
|
73 |
+
";
|
74 |
+
}
|
75 |
+
}
|
76 |
$products = Mage::getModel('catalog/product')->setStoreId( $this->StoreId )->getCollection();
|
77 |
$products->addAttributeToFilter('status', 1);//enabled
|
78 |
$products->addAttributeToFilter('visibility', 4);//catalog, search
|
124 |
if( $this->includeshortdescription ){
|
125 |
$shortDescription = $product->getShortDescription();
|
126 |
if( !empty( $shortDescription ) ){
|
127 |
+
$shortDescription = $this->_cleanStr( $shortDescription );
|
128 |
if( strpos( $shortDescription, self::TAG_P ) !== false ){
|
129 |
$new = strlen( $shortDescription );
|
130 |
$pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
|
138 |
if( $this->includelongdescription ){
|
139 |
$longDescription = $product->getDescription();
|
140 |
if( !empty( $longDescription ) ){
|
141 |
+
$longDescription = $this->_cleanStr( $longDescription );
|
142 |
if( strpos( $longDescription, self::TAG_P ) !== false ){
|
143 |
$new = strlen( $longDescription );
|
144 |
$pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
|
182 |
}
|
183 |
}
|
184 |
if($this->publishtieredpricing == "1"){
|
185 |
+
$TierPriceAttributes = $this->_getTierPrices( $product );
|
186 |
$sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
|
187 |
$ProductAttributes .= $sp.$TierPriceAttributes;
|
188 |
}
|
189 |
if( !empty( $ProductAttributes ) )
|
190 |
+
$ProductAttributes = $this->_cleanStr( $ProductAttributes );
|
191 |
// echo "product image: ".$product->getImage()."
|
192 |
//small image: ".$product->getSmallImage()."
|
193 |
//thumbnail: ".$product->getThumbnail()."
|
214 |
$prodImages = implode( "#|#", $prodImages );
|
215 |
$ProductURL = $product->getProductUrl();
|
216 |
if( !empty( $ProductURL ) )
|
217 |
+
$ProductURL = $this->_correctProdUrlStr( $ProductURL );
|
218 |
$productName = $product->getName();
|
219 |
+
$productName = $product->getId().'#$#'.$this->_cleanStr( $productName );
|
220 |
+
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
221 |
if( !empty( $Reviews ) )
|
222 |
+
$Reviews = $this->_cleanStr( $Reviews );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
if($this->_DEBUG){
|
224 |
echo "associated IDs: ";
|
225 |
foreach($AssociatedProductIds as $UsedProductid) echo "".$UsedProductid." ";
|
235 |
$renderSPrice = FALSE;
|
236 |
if( $this->includespecialprice ){
|
237 |
foreach($UsedProducts as $UsedProduct){
|
238 |
+
$SPrice = $UsedProduct->getSpecialPrice();
|
|
|
|
|
239 |
if( trim( $SPrice ) != "" ){
|
240 |
$renderSPrice = TRUE;
|
241 |
break;
|
248 |
if($this->_DEBUG) echo "".$UsedProduct->getSku()." prices: Regular=".$UsedProduct->getData('price')." Final=".$UsedProduct->getFinalPrice()." Special=".$UsedProduct->getSpecialPrice()." FromDate=".$UsedProduct->getSpecialFromDate()." ToDate=".$UsedProduct->getSpecialToDate()."
|
249 |
";
|
250 |
$ItemName= $UsedProduct->getName();
|
251 |
+
$ProdRPrice = $UsedProduct->getData('price');
|
252 |
+
$ProdSPrice = $UsedProduct->getSpecialPrice();
|
253 |
+
$ProdSFromDate = $UsedProduct->getSpecialFromDate();
|
254 |
+
$ProdSToDate = $UsedProduct->getSpecialToDate();
|
255 |
+
$ProdGroupPrices = FALSE;
|
256 |
+
$mageVersionArray = Mage::getVersionInfo();
|
257 |
+
if( $mageVersionArray[ 'major' ] > 1 || $mageVersionArray[ 'minor' ] > 6 ){
|
258 |
+
$ProdGroupPrices = $UsedProduct->getData('group_price');
|
259 |
+
if( $this->_DEBUG && count( $ProdGroupPrices ) > 0 ) echo "group_price: ".var_export( $ProdGroupPrices, true )."
|
260 |
+
";
|
261 |
+
}
|
262 |
+
$ProdSpecGroupPrices = FALSE;
|
263 |
+
if( $ProdGroupPrices ){
|
264 |
+
$ProdSpecGroupPrices = array();
|
265 |
+
foreach( $ProdGroupPrices as $groupPrice ){
|
266 |
+
if( $groupPrice[ 'cust_group' ] == '0' ){
|
267 |
+
$notLoggedInPrice = 0.0 + $groupPrice[ 'price' ];
|
268 |
+
if( trim( $ProdSPrice ) == "" || $notLoggedInPrice < 0.0 + $ProdSPrice ){
|
269 |
+
$ProdSPrice = $groupPrice[ 'price' ];
|
270 |
+
$ProdSFromDate = FALSE;
|
271 |
+
$ProdSToDate = FALSE;
|
272 |
+
}
|
273 |
+
} else
|
274 |
+
$ProdSpecGroupPrices[] = $groupPrice;
|
275 |
}
|
276 |
}
|
277 |
+
if( trim( $ProdSPrice ) == "" ){
|
278 |
+
$ProdSPrice = -1;
|
279 |
+
$ProdSFromDate = FALSE;
|
280 |
+
$ProdSToDate = FALSE;
|
281 |
+
}
|
282 |
$SFromDate = $ProdSFromDate;
|
283 |
$SToDate = $ProdSToDate;
|
284 |
$RPrice = $ProdRPrice;
|
285 |
+
if( !empty( $RPrice ) && $this->includetaxes )
|
286 |
+
$RPrice = $this->taxhelper->getPrice( $UsedProduct, $RPrice, true );
|
|
|
|
|
|
|
|
|
287 |
$SPrice = $ProdSPrice;
|
288 |
+
if( $SPrice >= 0 && $this->includetaxes )
|
289 |
+
$SPrice = $this->taxhelper->getPrice( $UsedProduct, $SPrice, true );
|
|
|
|
|
|
|
|
|
290 |
if($this->_DEBUG) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$SFromDate." ToDate=".$SToDate."
|
291 |
";
|
292 |
+
if( $this->ignoreassprodimages ) $itemImages = "";
|
293 |
else{
|
294 |
// echo "grouped item image: ".$UsedProduct->getImage()."
|
295 |
//small image: ".$UsedProduct->getSmallImage()."
|
346 |
if( $this->includeinvqty ){
|
347 |
if( !empty( $ItemAttributes ) )
|
348 |
$ItemAttributes .= "|";
|
349 |
+
$ItemAttributes .= "Inventory=".$this->_formatQty( "".$this->catalogInventoryModel->loadByProduct( $UsedProduct )->getQty() );
|
350 |
}
|
351 |
+
$RPrice = $this->_formatPrice( $RPrice );
|
352 |
if( $this->includespecialprice ){
|
353 |
if( $SPrice >= 0 ){
|
354 |
+
$SPrice = $this->_formatPrice( $SPrice );
|
355 |
if( !empty( $ItemAttributes ) )
|
356 |
$ItemAttributes .= "|";
|
357 |
$ItemAttributes .= "Special Price=".$SPrice;
|
375 |
$ItemAttributes .= "Special Price To Date=".substr( $SToDate, 0, 10 );
|
376 |
}
|
377 |
}
|
378 |
+
if( $ProdSpecGroupPrices ){
|
379 |
+
foreach( $ProdSpecGroupPrices as $groupPrice ){
|
380 |
+
$price = 0.0 + $groupPrice[ 'price' ];
|
381 |
+
if( $price >= 0 && $this->includetaxes )
|
382 |
+
$price = $this->taxhelper->getPrice( $UsedProduct, $price, true );
|
383 |
+
if( !empty( $ItemAttributes ) )
|
384 |
+
$ItemAttributes .= "|";
|
385 |
+
$ItemAttributes .= "price_".$this->customerGroups[ $groupPrice[ 'cust_group' ] ]."=".$this->_formatPrice( $price );
|
386 |
+
}
|
387 |
+
}
|
388 |
$itemID = $UsedProduct->getSku();
|
389 |
+
$ProducttoString .= $this->_cleanStr( $itemID ) //ItemID
|
390 |
."\t" //ItemQty
|
391 |
."\t" //ItemUom
|
392 |
."\t" .$RPrice //ItemPrice
|
393 |
+
."\t" .$this->_cleanStr( $ItemName) //ItemDescription
|
394 |
."\t" //ItemLink
|
395 |
+
."\t" .$this->_cleanStr( $ItemAttributes ) //ItemAttributes
|
396 |
."\t" .$itemImages //ItemGraphic
|
397 |
."\t" .$productName //ProductName
|
398 |
."\t" .$ProductDescription
|
420 |
if( $this->includeshortdescription ){
|
421 |
$shortDescription = $product->getShortDescription();
|
422 |
if( !empty( $shortDescription ) ){
|
423 |
+
$shortDescription = $this->_cleanStr( $shortDescription );
|
424 |
if( strpos( $shortDescription, self::TAG_P ) !== false ){
|
425 |
$new = strlen( $shortDescription );
|
426 |
$pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
|
434 |
if( $this->includelongdescription ){
|
435 |
$longDescription = $product->getDescription();
|
436 |
if( !empty( $longDescription ) ){
|
437 |
+
$longDescription = $this->_cleanStr( $longDescription );
|
438 |
if( strpos( $longDescription, self::TAG_P ) !== false ){
|
439 |
$new = strlen( $longDescription );
|
440 |
$pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
|
473 |
}
|
474 |
}
|
475 |
if($this->publishtieredpricing == "1"){
|
476 |
+
$TierPriceAttributes = $this->_getTierPrices($product);
|
477 |
$sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
|
478 |
$ProductAttributes.= $sp.$TierPriceAttributes;
|
479 |
}
|
480 |
if( !empty( $ProductAttributes ) )
|
481 |
+
$ProductAttributes = $this->_cleanStr( $ProductAttributes );
|
482 |
// echo "product image: ".$product->getImage()."
|
483 |
//small image: ".$product->getSmallImage()."
|
484 |
//thumbnail: ".$product->getThumbnail()."
|
505 |
$prodImages = implode( "#|#", $prodImages );
|
506 |
$ProductURL = $product->getProductUrl();
|
507 |
if( !empty( $ProductURL ) )
|
508 |
+
$ProductURL = $this->_correctProdUrlStr( $ProductURL );
|
509 |
$productName = $product->getName();
|
510 |
+
$productName = $product->getId().'#$#'.$this->_cleanStr( $productName );
|
511 |
+
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
512 |
if( !empty( $Reviews ) )
|
513 |
+
$Reviews = $this->_cleanStr( $Reviews );
|
514 |
$ProdRPrice = $product->getData('price');
|
|
|
515 |
$ProdSPrice = $product->getSpecialPrice();
|
516 |
$ProdSFromDate = $product->getSpecialFromDate();
|
517 |
$ProdSToDate = $product->getSpecialToDate();
|
518 |
+
if($this->_DEBUG) echo "prod prices: Regular=".$ProdRPrice." Special=".$ProdSPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
|
519 |
";
|
520 |
+
$ProdGroupPrices = FALSE;
|
521 |
+
$mageVersionArray = Mage::getVersionInfo();
|
522 |
+
if( $mageVersionArray[ 'major' ] > 1 || $mageVersionArray[ 'minor' ] > 6 ){
|
523 |
+
$ProdGroupPrices = $product->getData('group_price');
|
524 |
+
if( $this->_DEBUG && count( $ProdGroupPrices ) > 0 ) echo "group_price: ".var_export( $ProdGroupPrices, true )."
|
525 |
+
";
|
526 |
+
}
|
527 |
+
$ProdSpecGroupPrices = FALSE;
|
528 |
+
if( $ProdGroupPrices ){
|
529 |
+
$ProdSpecGroupPrices = array();
|
530 |
+
foreach( $ProdGroupPrices as $groupPrice ){
|
531 |
+
if( $groupPrice[ 'cust_group' ] == '0' ){
|
532 |
+
$notLoggedInPrice = 0.0 + $groupPrice[ 'price' ];
|
533 |
+
if( trim( $ProdSPrice ) == "" || $notLoggedInPrice < 0.0 + $ProdSPrice ){
|
534 |
+
$ProdSPrice = $groupPrice[ 'price' ];
|
535 |
+
$ProdSFromDate = FALSE;
|
536 |
+
$ProdSToDate = FALSE;
|
537 |
+
}
|
538 |
+
} else {
|
539 |
+
$ProdSpecGroupPrices[] = $groupPrice;
|
540 |
+
}
|
541 |
+
}
|
542 |
+
}
|
543 |
if( trim( $ProdSPrice ) == "" ){
|
544 |
$ProdSPrice = -1;
|
545 |
$ProdSFromDate = FALSE;
|
555 |
if($this->_DEBUG){
|
556 |
foreach( $ConfigurableAttributes as $attribute ){
|
557 |
$configurableProdAttribute = $attribute->getProductAttribute();
|
558 |
+
foreach ( $configurableProdAttribute->getSource()->getAllOptions() as $option )
|
559 |
+
echo "variation option: ".$option['value' ]."=>".$option['label' ]."
|
560 |
";
|
|
|
561 |
}
|
562 |
}
|
563 |
$UsedProducts = array();
|
566 |
$UsedProducts[ $UsedProductid ] = $UsedProduct;
|
567 |
}
|
568 |
$cpLines = array();
|
569 |
+
foreach( $UsedProducts as $UsedProductid => $UsedProduct ){
|
570 |
$cpLine = new ConfiguredProductLine();
|
571 |
if($this->_DEBUG) echo "".$UsedProduct->getSku()." prices: Regular=".$UsedProduct->getData('price')." Final=".$UsedProduct->getFinalPrice()." Special=".$UsedProduct->getSpecialPrice()." FromDate=".$UsedProduct->getSpecialFromDate()." ToDate=".$UsedProduct->getSpecialToDate()."
|
572 |
";
|
576 |
$SPrice0 = $ProdSPrice;
|
577 |
$SFromDate = !empty($SPrice) ? $ProdSFromDate : FALSE;
|
578 |
$SToDate = !empty($SPrice) ? $ProdSToDate : FALSE;
|
579 |
+
$SpecGroupPrices = FALSE;
|
580 |
+
$SpecGroupPrices0 = FALSE;
|
581 |
+
if( $ProdSpecGroupPrices ){
|
582 |
+
$SpecGroupPrices = array();
|
583 |
+
$SpecGroupPrices0 = array();
|
584 |
+
foreach( $ProdSpecGroupPrices as $prodGroupPrice ){
|
585 |
+
$SpecGroupPrices[ $prodGroupPrice[ 'cust_group' ] ] = 0.0 + $prodGroupPrice[ 'price' ];
|
586 |
+
$SpecGroupPrices0[ $prodGroupPrice[ 'cust_group' ] ] = 0.0 + $prodGroupPrice[ 'price' ];
|
587 |
+
}
|
588 |
+
}
|
589 |
$attributes = $UsedProduct->getAttributes();
|
590 |
$ItemAttributes = "";
|
591 |
foreach( $ConfigurableAttributes as $attribute ){
|
614 |
if( !empty( $ItemAttributes ) )
|
615 |
$ItemAttributes .= "|";
|
616 |
$ItemAttributes .= $AttributeLabel."=".$AttributeValue;
|
617 |
+
foreach( $attribute->getPrices() as $addedPrice ){
|
618 |
+
if( $AttributeValue == $addedPrice['label']){
|
619 |
+
if( $addedPrice['is_percent'] ){
|
620 |
+
$RPrice += round( $RPrice0 * $addedPrice['pricing_value'] / 100, 2 );
|
621 |
+
if( $SPrice >= 0 )
|
622 |
+
$SPrice += round( $RPrice0 * $addedPrice['pricing_value'] / 100, 2 );
|
623 |
+
if( $SpecGroupPrices ){
|
624 |
+
foreach( $SpecGroupPrices0 as $key => $value ){
|
625 |
+
$SpecGroupPrices[ $key ] += round( $value * $addedPrice['pricing_value'] / 100, 2 );
|
626 |
+
}
|
627 |
+
}
|
628 |
+
} else {
|
629 |
+
$RPrice += $addedPrice['pricing_value'];
|
630 |
+
if( $SPrice >= 0 )
|
631 |
+
$SPrice += $addedPrice['pricing_value'];
|
632 |
+
if( $SpecGroupPrices ){
|
633 |
+
foreach( $SpecGroupPrices0 as $key => $value ){
|
634 |
+
$SpecGroupPrices[ $key ] += $addedPrice['pricing_value'];
|
635 |
+
}
|
636 |
+
}
|
637 |
}
|
638 |
}
|
639 |
}
|
640 |
}
|
641 |
+
if( !empty($RPrice) && $this->includetaxes )
|
642 |
+
$RPrice = $this->taxhelper->getPrice( $UsedProduct, $RPrice, true );
|
643 |
+
if( !empty($SPrice) && $this->includetaxes )
|
644 |
+
$SPrice = $this->taxhelper->getPrice( $UsedProduct, $SPrice, true );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
645 |
if( $this->includeinvqty ){
|
646 |
if( !empty( $ItemAttributes ) )
|
647 |
$ItemAttributes .= "|";
|
648 |
+
$ItemAttributes .= "Inventory=".$this->_formatQty( "".$this->catalogInventoryModel->loadByProduct( $UsedProduct )->getQty() );
|
649 |
}
|
650 |
if($this->_DEBUG) echo "resulting prices: Regular=".$RPrice." Special=".$SPrice." FromDate=".$SFromDate." ToDate=".$SToDate."
|
651 |
";
|
652 |
+
$RPrice = $this->_formatPrice( $RPrice );
|
653 |
if( $this->includespecialprice ){
|
654 |
if( $SPrice >= 0 ){
|
655 |
+
$SPrice = $this->_formatPrice( $SPrice );
|
656 |
if( !empty( $ItemAttributes ) )
|
657 |
$ItemAttributes .= "|";
|
658 |
$ItemAttributes .= "Special Price=".$SPrice;
|
672 |
$ItemAttributes .= "Special Price To Date=".substr( $SToDate, 0, 10 );
|
673 |
}
|
674 |
}
|
675 |
+
if( $SpecGroupPrices ){
|
676 |
+
foreach( $SpecGroupPrices as $groupID => $price ){
|
677 |
+
if( $price >= 0 && $this->includetaxes )
|
678 |
+
$price = $this->taxhelper->getPrice( $UsedProduct, $price, true );
|
679 |
+
if( !empty( $ItemAttributes ) )
|
680 |
+
$ItemAttributes .= "|";
|
681 |
+
$ItemAttributes .= "price_".$this->customerGroups[ $groupID ]."=".$this->_formatPrice( $price );
|
682 |
+
}
|
683 |
+
}
|
684 |
if($this->ignoreassprodimages) $itemImages = "";
|
685 |
else{
|
686 |
// echo "config item image: ".$UsedProduct->getImage()."
|
709 |
$itemImages = implode( "#|#", $itemImages );
|
710 |
}
|
711 |
$itemID = $UsedProduct->getSku();
|
712 |
+
$cpLine->line = $this->_cleanStr( $itemID ) //ItemID
|
713 |
."\t" //ItemQty
|
714 |
."\t" //ItemUom
|
715 |
."\t" .$RPrice //ItemPrice
|
716 |
."\t" //ItemDescription
|
717 |
."\t" //ItemLink
|
718 |
+
."\t" .$this->_cleanStr( $ItemAttributes ) //ItemAttributes
|
719 |
."\t" .$itemImages //ItemitemGraphic
|
720 |
."\t" .$productName //ProductName
|
721 |
."\t" .$ProductDescription
|
794 |
if( $this->includeshortdescription ){
|
795 |
$shortDescription = $product->getShortDescription();
|
796 |
if( !empty( $shortDescription ) ){
|
797 |
+
$shortDescription = $this->_cleanStr( $shortDescription );
|
798 |
if( strpos( $shortDescription, self::TAG_P ) !== false ){
|
799 |
$new = strlen( $shortDescription );
|
800 |
$pos = strrpos( $shortDescription, self::TAG_P_CLOSE ) + 4;
|
808 |
if( $this->includelongdescription ){
|
809 |
$longDescription = $product->getDescription();
|
810 |
if( !empty( $longDescription ) ){
|
811 |
+
$longDescription = $this->_cleanStr( $longDescription );
|
812 |
if( strpos( $longDescription, self::TAG_P ) !== false ){
|
813 |
$new = strlen( $longDescription );
|
814 |
$pos = strrpos( $longDescription, self::TAG_P_CLOSE ) + 4;
|
847 |
if( $this->_DEBUG ) echo "URL= ".$URL."
|
848 |
";
|
849 |
if( !empty( $URL ) )
|
850 |
+
$URL = $this->_correctProdUrlStr( $URL );
|
851 |
$attributes = $product->getAttributes();
|
852 |
$Manufacturer = "";
|
853 |
$ProductAttributes = "";
|
881 |
}
|
882 |
}
|
883 |
if($this->publishtieredpricing == "1"){
|
884 |
+
$TierPriceAttributes = $this->_getTierPrices( $product );
|
885 |
$sp = ( empty( $ProductAttributes ) || empty( $TierPriceAttributes ) ) ? "" : "|";
|
886 |
$ProductAttributes.= $sp.$TierPriceAttributes;
|
887 |
}
|
888 |
if( !empty( $ProductAttributes ) )
|
889 |
+
$ProductAttributes = $this->_cleanStr( $ProductAttributes );
|
890 |
$ProdRPrice = $product->getData('price');
|
|
|
891 |
$ProdSPrice = $product->getSpecialPrice();
|
892 |
$ProdSFromDate = $product->getSpecialFromDate();
|
893 |
$ProdSToDate = $product->getSpecialToDate();
|
894 |
+
if($this->_DEBUG) echo "prod prices: Regular=".$ProdRPrice." Special=".$ProdSPrice." FromDate=".$ProdSFromDate." ToDate=".$ProdSToDate."
|
895 |
";
|
896 |
+
$ProdGroupPrices = FALSE;
|
897 |
+
$mageVersionArray = Mage::getVersionInfo();
|
898 |
+
if( $mageVersionArray[ 'major' ] > 1 || $mageVersionArray[ 'minor' ] > 6 ){
|
899 |
+
$ProdGroupPrices = $product->getData('group_price');
|
900 |
+
if( $this->_DEBUG && count( $ProdGroupPrices ) > 0 ) echo "group_price: ".var_export( $ProdGroupPrices, true )."
|
901 |
+
";
|
902 |
+
}
|
903 |
+
$ProdSpecGroupPrices = FALSE;
|
904 |
+
if( $ProdGroupPrices ){
|
905 |
+
$ProdSpecGroupPrices = array();
|
906 |
+
foreach( $ProdGroupPrices as $groupPrice ){
|
907 |
+
if( $groupPrice[ 'cust_group' ] == '0' ){
|
908 |
+
$notLoggedInPrice = 0.0 + $groupPrice[ 'price' ];
|
909 |
+
if( trim( $ProdSPrice ) == "" || $notLoggedInPrice < 0.0 + $ProdSPrice ){
|
910 |
+
$ProdSPrice = $groupPrice[ 'price' ];
|
911 |
+
$ProdSFromDate = FALSE;
|
912 |
+
$ProdSToDate = FALSE;
|
913 |
+
}
|
914 |
+
} else
|
915 |
+
$ProdSpecGroupPrices[] = $groupPrice;
|
916 |
+
}
|
917 |
+
}
|
918 |
if( trim( $ProdSPrice ) == "" ){
|
919 |
$ProdSPrice = -1;
|
920 |
$ProdSFromDate = FALSE;
|
955 |
";
|
956 |
$ItemAttributes = "";
|
957 |
if( $this->includeinvqty )
|
958 |
+
$ItemAttributes = "Inventory=".$this->_formatQty( "".$this->catalogInventoryModel->loadByProduct( $product )->getQty() );
|
959 |
+
$RPrice = $this->_formatPrice( $RPrice );
|
960 |
if( $this->includespecialprice ){
|
961 |
if( $SPrice >= 0 ){
|
962 |
+
$SPrice = $this->_formatPrice( $SPrice );
|
963 |
if( !empty( $ItemAttributes ) )
|
964 |
$ItemAttributes .= "|";
|
965 |
$ItemAttributes .= "Special Price=".$SPrice;
|
979 |
$ItemAttributes .= "Special Price To Date=".substr( $ProdSToDate, 0, 10 );
|
980 |
}
|
981 |
}
|
982 |
+
if( $ProdSpecGroupPrices ){
|
983 |
+
foreach( $ProdSpecGroupPrices as $groupPrice ){
|
984 |
+
$price = 0.0 + $groupPrice[ 'price' ];
|
985 |
+
if( $price >= 0 && $this->includetaxes )
|
986 |
+
$price = $this->taxhelper->getPrice( $product, $price, true );
|
987 |
+
if( !empty( $ItemAttributes ) )
|
988 |
+
$ItemAttributes .= "|";
|
989 |
+
$ItemAttributes .= "price_".$this->customerGroups[ $groupPrice[ 'cust_group' ] ]."=".$this->_formatPrice( $price );
|
990 |
+
}
|
991 |
+
}
|
992 |
+
$Reviews = $this->enablereviews ? $this->_getReviews($product->getId()) : '';
|
993 |
if( !empty( $Reviews ) )
|
994 |
+
$Reviews = $this->_cleanStr( $Reviews );
|
995 |
$prodSku = $product->getSku();
|
996 |
$prodName = $product->getName();
|
997 |
+
$ProducttoString = $this->_cleanStr( $prodSku ) //ItemID
|
998 |
."\t" //ItemQty
|
999 |
."\t" //ItemUom
|
1000 |
."\t" .$RPrice //ItemPrice
|
1002 |
."\t" //ItemLink
|
1003 |
."\t" .$ItemAttributes //ItemAttributes
|
1004 |
."\t" //ItemitemGraphic
|
1005 |
+
."\t" .$product->getId().'#$#'.$this->_cleanStr( $prodName ) //ProductName
|
1006 |
."\t" .$ProductDescription //ProductDescription
|
1007 |
."\t" .$prodImages //ProductGraphic
|
1008 |
."\t" .$URL //ProductLink
|
1036 |
}
|
1037 |
}
|
1038 |
|
1039 |
+
private function _cleanStr( &$str ){
|
1040 |
return str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $str ) ) ) );
|
1041 |
}
|
1042 |
|
1043 |
+
private function _correctProdUrlStr( &$str ){
|
1044 |
$str = str_replace( self::SCRIPTNAME, "index.php", $str );
|
1045 |
$pos = strpos( $str, "?" );
|
1046 |
if( $pos === false )
|
1049 |
return substr( $str, 0, $pos );
|
1050 |
}
|
1051 |
|
1052 |
+
private function _getReviews( $productid ){
|
1053 |
$reviewsCollection = $this->reviewsModel->getCollection()
|
1054 |
->addStoreFilter($this->StoreId)
|
1055 |
->addStatusFilter('approved')
|
1062 |
return $Reviews;
|
1063 |
}
|
1064 |
|
1065 |
+
private function _formatPrice( $Price ){
|
1066 |
$rv = str_replace("\n"," ", str_replace("\r"," ", str_replace("\r\n"," ", str_replace("\t"," ", $Price ) ) ) );
|
1067 |
if( empty( $rv ) || $rv == "0" )
|
1068 |
return "";
|
1074 |
return $rv;
|
1075 |
}
|
1076 |
|
1077 |
+
private function _formatQty( $qty ){
|
1078 |
$tail = strrchr( $qty, "." );
|
1079 |
if( !empty( $tail ) )
|
1080 |
$qty = substr( $qty, 0, strlen( $qty ) - strlen( $tail ) );
|
1081 |
return $qty;
|
1082 |
}
|
1083 |
|
1084 |
+
private function _getTierPrices( &$product ){
|
1085 |
$res="";
|
1086 |
$prices = $product->getFormatedTierPrice();
|
1087 |
$rightstr = "";
|
1099 |
$this->taxhelper->getPrice($product,$price['price'],true) :
|
1100 |
$price['price'];
|
1101 |
if( $tierPrice < $prodFinalPrice ){
|
1102 |
+
$tierPrice = $this->_formatPrice( "".$tierPrice );
|
1103 |
$rightstr .= $price['price_qty'].'#$#';
|
1104 |
$rightstr.=$tierPrice.'#$#';
|
1105 |
if( $i == $count )
|
1302 |
if( count( $positions ) > 0 )
|
1303 |
$position = $positions[ $product->getId() ];
|
1304 |
$productName = $product->getName();
|
1305 |
+
$ProducttoString .= $product->getId().'#$#'.$this->_cleanStr( $productName ) //ProductKey
|
1306 |
+
. "\t" . $product->getId().'#$#'.$this->_cleanStr( $productName ) //Product Name
|
1307 |
. "\t" . $position //Prod Sequence
|
1308 |
. "\tGeneral" //Proj Name
|
1309 |
. "\t" . $hpath //Hirarachi Path
|
1315 |
}
|
1316 |
if( !$listed ){
|
1317 |
$productName = $product->getName();
|
1318 |
+
$ProducttoString .= $product->getId().'#$#'.$this->_cleanStr( $productName ) //ProductKey
|
1319 |
+
. "\t" . $product->getId().'#$#'.$this->_cleanStr( $productName ) //Product Name
|
1320 |
. "\t" . $this->unCatPosition //Prod Sequence
|
1321 |
. "\tGeneral" //Proj Name
|
1322 |
. "\tUncategorized" //Hirarachi Path
|
1349 |
if( count( $positions ) > 0 )
|
1350 |
$position = $positions[ $product->getId() ];
|
1351 |
$productName = $product->getName();
|
1352 |
+
$ProducttoString .= $product->getId().'#$#'. $this->_cleanStr( $productName ) //ProductKey
|
1353 |
+
. "\t" . $product->getId().'#$#'.$this->_cleanStr( $productName ) //Product Name
|
1354 |
. "\t" . $position //Prod Sequence
|
1355 |
. "\tGeneral" //Proj Name
|
1356 |
. "\t" . $hpath //Hirarachi Path
|
1362 |
}
|
1363 |
if( !$listed ){
|
1364 |
$productName = $product->getName();
|
1365 |
+
$ProducttoString .= $product->getId().'#$#'.$this->_cleanStr( $productName ) //ProductKey
|
1366 |
+
. "\t" . $product->getId().'#$#'.$this->_cleanStr( $productName ) //Product Name
|
1367 |
. "\t" . $this->unCatPosition //Prod Sequence
|
1368 |
. "\tGeneral" //Proj Name
|
1369 |
. "\tUncategorized" //Hirarachi Path
|
app/code/community/Mage/CodiScript/controllers/IndexController.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
define("__VERSION__","2014-
|
3 |
define("__SCRIPTNAME__",basename(__FILE__));
|
4 |
|
5 |
class Mage_CodiScript_IndexController extends Mage_Core_Controller_Front_Action{
|
@@ -53,7 +53,6 @@ if( $Class=="DataFile" ){
|
|
53 |
$ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
|
54 |
$includeshortdescription = ( isset($_REQUEST["includeshortdescription"]) && $_REQUEST["includeshortdescription"] == "1" );
|
55 |
$includelongdescription = ( isset($_REQUEST["includelongdescription"]) ? $_REQUEST["includelongdescription"] == "1" : TRUE );
|
56 |
-
$getpricefromchild = ( isset($_REQUEST["getpricefromchild"]) && $_REQUEST["getpricefromchild"] == "1" );
|
57 |
$publishtieredpricing = ( isset($_REQUEST["publishtieredpricing"]) && $_REQUEST["publishtieredpricing"] == "1" );
|
58 |
$quantitylabel = isset($_REQUEST["quantitylabel"]) ? $_REQUEST["quantitylabel"] : "Quantity";
|
59 |
$pricelabel = isset($_REQUEST["pricelabel"]) ? $_REQUEST["pricelabel"] : "Price";
|
@@ -83,7 +82,6 @@ if( $Class=="DataFile" ){
|
|
83 |
ignoretopcategory=".$ignoretopcategory."
|
84 |
includeshortdescription=".$includeshortdescription."
|
85 |
includelongdescription=".$includelongdescription."
|
86 |
-
getpricefromchild=".$getpricefromchild."
|
87 |
publishtieredpricing=".$publishtieredpricing."
|
88 |
quantitylabel=".$quantitylabel."
|
89 |
pricelabel=".$pricelabel."
|
@@ -162,7 +160,6 @@ if($Class=="DataFile"){
|
|
162 |
$cfModel->ignoretopcategory = $ignoretopcategory;
|
163 |
$cfModel->includeshortdescription = $includeshortdescription;
|
164 |
$cfModel->includelongdescription = $includelongdescription;
|
165 |
-
$cfModel->getpricefromchild = $getpricefromchild;
|
166 |
$cfModel->publishtieredpricing = $publishtieredpricing;
|
167 |
$cfModel->quantitylabel = $quantitylabel;
|
168 |
$cfModel->pricelabel = $pricelabel;
|
@@ -219,6 +216,10 @@ executed in ".( time() - $started_time )." sec.
|
|
219 |
";
|
220 |
die();
|
221 |
/* RELEASE NOTES
|
|
|
|
|
|
|
|
|
222 |
* 2014-02-24
|
223 |
* 1. includecustomfields parameter added / implemented
|
224 |
* 2. Improved langiage-specific section rendering
|
1 |
<?php
|
2 |
+
define("__VERSION__","2014-04-01");
|
3 |
define("__SCRIPTNAME__",basename(__FILE__));
|
4 |
|
5 |
class Mage_CodiScript_IndexController extends Mage_Core_Controller_Front_Action{
|
53 |
$ignoretopcategory = ( isset($_REQUEST["ignoretopcategory"]) && $_REQUEST["ignoretopcategory"] == "1" );
|
54 |
$includeshortdescription = ( isset($_REQUEST["includeshortdescription"]) && $_REQUEST["includeshortdescription"] == "1" );
|
55 |
$includelongdescription = ( isset($_REQUEST["includelongdescription"]) ? $_REQUEST["includelongdescription"] == "1" : TRUE );
|
|
|
56 |
$publishtieredpricing = ( isset($_REQUEST["publishtieredpricing"]) && $_REQUEST["publishtieredpricing"] == "1" );
|
57 |
$quantitylabel = isset($_REQUEST["quantitylabel"]) ? $_REQUEST["quantitylabel"] : "Quantity";
|
58 |
$pricelabel = isset($_REQUEST["pricelabel"]) ? $_REQUEST["pricelabel"] : "Price";
|
82 |
ignoretopcategory=".$ignoretopcategory."
|
83 |
includeshortdescription=".$includeshortdescription."
|
84 |
includelongdescription=".$includelongdescription."
|
|
|
85 |
publishtieredpricing=".$publishtieredpricing."
|
86 |
quantitylabel=".$quantitylabel."
|
87 |
pricelabel=".$pricelabel."
|
160 |
$cfModel->ignoretopcategory = $ignoretopcategory;
|
161 |
$cfModel->includeshortdescription = $includeshortdescription;
|
162 |
$cfModel->includelongdescription = $includelongdescription;
|
|
|
163 |
$cfModel->publishtieredpricing = $publishtieredpricing;
|
164 |
$cfModel->quantitylabel = $quantitylabel;
|
165 |
$cfModel->pricelabel = $pricelabel;
|
216 |
";
|
217 |
die();
|
218 |
/* RELEASE NOTES
|
219 |
+
* 2014-04-01
|
220 |
+
* 1. Group prices retrieval implemented (Magento 1.7+)
|
221 |
+
* 2. Obsoleted getpricefromchild option
|
222 |
+
*
|
223 |
* 2014-02-24
|
224 |
* 1. includecustomfields parameter added / implemented
|
225 |
* 2. Improved langiage-specific section rendering
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Mage_Codi</name>
|
4 |
-
<version>4.1.
|
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>2014-
|
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.1.3</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>2014-04-02</date>
|
14 |
+
<time>23:05:44</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="d930ec672c6602ff311c94de183ad0aa"/></dir><dir name="controllers"><file name="IndexController.php" hash="bb4f00aba4c4173ac7450b43a62a2535"/></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>
|