Version Notes
3.0.9- Allow apostrophe and other special characters in category name
Download this release
Release Info
Developer | Magento Core Team |
Extension | Mage_PDF_per_Product |
Version | 3.0.9 |
Comparing to | |
See all releases |
Code changes from version 3.0.8 to 3.0.9
app/code/community/Mage/Codi/Helper/Data.php
CHANGED
@@ -1,320 +1,322 @@
|
|
1 |
-
<?php
|
2 |
-
class Mage_Codi_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
-
{
|
4 |
-
function output_file($file, $name, $mime_type='')
|
5 |
-
{
|
6 |
-
/*
|
7 |
-
This function takes a path to a file to output ($file),
|
8 |
-
the filename that the browser will see ($name) and
|
9 |
-
the MIME type of the file ($mime_type, optional).
|
10 |
-
|
11 |
-
*/
|
12 |
-
if(!is_readable($file)) die('File not found or inaccessible!');
|
13 |
-
|
14 |
-
$size = filesize($file);
|
15 |
-
$name = rawurldecode($name);
|
16 |
-
|
17 |
-
/* Figure out the MIME type (if not specified) */
|
18 |
-
$known_mime_types=array(
|
19 |
-
"pdf" => "application/pdf",
|
20 |
-
"txt" => "text/plain",
|
21 |
-
"html" => "text/html",
|
22 |
-
"htm" => "text/html",
|
23 |
-
"exe" => "application/octet-stream",
|
24 |
-
"zip" => "application/zip",
|
25 |
-
"doc" => "application/msword",
|
26 |
-
"xls" => "application/vnd.ms-excel",
|
27 |
-
"ppt" => "application/vnd.ms-powerpoint",
|
28 |
-
"gif" => "image/gif",
|
29 |
-
"png" => "image/png",
|
30 |
-
"jpeg"=> "image/jpg",
|
31 |
-
"jpg" => "image/jpg",
|
32 |
-
"php" => "text/plain"
|
33 |
-
);
|
34 |
-
|
35 |
-
if($mime_type==''){
|
36 |
-
$file_extension = strtolower(substr(strrchr($file,"."),1));
|
37 |
-
if(array_key_exists($file_extension, $known_mime_types)){
|
38 |
-
$mime_type=$known_mime_types[$file_extension];
|
39 |
-
} else {
|
40 |
-
$mime_type="application/force-download";
|
41 |
-
};
|
42 |
-
};
|
43 |
-
|
44 |
-
@ob_end_clean(); //turn off output buffering to decrease cpu usage
|
45 |
-
|
46 |
-
// required for IE, otherwise Content-Disposition may be ignored
|
47 |
-
if(ini_get('zlib.output_compression'))
|
48 |
-
ini_set('zlib.output_compression', 'Off');
|
49 |
-
|
50 |
-
header('Content-Type: ' . $mime_type);
|
51 |
-
header('Content-Disposition: attachment; filename="'.$name.'"');
|
52 |
-
header("Content-Transfer-Encoding: binary");
|
53 |
-
header('Accept-Ranges: bytes');
|
54 |
-
|
55 |
-
/* The three lines below basically make the
|
56 |
-
download non-cacheable */
|
57 |
-
header("Cache-control: private");
|
58 |
-
header('Pragma: private');
|
59 |
-
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
60 |
-
|
61 |
-
// multipart-download and download resuming support
|
62 |
-
if(isset($_SERVER['HTTP_RANGE']))
|
63 |
-
{
|
64 |
-
list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2);
|
65 |
-
list($range) = explode(",",$range,2);
|
66 |
-
list($range, $range_end) = explode("-", $range);
|
67 |
-
$range=intval($range);
|
68 |
-
if(!$range_end) {
|
69 |
-
$range_end=$size-1;
|
70 |
-
} else {
|
71 |
-
$range_end=intval($range_end);
|
72 |
-
}
|
73 |
-
|
74 |
-
$new_length = $range_end-$range+1;
|
75 |
-
header("HTTP/1.1 206 Partial Content");
|
76 |
-
header("Content-Length: $new_length");
|
77 |
-
header("Content-Range: bytes $range-$range_end/$size");
|
78 |
-
} else {
|
79 |
-
$new_length=$size;
|
80 |
-
header("Content-Length: ".$size);
|
81 |
-
}
|
82 |
-
|
83 |
-
/* output the file itself */
|
84 |
-
$chunksize = 1*(1024*1024); //you may want to change this
|
85 |
-
$bytes_send = 0;
|
86 |
-
if ($file = fopen($file, 'r'))
|
87 |
-
{
|
88 |
-
if(isset($_SERVER['HTTP_RANGE']))
|
89 |
-
fseek($file, $range);
|
90 |
-
|
91 |
-
while(!feof($file) &&
|
92 |
-
(!connection_aborted()) &&
|
93 |
-
($bytes_send<$new_length)
|
94 |
-
)
|
95 |
-
{
|
96 |
-
$buffer = fread($file, $chunksize);
|
97 |
-
print($buffer); //echo($buffer); // is also possible
|
98 |
-
flush();
|
99 |
-
$bytes_send += strlen($buffer);
|
100 |
-
}
|
101 |
-
fclose($file);
|
102 |
-
} else die('Error - can not open file.');
|
103 |
-
|
104 |
-
die();
|
105 |
-
}
|
106 |
-
|
107 |
-
function deleteFile($basePath='',$filename='')
|
108 |
-
{
|
109 |
-
@unlink($basePath.$filename);
|
110 |
-
//remove text files
|
111 |
-
$filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
|
112 |
-
foreach($filesn as $filen)
|
113 |
-
{
|
114 |
-
unlink($filen);
|
115 |
-
}
|
116 |
-
}
|
117 |
-
//function for get the theme
|
118 |
-
function getTheme()
|
119 |
-
{
|
120 |
-
foreach (Mage::app()->getWebsites() as $website)
|
121 |
-
{
|
122 |
-
$defaultGroup = $website->getDefaultGroup();
|
123 |
-
$StoreId = $defaultGroup->getDefaultStoreId();
|
124 |
-
}
|
125 |
-
|
126 |
-
$design = Mage::getSingleton('core/design')->loadChange($StoreId);
|
127 |
-
|
128 |
-
$package = $design->getPackage();
|
129 |
-
$default_theme = $design->getTheme();
|
130 |
-
|
131 |
-
if ( $package == "" && $default_theme == "" ){
|
132 |
-
|
133 |
-
$package = Mage::getStoreConfig('design/package/name', $StoreId);
|
134 |
-
$default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
|
135 |
-
}
|
136 |
-
|
137 |
-
if ( $package == "" ) $package = "default";
|
138 |
-
if ( $default_theme == "" ) $default_theme = "default";
|
139 |
-
|
140 |
-
return $package.'/'.$default_theme;
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
}
|
145 |
-
function array2json($arr) {
|
146 |
-
|
147 |
-
if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
|
148 |
-
$parts = array();
|
149 |
-
$is_list = false;
|
150 |
-
|
151 |
-
//Find out if the given array is a numerical array
|
152 |
-
$keys = array_keys($arr);
|
153 |
-
$max_length = count($arr)-1;
|
154 |
-
if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1
|
155 |
-
$is_list = true;
|
156 |
-
for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
|
157 |
-
if($i != $keys[$i]) { //A key fails at position check.
|
158 |
-
$is_list = false; //It is an associative array.
|
159 |
-
break;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
foreach($arr as $key=>$value) {
|
165 |
-
if(is_array($value)) { //Custom handling for arrays
|
166 |
-
if($is_list) $parts[] = array2json($value); /* :RECURSION: */
|
167 |
-
else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */
|
168 |
-
} else {
|
169 |
-
$str = '';
|
170 |
-
if(!$is_list) $str = '"' . $key . '":';
|
171 |
-
|
172 |
-
//Custom handling for multiple data types
|
173 |
-
if(is_numeric($value)) $str .= $value; //Numbers
|
174 |
-
elseif($value === false) $str .= 'false'; //The booleans
|
175 |
-
elseif($value === true) $str .= 'true';
|
176 |
-
else $str .= '"' . addslashes($value) . '"'; //All other things
|
177 |
-
// :TODO: Is there any more datatype we should be in the lookout for? (Object?)
|
178 |
-
|
179 |
-
$parts[] = $str;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
$json = implode(',',$parts);
|
183 |
-
|
184 |
-
if($is_list) return '[' . $json . ']';//Return numerical JSON
|
185 |
-
return '{' . $json . '}';//Return associative JSON
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
function geTierprice($product)
|
190 |
-
{
|
191 |
-
|
192 |
-
if (is_null($product)) {
|
193 |
-
return array();
|
194 |
-
}
|
195 |
-
$res='';
|
196 |
-
$codquantity=Mage::getStoreConfig('codi/codi/codquantity');
|
197 |
-
$codprice=Mage::getStoreConfig('codi/codi/codprice');
|
198 |
-
$codsavings=Mage::getStoreConfig('codi/codi/codsavings');
|
199 |
-
|
200 |
-
//[tier qty 1]#$#[tier price 1]#$#[(product price-tier price 1)/product price%]#$$#
|
201 |
-
|
202 |
-
$prices = $product->getFormatedTierPrice();
|
203 |
-
|
204 |
-
$rightstr = '';
|
205 |
-
if (is_array($prices)) {
|
206 |
-
|
207 |
-
$i='1';
|
208 |
-
$count=count($prices);
|
209 |
-
if($count>0)
|
210 |
-
$res='[TierPriceTable]#$$#'.$codquantity.'#$#'.$codprice.'#$#'.$codsavings."=";
|
211 |
-
|
212 |
-
foreach ($prices as $price) {
|
213 |
-
$price['price_qty'] = $price['price_qty']*1;
|
214 |
-
$rightstr.=$price['price_qty'].'#$#';
|
215 |
-
if ($product->getPrice() != $product->getFinalPrice()) {
|
216 |
-
if ($price['price']<$product->getFinalPrice()) {
|
217 |
-
|
218 |
-
$rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
|
219 |
-
|
220 |
-
if($i==$count)
|
221 |
-
{
|
222 |
-
$rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%';
|
223 |
-
}
|
224 |
-
else
|
225 |
-
{
|
226 |
-
$rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%#$$#';
|
227 |
-
}
|
228 |
-
|
229 |
-
}
|
230 |
-
} else {
|
231 |
-
if ($price['price']<$product->getPrice()) {
|
232 |
-
$rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
|
233 |
-
|
234 |
-
if($i==$count)
|
235 |
-
$rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%';
|
236 |
-
else
|
237 |
-
$rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%#$$#';
|
238 |
-
}
|
239 |
-
}
|
240 |
-
$i++;
|
241 |
-
}
|
242 |
-
}
|
243 |
-
|
244 |
-
return $res.$rightstr;
|
245 |
-
|
246 |
-
}
|
247 |
-
//Code for Catalog section code
|
248 |
-
function drawItem($category, $level=0,$name='',$i=1,$j=1,$path='')
|
249 |
-
{
|
250 |
-
$html='';
|
251 |
-
|
252 |
-
$catalogSectionModel=Mage::getModel('codi/codi');
|
253 |
-
//Get Category child
|
254 |
-
$childrennew=$category->getChildrenCategories();
|
255 |
-
|
256 |
-
$id=$category->getId();
|
257 |
-
if($level!=1)
|
258 |
-
{
|
259 |
-
$path.='-'.$j;
|
260 |
-
$name=$name.'#$#'.$category->getName();//.' '.$i.$path;
|
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 |
-
return
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
$position
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
}
|
320 |
-
|
|
|
|
1 |
+
<?php
|
2 |
+
class Mage_Codi_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
function output_file($file, $name, $mime_type='')
|
5 |
+
{
|
6 |
+
/*
|
7 |
+
This function takes a path to a file to output ($file),
|
8 |
+
the filename that the browser will see ($name) and
|
9 |
+
the MIME type of the file ($mime_type, optional).
|
10 |
+
|
11 |
+
*/
|
12 |
+
if(!is_readable($file)) die('File not found or inaccessible!');
|
13 |
+
|
14 |
+
$size = filesize($file);
|
15 |
+
$name = rawurldecode($name);
|
16 |
+
|
17 |
+
/* Figure out the MIME type (if not specified) */
|
18 |
+
$known_mime_types=array(
|
19 |
+
"pdf" => "application/pdf",
|
20 |
+
"txt" => "text/plain",
|
21 |
+
"html" => "text/html",
|
22 |
+
"htm" => "text/html",
|
23 |
+
"exe" => "application/octet-stream",
|
24 |
+
"zip" => "application/zip",
|
25 |
+
"doc" => "application/msword",
|
26 |
+
"xls" => "application/vnd.ms-excel",
|
27 |
+
"ppt" => "application/vnd.ms-powerpoint",
|
28 |
+
"gif" => "image/gif",
|
29 |
+
"png" => "image/png",
|
30 |
+
"jpeg"=> "image/jpg",
|
31 |
+
"jpg" => "image/jpg",
|
32 |
+
"php" => "text/plain"
|
33 |
+
);
|
34 |
+
|
35 |
+
if($mime_type==''){
|
36 |
+
$file_extension = strtolower(substr(strrchr($file,"."),1));
|
37 |
+
if(array_key_exists($file_extension, $known_mime_types)){
|
38 |
+
$mime_type=$known_mime_types[$file_extension];
|
39 |
+
} else {
|
40 |
+
$mime_type="application/force-download";
|
41 |
+
};
|
42 |
+
};
|
43 |
+
|
44 |
+
@ob_end_clean(); //turn off output buffering to decrease cpu usage
|
45 |
+
|
46 |
+
// required for IE, otherwise Content-Disposition may be ignored
|
47 |
+
if(ini_get('zlib.output_compression'))
|
48 |
+
ini_set('zlib.output_compression', 'Off');
|
49 |
+
|
50 |
+
header('Content-Type: ' . $mime_type);
|
51 |
+
header('Content-Disposition: attachment; filename="'.$name.'"');
|
52 |
+
header("Content-Transfer-Encoding: binary");
|
53 |
+
header('Accept-Ranges: bytes');
|
54 |
+
|
55 |
+
/* The three lines below basically make the
|
56 |
+
download non-cacheable */
|
57 |
+
header("Cache-control: private");
|
58 |
+
header('Pragma: private');
|
59 |
+
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
60 |
+
|
61 |
+
// multipart-download and download resuming support
|
62 |
+
if(isset($_SERVER['HTTP_RANGE']))
|
63 |
+
{
|
64 |
+
list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2);
|
65 |
+
list($range) = explode(",",$range,2);
|
66 |
+
list($range, $range_end) = explode("-", $range);
|
67 |
+
$range=intval($range);
|
68 |
+
if(!$range_end) {
|
69 |
+
$range_end=$size-1;
|
70 |
+
} else {
|
71 |
+
$range_end=intval($range_end);
|
72 |
+
}
|
73 |
+
|
74 |
+
$new_length = $range_end-$range+1;
|
75 |
+
header("HTTP/1.1 206 Partial Content");
|
76 |
+
header("Content-Length: $new_length");
|
77 |
+
header("Content-Range: bytes $range-$range_end/$size");
|
78 |
+
} else {
|
79 |
+
$new_length=$size;
|
80 |
+
header("Content-Length: ".$size);
|
81 |
+
}
|
82 |
+
|
83 |
+
/* output the file itself */
|
84 |
+
$chunksize = 1*(1024*1024); //you may want to change this
|
85 |
+
$bytes_send = 0;
|
86 |
+
if ($file = fopen($file, 'r'))
|
87 |
+
{
|
88 |
+
if(isset($_SERVER['HTTP_RANGE']))
|
89 |
+
fseek($file, $range);
|
90 |
+
|
91 |
+
while(!feof($file) &&
|
92 |
+
(!connection_aborted()) &&
|
93 |
+
($bytes_send<$new_length)
|
94 |
+
)
|
95 |
+
{
|
96 |
+
$buffer = fread($file, $chunksize);
|
97 |
+
print($buffer); //echo($buffer); // is also possible
|
98 |
+
flush();
|
99 |
+
$bytes_send += strlen($buffer);
|
100 |
+
}
|
101 |
+
fclose($file);
|
102 |
+
} else die('Error - can not open file.');
|
103 |
+
|
104 |
+
die();
|
105 |
+
}
|
106 |
+
|
107 |
+
function deleteFile($basePath='',$filename='')
|
108 |
+
{
|
109 |
+
@unlink($basePath.$filename);
|
110 |
+
//remove text files
|
111 |
+
$filesn = glob($basePath."CoDzip/CoDfiles/*.txt");
|
112 |
+
foreach($filesn as $filen)
|
113 |
+
{
|
114 |
+
unlink($filen);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
//function for get the theme
|
118 |
+
function getTheme()
|
119 |
+
{
|
120 |
+
foreach (Mage::app()->getWebsites() as $website)
|
121 |
+
{
|
122 |
+
$defaultGroup = $website->getDefaultGroup();
|
123 |
+
$StoreId = $defaultGroup->getDefaultStoreId();
|
124 |
+
}
|
125 |
+
|
126 |
+
$design = Mage::getSingleton('core/design')->loadChange($StoreId);
|
127 |
+
|
128 |
+
$package = $design->getPackage();
|
129 |
+
$default_theme = $design->getTheme();
|
130 |
+
|
131 |
+
if ( $package == "" && $default_theme == "" ){
|
132 |
+
|
133 |
+
$package = Mage::getStoreConfig('design/package/name', $StoreId);
|
134 |
+
$default_theme = Mage::getStoreConfig('design/theme/default', $StoreId);
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( $package == "" ) $package = "default";
|
138 |
+
if ( $default_theme == "" ) $default_theme = "default";
|
139 |
+
|
140 |
+
return $package.'/'.$default_theme;
|
141 |
+
|
142 |
+
|
143 |
+
|
144 |
+
}
|
145 |
+
function array2json($arr) {
|
146 |
+
|
147 |
+
if(function_exists('json_encode')) return json_encode($arr); //Lastest versions of PHP already has this functionality.
|
148 |
+
$parts = array();
|
149 |
+
$is_list = false;
|
150 |
+
|
151 |
+
//Find out if the given array is a numerical array
|
152 |
+
$keys = array_keys($arr);
|
153 |
+
$max_length = count($arr)-1;
|
154 |
+
if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {//See if the first key is 0 and last key is length - 1
|
155 |
+
$is_list = true;
|
156 |
+
for($i=0; $i<count($keys); $i++) { //See if each key correspondes to its position
|
157 |
+
if($i != $keys[$i]) { //A key fails at position check.
|
158 |
+
$is_list = false; //It is an associative array.
|
159 |
+
break;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
foreach($arr as $key=>$value) {
|
165 |
+
if(is_array($value)) { //Custom handling for arrays
|
166 |
+
if($is_list) $parts[] = array2json($value); /* :RECURSION: */
|
167 |
+
else $parts[] = '"' . $key . '":' . array2json($value); /* :RECURSION: */
|
168 |
+
} else {
|
169 |
+
$str = '';
|
170 |
+
if(!$is_list) $str = '"' . $key . '":';
|
171 |
+
|
172 |
+
//Custom handling for multiple data types
|
173 |
+
if(is_numeric($value)) $str .= $value; //Numbers
|
174 |
+
elseif($value === false) $str .= 'false'; //The booleans
|
175 |
+
elseif($value === true) $str .= 'true';
|
176 |
+
else $str .= '"' . addslashes($value) . '"'; //All other things
|
177 |
+
// :TODO: Is there any more datatype we should be in the lookout for? (Object?)
|
178 |
+
|
179 |
+
$parts[] = $str;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
$json = implode(',',$parts);
|
183 |
+
|
184 |
+
if($is_list) return '[' . $json . ']';//Return numerical JSON
|
185 |
+
return '{' . $json . '}';//Return associative JSON
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
function geTierprice($product)
|
190 |
+
{
|
191 |
+
|
192 |
+
if (is_null($product)) {
|
193 |
+
return array();
|
194 |
+
}
|
195 |
+
$res='';
|
196 |
+
$codquantity=Mage::getStoreConfig('codi/codi/codquantity');
|
197 |
+
$codprice=Mage::getStoreConfig('codi/codi/codprice');
|
198 |
+
$codsavings=Mage::getStoreConfig('codi/codi/codsavings');
|
199 |
+
|
200 |
+
//[tier qty 1]#$#[tier price 1]#$#[(product price-tier price 1)/product price%]#$$#
|
201 |
+
|
202 |
+
$prices = $product->getFormatedTierPrice();
|
203 |
+
|
204 |
+
$rightstr = '';
|
205 |
+
if (is_array($prices)) {
|
206 |
+
|
207 |
+
$i='1';
|
208 |
+
$count=count($prices);
|
209 |
+
if($count>0)
|
210 |
+
$res='[TierPriceTable]#$$#'.$codquantity.'#$#'.$codprice.'#$#'.$codsavings."=";
|
211 |
+
|
212 |
+
foreach ($prices as $price) {
|
213 |
+
$price['price_qty'] = $price['price_qty']*1;
|
214 |
+
$rightstr.=$price['price_qty'].'#$#';
|
215 |
+
if ($product->getPrice() != $product->getFinalPrice()) {
|
216 |
+
if ($price['price']<$product->getFinalPrice()) {
|
217 |
+
|
218 |
+
$rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
|
219 |
+
|
220 |
+
if($i==$count)
|
221 |
+
{
|
222 |
+
$rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%';
|
223 |
+
}
|
224 |
+
else
|
225 |
+
{
|
226 |
+
$rightstr.=ceil(100 - (( 100/$product->getFinalPrice() ) * $price['price'] )).'%#$$#';
|
227 |
+
}
|
228 |
+
|
229 |
+
}
|
230 |
+
} else {
|
231 |
+
if ($price['price']<$product->getPrice()) {
|
232 |
+
$rightstr.=Mage::helper('tax')->getPrice($product, $price['website_price'], true).'#$#';
|
233 |
+
|
234 |
+
if($i==$count)
|
235 |
+
$rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%';
|
236 |
+
else
|
237 |
+
$rightstr.= ceil(100 - (( 100/$product->getPrice() ) * $price['price'] )).'%#$$#';
|
238 |
+
}
|
239 |
+
}
|
240 |
+
$i++;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
return $res.$rightstr;
|
245 |
+
|
246 |
+
}
|
247 |
+
//Code for Catalog section code
|
248 |
+
function drawItem($category, $level=0,$name='',$i=1,$j=1,$path='')
|
249 |
+
{
|
250 |
+
$html='';
|
251 |
+
|
252 |
+
$catalogSectionModel=Mage::getModel('codi/codi');
|
253 |
+
//Get Category child
|
254 |
+
$childrennew=$category->getChildrenCategories();
|
255 |
+
|
256 |
+
$id=$category->getId();
|
257 |
+
if($level!=1)
|
258 |
+
{
|
259 |
+
$path.='-'.$j;
|
260 |
+
$name=$name.'#$#'.$category->getName();//.' '.$i.$path;
|
261 |
+
$sql_name=addslashes($name);
|
262 |
+
$sec_path.=str_replace("-",",",$path);
|
263 |
+
$seq=$i.$sec_path;
|
264 |
+
}
|
265 |
+
else
|
266 |
+
{
|
267 |
+
$name=$category->getName();//.' '.$i;
|
268 |
+
$sql_name=addslashes($name);
|
269 |
+
$seq=$i;
|
270 |
+
}
|
271 |
+
|
272 |
+
$catalogSectionModel->addCatalogSection($id,$sql_name);
|
273 |
+
$html= "General\t".$seq."\t".$name."\t". $sec_Flag . "\n";
|
274 |
+
|
275 |
+
if(count($childrennew))
|
276 |
+
{
|
277 |
+
$j = 1;
|
278 |
+
foreach ($childrennew as $cat)
|
279 |
+
{
|
280 |
+
//$cat=$this->createCategoryObj($child->getID());
|
281 |
+
if($cat!=false)
|
282 |
+
$htmlChildren.= $this->drawItem($cat, $level+1,$name,$i,$j,$path);
|
283 |
+
$j++;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
return $html.= $htmlChildren;
|
287 |
+
}
|
288 |
+
//Create category object
|
289 |
+
function createCategoryObj($cid)
|
290 |
+
{
|
291 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
292 |
+
->setStoreId('1')
|
293 |
+
->addAttributeToSelect('name')
|
294 |
+
->addAttributeToSelect('is_active')
|
295 |
+
->addAttributeToFilter('entity_id', array('eq' => $cid));
|
296 |
+
foreach($collection as $category)
|
297 |
+
{
|
298 |
+
if($category)
|
299 |
+
return $category;
|
300 |
+
else
|
301 |
+
return false;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
//get product Postion
|
305 |
+
function productPostion($category_id,$productId)
|
306 |
+
{
|
307 |
+
|
308 |
+
$category = Mage::getModel('catalog/category')
|
309 |
+
->setStoreId(1)
|
310 |
+
->load($category_id);
|
311 |
+
$positions = $category->getProductsPosition();
|
312 |
+
if(count($positions)>0)
|
313 |
+
$position=$positions[$productId];
|
314 |
+
else
|
315 |
+
$position='';
|
316 |
+
|
317 |
+
return $position;
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
}
|
322 |
+
?>
|
app/code/community/Mage/Codi/Model/Codi.php
CHANGED
@@ -7,7 +7,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
7 |
public $userid ;
|
8 |
public $password ;
|
9 |
public $disableextension ;
|
10 |
-
public $version = "3.0.
|
11 |
|
12 |
public $customerid ;
|
13 |
public $customerdatasourceid ;
|
@@ -1067,6 +1067,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
1067 |
$i++;
|
1068 |
}
|
1069 |
}
|
|
|
1070 |
catch (Exception $e)
|
1071 |
{
|
1072 |
Mage::log("Notice : Codi Import Products Exception :".$e->getMessage(), null, $this->_logFile);
|
@@ -1126,6 +1127,9 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
1126 |
$i++;
|
1127 |
}
|
1128 |
}
|
|
|
|
|
|
|
1129 |
if($count==0)
|
1130 |
{
|
1131 |
$progress=0;
|
@@ -1240,11 +1244,14 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
1240 |
$CategoriesString = "" ;
|
1241 |
$helper=Mage::helper('codi');
|
1242 |
$catelogSectionModel=Mage::getModel('codi/codi');
|
1243 |
-
|
1244 |
-
|
1245 |
-
$
|
1246 |
-
|
1247 |
-
|
|
|
|
|
|
|
1248 |
$data=$catelogSectionModel->isCatalogSectionStart($_category_id);
|
1249 |
$CategoriesString=$data['category_hirarchy_path'];
|
1250 |
//code for product position
|
@@ -1259,9 +1266,22 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
1259 |
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
1260 |
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
1261 |
//************************* Concatenate Product Info End ************************* cleanStr
|
1262 |
-
|
1263 |
}
|
1264 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1265 |
//Clean up
|
1266 |
unset($categories);
|
1267 |
unset($catelogSectionModel);
|
@@ -1288,28 +1308,44 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
1288 |
$CategoriesString = "" ;
|
1289 |
$catelogSectionModel=Mage::getModel('codi/codi');
|
1290 |
$helper=Mage::helper('codi');
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
$
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1301 |
|
1302 |
-
if ($CategoriesString == false ) $CategoriesString = 'Uncategorized' ;
|
1303 |
-
//************************* Concatenate Product Info Start ***********************
|
1304 |
-
$ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
|
1305 |
-
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
|
1306 |
-
$ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
|
1307 |
-
$ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
|
1308 |
-
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
|
1309 |
-
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
1310 |
-
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
1311 |
-
//************************* Concatenate Product Info End ************************* cleanStr
|
1312 |
-
}
|
1313 |
}
|
1314 |
//Clean up
|
1315 |
unset($categories);
|
@@ -1343,7 +1379,7 @@ class Mage_Codi_Model_Codi extends Mage_Core_Model_Abstract
|
|
1343 |
|
1344 |
}
|
1345 |
|
1346 |
-
public function addCatalogSection( $category_id=1, $category_hirarchy_path = '
|
1347 |
|
1348 |
$this->existCatalogSectionTable();
|
1349 |
|
7 |
public $userid ;
|
8 |
public $password ;
|
9 |
public $disableextension ;
|
10 |
+
public $version = "3.0.9";
|
11 |
|
12 |
public $customerid ;
|
13 |
public $customerdatasourceid ;
|
1067 |
$i++;
|
1068 |
}
|
1069 |
}
|
1070 |
+
|
1071 |
catch (Exception $e)
|
1072 |
{
|
1073 |
Mage::log("Notice : Codi Import Products Exception :".$e->getMessage(), null, $this->_logFile);
|
1127 |
$i++;
|
1128 |
}
|
1129 |
}
|
1130 |
+
$lastId=$i;
|
1131 |
+
$str="General\t".$lastId."\tUncategorized\t". $sec_Flag . "\n";
|
1132 |
+
file_put_contents($file,$str,FILE_APPEND);
|
1133 |
if($count==0)
|
1134 |
{
|
1135 |
$progress=0;
|
1244 |
$CategoriesString = "" ;
|
1245 |
$helper=Mage::helper('codi');
|
1246 |
$catelogSectionModel=Mage::getModel('codi/codi');
|
1247 |
+
if($categories)
|
1248 |
+
{
|
1249 |
+
foreach($categories as $k => $_category_id)
|
1250 |
+
{
|
1251 |
+
set_time_limit(20);
|
1252 |
+
$_cat = Mage::getModel('catalog/category')->load($_category_id);
|
1253 |
+
if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
1254 |
+
{
|
1255 |
$data=$catelogSectionModel->isCatalogSectionStart($_category_id);
|
1256 |
$CategoriesString=$data['category_hirarchy_path'];
|
1257 |
//code for product position
|
1266 |
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
1267 |
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
1268 |
//************************* Concatenate Product Info End ************************* cleanStr
|
1269 |
+
}
|
1270 |
}
|
1271 |
+
}
|
1272 |
+
else
|
1273 |
+
{
|
1274 |
+
$ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
|
1275 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
|
1276 |
+
$ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
|
1277 |
+
$ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
|
1278 |
+
$ProducttoString .= "\t" . $this->cleanStr('Uncategorized'); //Hirarachi Path
|
1279 |
+
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
1280 |
+
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
1281 |
+
|
1282 |
+
|
1283 |
+
|
1284 |
+
}
|
1285 |
//Clean up
|
1286 |
unset($categories);
|
1287 |
unset($catelogSectionModel);
|
1308 |
$CategoriesString = "" ;
|
1309 |
$catelogSectionModel=Mage::getModel('codi/codi');
|
1310 |
$helper=Mage::helper('codi');
|
1311 |
+
if($categories)
|
1312 |
+
{
|
1313 |
+
foreach($categories as $k => $_category_id){
|
1314 |
+
set_time_limit(20);
|
1315 |
+
//Code for add category hirarchi_path
|
1316 |
+
$_cat = Mage::getModel('catalog/category')->load($_category_id);
|
1317 |
+
if(($_cat->getName() != '') && ($_cat->getIsActive() == 1) && ($_cat->getName() != 'Root Catalog') && ((string)$_cat->getLevel() != '1') && ($_cat->getParentId() > 1 ) )
|
1318 |
+
{
|
1319 |
+
$data=$catelogSectionModel->isCatalogSectionStart($_category_id);
|
1320 |
+
$CategoriesString=$data['category_hirarchy_path'];
|
1321 |
+
//code for product position
|
1322 |
+
$position=$helper->productPostion($_category_id,$product->getId());
|
1323 |
+
|
1324 |
+
if ($CategoriesString == false ) $CategoriesString = 'Uncategorized' ;
|
1325 |
+
//************************* Concatenate Product Info Start ***********************
|
1326 |
+
$ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
|
1327 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
|
1328 |
+
$ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
|
1329 |
+
$ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
|
1330 |
+
$ProducttoString .= "\t" . $this->cleanStr( $CategoriesString ); //Hirarachi Path
|
1331 |
+
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
1332 |
+
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
1333 |
+
//************************* Concatenate Product Info End ************************* cleanStr
|
1334 |
+
}
|
1335 |
+
}
|
1336 |
+
}
|
1337 |
+
else
|
1338 |
+
{
|
1339 |
+
$ProducttoString .= "\r\n" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //ProductKey
|
1340 |
+
$ProducttoString .= "\t" . $product->getId().'#$#'.$this->cleanStr( $product->getName()); //Product Name
|
1341 |
+
$ProducttoString .= "\t" . $this->cleanStr($position) ; //Prod Sequence
|
1342 |
+
$ProducttoString .= "\t" . $this->cleanStr('General'); //Change cleanstr parameter from Magento to General //Proj Name
|
1343 |
+
$ProducttoString .= "\t" . $this->cleanStr('Uncategorized'); //Hirarachi Path
|
1344 |
+
$ProducttoString .= "\t" . $this->cleanStr('');//Proj Flag
|
1345 |
+
$ProducttoString .= "\t" . $this->cleanStr(''); //Proj Prod layout
|
1346 |
+
|
1347 |
+
|
1348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1349 |
}
|
1350 |
//Clean up
|
1351 |
unset($categories);
|
1379 |
|
1380 |
}
|
1381 |
|
1382 |
+
public function addCatalogSection( $category_id=1, $category_hirarchy_path = 'Uncategorized' ){
|
1383 |
|
1384 |
$this->existCatalogSectionTable();
|
1385 |
|
app/code/community/Mage/Codi/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Mage_Codi>
|
5 |
-
<version>3.0.
|
6 |
</Mage_Codi>
|
7 |
</modules>
|
8 |
<adminhtml>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Mage_Codi>
|
5 |
+
<version>3.0.9</version>
|
6 |
</Mage_Codi>
|
7 |
</modules>
|
8 |
<adminhtml>
|
app/design/frontend/default/default/template/catalog/product/view.phtml
CHANGED
@@ -48,7 +48,7 @@ $enablefreshflyers = Mage::getStoreConfig('codi/codi/enablefreshflyers');
|
|
48 |
|
49 |
//Change on 5-Dec-2011
|
50 |
|
51 |
-
$flyerlink = '<a target="_blank" href="http://catalog-on-demand.com/PDF-e-Link/?AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';
|
52 |
|
53 |
//Catalog-on-Demand
|
54 |
?>
|
48 |
|
49 |
//Change on 5-Dec-2011
|
50 |
|
51 |
+
$flyerlink = '<a target="_blank" href="http://www.catalog-on-demand.com/PDF-e-Link/?AID=' . Mage::getStoreConfig('codi/codi/codusername'). '|' . urlencode($_product->getId()) . '">'. '<img id="codflyerlinkimgalt" title="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" alt="' . Mage::getStoreConfig('codi/codi/codflyerlinkimgalt') . '" src="' . $codflyerlinkimgurl . '">'. '</a>';
|
52 |
|
53 |
//Catalog-on-Demand
|
54 |
?>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Mage_PDF_per_Product</name>
|
4 |
-
<version>3.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Catalog-On-Demand</summary>
|
10 |
<description>Catalog-On-Demand</description>
|
11 |
-
<notes>3.0.
|
12 |
<authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
|
13 |
-
<date>2012-
|
14 |
-
<time>
|
15 |
-
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="codimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="codimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="codi"><file name="index.phtml" hash="df25f104d32ba9e1441ded87dd0516f8"/></dir></dir><dir name="layout"><file name="codi.xml" hash="9407985f30403744eb4e758312d62aef"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Mage_PDF_per_Product</name>
|
4 |
+
<version>3.0.9</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>
|
8 |
<extends/>
|
9 |
<summary>Catalog-On-Demand</summary>
|
10 |
<description>Catalog-On-Demand</description>
|
11 |
+
<notes>3.0.9- Allow apostrophe and other special characters in category name</notes>
|
12 |
<authors><author><name>catalogondemand</name><user>auto-converted</user><email>timh@catalog-on-demand.com</email></author></authors>
|
13 |
+
<date>2012-04-24</date>
|
14 |
+
<time>11:32:16</time>
|
15 |
+
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="codimport_run.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="codimport_yes.gif" hash="0afb20898a704a106cb4c598868abf32"/><file name="preview_field_help.png" hash="1b1601459d25e8b1a6b1d109782078d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="codi"><file name="index.phtml" hash="df25f104d32ba9e1441ded87dd0516f8"/></dir></dir><dir name="layout"><file name="codi.xml" hash="9407985f30403744eb4e758312d62aef"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="catalog"><dir name="product"><file name="view.phtml" hash="ed36b7697b537fb4ff4100530450a832"/></dir></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="jquery"><file name="jquery-1.2.6.noConflict.min.js" hash="090fdb3fbcb4727c0ca20cca87e7e12d"/><file name="jquery.tooltip.js" hash="8217c6611da6cfe45094e58485d013f0"/></dir></dir></target><target name="magecommunity"><dir name="Mage"><dir name="Codi"><dir name="Block"><dir name="Adminhtml"><file name="Menu.php" hash="ae8a9d1be49f00102911ef5fbe97c126"/><file name="Switcher.php" hash="62f36d23f039d7c21ec84b42fd0532ff"/></dir><dir name="Customer"><file name="Codi.php" hash="17c557dbcfadd336dc7ba773d6304fc0"/></dir></dir><dir name="Helper"><file name="Createzip.php" hash="03fe07641f6f3f480b1d1c47b5ab3901"/><file name="Data.php" hash="20fb4b3deed697fd80f61f6b5c36e416"/></dir><dir name="Model"><file name="Codi.php" hash="b205f5d6906b7c96190c7aaa26f239c9"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="MenuController.php" hash="0db56a3c8d2bdd2564c8231b1efa8860"/></dir><file name="DeleteController.php" hash="8030915b46c87e5369a7c34d979873b4"/><file name="NsyncController.php" hash="d4bb9b709c9c907731d2f4e609205934"/><file name="SyncController.php" hash="ce7dfa71ab6214fbb825578ea81f55d2"/></dir><dir name="etc"><file name="config.xml" hash="72185be863584c38ffc1bc226afe89b9"/></dir><dir name="sql"><dir name="codi_setup"><file name="mysql4-install-3.0.4.php" hash="ffa1c82119aa4a56a6123dd1c5feca8f"/><file name="mysql4-install-3.0.6.php" hash="ffa1c82119aa4a56a6123dd1c5feca8f"/></dir></dir><file name="Codi_Process.php" hash="07b09ec755a1ae56c3a9f3945aa72035"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Codi.xml" hash="5d635cd2a0d415b67f095bda0298445d"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|