How do I add a CMS Static Block Text Box To All Product Listings In Magento?

by Shahrooz   Last Updated May 15, 2018 20:09 PM

I would like to display a CMS Static Block text box at the bottom of all product listings in Magento, but I would need the code to put in CMS -> Static Blocks in the admin panel in order to do so. Any help would be appreciated, thank you.



Answers 2


You need a custom theme or a module to do this. In the case of a theme, create the following file:

/app/design/frontend/[Company]/[ThemeName]/Magento_Catalog/layout/catalog_category_view.xml

WIth the following content:

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>
    <referenceContainer name="content">
      <block class="Magento\Cms\Block\Block" name="yourblockname">
        <arguments>
          <argument name="block_id" xsi:type="string">id_defined_in_block_admin</argument>
        </arguments>
      </block>
    </referenceContainer>
  </body>
</page>

Your block will then appear at the bottom of all product listing (category) pages.

Geat
Geat
May 15, 2018 22:39 PM

you can add code in your list.phtml from your theme(template\catalog\product).

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml(); 
?>
Yogesh
Yogesh
May 16, 2018 05:34 AM

Related Questions


Why changes in a CMS block doesn't appear?

Updated May 31, 2017 12:09 PM

Trying to add a Block to allowed blocks - white page

Updated October 13, 2017 15:09 PM



Magento 2.1.9 CMS Block massdelete action gives error

Updated November 07, 2017 11:09 AM