Trigger a cron job on custom form submit in magento 2?Create a custom cron jobMagento 2 cron job for custom modulemagento 2 captcha not rendering if I override layout xmlMagento cron job disappearingMagento 2 : Problem while adding custom button order view page?Magento2 Cron job not runningTurning off custom cron jobMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsHow to create custom form in Magento 2.2.3

Adding a (stair/baby) gate without facing walls

Constant Scan spooling

Can I shorten this filter, that finds disk sizes over 100G?

What is the most 'environmentally friendly' way to learn to fly?

What is my clock telling me to do?

Should students have access to past exams or an exam bank?

"Fewer errors means better products" or "Fewer errors mean better products"?

When did J.K. Rowling decide to make Harry and Ginny a couple?

Can the additional attack from a Samurai's Rapid Strike have advantage?

Went to a big 4 but got fired for underperformance in a year recently - Now every one thinks I'm pro - How to balance expectations?

Does the problem of P vs NP come under the category of Operational Research?

Can birds evolve without trees?

A conjectural trigonometric identity

What is the significance of $(logname)?

How can flights operated by the same company have such different prices when marketed by another?

Why do MS SQL Server SEQUENCEs not have an ORDER parameter like Oracle?

Is this mechanically safe?

Why do we need a voltage divider when we get the same voltage at the output as the input?

PI 4 screen rotation from the terminal

Is it really a problem to declare that a visitor to the UK is my "girlfriend", in terms of her successfully getting a Standard Visitor visa?

Accurately recalling the key - can everyone do it?

Overful hbox (How to make the sentence in a table into 2 line?)

Python π = 1 + (1/2) + (1/3) + (1/4) - (1/5) + (1/6) + (1/7) + (1/8) + (1/9) - (1/10) ...1748 Euler

Why have both: BJT and FET transistors on IC output?



Trigger a cron job on custom form submit in magento 2?


Create a custom cron jobMagento 2 cron job for custom modulemagento 2 captcha not rendering if I override layout xmlMagento cron job disappearingMagento 2 : Problem while adding custom button order view page?Magento2 Cron job not runningTurning off custom cron jobMagento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsHow to create custom form in Magento 2.2.3






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








0















Can I trigger a cron job at the time of form submission?



Actually, I need to download a product pdf when the form gets submitted.



But my pdf file has a large amount of data. So the site gets slow down.



So that I have moved on to cron.



I've successfully set a cron by referring this link.



Here is my code,



/etc/crontab.xml



<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">

<group id="default">
<job name="test_cronjob" instance="TestCatalogPrintCronPdfdownload" method="execute">
<schedule>*/1 * * * *</schedule>
</job>
</group>
</config>


Cron/Pdfdownload.php



<?php

namespace TestCatalogPrintCron;
class Pdfdownload extends MagentoFrameworkAppActionAction

// doing my stuff on here

?>


And my form in the template file,



form.phtml



<form action="<?php echo $block->getFormAction() ?>" method="post" class="downloadPDF-account">
<label>Brochure Name: <input name="pdfname" type="text" /></label>
<input type="submit" value="Download" />
</form>


Actually now in this form action <?php echo $block->getFormAction() ?>' , I given my controller path.



But I need to run my cron file (TestCatalogPrintCronPdfdownload) on here.



If I'm doing the same stuff on my controller, means it takes too much time and slow down my site.



Please help me. I am a novice in magento and I am stuck at this point. Thank you in advance!!










share|improve this question
































    0















    Can I trigger a cron job at the time of form submission?



    Actually, I need to download a product pdf when the form gets submitted.



    But my pdf file has a large amount of data. So the site gets slow down.



    So that I have moved on to cron.



    I've successfully set a cron by referring this link.



    Here is my code,



    /etc/crontab.xml



    <?xml version="1.0"?>

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">

    <group id="default">
    <job name="test_cronjob" instance="TestCatalogPrintCronPdfdownload" method="execute">
    <schedule>*/1 * * * *</schedule>
    </job>
    </group>
    </config>


    Cron/Pdfdownload.php



    <?php

    namespace TestCatalogPrintCron;
    class Pdfdownload extends MagentoFrameworkAppActionAction

    // doing my stuff on here

    ?>


    And my form in the template file,



    form.phtml



    <form action="<?php echo $block->getFormAction() ?>" method="post" class="downloadPDF-account">
    <label>Brochure Name: <input name="pdfname" type="text" /></label>
    <input type="submit" value="Download" />
    </form>


    Actually now in this form action <?php echo $block->getFormAction() ?>' , I given my controller path.



    But I need to run my cron file (TestCatalogPrintCronPdfdownload) on here.



    If I'm doing the same stuff on my controller, means it takes too much time and slow down my site.



    Please help me. I am a novice in magento and I am stuck at this point. Thank you in advance!!










    share|improve this question




























      0












      0








      0








      Can I trigger a cron job at the time of form submission?



      Actually, I need to download a product pdf when the form gets submitted.



      But my pdf file has a large amount of data. So the site gets slow down.



      So that I have moved on to cron.



      I've successfully set a cron by referring this link.



      Here is my code,



      /etc/crontab.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">

      <group id="default">
      <job name="test_cronjob" instance="TestCatalogPrintCronPdfdownload" method="execute">
      <schedule>*/1 * * * *</schedule>
      </job>
      </group>
      </config>


      Cron/Pdfdownload.php



      <?php

      namespace TestCatalogPrintCron;
      class Pdfdownload extends MagentoFrameworkAppActionAction

      // doing my stuff on here

      ?>


      And my form in the template file,



      form.phtml



      <form action="<?php echo $block->getFormAction() ?>" method="post" class="downloadPDF-account">
      <label>Brochure Name: <input name="pdfname" type="text" /></label>
      <input type="submit" value="Download" />
      </form>


      Actually now in this form action <?php echo $block->getFormAction() ?>' , I given my controller path.



      But I need to run my cron file (TestCatalogPrintCronPdfdownload) on here.



      If I'm doing the same stuff on my controller, means it takes too much time and slow down my site.



      Please help me. I am a novice in magento and I am stuck at this point. Thank you in advance!!










      share|improve this question
















      Can I trigger a cron job at the time of form submission?



      Actually, I need to download a product pdf when the form gets submitted.



      But my pdf file has a large amount of data. So the site gets slow down.



      So that I have moved on to cron.



      I've successfully set a cron by referring this link.



      Here is my code,



      /etc/crontab.xml



      <?xml version="1.0"?>

      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">

      <group id="default">
      <job name="test_cronjob" instance="TestCatalogPrintCronPdfdownload" method="execute">
      <schedule>*/1 * * * *</schedule>
      </job>
      </group>
      </config>


      Cron/Pdfdownload.php



      <?php

      namespace TestCatalogPrintCron;
      class Pdfdownload extends MagentoFrameworkAppActionAction

      // doing my stuff on here

      ?>


      And my form in the template file,



      form.phtml



      <form action="<?php echo $block->getFormAction() ?>" method="post" class="downloadPDF-account">
      <label>Brochure Name: <input name="pdfname" type="text" /></label>
      <input type="submit" value="Download" />
      </form>


      Actually now in this form action <?php echo $block->getFormAction() ?>' , I given my controller path.



      But I need to run my cron file (TestCatalogPrintCronPdfdownload) on here.



      If I'm doing the same stuff on my controller, means it takes too much time and slow down my site.



      Please help me. I am a novice in magento and I am stuck at this point. Thank you in advance!!







      magento2 cron






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 23 at 9:46









      Faisal Sheikh

      3511 silver badge11 bronze badges




      3511 silver badge11 bronze badges










      asked Jul 23 at 9:37









      RamyaRamya

      258 bronze badges




      258 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          6














          No, you cannot trigger a cron on any particular event. But you can do something like this in your case.




          1. Save the form in the database as submitted.

          2. Run a cron job maybe every minute. Check if there is any form submitted and email is not sent. Here generate the PDF and send it to
            the customer via email as an attachment.

          3. Mark the record as email sent so that next time when cron is executed it will not resend the email.



          Hope it finds helpful.






          share|improve this answer





























            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%2f282975%2ftrigger-a-cron-job-on-custom-form-submit-in-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            6














            No, you cannot trigger a cron on any particular event. But you can do something like this in your case.




            1. Save the form in the database as submitted.

            2. Run a cron job maybe every minute. Check if there is any form submitted and email is not sent. Here generate the PDF and send it to
              the customer via email as an attachment.

            3. Mark the record as email sent so that next time when cron is executed it will not resend the email.



            Hope it finds helpful.






            share|improve this answer































              6














              No, you cannot trigger a cron on any particular event. But you can do something like this in your case.




              1. Save the form in the database as submitted.

              2. Run a cron job maybe every minute. Check if there is any form submitted and email is not sent. Here generate the PDF and send it to
                the customer via email as an attachment.

              3. Mark the record as email sent so that next time when cron is executed it will not resend the email.



              Hope it finds helpful.






              share|improve this answer





























                6












                6








                6







                No, you cannot trigger a cron on any particular event. But you can do something like this in your case.




                1. Save the form in the database as submitted.

                2. Run a cron job maybe every minute. Check if there is any form submitted and email is not sent. Here generate the PDF and send it to
                  the customer via email as an attachment.

                3. Mark the record as email sent so that next time when cron is executed it will not resend the email.



                Hope it finds helpful.






                share|improve this answer















                No, you cannot trigger a cron on any particular event. But you can do something like this in your case.




                1. Save the form in the database as submitted.

                2. Run a cron job maybe every minute. Check if there is any form submitted and email is not sent. Here generate the PDF and send it to
                  the customer via email as an attachment.

                3. Mark the record as email sent so that next time when cron is executed it will not resend the email.



                Hope it finds helpful.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 23 at 10:11









                Raj Mohan R

                1,7993 silver badges13 bronze badges




                1,7993 silver badges13 bronze badges










                answered Jul 23 at 9:54









                Abdul PathanAbdul Pathan

                8772 silver badges11 bronze badges




                8772 silver badges11 bronze badges






























                    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%2f282975%2ftrigger-a-cron-job-on-custom-form-submit-in-magento-2%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

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

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

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form