87 $this->_catalogLayer = $layerResolver->
get();
88 $this->_postDataHelper = $postDataHelper;
115 if ($this->_productCollection ===
null) {
116 $this->_productCollection = $this->initializeProductCollection();
153 return $this->getDefaultListingMode();
163 private function getDefaultListingMode()
167 $availableModes = $defaultToolbar->getModes();
172 if (!
$mode || !isset($availableModes[
$mode])) {
174 $mode = $defaultToolbar->getCurrentMode();
193 return parent::_beforeToHtml();
203 $toolbarLayout = $this->getToolbarFromLayout();
205 if ($toolbarLayout) {
206 $this->configureToolbar($toolbarLayout,
$collection);
217 $block = $this->getToolbarFromLayout();
220 $block = $this->
getLayout()->createBlock($this->_defaultToolbarBlock, uniqid(microtime()));
231 private function getToolbarFromLayout()
233 $blockName = $this->getToolbarBlockName();
235 $toolbarLayout =
false;
238 $toolbarLayout = $this->
getLayout()->getBlock($blockName);
241 return $toolbarLayout;
289 return $this->
_getData(
'price_block_template');
310 if (!$this->getAvailableOrders()) {
311 $this->setAvailableOrders(
$category->getAvailableSortByOptions());
313 $availableOrders = $this->getAvailableOrders();
314 if (!$this->getSortBy()) {
315 $categorySortBy = $this->getDefaultSortBy() ?:
$category->getDefaultSortBy();
316 if ($categorySortBy) {
317 if (!$availableOrders) {
318 $availableOrders = $this->
_getConfig()->getAttributeUsedForSortByArray();
320 if (isset($availableOrders[$categorySortBy])) {
321 $this->setSortBy($categorySortBy);
349 $identities = array_merge($identities,
$item->getIdentities());
367 'product' =>
$product->getEntityId(),
383 $price = $priceRender->render(
387 'include_container' =>
true,
388 'display_minimal_price' =>
true,
390 'list_category_page' =>
true 406 return $this->
getLayout()->getBlock(
'product.price.render.default')
407 ->setData(
'is_product_list',
true);
425 private function initializeProductCollection()
429 if ($this->getShowRootCategory()) {
430 $this->setCategoryId($this->_storeManager->getStore()->getRootCategoryId());
434 if ($this->_coreRegistry->registry(
'product')) {
436 $categories = $this->_coreRegistry->registry(
'product')
437 ->getCategoryCollection()->setPage(1, 1)
442 $this->setCategoryId(current(
$categories->getIterator())->getId());
446 $origCategory =
null;
447 if ($this->getCategoryId()) {
449 $category = $this->categoryRepository->get($this->getCategoryId());
450 }
catch (NoSuchEntityException $e) {
455 $origCategory = $layer->getCurrentCategory();
464 $layer->setCurrentCategory($origCategory);
469 $this->_eventManager->dispatch(
470 'catalog_block_product_list_collection',
488 private function configureToolbar(Toolbar $toolbar, Collection
$collection)
491 $orders = $this->getAvailableOrders();
493 $toolbar->setAvailableOrders(
$orders);
495 $sort = $this->getSortBy();
497 $toolbar->setDefaultOrder($sort);
499 $dir = $this->getDefaultDirection();
501 $toolbar->setDefaultDirection($dir);
503 $modes = $this->getModes();
505 $toolbar->setModes($modes);
509 $this->
setChild(
'toolbar', $toolbar);
getData($key='', $index=null)
getAddToCartPostParams(Product $product)
setCollection($collection)
getProductPrice(Product $product)
__construct(Context $context, PostHelper $postDataHelper, Resolver $layerResolver, CategoryRepositoryInterface $categoryRepository, Data $urlHelper, array $data=[])
const CACHE_PRODUCT_CATEGORY_TAG
const PARAM_NAME_URL_ENCODED
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
prepareSortableFieldsByCategory($category)
getAddToCartUrl($product, $additional=[])
getLoadedProductCollection()
getChildHtml($alias='', $useCache=true)