Add videos to products programatically The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar ManaraHow to integrate RabbitMQ with Magento 2.2.* EEAdd video to product programaticallyMagento 2.2.5 : Add video to product programmaticallyImporting product videosProgrammatically trigger admin save action on productImporting product videosProduct price attribute is not showing up on details pageCollection items don't trigger product load event observers or backend models, but can they?Add video to product programaticallyWhat and why is the proper way to load a modelMagento 2: Products images are not showing on category pageUpload Videos in media storageCan't add or edit products on Magento 2.2.5Magento 2 images and videos in custom module

Is this wall load bearing? Blueprints and photos attached

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

Am I ethically obligated to go into work on an off day if the reason is sudden?

Student Loan from years ago pops up and is taking my salary

1960s short story making fun of James Bond-style spy fiction

Can the Right Ascension and Argument of Perigee of a spacecraft's orbit keep varying by themselves with time?

Python - Fishing Simulator

Could an empire control the whole planet with today's comunication methods?

Variable with quotation marks "$()"

Did the new image of black hole confirm the general theory of relativity?

Working through the single responsibility principle (SRP) in Python when calls are expensive

Simulating Exploding Dice

how can a perfect fourth interval be considered either consonant or dissonant?

What do I do when my TA workload is more than expected?

My body leaves; my core can stay

Circular reasoning in L'Hopital's rule

Do I have Disadvantage attacking with an off-hand weapon?

What's the point in a preamp?

Do working physicists consider Newtonian mechanics to be "falsified"?

Are spiders unable to hurt humans, especially very small spiders?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Does Parliament need to approve the new Brexit delay to 31 October 2019?

Match Roman Numerals

Presidential Pardon



Add videos to products programatically



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraHow to integrate RabbitMQ with Magento 2.2.* EEAdd video to product programaticallyMagento 2.2.5 : Add video to product programmaticallyImporting product videosProgrammatically trigger admin save action on productImporting product videosProduct price attribute is not showing up on details pageCollection items don't trigger product load event observers or backend models, but can they?Add video to product programaticallyWhat and why is the proper way to load a modelMagento 2: Products images are not showing on category pageUpload Videos in media storageCan't add or edit products on Magento 2.2.5Magento 2 images and videos in custom module



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I know this question has been asked before:




  • Add video to product programatically


  • Magento 2.2.5 : Add video to product programmatically


  • Importing product videos

  • maybe others

but I need something different.

The answers in the questions linked above suggest using some core methods that (all of them) load the full product and save the full product, either via repository or via the load/save deprecated methods.

I have a lot of products. Somewhere between 5k and 10k.

Going through all of them with load/save it is not really a viable option.



Any other suggestions?










share|improve this question




























    3















    I know this question has been asked before:




    • Add video to product programatically


    • Magento 2.2.5 : Add video to product programmatically


    • Importing product videos

    • maybe others

    but I need something different.

    The answers in the questions linked above suggest using some core methods that (all of them) load the full product and save the full product, either via repository or via the load/save deprecated methods.

    I have a lot of products. Somewhere between 5k and 10k.

    Going through all of them with load/save it is not really a viable option.



    Any other suggestions?










    share|improve this question
























      3












      3








      3








      I know this question has been asked before:




      • Add video to product programatically


      • Magento 2.2.5 : Add video to product programmatically


      • Importing product videos

      • maybe others

      but I need something different.

      The answers in the questions linked above suggest using some core methods that (all of them) load the full product and save the full product, either via repository or via the load/save deprecated methods.

      I have a lot of products. Somewhere between 5k and 10k.

      Going through all of them with load/save it is not really a viable option.



      Any other suggestions?










      share|improve this question














      I know this question has been asked before:




      • Add video to product programatically


      • Magento 2.2.5 : Add video to product programmatically


      • Importing product videos

      • maybe others

      but I need something different.

      The answers in the questions linked above suggest using some core methods that (all of them) load the full product and save the full product, either via repository or via the load/save deprecated methods.

      I have a lot of products. Somewhere between 5k and 10k.

      Going through all of them with load/save it is not really a viable option.



      Any other suggestions?







      magento2 product magento2.2 video






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 22 '18 at 12:43









      MariusMarius

      168k28324692




      168k28324692




















          2 Answers
          2






          active

          oldest

          votes


















          2














          I ended up doing it with the risky inserts directly into the tables.



          the tables involved are (in this order)



          • catalog_product_entity_media_gallery

          • catalog_product_entity_media_gallery_value

          • catalog_product_entity_media_gallery_value_to_entity

          • catalog_product_entity_media_gallery_value_video

          Pre-explanations:
          This should happen inside one class.

          This class has these members that are added via constructor (di will take care of instantiating them)



          // MagentoFrameworkAppResourceConnection
          private $resourceConnection;
          // MagentoCatalogApiProductAttributeRepositoryInterface
          private $attributeRepository;


          Let's take the tables 1 by 1:



          catalog_product_entity_media_gallery



          $mediaAttributeId = $this->attributeRepository->get('media_gallery')->getAttributeId();
          $image = 'someImage.jpg'; //This is the preview image of the video. the image needs to exist in `/media/catalog/product/`. I'm not going to cover how you add it there
          $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery');
          $data = [
          'attribute_id' => $mediaAttributeId,
          'value' => $image,
          'media_type' => MagentoProductVideoModelProductAttributeMediaExternalVideoEntryConverter::MEDIA_TYPE_CODE,
          'disabled' => 0
          ];
          $this->resourceConnection->getConnection()->insert($table, $data);


          Now remember the last added increment id because it is needed in the later inserts.



          $valueId = $this->resourceConnection->getConnection()->lastInsertId();


          catalog_product_entity_media_gallery_value



          $storeId = the store id for witch the video is available. Use 0 for global;
          $productId = the id of the product for which you add the video
          $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value');
          $data = [
          'value_id' => $valueId, //the increment id from above
          'store_id' => $storeId,
          'entity_id' => $productId,
          'position' => 1, //any number goes here
          'disabled' => 0
          ];
          $this->resourceConnection->getConnection()->insert($table, $data);


          catalog_product_entity_media_gallery_value_to_entity



          $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_to_entity');
          $data = [
          'value_id' => $valueId, // increment id from above
          'entity_id' => $productId, // product id from the step above
          ];
          $this->resourceConnection->getConnection()->insert($table, $data);


          catalog_product_entity_media_gallery_value_video



          $videoUrl = 'url of the video from youtube or vimeo'; 
          $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_video');
          $data = [
          'value_id' => $valueId, //saved increment id from above
          'store_id' => $storeId, // Store id from the steps above
          'provider' => '',
          'url' => $videoUrl,
          'title' => "Video title", //this is mandatory
          'description' => 'Video description', //this can be empty
          'metadata' => '' //I have no idea what this does
          ];
          $this->resourceConnection->getConnection()->insert($table, $data);


          That's it. Some reindexing may be needed.






          share|improve this answer
































            0














            When it comes to tasks like this one most of the time I always use SQS, rabbitMQ or some sort of queueing system, depending on the requirements, infrastructure of the site and the complexity/intensity of the task. If you're using community edition one of my friends did a rabbitMQ/Sql implementation for it here.



            The enterprise edition implements bulk operations based on queueing systems, its not hard to implement something for the CE version.



            I find using message queueing system a really good option for bulk operation as they be scalable automatically e.g you can spawn consumers depending on how many messages there in a queue. I've created an integration before with some AWS services where for every 100 messages a new consumer would spawn automatically (magento doesn't do this, you have to do some customisation to it).



            Here some references you could have a look:



            RabbitMQ in M2.2.*+



            RabbitMQ PHP






            share|improve this answer























            • thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

              – Marius
              Aug 22 '18 at 13:12











            • No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

              – André Ferraz
              Aug 22 '18 at 13:27











            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f239227%2fadd-videos-to-products-programatically%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            I ended up doing it with the risky inserts directly into the tables.



            the tables involved are (in this order)



            • catalog_product_entity_media_gallery

            • catalog_product_entity_media_gallery_value

            • catalog_product_entity_media_gallery_value_to_entity

            • catalog_product_entity_media_gallery_value_video

            Pre-explanations:
            This should happen inside one class.

            This class has these members that are added via constructor (di will take care of instantiating them)



            // MagentoFrameworkAppResourceConnection
            private $resourceConnection;
            // MagentoCatalogApiProductAttributeRepositoryInterface
            private $attributeRepository;


            Let's take the tables 1 by 1:



            catalog_product_entity_media_gallery



            $mediaAttributeId = $this->attributeRepository->get('media_gallery')->getAttributeId();
            $image = 'someImage.jpg'; //This is the preview image of the video. the image needs to exist in `/media/catalog/product/`. I'm not going to cover how you add it there
            $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery');
            $data = [
            'attribute_id' => $mediaAttributeId,
            'value' => $image,
            'media_type' => MagentoProductVideoModelProductAttributeMediaExternalVideoEntryConverter::MEDIA_TYPE_CODE,
            'disabled' => 0
            ];
            $this->resourceConnection->getConnection()->insert($table, $data);


            Now remember the last added increment id because it is needed in the later inserts.



            $valueId = $this->resourceConnection->getConnection()->lastInsertId();


            catalog_product_entity_media_gallery_value



            $storeId = the store id for witch the video is available. Use 0 for global;
            $productId = the id of the product for which you add the video
            $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value');
            $data = [
            'value_id' => $valueId, //the increment id from above
            'store_id' => $storeId,
            'entity_id' => $productId,
            'position' => 1, //any number goes here
            'disabled' => 0
            ];
            $this->resourceConnection->getConnection()->insert($table, $data);


            catalog_product_entity_media_gallery_value_to_entity



            $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_to_entity');
            $data = [
            'value_id' => $valueId, // increment id from above
            'entity_id' => $productId, // product id from the step above
            ];
            $this->resourceConnection->getConnection()->insert($table, $data);


            catalog_product_entity_media_gallery_value_video



            $videoUrl = 'url of the video from youtube or vimeo'; 
            $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_video');
            $data = [
            'value_id' => $valueId, //saved increment id from above
            'store_id' => $storeId, // Store id from the steps above
            'provider' => '',
            'url' => $videoUrl,
            'title' => "Video title", //this is mandatory
            'description' => 'Video description', //this can be empty
            'metadata' => '' //I have no idea what this does
            ];
            $this->resourceConnection->getConnection()->insert($table, $data);


            That's it. Some reindexing may be needed.






            share|improve this answer





























              2














              I ended up doing it with the risky inserts directly into the tables.



              the tables involved are (in this order)



              • catalog_product_entity_media_gallery

              • catalog_product_entity_media_gallery_value

              • catalog_product_entity_media_gallery_value_to_entity

              • catalog_product_entity_media_gallery_value_video

              Pre-explanations:
              This should happen inside one class.

              This class has these members that are added via constructor (di will take care of instantiating them)



              // MagentoFrameworkAppResourceConnection
              private $resourceConnection;
              // MagentoCatalogApiProductAttributeRepositoryInterface
              private $attributeRepository;


              Let's take the tables 1 by 1:



              catalog_product_entity_media_gallery



              $mediaAttributeId = $this->attributeRepository->get('media_gallery')->getAttributeId();
              $image = 'someImage.jpg'; //This is the preview image of the video. the image needs to exist in `/media/catalog/product/`. I'm not going to cover how you add it there
              $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery');
              $data = [
              'attribute_id' => $mediaAttributeId,
              'value' => $image,
              'media_type' => MagentoProductVideoModelProductAttributeMediaExternalVideoEntryConverter::MEDIA_TYPE_CODE,
              'disabled' => 0
              ];
              $this->resourceConnection->getConnection()->insert($table, $data);


              Now remember the last added increment id because it is needed in the later inserts.



              $valueId = $this->resourceConnection->getConnection()->lastInsertId();


              catalog_product_entity_media_gallery_value



              $storeId = the store id for witch the video is available. Use 0 for global;
              $productId = the id of the product for which you add the video
              $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value');
              $data = [
              'value_id' => $valueId, //the increment id from above
              'store_id' => $storeId,
              'entity_id' => $productId,
              'position' => 1, //any number goes here
              'disabled' => 0
              ];
              $this->resourceConnection->getConnection()->insert($table, $data);


              catalog_product_entity_media_gallery_value_to_entity



              $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_to_entity');
              $data = [
              'value_id' => $valueId, // increment id from above
              'entity_id' => $productId, // product id from the step above
              ];
              $this->resourceConnection->getConnection()->insert($table, $data);


              catalog_product_entity_media_gallery_value_video



              $videoUrl = 'url of the video from youtube or vimeo'; 
              $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_video');
              $data = [
              'value_id' => $valueId, //saved increment id from above
              'store_id' => $storeId, // Store id from the steps above
              'provider' => '',
              'url' => $videoUrl,
              'title' => "Video title", //this is mandatory
              'description' => 'Video description', //this can be empty
              'metadata' => '' //I have no idea what this does
              ];
              $this->resourceConnection->getConnection()->insert($table, $data);


              That's it. Some reindexing may be needed.






              share|improve this answer



























                2












                2








                2







                I ended up doing it with the risky inserts directly into the tables.



                the tables involved are (in this order)



                • catalog_product_entity_media_gallery

                • catalog_product_entity_media_gallery_value

                • catalog_product_entity_media_gallery_value_to_entity

                • catalog_product_entity_media_gallery_value_video

                Pre-explanations:
                This should happen inside one class.

                This class has these members that are added via constructor (di will take care of instantiating them)



                // MagentoFrameworkAppResourceConnection
                private $resourceConnection;
                // MagentoCatalogApiProductAttributeRepositoryInterface
                private $attributeRepository;


                Let's take the tables 1 by 1:



                catalog_product_entity_media_gallery



                $mediaAttributeId = $this->attributeRepository->get('media_gallery')->getAttributeId();
                $image = 'someImage.jpg'; //This is the preview image of the video. the image needs to exist in `/media/catalog/product/`. I'm not going to cover how you add it there
                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery');
                $data = [
                'attribute_id' => $mediaAttributeId,
                'value' => $image,
                'media_type' => MagentoProductVideoModelProductAttributeMediaExternalVideoEntryConverter::MEDIA_TYPE_CODE,
                'disabled' => 0
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                Now remember the last added increment id because it is needed in the later inserts.



                $valueId = $this->resourceConnection->getConnection()->lastInsertId();


                catalog_product_entity_media_gallery_value



                $storeId = the store id for witch the video is available. Use 0 for global;
                $productId = the id of the product for which you add the video
                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value');
                $data = [
                'value_id' => $valueId, //the increment id from above
                'store_id' => $storeId,
                'entity_id' => $productId,
                'position' => 1, //any number goes here
                'disabled' => 0
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                catalog_product_entity_media_gallery_value_to_entity



                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_to_entity');
                $data = [
                'value_id' => $valueId, // increment id from above
                'entity_id' => $productId, // product id from the step above
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                catalog_product_entity_media_gallery_value_video



                $videoUrl = 'url of the video from youtube or vimeo'; 
                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_video');
                $data = [
                'value_id' => $valueId, //saved increment id from above
                'store_id' => $storeId, // Store id from the steps above
                'provider' => '',
                'url' => $videoUrl,
                'title' => "Video title", //this is mandatory
                'description' => 'Video description', //this can be empty
                'metadata' => '' //I have no idea what this does
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                That's it. Some reindexing may be needed.






                share|improve this answer















                I ended up doing it with the risky inserts directly into the tables.



                the tables involved are (in this order)



                • catalog_product_entity_media_gallery

                • catalog_product_entity_media_gallery_value

                • catalog_product_entity_media_gallery_value_to_entity

                • catalog_product_entity_media_gallery_value_video

                Pre-explanations:
                This should happen inside one class.

                This class has these members that are added via constructor (di will take care of instantiating them)



                // MagentoFrameworkAppResourceConnection
                private $resourceConnection;
                // MagentoCatalogApiProductAttributeRepositoryInterface
                private $attributeRepository;


                Let's take the tables 1 by 1:



                catalog_product_entity_media_gallery



                $mediaAttributeId = $this->attributeRepository->get('media_gallery')->getAttributeId();
                $image = 'someImage.jpg'; //This is the preview image of the video. the image needs to exist in `/media/catalog/product/`. I'm not going to cover how you add it there
                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery');
                $data = [
                'attribute_id' => $mediaAttributeId,
                'value' => $image,
                'media_type' => MagentoProductVideoModelProductAttributeMediaExternalVideoEntryConverter::MEDIA_TYPE_CODE,
                'disabled' => 0
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                Now remember the last added increment id because it is needed in the later inserts.



                $valueId = $this->resourceConnection->getConnection()->lastInsertId();


                catalog_product_entity_media_gallery_value



                $storeId = the store id for witch the video is available. Use 0 for global;
                $productId = the id of the product for which you add the video
                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value');
                $data = [
                'value_id' => $valueId, //the increment id from above
                'store_id' => $storeId,
                'entity_id' => $productId,
                'position' => 1, //any number goes here
                'disabled' => 0
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                catalog_product_entity_media_gallery_value_to_entity



                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_to_entity');
                $data = [
                'value_id' => $valueId, // increment id from above
                'entity_id' => $productId, // product id from the step above
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                catalog_product_entity_media_gallery_value_video



                $videoUrl = 'url of the video from youtube or vimeo'; 
                $table = $this->resourceConnection->getTableName('catalog_product_entity_media_gallery_value_video');
                $data = [
                'value_id' => $valueId, //saved increment id from above
                'store_id' => $storeId, // Store id from the steps above
                'provider' => '',
                'url' => $videoUrl,
                'title' => "Video title", //this is mandatory
                'description' => 'Video description', //this can be empty
                'metadata' => '' //I have no idea what this does
                ];
                $this->resourceConnection->getConnection()->insert($table, $data);


                That's it. Some reindexing may be needed.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited yesterday

























                answered Aug 31 '18 at 7:47









                MariusMarius

                168k28324692




                168k28324692























                    0














                    When it comes to tasks like this one most of the time I always use SQS, rabbitMQ or some sort of queueing system, depending on the requirements, infrastructure of the site and the complexity/intensity of the task. If you're using community edition one of my friends did a rabbitMQ/Sql implementation for it here.



                    The enterprise edition implements bulk operations based on queueing systems, its not hard to implement something for the CE version.



                    I find using message queueing system a really good option for bulk operation as they be scalable automatically e.g you can spawn consumers depending on how many messages there in a queue. I've created an integration before with some AWS services where for every 100 messages a new consumer would spawn automatically (magento doesn't do this, you have to do some customisation to it).



                    Here some references you could have a look:



                    RabbitMQ in M2.2.*+



                    RabbitMQ PHP






                    share|improve this answer























                    • thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

                      – Marius
                      Aug 22 '18 at 13:12











                    • No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

                      – André Ferraz
                      Aug 22 '18 at 13:27















                    0














                    When it comes to tasks like this one most of the time I always use SQS, rabbitMQ or some sort of queueing system, depending on the requirements, infrastructure of the site and the complexity/intensity of the task. If you're using community edition one of my friends did a rabbitMQ/Sql implementation for it here.



                    The enterprise edition implements bulk operations based on queueing systems, its not hard to implement something for the CE version.



                    I find using message queueing system a really good option for bulk operation as they be scalable automatically e.g you can spawn consumers depending on how many messages there in a queue. I've created an integration before with some AWS services where for every 100 messages a new consumer would spawn automatically (magento doesn't do this, you have to do some customisation to it).



                    Here some references you could have a look:



                    RabbitMQ in M2.2.*+



                    RabbitMQ PHP






                    share|improve this answer























                    • thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

                      – Marius
                      Aug 22 '18 at 13:12











                    • No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

                      – André Ferraz
                      Aug 22 '18 at 13:27













                    0












                    0








                    0







                    When it comes to tasks like this one most of the time I always use SQS, rabbitMQ or some sort of queueing system, depending on the requirements, infrastructure of the site and the complexity/intensity of the task. If you're using community edition one of my friends did a rabbitMQ/Sql implementation for it here.



                    The enterprise edition implements bulk operations based on queueing systems, its not hard to implement something for the CE version.



                    I find using message queueing system a really good option for bulk operation as they be scalable automatically e.g you can spawn consumers depending on how many messages there in a queue. I've created an integration before with some AWS services where for every 100 messages a new consumer would spawn automatically (magento doesn't do this, you have to do some customisation to it).



                    Here some references you could have a look:



                    RabbitMQ in M2.2.*+



                    RabbitMQ PHP






                    share|improve this answer













                    When it comes to tasks like this one most of the time I always use SQS, rabbitMQ or some sort of queueing system, depending on the requirements, infrastructure of the site and the complexity/intensity of the task. If you're using community edition one of my friends did a rabbitMQ/Sql implementation for it here.



                    The enterprise edition implements bulk operations based on queueing systems, its not hard to implement something for the CE version.



                    I find using message queueing system a really good option for bulk operation as they be scalable automatically e.g you can spawn consumers depending on how many messages there in a queue. I've created an integration before with some AWS services where for every 100 messages a new consumer would spawn automatically (magento doesn't do this, you have to do some customisation to it).



                    Here some references you could have a look:



                    RabbitMQ in M2.2.*+



                    RabbitMQ PHP







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 22 '18 at 13:01









                    André FerrazAndré Ferraz

                    1,80711132




                    1,80711132












                    • thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

                      – Marius
                      Aug 22 '18 at 13:12











                    • No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

                      – André Ferraz
                      Aug 22 '18 at 13:27

















                    • thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

                      – Marius
                      Aug 22 '18 at 13:12











                    • No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

                      – André Ferraz
                      Aug 22 '18 at 13:27
















                    thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

                    – Marius
                    Aug 22 '18 at 13:12





                    thanks for the effort, but I don't want to introduce a new dependency to the project just for this. I'm asking if there is a built in way to attach videos to products without going through load/save. If there isn't, I can reverse engineer the save process to see what tables are affected and how, and do direct inserts. It shouldn't get any faster than that. But I'm trying to avoid this method since it is risky. I will use it as a last resort.

                    – Marius
                    Aug 22 '18 at 13:12













                    No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

                    – André Ferraz
                    Aug 22 '18 at 13:27





                    No worries. Yeah you could do that too. The other option I can think of is to create a new resource model and only load product data you need and only use this resource model for that operation, can't really think of anything else ...

                    – André Ferraz
                    Aug 22 '18 at 13:27

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f239227%2fadd-videos-to-products-programatically%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?