1.In my case i created a 'Customer Provident' product using upgradeData.php with version 1.0.3 and module version also 1.0.3 and it's created successfully.

2.Second time i wrote the code to update the table column using Upgradeschema.php with version 1.0.5 and module version 1.0.5 worked successfully.

3.Now i deleted the product 'Customer Provident' from magento backend and i want to create same product if we upgrade once.Is this possible one this time i don't change module.xml version it's as it is 1.0.5 but this product not created

  1. But this time i want to create the product

Is there any way to achieve it,if anyone have idea please guide me.

  • @All, RecurringData.php made this scenario awesome way – hitesh balpande May 16 at 14:07


when you run upgrade command it will run UpgradeData.php file and in that it will compare the version based on that version it will execute the code,

Since the product creation code is not present in the current version. That will not create the product for you.

Better approach is use RecurringData.php

The recurring scripts are executed after any module setup. They also execute on each and every setup:upgrade command, regardless of the schema_version or data_version logged against the setup_module table.

Note: You need to check if the Product created is exist already, otherwise you mayget constraint error

I hope this will help in your scenario.


Please check RecurringData.php worked for me.

    namespace Vendor\Module\Setup;
    use Magento\Framework\Setup\InstallDataInterface;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\ModuleDataSetupInterface;
    use Magento\Customer\Model\GroupFactory;

    class RecurringData implements InstallDataInterface

        protected $_indexerFactory;
        public $indexerIds = array(

        public function __construct(
            \Magento\Indexer\Model\IndexerFactory $indexerFactory
        ) {
            $this->_indexerFactory = $indexerFactory;

        public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)

        public function reindexAll() {
            foreach ($this->indexerIds as $indexerId) {
                $indexer = $this->_indexerFactory->create();

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.