|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| -# Copyright (C) 2013 Global Era (http://www.globalera.com). All Rights Reserved |
| 3 | +# Copyright (C) 2013-2015 Global Era Commerce (http://www.globalera.com). All Rights Reserved |
4 | 4 | # @author Serenus Infotech <[email protected]>
|
| 5 | +# @author Intelliant <[email protected]> |
5 | 6 | #
|
6 | 7 | # This program is free software: you can redistribute it and/or modify
|
7 | 8 | # it under the terms of the GNU Affero General Public License as
|
|
15 | 16 | #
|
16 | 17 | # You should have received a copy of the GNU Affero General Public License
|
17 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
| -**/ |
| 19 | + **/ |
19 | 20 |
|
20 | 21 | class Gec_Customimport_Helper_Catalog_Image extends Mage_Catalog_Helper_Image
|
21 | 22 | {
|
@@ -89,53 +90,133 @@ public function init(Mage_Catalog_Model_Product $product, $attributeName, $image
|
89 | 90 | */
|
90 | 91 | public function __toString()
|
91 | 92 | {
|
92 |
| - try { |
93 |
| - // echo $this->_requestedImage; |
94 |
| - |
95 |
| - $model = $this->_getModel(); |
96 |
| - if ($this->getImageFile()) { |
97 |
| - $model->setBaseFile($this->getImageFile()); |
98 |
| - } else { |
99 |
| - $model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir())); |
100 |
| - } |
| 93 | + if(Mage::getStoreConfig("catalog/proimgusage/imgusage")){ |
| 94 | + try { |
| 95 | + $model = $this->_getModel(); |
| 96 | + if ($this->getImageFile()) { |
| 97 | + $model->setBaseFile($this->getImageFile()); |
| 98 | + } else { |
| 99 | + $path = Mage::getBaseDir('media').'/catalog/product'; |
| 100 | + if($this->getProduct()->getData($model->getDestinationSubdir()) == "no_selection" || !is_file($path.$this->getProduct()->getData($model->getDestinationSubdir()))){ |
| 101 | + try{ |
| 102 | + $model = $this->_getModel(); |
| 103 | + if ($this->getImageFile()) { |
| 104 | + $model->setBaseFile($this->getImageFile()); |
| 105 | + } else { |
| 106 | + $model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir())); |
| 107 | + } |
| 108 | + |
| 109 | + if($this->_requestedImage == 'image' || $this->_requestedImage == 'small_image' || $this->_requestedImage == 'thumbnail'){ |
| 110 | + $external_attribute = 'external_'.$this->_requestedImage; |
| 111 | + $_product = Mage::getModel('catalog/product')->load($this->getProduct()->getId()); |
| 112 | + $externalImg = $_product->getData($external_attribute); |
| 113 | + |
| 114 | + } |
| 115 | + if ($model->isCached()) { |
| 116 | + if($externalImg){ |
| 117 | + return $externalImg; |
| 118 | + } |
| 119 | + return $model->getUrl(); |
| 120 | + } else { |
| 121 | + if ($this->_scheduleRotate) { |
| 122 | + $model->rotate($this->getAngle()); |
| 123 | + } |
| 124 | + |
| 125 | + if ($this->_scheduleResize) { |
| 126 | + $model->resize(); |
| 127 | + } |
| 128 | + |
| 129 | + if ($this->getWatermark()) { |
| 130 | + $model->setWatermark($this->getWatermark()); |
| 131 | + } |
| 132 | + |
| 133 | + $url = $model->saveFile()->getUrl(); |
| 134 | + if($externalImg){ |
| 135 | + $url = $externalImg; |
| 136 | + } |
| 137 | + } |
| 138 | + }catch (Exception $e) { |
| 139 | + $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder()); |
| 140 | + } |
| 141 | + return $url; |
| 142 | + }else{ |
| 143 | + $model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir())); |
| 144 | + } |
| 145 | + } |
101 | 146 |
|
102 |
| - if($this->_requestedImage == 'image' || $this->_requestedImage == 'small_image' || $this->_requestedImage == 'thumbnail'){ |
103 |
| - $external_attribute = 'external_'.$this->_requestedImage; |
104 |
| - $_product = Mage::getModel('catalog/product')->load($this->getProduct()->getId()); |
105 |
| - $externalImg = $_product->getData($external_attribute); |
| 147 | + if ($model->isCached()) { |
| 148 | + return $model->getUrl(); |
| 149 | + } else { |
| 150 | + if ($this->_scheduleRotate) { |
| 151 | + $model->rotate($this->getAngle()); |
| 152 | + } |
106 | 153 |
|
107 |
| - } |
| 154 | + if ($this->_scheduleResize) { |
| 155 | + $model->resize(); |
| 156 | + } |
108 | 157 |
|
| 158 | + if ($this->getWatermark()) { |
| 159 | + $model->setWatermark($this->getWatermark()); |
| 160 | + } |
109 | 161 |
|
110 |
| - if ($model->isCached()) { |
111 |
| - // return 'http://staging.serenusinfotech.com/smikum/gec/skin/frontend/default/default/images/media/col_left_callout.jpg'; |
112 |
| - if($externalImg){ |
113 |
| - return $externalImg; |
| 162 | + $url = $model->saveFile()->getUrl(); |
114 | 163 | }
|
115 |
| - return $model->getUrl(); |
116 |
| - } else { |
117 |
| - if ($this->_scheduleRotate) { |
118 |
| - $model->rotate($this->getAngle()); |
| 164 | + } catch (Exception $e) { |
| 165 | + $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder()); |
| 166 | + } |
| 167 | + return $url; |
| 168 | + } else { |
| 169 | + |
| 170 | + try { |
| 171 | + // echo $this->_requestedImage; |
| 172 | + |
| 173 | + $model = $this->_getModel(); |
| 174 | + if ($this->getImageFile()) { |
| 175 | + $model->setBaseFile($this->getImageFile()); |
| 176 | + } else { |
| 177 | + $model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir())); |
119 | 178 | }
|
120 | 179 |
|
121 |
| - if ($this->_scheduleResize) { |
122 |
| - $model->resize(); |
123 |
| - } |
| 180 | + if($this->_requestedImage == 'image' || $this->_requestedImage == 'small_image' || $this->_requestedImage == 'thumbnail'){ |
| 181 | + $external_attribute = 'external_'.$this->_requestedImage; |
| 182 | + $_product = Mage::getModel('catalog/product')->load($this->getProduct()->getId()); |
| 183 | + $externalImg = $_product->getData($external_attribute); |
124 | 184 |
|
125 |
| - if ($this->getWatermark()) { |
126 |
| - $model->setWatermark($this->getWatermark()); |
127 | 185 | }
|
128 | 186 |
|
129 |
| - $url = $model->saveFile()->getUrl(); |
130 |
| - if($externalImg){ |
131 |
| - $url = $externalImg; |
| 187 | + |
| 188 | + if ($model->isCached()) { |
| 189 | + // return 'http://staging.serenusinfotech.com/smikum/gec/skin/frontend/default/default/images/media/col_left_callout.jpg'; |
| 190 | + if($externalImg){ |
| 191 | + return $externalImg; |
| 192 | + } |
| 193 | + return $model->getUrl(); |
| 194 | + } else { |
| 195 | + if ($this->_scheduleRotate) { |
| 196 | + $model->rotate($this->getAngle()); |
| 197 | + } |
| 198 | + |
| 199 | + if ($this->_scheduleResize) { |
| 200 | + $model->resize(); |
| 201 | + } |
| 202 | + |
| 203 | + if ($this->getWatermark()) { |
| 204 | + $model->setWatermark($this->getWatermark()); |
| 205 | + } |
| 206 | + |
| 207 | + $url = $model->saveFile()->getUrl(); |
| 208 | + if($externalImg){ |
| 209 | + $url = $externalImg; |
| 210 | + } |
132 | 211 | }
|
| 212 | + } catch (Exception $e) { |
| 213 | + $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder()); |
133 | 214 | }
|
134 |
| - } catch (Exception $e) { |
135 |
| - $url = Mage::getDesign()->getSkinUrl($this->getPlaceholder()); |
136 |
| - } |
137 |
| - return $url; |
138 |
| - // return 'http://staging.serenusinfotech.com/smikum/gec/skin/frontend/default/default/images/media/col_left_callout.jpg'; |
139 |
| - } |
140 |
| - |
141 |
| -} |
| 215 | + return $url; |
| 216 | + // return 'http://staging.serenusinfotech.com/smikum/gec/skin/frontend/default/default/images/media/col_left_callout.jpg'; |
| 217 | + |
| 218 | + } // If condition over |
| 219 | + |
| 220 | + } // Function over |
| 221 | + |
| 222 | +} // Class over |
0 commit comments