Установить разбиение на страницы в соответствии с фильтром в magento

Пожалуйста, просмотрите мои действия для вопроса.

Я создал одну категорию продукта magento под названием Категория, которая применима ко всей категории продуктов.

Для описания списка продуктов я создал custom_list.phtml в папке каталога, и я обновил файл макета в конце magento.

код для custom_list.phtml

<!--?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [removed_email] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category design
 * @package base_default
 * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
 */
?-->
<!--?php
/**
 * Product list template
 *
 * @see Mage_Catalog_Block_Product_List
 */
?-->
<!--?php
 $_productCollection=$this--->getLoadedProductCollection();
 $_helper = $this->helper('catalog/output');
 $startWith = $_REQUEST['startWith'];
 $byCountry = $_REQUEST['byCountry'];
 $currentCategory = $this->getCurrentCategory(); 
 var_dump(get_class_methods(get_class($this)));
?>
<div>
 <!--?php if(isset($startWith)): ?-->
 <!--?php
 $_productCollection--->clear()
 ->addAttributeToFilter('name', array( array('like' => $startWith.'%')))
 ->load();
 ?>
 <span><!--?php echo $this--->__('WINES WITH THE LETTER ').'"'.$startWith.'"'; ?></span>
 <!--?php elseif(isset($byCountry)): ?-->
 <!--?php
 $_productCollection--->clear()
 ->addAttributeToFilter('country_of_manufacture', array( array('like' => $byCountry)))
 ->load();
 /*$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
 ->setCodeFilter('country_of_manufacture')
 ->getFirstItem();*/
 $attribute_code = "country_of_manufacture";
 $attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code);
 $options = $attribute_details->getSource()->getAllOptions(false);
 $countryLabel="";
 foreach($options as $option){
 // print_r($option) and find all the elements
 //echo $option["value"];
 //echo $option["label"];
 if($option["value"]==$byCountry){
 $countryLabel = $option["label"];
 }
 }
 ?>
 <span><!--?php echo $this--->__('WINES FROM ').'“ '.$countryLabel.' ”'; ?></span>
 <!--?php endif; ?-->
 <span><a href="<?php echo Mage::getModel('catalog/layer')->getCurrentCategory()->getUrl(); ?>"><!--?php echo $this--->__('GO BACK TO MAP'); ?></a></span>
</div>
<!--?php if(!$_productCollection--->count()): ?>
<p><!--?php echo $this--->__('There are no products matching the selection.') ?></p>
<!--?php else: ?-->
<div>
 <!--?php //echo $this--->getToolbarHtml() ?>
 <!--?php // List mode ?-->
 <!--?php $_iterator = 0; ?-->
 <ol id="products-list">
 <!--?php foreach ($_productCollection as $_product): ?-->
 <li>
 <!--?php // Product Image ?-->
 <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>">
 
 <!--?php /**********************************************************/ ?-->
 <!--?php
 // Get the Special Price
 $specialprice = Mage::getModel('catalog/product')--->load($_product->getId())->getSpecialPrice();
 // Get the Special Price FROM date
 $specialPriceFromDate = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialFromDate();
 // Get the Special Price TO date
 $specialPriceToDate = Mage::getModel('catalog/product')->load($_product->getId())->getSpecialToDate();
 // Get Current date
 $today = time();
 if ($specialprice):
 if($today >= strtotime( $specialPriceFromDate) && $today <= strtotime($specialPriceToDate) || $today >= strtotime( $specialPriceFromDate) && is_null($specialPriceToDate)):
 ?>
 
 <!--?php
 endif;
 endif;
 ?-->
 <!--?php /**********************************************************/ ?-->
 </a>
 <!--?php // Product description ?-->
 <div>
 <div>
 <!--?php $_productNameStripped = $this--->stripTags($_product->getName(), null, true); ?>
 <h2><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><!--?php echo $_helper--->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
 <!--?php if($_product--->getRatingSummary()): ?>
 <!--?php echo $this--->getReviewsSummaryHtml($_product) ?>
 <!--?php endif; ?-->
 <div>
 <!--?php echo $_helper--->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
 <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>"><!--?php echo $this--->__('Learn More') ?></a>
 </div>
 <div>
 <!--?php echo $this--->getPriceHtml($_product, true) ?>
 <!--?php if($_product--->isSaleable()): ?>
 <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><!--?php echo $this--->__('Add to Cart') ?></span></span></button></p>
 <!--?php else: ?-->
 <p><span><!--?php echo $this--->__('Out of stock') ?></span></p>
 <!--?php endif; ?-->
 </div>
 </div>
 </div>
 </li>
 <!--?php endforeach; ?-->
 </ol>
 
 <div>
 <!--?php echo $this--->getToolbarHtml() ?>
 </div>
</div>
<!--?php endif; ?-->

fiter работает нормально, но разбиение на страницы не работает. может ли любой орган, пожалуйста, помогите мне, как я могу его достичь?

1 ответ

Вы можете добавить этот код в свой шаблон.

<!--?php
 $pager=new Mage_Page_Block_Html_Pager();
 $pager--->setAvailableLimit(8);
 $pager->setCollection($_productCollection);
 $pager->setShowPerPage(6);
?>

Возможно, это поможет вам. $_productCollection - ваш продукт коллекционирования в вашем шаблоне.

licensed under cc by-sa 3.0 with attribution.