SHOW:
|
|
- or go back to the newest paste.
1 | <!-- app\design\frontend\rwd\default\template\catalog\product\list.phtml --> | |
2 | ||
3 | <?php | |
4 | /** | |
5 | * Magento | |
6 | * | |
7 | * NOTICE OF LICENSE | |
8 | * | |
9 | * This source file is subject to the Academic Free License (AFL 3.0) | |
10 | * that is bundled with this package in the file LICENSE_AFL.txt. | |
11 | * It is also available through the world-wide-web at this URL: | |
12 | * http://opensource.org/licenses/afl-3.0.php | |
13 | * If you did not receive a copy of the license and are unable to | |
14 | * obtain it through the world-wide-web, please send an email | |
15 | * to [email protected] so we can send you a copy immediately. | |
16 | * | |
17 | * DISCLAIMER | |
18 | * | |
19 | * Do not edit or add to this file if you wish to upgrade Magento to newer | |
20 | * versions in the future. If you wish to customize Magento for your | |
21 | * needs please refer to http://www.magento.com for more information. | |
22 | * | |
23 | * @category design | |
24 | * @package rwd_default | |
25 | * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com) | |
26 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | |
27 | */ | |
28 | ?> | |
29 | <?php | |
30 | /** | |
31 | * Product list template | |
32 | * | |
33 | * @see Mage_Catalog_Block_Product_List | |
34 | */ | |
35 | /* @var $this Mage_Catalog_Block_Product_List */ | |
36 | ?> | |
37 | <?php | |
38 | ||
39 | - | |
39 | + | $cat = Mage::app()->getRequest()->getParam('cat'); |
40 | - | $_category = Mage::registry('current_category'); |
40 | + | |
41 | - | if($_category) |
41 | + | |
42 | - | $currentCategoryId= $_category->getId(); |
42 | + | $_category = Mage::registry('current_category'); |
43 | if($cat == '') | |
44 | $currentCategoryId = $_category->getId(); | |
45 | else | |
46 | $currentCategoryId = $cat; | |
47 | ||
48 | $limit = Mage::getSingleton('catalog/session')->getLimitPage(); | |
49 | - | <?php echo $this->getToolbarHtml() ?> |
49 | + | |
50 | if($limit == ""){ | |
51 | - | if($currentCategoryId){ |
51 | + | $limit = Mage::getStoreConfig('catalog/frontend/grid_per_page'); |
52 | - | $order = Mage::getSingleton('catalog/session')->getSortOrder(); |
52 | + | |
53 | - | $direction = Mage::getSingleton('catalog/session')->getSortDirection(); |
53 | + | |
54 | - | $display = Mage::getSingleton('catalog/session')->getDisplayMode(); |
54 | + | |
55 | - | $limit = Mage::getSingleton('catalog/session')->getLimitPage(); |
55 | + | |
56 | <?php if(!$_productCollection->count()): ?> | |
57 | - | if($order == 'name') { |
57 | + | |
58 | - | if($direction == '') { |
58 | + | |
59 | - | $direction = 'asc'; |
59 | + | |
60 | - | } |
60 | + | <?php echo $this->getToolbarHtml(); |
61 | - | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
61 | + | $current_page = Mage::getBlockSingleton('page/html_pager')->getCurrentPage(); |
62 | - | ->getProductCollection() |
62 | + | //echo 'current page : ' . $current_page; |
63 | - | ->addAttributeToSelect('*') |
63 | + | |
64 | - | ->addAttributeToFilter('status', 1) |
64 | + | |
65 | - | ->addAttributeToFilter('visibility', 4) |
65 | + | |
66 | - | ->setPageSize('name', $limit) |
66 | + | if($currentCategoryId){ |
67 | - | ->setCurPage($limit) |
67 | + | $order = Mage::getSingleton('catalog/session')->getSortOrder(); |
68 | - | ->setOrder('name', $direction); |
68 | + | $direction = Mage::getSingleton('catalog/session')->getSortDirection(); |
69 | $display = Mage::getSingleton('catalog/session')->getDisplayMode(); | |
70 | - | echo $_productCollection->getSelect(); |
70 | + | |
71 | - | //$_productCollection->printLogQuery(true); |
71 | + | if($order == 'name') { |
72 | - | } |
72 | + | if($direction == '') { |
73 | $direction = 'asc'; | |
74 | - | if($order == 'price') { |
74 | + | } |
75 | - | if($direction == '') { |
75 | + | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
76 | - | $direction = 'asc'; |
76 | + | ->getProductCollection() |
77 | - | } |
77 | + | ->addAttributeToSelect('*') |
78 | - | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
78 | + | ->addAttributeToFilter('status', 1) |
79 | - | ->getProductCollection() |
79 | + | ->addAttributeToFilter('visibility', 4) |
80 | - | ->addAttributeToSelect('*') |
80 | + | ->setOrder('name', $direction); |
81 | - | ->addAttributeToFilter('status', 1) |
81 | + | //$_productCollection->printLogQuery(true); |
82 | - | ->addAttributeToFilter('visibility', 4) |
82 | + | } |
83 | - | ->setOrder('price', $direction); |
83 | + | |
84 | - | } |
84 | + | if($order == 'price') { |
85 | if($direction == '') { | |
86 | - | if($order == 'position') { |
86 | + | $direction = 'asc'; |
87 | - | if($direction == '') { |
87 | + | } |
88 | - | $direction = 'asc'; |
88 | + | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
89 | - | } |
89 | + | ->getProductCollection() |
90 | - | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
90 | + | ->addAttributeToSelect('*') |
91 | - | ->getProductCollection() |
91 | + | ->addAttributeToFilter('status', 1) |
92 | - | ->addAttributeToSelect('*') |
92 | + | ->addAttributeToFilter('visibility', 4) |
93 | - | ->addAttributeToFilter('status', 1) |
93 | + | ->setOrder('price', $direction); |
94 | - | ->addAttributeToFilter('visibility', 4) |
94 | + | } |
95 | - | ->setOrder('position', $direction); |
95 | + | |
96 | - | } |
96 | + | if($order == 'position') { |
97 | if($direction == '') { | |
98 | - | if($order == '') { |
98 | + | $direction = 'asc'; |
99 | - | if($direction == '') { |
99 | + | } |
100 | - | $direction = 'asc'; |
100 | + | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
101 | - | } |
101 | + | ->getProductCollection() |
102 | - | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) |
102 | + | ->addAttributeToSelect('*') |
103 | - | ->getProductCollection() |
103 | + | ->addAttributeToFilter('status', 1) |
104 | - | ->addAttributeToSelect('*') |
104 | + | ->addAttributeToFilter('visibility', 4) |
105 | - | ->addAttributeToFilter('status', 1) |
105 | + | ->setOrder('position', $direction); |
106 | - | ->addAttributeToFilter('visibility', 4) |
106 | + | } |
107 | - | ->setOrder('news_from_date', 'desc') |
107 | + | |
108 | - | ->setOrder('created_at', 'desc'); |
108 | + | if($order == '') { |
109 | if($direction == '') { | |
110 | - | } |
110 | + | $direction = 'asc'; |
111 | } | |
112 | $_productCollection = Mage::getModel('catalog/category')->load($currentCategoryId) | |
113 | ->getProductCollection() | |
114 | ->addAttributeToSelect('*') | |
115 | ->addAttributeToFilter('status', 1) | |
116 | ->addAttributeToFilter('visibility', 4) | |
117 | ->setOrder('news_from_date', 'desc') | |
118 | ->setOrder('created_at', 'desc'); | |
119 | } | |
120 | ||
121 | //layered navigation handling | |
122 | //price | |
123 | $price = Mage::app()->getRequest()->getParam('price'); | |
124 | $class = Mage::app()->getRequest()->getParam('class'); | |
125 | $silos = Mage::app()->getRequest()->getParam('silos'); | |
126 | ||
127 | if($price != ''){ | |
128 | $arr_price = explode('-',$price); | |
129 | ||
130 | if($arr_price[1] == '') | |
131 | $_productCollection->addAttributeToFilter('price',array('from'=> $arr_price[0])); | |
132 | else | |
133 | $_productCollection->addAttributeToFilter('price',array('from'=> $arr_price[0], 'to' => $arr_price[1])); | |
134 | } | |
135 | ||
136 | if($class != ''){ | |
137 | //$_productCollection->addAttributeToSelect('class'); | |
138 | $_productCollection->addAttributeToFilter('class', $class); | |
139 | } | |
140 | ||
141 | if($silos != ''){ | |
142 | $_productCollection->addAttributeToFilter('silos', $silos); | |
143 | } | |
144 | } | |
145 | ||
146 | if($limit != 'all'){ | |
147 | $_productCollection->setPageSize($limit)->setCurPage($current_page); | |
148 | } | |
149 | ||
150 | //echo $_productCollection->getSelect()->assemble(); | |
151 | ||
152 | ?> | |
153 | <!-- List mode --> | |
154 | <?php if($this->getMode()!='grid'): ?> | |
155 | <?php $_iterator = 0; ?> | |
156 | <ol class="products-list" id="products-list"> | |
157 | <?php foreach ($_productCollection as $_product): ?> | |
158 | <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>"> | |
159 | <!-- Product Image -- > | |
160 | <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"> | |
161 | <?php $_imgSize = 300; ?> | |
162 | <img id="product-collection-image-<?php echo $_product->getId(); ?>" | |
163 | src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize($_imgSize); ?>" | |
164 | alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> | |
165 | </a> | |
166 | <!-- Product description --> | |
167 | <div class="product-shop"> | |
168 | <div class="f-fix"> | |
169 | <div class="product-primary"> | |
170 | <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?> | |
171 | <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2> | |
172 | <?php if($_product->getRatingSummary()): ?> | |
173 | <?php echo $this->getReviewsSummaryHtml($_product) ?> | |
174 | <?php endif; ?> | |
175 | <?php | |
176 | if ($this->getChild('name.after')) { | |
177 | $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); | |
178 | foreach ($_nameAfterChildren as $_nameAfterChildName) { | |
179 | $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); | |
180 | $_nameAfterChild->setProduct($_product); | |
181 | echo $_nameAfterChild->toHtml(); | |
182 | } | |
183 | } | |
184 | ?> | |
185 | </div> | |
186 | <div class="product-secondary"> | |
187 | <?php echo $this->getPriceHtml($_product, true) ?> | |
188 | - | foreach ($_productCollection as $_product): ?> |
188 | + | |
189 | <div class="product-secondary"> | |
190 | <?php if(!$_product->canConfigure() && $_product->isSaleable()): ?> | |
191 | <p class="action"><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p> | |
192 | <?php elseif($_product->getStockItem() && $_product->getStockItem()->getIsInStock()): ?> | |
193 | <p class="action"><a title="<?php echo $this->__('View Details') ?>" class="button" href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a></p> | |
194 | - | |
194 | + | |
195 | <p class="action availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p> | |
196 | <?php endif; ?> | |
197 | <ul class="add-to-links"> | |
198 | <?php if ($this->helper('wishlist')->isAllow()) : ?> | |
199 | <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li> | |
200 | <?php endif; ?> | |
201 | <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?> | |
202 | <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li> | |
203 | <?php endif; ?> | |
204 | </ul> | |
205 | </div> | |
206 | <div class="desc std"> | |
207 | <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?> | |
208 | <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a> | |
209 | </div> | |
210 | </div> | |
211 | </div> | |
212 | </li> | |
213 | <?php endforeach; ?> | |
214 | </ol> | |
215 | <script type="text/javascript">decorateList('products-list', 'none-recursive')</script> | |
216 | ||
217 | <?php else: ?> | |
218 | ||
219 | <!-- Grid Mode --> | |
220 | ||
221 | <?php $_collectionSize = $_productCollection->count() ?> | |
222 | <?php | |
223 | //$_columnCount = $this->getColumnCount | |
224 | $_columnCount = 4; | |
225 | ?> | |
226 | <ul class="products-grid ali-grid products-grid--max-<?php echo $_columnCount; ?>-col"> | |
227 | <?php $i=0; | |
228 | foreach ($_productCollection as $_product): ?> | |
229 | <?php /*if ($i++%$_columnCount==0): ?> | |
230 | <?php endif*/ ?> | |
231 | <?php //echo $_productCollection->getSelect()->assemble() ?> | |
232 | <?php //echo '<pre>'; //print_r(debug_print_backtrace()); //echo '</pre>'; ?> | |
233 | <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>"> | |
234 | ||
235 | <div class="img-prod"> | |
236 | <?php | |
237 | if($_product->getSpecialPrice()): | |
238 | ?> | |
239 | <div class="embel-embel sale"><?php echo $this->__('Sale')?><span class="sale"></span></div> | |
240 | <?php endif;?> | |
241 | <?php | |
242 | $date = date("Y-m-d 00:00:00"); | |
243 | $newtodate = $_product['news_to_date']; | |
244 | $newfromdate = $_product['news_from_date']; | |
245 | ||
246 | if (isset($newfromdate) and isset($newtodate) and $date >= $newfromdate and $date <= $newtodate) : | |
247 | ?> | |
248 | <div class="embel-embel new"><?php echo $this->__('New')?><span class="new"></span></div> | |
249 | ||
250 | <?php | |
251 | elseif(isset($newfromdate)): | |
252 | ?> | |
253 | <div class="embel-embel new"><?php echo $this->__('New')?><span class="new"></span></div> | |
254 | <?php endif;?> | |
255 | <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"> | |
256 | <?php $_imgSize = 210; ?> | |
257 | <img id="product-collection-image-<?php echo $_product->getId(); ?>" | |
258 | src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(238,317); ?>" | |
259 | alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /> | |
260 | </a> | |
261 | </div> | |
262 | <div class="product-info"> | |
263 | <div class="prod-title"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></div> | |
264 | <h2 style="display:none" class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName(), 'name') ?></a></h2> | |
265 | <?php | |
266 | // Provides extra blocks on which to hang some features for products in the list | |
267 | // Features providing UI elements targeting this block will display directly below the product name | |
268 | /*if ($this->getChild('name.after')) { | |
269 | $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren(); | |
270 | foreach ($_nameAfterChildren as $_nameAfterChildName) { | |
271 | $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName); | |
272 | $_nameAfterChild->setProduct($_product); | |
273 | echo $_nameAfterChild->toHtml(); | |
274 | } | |
275 | }*/ | |
276 | ?> | |
277 | <?php echo $this->getPriceHtml($_product, true) ?> | |
278 | <?php //if($_product->getRatingSummary()): ?> | |
279 | <?php //echo $this->getReviewsSummaryHtml($_product, 'short') ?> | |
280 | <?php //endif; ?> | |
281 | <div class="actions" style="display:none"> | |
282 | <?php if(!$_product->canConfigure() && $_product->isSaleable()): ?> | |
283 | <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button> | |
284 | <?php elseif($_product->getStockItem() && $_product->getStockItem()->getIsInStock()): ?> | |
285 | <a title="<?php echo $this->__('View Details') ?>" class="button" href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a> | |
286 | <?php else: ?> | |
287 | <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p> | |
288 | <?php endif; ?> | |
289 | <ul class="add-to-links"> | |
290 | <?php if ($this->helper('wishlist')->isAllow()) : ?> | |
291 | <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li> | |
292 | <?php endif; ?> | |
293 | <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?> | |
294 | <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li> | |
295 | <?php endif; ?> | |
296 | </ul> | |
297 | </div> | |
298 | </div> | |
299 | </li> | |
300 | <?php /*if ($i%$_columnCount==0 || $i==$_collectionSize): ?> | |
301 | <?php endif*/ ?> | |
302 | <?php endforeach ?> | |
303 | </ul> | |
304 | <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script> | |
305 | <?php endif; ?> | |
306 | ||
307 | <div class="toolbar-bottom"> | |
308 | <?php echo $this->getToolbarHtml() ?> | |
309 | </div> | |
310 | </div> | |
311 | <?php endif; ?> | |
312 | <?php | |
313 | // Provides a block where additional page components may be attached, primarily good for in-page JavaScript | |
314 | if ($this->getChild('after')) { | |
315 | $_afterChildren = $this->getChild('after')->getSortedChildren(); | |
316 | foreach ($_afterChildren as $_afterChildName) { | |
317 | $_afterChild = $this->getChild('after')->getChild($_afterChildName); | |
318 | //set product collection on after blocks | |
319 | $_afterChild->setProductCollection($_productCollection); | |
320 | echo $_afterChild->toHtml(); | |
321 | } | |
322 | } | |
323 | ?> |