4

I'm wondering if it is possible at all to load some content (different per page) in between the product collection. I've made a module injecting some content that I enter in the backend, but obviously every page of my category now displays the same content blocks at the same place, since the product collection is just loaded a second time for the second page.

What I want is to be able to inject different content for the second, third page etc. I added some screenshots of how I would want it to be. Any help would be appreciated! page 1 page 2

1

Inserting varied content relevant to your page will be possible likely: for instance in the category page, I would write an afterplugin onto the function \Magento\Catalog\Block\Product\ListProduct::getLoadedProductCollection.

your plugin may get the data fetching the current category id and load a specific content from here with business rule you will have to define.

and then in the plugin you can add some items to the collection like below:

$object = new \Magento\Framework\DataObject //used to be Varien_Object in M1

$object->setData('id', uniqid());
$object->setData('type', 'cms');
$object->setData('html', $html);

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.