0

I have installed the Amasty ShopBy Extension and am trying to make my own modifications the correct way: using my own extension.

I have created a preference in di.xml (tried in /etc and /etc/frontend) as follows:

<preference for="Amasty\ShopbyBrand\Block\Widget\BrandList" type="Wildcard\AmastyShopbyExtension\Block\Widget\BrandList" />

And the widget block file:

<?php

namespace Wildcard\AmastyShopbyExtension\Block\Widget;

use Amasty\ShopbyBrand\Block\Widget\BrandList as AmastyBrandList;

class BrandList extends AmastyBrandList
{

}

With the above in place, the widget does not show anything at all. However, if I place a die('here'); right before the class declaration, the word 'here' is printed. This tells me that the preference is working as it should.

Surely if I have an empty class and am extending from another, the properties and methods from the other class would all still be in tact and apply?

Also, if I add the following in my class:

protected function _beforeToHtml()
{
    echo "This works";

    return parent::_beforeToHtml();
}

The 'This works' string is echoed to screen.

Is there anything I am missing?

Using Magento 2.1.7

0

Looks like you forget about template. Check out

Amasty/ShopbyBrand/view/frontend/layout directory.

You need to make sure template path contains Amasty_ShopbyBrand prefix. To fix template path you can overwrite $_template variable in your own block or copy template file to your module.

  • There isn't anything in the Amasty/ShopbyBrand/view/frontend/layout directory... The only XML file that brings in the block is etc/widgets.xml – Wildcard27 Jun 19 '17 at 1:12
  • I'm sorry I don't know this plugin very well, but just want to say it could be an issue with template path. you can find this path in layout xml or check out Amasty\ShopbyBrand\Block\Widget\BrandList class. – Nicholas Miller Jun 19 '17 at 2:59
  • Sorry, I can't take anything from this answer to help me out. Appreciate the response, though – Wildcard27 Jun 20 '17 at 1:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.