3

I have a ProductFactory , it's construction must manual pass a parameter, But I don't know how to pass it. I use

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $objectManager->get(ProductFeedCaptureFactory::class, ['instanceType' => $type]);

The ProductFactory code below:

class ProductFactory    
{
/**
 * Object Manager instance
 *
 * @var \Magento\Framework\ObjectManagerInterface
 */
protected $_objectManager = null;
/**
 * Instance name to create
 *
 * @var string
 */
protected $_instanceName = null;

/**
 * Factory constructor
 *
 * @param \Magento\Framework\ObjectManagerInterface $objectManager
 * @param string $instanceType  ftp、http、file
 * 
 */
 public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager,  $instanceType )
 {
 }
}

But I got an exception :

Missing required argument $instanceType

How I fix it ? Thanks.

1

Use create instead of get to create a new instance of the factory with this call instead of accessing an existing shared instance

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.