0

I want collection of one module in other module. I am doing it like

use Test\CompanyAddresses\Model\CompanyAddressFactory;

class ReformatTelephoneField implements DataPatchInterface
{
    protected $companyAddressFactory;

    /**
     * @param CompanyAddressFactory $companyAddressFactory
     */
    public function __construct(
        CompanyAddressFactory $companyAddressFactory
    ) {
        $this->companyAddressFactory = $companyAddressFactory;
    }

public function apply()
    {
        $companyAddressCollection = $this->companyAddressFactory->create()->getCollection();
    }
}

I have provided basic code logic that how I am getting collection but on setup:upgrade I am getting issue like Model collection resource name is not defined. Don't know what is the issue.

1 Answer 1

0

Try to edit module sequence

etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Test_Module1">
        <sequence>
            <module name="Test_Module2_WITH_COLLECTION"/>
        </sequence>
    </module>
</config>

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.