I'm trying to make use of a virtual type. I'm following the docs on this and everything should be pretty straight forward yet I'm kinda stuck.

This is what I have.

The class.

namespace Company\Extension\Model\Product\Attribute\Source;

class Test
    protected $string;

    public function __construct(String $test)
        $this->string = $test;

    public function test()
        return $this->string;

The di.xml

    <virtualType name="TestVirtualType" type="Company\Extension\Model\Product\Attribute\Source\Test">
            <argument name="value" xsi:type="string">foo</argument>

Now when running a simple php/bin magento

  Invalid Document                                                                                            
  Element 'argument': The type definition is abstract.                                                        
  Line: 13                                                                                                    
  Internal error: xmlSchemaXPathProcessHistory, The state object to be removed is not the first in the list.  
  Line: 12                                                                                                    
  Internal error: xmlSchemaValidateChildElem, calling xmlRegExecPushString2().                                
  Line: 3                                                                                                     
  Internal error: xmlSchemaValidateElem, calling xmlSchemaStreamValidateChildElement().                       
  Line: 3                                                                                                     
  Internal error: xmlSchemaDocWalk, calling xmlSchemaValidateElem().                                          
  Line: 3     

I'm following the docs on this as well as many provided examples. I'm not really sure what I'm doing wrong. Any help or pointers in the right direction are highly appreciated

2 Answers 2


Found it. I forgot this part

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
this might have occured due to xmlns:xsi="//www.w3.org/2001/XMLSchema-instance"

in the above line "http:" is missing so please try adding that and your error will be resolved!!

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.