問題:デフォルトのMagento phtmlファイルを上書きしようとすると、エラーが発生する
これらを取得する必要があります:( フッターのページ分割、ソーター)
私のカスタムモジュール:
1) Vendor/TglsSearch  --> Override from Magento CatalogSearch
2) Vendor/Tglcatalog ---> from Magento Cataloではアプリ\設計\フロントエンド\ベンダー\タグ
更新されたコード:
以下のフォルダを削除しました
ではMagento_Catalogフォルダ:
templates\product\list\toolbar.phtml
templates\product\list\toolbar\amount.phtml
templates\product\list\toolbar\limiter.phtml
templates\product\list\toolbar\sorter.phtml
templates\product\list\toolbar\viewmode.phtmlこれは私がフロントページに結果なしで空白のページを取得するものです:
上記のコードをブロックファイルに追加しました。
Vendor \ Module \ Block \ Product \ ListProduct.php
class ListProduct extends \Magento\Catalog\Block\Product\ListProduct
{
    public function __construct(
    /*passing all Constructors parameters to the parent class */
    \Magento\Catalog\Block\Product\Context $context,
    \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
    \Magento\Catalog\Model\Layer\Resolver $layerResolver,
     CategoryRepositoryInterface $categoryRepository,
    \Magento\Framework\Url\Helper\Data $urlHelper,
    \Vendor\Module\Helper\Data $tglssearchHelper,
    \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $catalogResourceModelProductCollectionFactory,
    \Magento\Catalog\Model\Config $catalogConfig,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Catalog\Model\ProductFactory $productFactory,      //Pagination
    array $data = []
) {
    $this->tglssearchHelper = $tglssearchHelper;
    $this->catalogResourceModelProductCollectionFactory = $catalogResourceModelProductCollectionFactory;
    $this->catalogConfig = $catalogConfig;
    $this->storeManager = $storeManager;
    $this->_productFactory = $productFactory;  //Pagination
    $this->urlHelper = $urlHelper;
      parent::__construct(
        $context,
        $postDataHelper,
        $layerResolver,
        $categoryRepository,
        $urlHelper,
        $data
    );
    //updated code
     $collection= $this->_getProductCollection();
    $this->setCollection($collection);
}
public function _prepareLayout(){
   parent::_prepareLayout();
    if ($this->_getProductCollection()) { 
        // create pager block for collection 
        $toolbar = $this->getToolbarBlock();  
        $pager = $this->getLayout()->createBlock(
                        'Magento\Theme\Block\Html\Pager', 'list.pager'
                )->setCollection(
                $this->_getProductCollection() // assign collection to pager
        );  
        $toolbar->setChild('product_list_toolbar_pager', $pager); // set pager block in layout
        // called prepare sortable parameters
        $collection = $this->_getProductCollection();  
        // use sortable parameters
        $orders = $this->getAvailableOrders();  
        if ($orders) {
            $toolbar->setAvailableOrders($orders);
        }
        $sort = $this->getSortBy();
        if ($sort) {
            $toolbar->setDefaultOrder($sort);
        }
        $dir = $this->getDefaultDirection();
        if ($dir) {
            $toolbar->setDefaultDirection($dir);
        }
        $modes = $this->getModes();
        if ($modes) {
            $toolbar->setModes($modes);
        }
        $toolbar->setCollection($collection);
        $this->setChild('toolbar', $toolbar);
        $this->_getProductCollection()->load();
   }
    return $this;
}
protected function _getProductCollection()
{
      $tagalys = $this->tglssearchHelper->getSearchData();
        if($tagalys == false) {
            return parent::_getProductCollection();
        } else {
        $searchResult = $tagalys;
        if(empty($searchResult)) {
            return parent::_getProductCollection();
        }
        $collection = $this->_productCollection = $this->catalogResourceModelProductCollectionFactory->create()
             ->addAttributeToSelect($this->catalogConfig->getProductAttributes())
             ->setStore($this->storeManager->getStore())
             ->addFieldToFilter('visibility', \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
             ->addAttributeToFilter( 'entity_id', array( 'in' => $searchResult['results'] ) );
        $orderString = array('CASE e.entity_id');
        foreach($searchResult['results'] as $i => $productId) {
            $orderString[] = 'WHEN '.$productId.' THEN '.$i;
        }
        $orderString[] = 'END';
        $orderString = implode(' ', $orderString);
    $collection->getSelect()->order(new \Zend_Db_Expr($orderString));
        return $this->_productCollection;
    }
}
public function getToolbarBlock()
{
    $blockName = $this->getToolbarBlockName();
    if ($blockName) {
        $block = $this->getLayout()->getBlock($blockName);
        if ($block) {
            return $block;
        }
    }
    $block = $this->getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
    return $block;
}
public function getMode()                       //Pagination
{
    return $this->getChildBlock('toolbar')->getCurrentMode();
}
public function getToolbarHtml()        //Pagination
{
    return $this->getChildHtml('toolbar');
}
protected function getPriceRender()
{
    return $this->getLayout()->getBlock('product.price.render.default');
}
protected function _getConfig()
{
    return $this->_catalogConfig;
}
}phtmlの場合:
\ app \ design \ frontend \ Vendor \ tag \ Magento_Catalog \ templates \ product \ list.phtml
<?php
   $_productCollection = $block->getLoadedProductCollection();
   $_helper = $this->helper('Magento\Catalog\Helper\Output');
?>
 <?php if (!$_productCollection->count()): ?>
<div class="message info empty"><div><?php /* @escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
 <?php else: ?>
   <?php echo $block->getToolbarHtml() ?>        //Have called here
     ....
     ....
    <?php echo($iterator == count($_productCollection)+1) ? '</li>' : '' ?>
        <?php endforeach; ?>
    </ol>
  </div>
  <?php echo $block->getToolbarHtml() ?>    //Have called here
    ....これは、フロントエンドのカテゴリリンクをクリックすると表示されるものです。
Magento_CatalogSearchで:
templates\result.phtmlMagento_Themeで:
templates\html\pager.phtml
layout\default.html
web\images\my_logo.png今、result.phtmlエラーはなくなったようですが、それでも私の製品はページネーションのあるフロントエンドでレンダリングされません
に
Admin->Content->Design configuration-> Enabled my Custom Theme.注: カスタムモジュールで、テンプレートとレイアウトファイルが含まれているビューフォルダーを削除しました。
問題点:
上記のphtmlファイルからページャー(ページネーション)、ソーターなどを取得する必要があります。
1)しかし、私の製品はresult.phtmlからレンダリングされません(しかし、私のvar / logには製品IDがあります)...フロントエンドが表示されません
2)ページネーションやソーターが表示されない



