3

In every page load, I am getting the following error in exception.log of my Magento 2 website.

main.CRITICAL: The element 'content' already has a child with alias 'product_list' {"exception":"[object] (Magento\Framework\Exception\LocalizedException(code: 0): The element 'content' already has a child with alias 'product_list' at /var/www/html/vendor/magento/framework/Data/Structure.php:611)"} []

Please help to solve this error. I don't know which extension is causing this error.

I have installed Darsh_Callforprice extension to add an option to make the call for price in some products.

If you have faced this kind of error previously then, please let me know how you solve this.

UPDATE

When I search "product_list" in all the xml inside my app/code folder I am getting the following result.

code\Darsh\Callforprice\view\frontend\layout\catalog_category_view.xml (1 hit) ..Please see the code here

 Line 6: <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.customlist" as="product_list" template="Darsh_Callforprice::list.phtml">

code\Mageplaza\Shopbybrand\view\frontend\layout\catalog_category_view.xml (1 hit)

Please see the code here

Line 7: <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml" >

code\Mageplaza\Shopbybrand\view\frontend\layout\catalog_category_view.xml-orginal (1 hit)

Line 7: <block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_catalog::product/list.phtml" >

code\Magiccart\Magicproduct\view\frontend\layout\magicproduct_bestseller_index.xml (1 hit)

Line 30: <block class="Magiccart\Magicproduct\Block\Product\ProductList" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">

code\Magiccart\Magicproduct\view\frontend\layout\magicproduct_featured_index.xml (1 hit)

Line 30: <block class="Magiccart\Magicproduct\Block\Product\ProductList" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">

code\Magiccart\Magicproduct\view\frontend\layout\magicproduct_latest_index.xml (1 hit)

Line 30: <block class="Magiccart\Magicproduct\Block\Product\ProductList" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">

code\Magiccart\Magicproduct\view\frontend\layout\magicproduct_newproduct_index.xml (1 hit)

Line 30: <block class="Magiccart\Magicproduct\Block\Product\ProductList" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">

3 Answers 3

3
+50

I see you have two catalog_category_view.xml and both are trying to alias product_list in their XML. It would be easier to answer if I could see the whole content of those two files.

But changing one product_list to something else (another_product_list) would fix the exception. However, you will need to add another_product_list in the phtml file too.

Bit of context:

When Magento is calling getChildHtml('produt_list') it is struggling to determine which one to call, since both of them are aliased the same name. So the rule of thumb, in the same parent node (throughout the layout), you shouldn't include same alias.

11
2

If I am interpreting the error correctly there is a module or theme file that tries to add a block or container with the name or alias "product_list" to the "content" container.

Do a search in your codebase filtered by .xml files only and add "product_list" (include the quotation marks) as the search term. In a clean magento installation it should only show 1 file in the magento catalog module. The file that breaks your magento should be among the other search results you are getting.

1
  • 2
    Thank you. This is super helpful. Could you please check my question once again, I updated the question with the search result. Jul 5, 2022 at 9:08
0

In 'theme OR module' layout file 'content' are use multiple times like as="content" that.so remove it and check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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