Closed leoquijano closed 8 years ago
An additional item of information here. I just noticed that for some reason I had a referenceBlock
in my Magento_Theme/layout/default.xml
file:
<referenceContainer name="product.info.main">
<arguments>
<argument name="htmlClass" xsi:type="string">product-info-main fixed-sidebar</argument>
</arguments>
</referenceContainer>
(I was adding a CSS class to the block)
When I remove it (or move it to catalog_product_view.xml
), the 404 error goes away, even without my core code changes. So this makes this issue less critical. But it may be a good idea to check anyway.
Hi @leoquijano
Thank you for reporting. Created internal ticket MAGETWO-52343 to investigate and fix this issue.
Thanks @shiftedreality.
It was probably a mix of my own development bugs and some small problems in M2. I would advise to investigate two things:
product.info.main
container should have a label
attribute.developer
modeFor me it is working now. Please do check the Generator/Container.php
code I mentioned before. If labels are optional for containers, that code section will throw a NOTICE that might break in some PHP configurations.
Fix was merged to develop branch.
Hi,
I'm developing a custom theme and I was stuck with a 404 error when displaying the product view page:
http://mystore.dev/some-product
I first thought that this was a problem with my own setup, but then I went in to debug some exceptions I was getting. Particularly this one:
Since I'm developing my theme on top of the
theme-frontend-blank
theme, I suspected that there was an issue with the most basic theme setup, an issue that might not be visible if I were using a theme that overrides some of the containers.So I went to debug
/vendor/magento/framework/View/Layout/Generator/Container.php
line 90 (as described in the extension), and found this:There you can see how some attributes are set to a container. The
CONTAINER_OPT_LABEL
attribute (i.e. "label") gets a special treatment. It is directly retrieved from the$options
array, and then set. The other attributes are set later.I then found out that even though most containers have labels, this one doesn't:
/vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml (line 30):
Now: not all PHP configurations are so strict as to throw an exception due to an invalid index error. Mine is. I'm using PHP 7.0.5-2 on top of an Ubuntu setup (Homestead). It's clear that there's an issue with this layout file. I'm not sure if all containers should have labels and this just doesn't, or if the container process should handle missing labels well.
As a workaround, I changed
Container.php
like this, and that fixed the problem for me. This, of course, will only work until the next update comes around, so I hope an official fix can be made?Why didn't I just override the container and added the label? I wanted to avoid any other issues like this with other containers. But that workaround is also good.
I'm using Magento 2.0.4, but I took a look at the HEAD source code and the issue seems to be still there at the moment I write this:
https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/View/Layout/Generator/Container.php https://github.com/magento/magento2/blob/develop/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view.xml
Lastly, I would like to point out that the 404 error caused by this error is a bit misleading and might cause confusion with some developers. Perhaps there's a better way to display these errors to developers?
Thanks in advance for your attention.