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

            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