0

The project is using the Bluefoot plugin to add the block in cms_index_home. I created a static block in Magento Admin with the follow content:

{{block class="ProductsRegulars\Block\Recommendation\Lists" name="product-recommendation" template="recommendation/list.phtml}}

But in my cms_index_home.xml I have some arguments essentials to block.

<arguments>
    <argument name="jsLayout" xsi:type="array">
        <item name="components" xsi:type="array">
            <item name="recommendation-list" xsi:type="array">
                <item name="component" xsi:type="string">ProductsRegulars/js/view/recommendation/list</item>
                <item name="config" xsi:type="array">
                    <item name="template" xsi:type="string">ProductsRegulars/recommendation/list</item>
                </item>

                <item name="children" xsi:type="array">
                    <item name="messages" xsi:type="array">
                        <item name="sortOrder" xsi:type="string">0</item>
                        <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>
                        <item name="displayArea" xsi:type="string">messages</item>
                    </item>
                </item>
            </item>
        </item>
    </argument>
</arguments>

When I run the page, occur the following error:

Uncaught SyntaxError: Unexpected token u in JSON at position 0

I believe that this error occurs because of the Magento not found the arguments.

0

Try to add your referenceBlock and write it's name . I hope it's work for you

<referenceBlock name="xxx.xxx.xxx">
    <arguments>
        <argument name="jsLayout" xsi:type="array">
            <item name="components" xsi:type="array">
                <item name="recommendation-list" xsi:type="array">
                    <item name="component" xsi:type="string">ProductsRegulars/js/view/recommendation/list</item>
                    <item name="config" xsi:type="array">
                        <item name="template" xsi:type="string">ProductsRegulars/recommendation/list</item>
                    </item>

                    <item name="children" xsi:type="array">
                        <item name="messages" xsi:type="array">
                            <item name="sortOrder" xsi:type="string">0</item>
                            <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>
                            <item name="displayArea" xsi:type="string">messages</item>
                        </item>
                    </item>
                </item>
            </item>
        </argument>
    </arguments>    
</referenceBlock>
0

I added the referenceBlock in my cms_index_home.xml. I did the test with identifier value and block name but it still did not work.

Static Block enter image description here

cms_index_home.xml

<referenceBlock name="product-recommendation">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="recommendation-list" xsi:type="array">
                        <item name="component" xsi:type="string">ProductsRegulars/js/view/recommendation/list</item>
                        <item name="config" xsi:type="array">
                            <item name="template" xsi:type="string">ProductsRegulars/recommendation/list</item>
                        </item>

                        <item name="children" xsi:type="array">
                            <item name="messages" xsi:type="array">
                                <item name="sortOrder" xsi:type="string">0</item>
                                <item name="component" xsi:type="string">Magento_Ui/js/view/messages</item>
                                <item name="displayArea" xsi:type="string">messages</item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>

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.