I'm trying to create my own widget in Magento 2 however I get this error:

Error filtering template: Invalid block type: Inchoo1\CatalogWidget\Block\Product\ProductsList

My code is identical to that of "https://inchoo.net/magento-2/magento-2-custom-widget/".

Inchoo/CatalogWidget/Block/Product - ProductList.php

namespace Inchoo\CatalogWidget\Block\Product;

class ProductsList extends \Magento\CatalogWidget\Block\Product\ProductsList

public function createCollection()
    /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
    $collection = $this->productCollectionFactory->create();

    $collection = $this->_addProductAttributesAndPrices($collection)
        ->setCurPage($this->getRequest()->getParam($this->getData('page_var_name'), 1))
        ->setOrder($this->getSortBy(), $this->getSortOrder());

    $conditions = $this->getConditions();
    $this->sqlBuilder->attachConditionToCollection($collection, $conditions);

    return $collection;

public function getSortBy()
    if (!$this->hasData('collection_sort_by')) {
        $this->setData('collection_sort_by', self::DEFAULT_COLLECTION_SORT_BY);
    return $this->getData('collection_sort_by');

public function getSortOrder()
    if (!$this->hasData('collection_sort_order')) {
        $this->setData('collection_sort_order', self::DEFAULT_COLLECTION_ORDER);
    return $this->getData('collection_sort_order');

Can anyone please direct me towards a fix, thanks :)

  • I think you are using Inchoo1 extension or you have rename the Inchoo extension to Inchoo1. Remove that completely and then run setup upgrade, di compile and static content deploy. – Sukumar Gorai Aug 17 '18 at 10:27
  • It is named Inchoo1 everywhere as i already had another module called Inchoo. I don't know if i'm using the extension. All i did was follow this tutorial and change inchoo to inchoo1 - inchoo.net/magento-2/magento-2-custom-widget – Greg Aug 17 '18 at 10:30
  • 1
    Inchoo is a namespace, so it will not create any issue. You can put your module custom widget under the same Inchoo folder. – Sukumar Gorai Aug 17 '18 at 10:33
  • Okay, now I get the same error but with Inchoo not inchoo 1 - Error filtering template: Invalid block type: Inchoo\CatalogWidget\Block\Product\ProductsList – Greg Aug 17 '18 at 10:58
  • Did you run setup upgrade, di compile and static-content deploy? – Sukumar Gorai Aug 17 '18 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.