Magento2: Magento 2.2 Upgrade - Element 'css', attribute 'order': The attribute 'order' is not allowed.

Created on 11 Nov 2017  路  7Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2.2
  2. PHP Version 7.0.14

Steps to reproduce

  1. After completing the upgrade process
  2. Load front website

Expected result

  1. It should be working fine

Actual result

  1. showing this error

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'css', attribute 'order': The attribute 'order' is not allowed.
Line: 62

upgrading issue

once I removed the order attribute from the layout. the error is gone but my custom CSS file not adding in frontend.
before: <css src="css/custom.css" order="200" />
now: <css src="css/custom.css" />

Cannot Reproduce Clear Description Format is valid

Most helpful comment

magento 2.2 does not support order or after attribute anymore.

U can solve the issue by using:
<css src="css/custom.css" media="all and (min-width: 1px)"/>
This will load your Custom CSS last and for all screen size.

All 7 comments

I'm also experiencing the same error.

How to fix it

magento 2.2 does not support order or after attribute anymore.

U can solve the issue by using:
<css src="css/custom.css" media="all and (min-width: 1px)"/>
This will load your Custom CSS last and for all screen size.

Even if the solution is simple, it is required to change an file in the magento framework : /vendor/magento/framework/View/Layout/etc/head.xsd

If you add an xs:attribute with the name order in the xs:complexType linkType everything works.

    <xs:complexType name="linkType">
        <!-- Keep everything here -->
        <xs:attribute name="order" type="xs:string"/>
    </xs:complexType>

Here is a patch that can be installed with the help cweagans/composer-patches library. Rename the file to have .patch extension and pu it in a patches folder in the Magento root directory.

Patch-Magento_Framework-M2.2.0-the-attribute-order-is-not-allowed.txt

In composer.json append :

    "extra": {
        "patches": {
            "magento/framework": {
                "Fix: https://github.com/magento/magento2/issues/12188": "patches/Patch-Magento_Framework-M2.2.0-the-attribute-order-is-not-allowed.patch"
            }
        },
        "magento-force": "override"
    }

Hi SpartakausMD

i added and new error
Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 1701016200 bytes) in .....\vendor\magento\framework\ObjectManager\Relations\Runtime.php on line 38

@LeLieu do you have the same issue if you remove the order attribute on css element in your layouts ?

@Priya-Ponnusamy, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.2.1

@magento-engcom-team I can confirm the issue that @Priya-Ponnusamy has. I've tested this on Magento 2.2.1 /PHP7.1.

By the way, the workaround that's suggested by @pieal86 works for me.

Was this page helpful?
0 / 5 - 0 ratings