I created a custom module that at regular intervals creates an XML file with selected product data. The process that generates the XML can also be run from Magento CLI via a custom command.

Although the custom command generates the feed, cron does not seem to get any products. In both cases, a helper is called that actually gets the products and writes the XML file. Here is the code that gets the products:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

            $appState = $objectManager->get('Magento\Framework\App\State');
        } finally {

        $this->collection = $objectManager->create('Magento\Catalog\Model\ResourceModel\Product\Collection');
        $this->collection->addAttributeToFilter('status', 1); //enabled
        $this->collection->addAttributeToFilter('visibility', 4); //catalog, search
        if( !$this->show_outofstock ) {

        $this->iterator->walk( $this->collection->getSelect(), array(array($this, 'productCallback')) );

In the cron log file I can see that the job is run (since the file is being created), but no products are in it...

Can anyone point me in the right direction with this one???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.