How to display list of coupon code in product page in magento 2.2.7 The Next CEO of Stack OverflowGet RuleId from Coupon Code in checkoutcartitemdefault.phtmlGet a coupon code to send in welcome emailGenerate Coupon code based on categorycoupon code error message for guest customersmagento coupon code is behaving strangely?Apply Magento Coupon in Ajax Without Redirecting to Cart PageProgramatically generated coupon code not displaying on shopping cart after appliedDisplay Auto-generated Coupon code on success pagegenerating lowercase Coupon codehow to show Promo code or coupon code on Checkout page in magento 1.9How to display MSRP price at product listing page and view page in magento 2.2.7?

Compilation of a 2d array and a 1d array

What difference does it make matching a word with/without a trailing whitespace?

Finitely generated matrix groups whose eigenvalues are all algebraic

Man transported from Alternate World into ours by a Neutrino Detector

Raspberry pi 3 B with Ubuntu 18.04 server arm64: what pi version

A hang glider, sudden unexpected lift to 25,000 feet altitude, what could do this?

Calculate the Mean mean of two numbers

Is a linearly independent set whose span is dense a Schauder basis?

Can Sri Krishna be called 'a person'?

Can this transistor (2n2222) take 6V on emitter-base? Am I reading datasheet incorrectly?

How should I connect my cat5 cable to connectors having an orange-green line?

Is it okay to majorly distort historical facts while writing a fiction story?

Is it possible to create a QR code using text?

Does int main() need a declaration on C++?

Does the Idaho Potato Commission associate potato skins with healthy eating?

The sum of any ten consecutive numbers from a fibonacci sequence is divisible by 11

Avoiding the "not like other girls" trope?

Is it OK to decorate a log book cover?

How to unfasten electrical subpanel attached with ramset

Another proof that dividing by 0 does not exist -- is it right?

Mathematica command that allows it to read my intentions

Airship steam engine room - problems and conflict

Masking layers by a vector polygon layer in QGIS

Calculating discount not working



How to display list of coupon code in product page in magento 2.2.7



The Next CEO of Stack OverflowGet RuleId from Coupon Code in checkoutcartitemdefault.phtmlGet a coupon code to send in welcome emailGenerate Coupon code based on categorycoupon code error message for guest customersmagento coupon code is behaving strangely?Apply Magento Coupon in Ajax Without Redirecting to Cart PageProgramatically generated coupon code not displaying on shopping cart after appliedDisplay Auto-generated Coupon code on success pagegenerating lowercase Coupon codehow to show Promo code or coupon code on Checkout page in magento 1.9How to display MSRP price at product listing page and view page in magento 2.2.7?










0















How to display list of coupon code in product page.










share|improve this question






















  • Try this answer @satish

    – Prathap Gunasekaran
    13 hours ago
















0















How to display list of coupon code in product page.










share|improve this question






















  • Try this answer @satish

    – Prathap Gunasekaran
    13 hours ago














0












0








0








How to display list of coupon code in product page.










share|improve this question














How to display list of coupon code in product page.







coupon-codes magento2.2.7






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 14 hours ago









satishsatish

16212




16212












  • Try this answer @satish

    – Prathap Gunasekaran
    13 hours ago


















  • Try this answer @satish

    – Prathap Gunasekaran
    13 hours ago

















Try this answer @satish

– Prathap Gunasekaran
13 hours ago






Try this answer @satish

– Prathap Gunasekaran
13 hours ago











1 Answer
1






active

oldest

votes


















0














Try this,



Add a helper on your custom module and path be like




app/code/Vendor/Module/Helper/Data.php




then add the below code to get the coupon code collection



<?php 
namespace VendorModuleNameHelper;
class Data extends MagentoFrameworkAppHelperAbstractHelper

public function __construct(
MagentoSalesRuleModelCouponFactory $couponFactory
)
$this->couponFactory = $couponFactory;

public function getCoupon()

$couponCollection = $this->couponFactory->create()->getCollection();
return $couponCollection;




then add catalog_product_view.xml in your custom module and path be like




app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml




then add the below code to it



<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="MagentoFrameworkViewElementTemplate" name="product_coupon" template="Vendor_Module::coupon.phtml">
</block>
</referenceContainer>
</body>
</page>


then add the phtml in the below path




app/code/Vendor/Module/view/frontend/templates/coupon.phtml




then add the below code to the phtml file to get the coupon collection



<?php $coupon = $this->helper('VendorModuleHelperData')->getCoupon();
foreach($coupon as $items)

echo "Coupon Code :" . $items->getCode();



You'll get all the coupon code there and you can get any other attribute from this table salesrule_coupon



For more information refer this link



Hope this helps.






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%2f268198%2fhow-to-display-list-of-coupon-code-in-product-page-in-magento-2-2-7%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









    0














    Try this,



    Add a helper on your custom module and path be like




    app/code/Vendor/Module/Helper/Data.php




    then add the below code to get the coupon code collection



    <?php 
    namespace VendorModuleNameHelper;
    class Data extends MagentoFrameworkAppHelperAbstractHelper

    public function __construct(
    MagentoSalesRuleModelCouponFactory $couponFactory
    )
    $this->couponFactory = $couponFactory;

    public function getCoupon()

    $couponCollection = $this->couponFactory->create()->getCollection();
    return $couponCollection;




    then add catalog_product_view.xml in your custom module and path be like




    app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml




    then add the below code to it



    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
    <referenceContainer name="content">
    <block class="MagentoFrameworkViewElementTemplate" name="product_coupon" template="Vendor_Module::coupon.phtml">
    </block>
    </referenceContainer>
    </body>
    </page>


    then add the phtml in the below path




    app/code/Vendor/Module/view/frontend/templates/coupon.phtml




    then add the below code to the phtml file to get the coupon collection



    <?php $coupon = $this->helper('VendorModuleHelperData')->getCoupon();
    foreach($coupon as $items)

    echo "Coupon Code :" . $items->getCode();



    You'll get all the coupon code there and you can get any other attribute from this table salesrule_coupon



    For more information refer this link



    Hope this helps.






    share|improve this answer



























      0














      Try this,



      Add a helper on your custom module and path be like




      app/code/Vendor/Module/Helper/Data.php




      then add the below code to get the coupon code collection



      <?php 
      namespace VendorModuleNameHelper;
      class Data extends MagentoFrameworkAppHelperAbstractHelper

      public function __construct(
      MagentoSalesRuleModelCouponFactory $couponFactory
      )
      $this->couponFactory = $couponFactory;

      public function getCoupon()

      $couponCollection = $this->couponFactory->create()->getCollection();
      return $couponCollection;




      then add catalog_product_view.xml in your custom module and path be like




      app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml




      then add the below code to it



      <?xml version="1.0"?>
      <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <body>
      <referenceContainer name="content">
      <block class="MagentoFrameworkViewElementTemplate" name="product_coupon" template="Vendor_Module::coupon.phtml">
      </block>
      </referenceContainer>
      </body>
      </page>


      then add the phtml in the below path




      app/code/Vendor/Module/view/frontend/templates/coupon.phtml




      then add the below code to the phtml file to get the coupon collection



      <?php $coupon = $this->helper('VendorModuleHelperData')->getCoupon();
      foreach($coupon as $items)

      echo "Coupon Code :" . $items->getCode();



      You'll get all the coupon code there and you can get any other attribute from this table salesrule_coupon



      For more information refer this link



      Hope this helps.






      share|improve this answer

























        0












        0








        0







        Try this,



        Add a helper on your custom module and path be like




        app/code/Vendor/Module/Helper/Data.php




        then add the below code to get the coupon code collection



        <?php 
        namespace VendorModuleNameHelper;
        class Data extends MagentoFrameworkAppHelperAbstractHelper

        public function __construct(
        MagentoSalesRuleModelCouponFactory $couponFactory
        )
        $this->couponFactory = $couponFactory;

        public function getCoupon()

        $couponCollection = $this->couponFactory->create()->getCollection();
        return $couponCollection;




        then add catalog_product_view.xml in your custom module and path be like




        app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml




        then add the below code to it



        <?xml version="1.0"?>
        <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
        <referenceContainer name="content">
        <block class="MagentoFrameworkViewElementTemplate" name="product_coupon" template="Vendor_Module::coupon.phtml">
        </block>
        </referenceContainer>
        </body>
        </page>


        then add the phtml in the below path




        app/code/Vendor/Module/view/frontend/templates/coupon.phtml




        then add the below code to the phtml file to get the coupon collection



        <?php $coupon = $this->helper('VendorModuleHelperData')->getCoupon();
        foreach($coupon as $items)

        echo "Coupon Code :" . $items->getCode();



        You'll get all the coupon code there and you can get any other attribute from this table salesrule_coupon



        For more information refer this link



        Hope this helps.






        share|improve this answer













        Try this,



        Add a helper on your custom module and path be like




        app/code/Vendor/Module/Helper/Data.php




        then add the below code to get the coupon code collection



        <?php 
        namespace VendorModuleNameHelper;
        class Data extends MagentoFrameworkAppHelperAbstractHelper

        public function __construct(
        MagentoSalesRuleModelCouponFactory $couponFactory
        )
        $this->couponFactory = $couponFactory;

        public function getCoupon()

        $couponCollection = $this->couponFactory->create()->getCollection();
        return $couponCollection;




        then add catalog_product_view.xml in your custom module and path be like




        app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml




        then add the below code to it



        <?xml version="1.0"?>
        <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
        <referenceContainer name="content">
        <block class="MagentoFrameworkViewElementTemplate" name="product_coupon" template="Vendor_Module::coupon.phtml">
        </block>
        </referenceContainer>
        </body>
        </page>


        then add the phtml in the below path




        app/code/Vendor/Module/view/frontend/templates/coupon.phtml




        then add the below code to the phtml file to get the coupon collection



        <?php $coupon = $this->helper('VendorModuleHelperData')->getCoupon();
        foreach($coupon as $items)

        echo "Coupon Code :" . $items->getCode();



        You'll get all the coupon code there and you can get any other attribute from this table salesrule_coupon



        For more information refer this link



        Hope this helps.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 hours ago









        Prathap GunasekaranPrathap Gunasekaran

        1,5861618




        1,5861618



























            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%2f268198%2fhow-to-display-list-of-coupon-code-in-product-page-in-magento-2-2-7%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?