Skip to content

Unable to override Fulltext\Collection in module et/di.xml #7734

Closed
@joachimVT

Description

@joachimVT

Preconditions

  1. Magento 2.1.1
  2. Using Ubuntu/trusty64 vagrant-box, php7, apache

Steps to reproduce

  1. Add a new custom module
  2. Update etc/di.xml in your custom module
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <preference for="Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection" type="Sanimarkt\App\Model\ResourceModel\Fulltext\Collection" />
</config>

  1. Add new Collection.php file and override _renderFiltersBefore() method
<?php

namespace Sanimarkt\App\Model\ResourceModel\Fulltext;

/**
 * Fulltext Collection
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Collection extends \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection
{
 protected function _renderFiltersBefore()
 {
  die('stopping here');
 }
}
  1. clear cache
  2. Make a search request

Expected result

  1. The search request should stop and show 'stopping here' on the screen

Actual result

  1. Nothing happens the custom class Sanimarkt\App\Model\ResourceModel\Fulltext\Collection.php is not executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions