对象已移动

可在此处找到该文档 How to save and display a custom form field value using the PrestaShop hook – New Self New Life
New Self New Life
No Result
View All Result
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
  • Home
  • Entertainment
  • Celebrity
  • Cinema
  • Music
  • Digital Lifestyle
  • Social Media
  • Softwares
  • Devices
New Self New Life
No Result
View All Result
Home Softwares

How to save and display a custom form field value using the PrestaShop hook

by admin
2 years ago
in Softwares
How to save and display a custom form field value using the PrestaShop hook
Share on FacebookShare on Twitter


On this weblog, we’ll discover ways to save the customized type subject and show the up to date worth on the Product Web page utilizing the PrestaShop hook. So, we’ll outline PrestaShop’s given hook.
I hope you already know tips on how to add a customized type subject on the PrestaShop product web page utilizing hook. If are new to this please learn our earlier weblog. Please click on right here.

Let’s proceed to our subject,

Step 1: Register the PrestaShop’s given hook for product save i.e. “actionProductSave” within the set up operate as follows

 public operate set up()
    {
        return mother or father::set up() && $this->registerHook(['actionProductFormBuilderModifier']) && $this->registerHook(['actionProductSave']);
    }

Step 2: Outline hook and carry out save operations for explicit merchandise.

    

    /**
     * Modify product type builder
     *
     * @param array $params
     */
    public operate hookActionProductFormBuilderModifier(array $params): void
    {
        /** @var ProductFormModifier $productFormModifier */
        $productFormModifier = $this->get(ProductFormModifier::class);
        $productId = isset($params['id']) ? new ProductId((int) $params['id']) : null;
        $productFormModifier->modify($productId, $params['form_builder']);
    }

    /**
     * Modify product type builder
     *
     * @param array $params
     */
    public operate hookActionProductSave(array $params): void
    {
        // Please write your logic and operation and save the information as per your want
        // We're utilizing configuration desk to save lots of the information
        $productData = Instruments::getValue('product');
        $demoPrice = $productData['pricing']['demo_module_pricing_field'];
        $demoSEOText = $productData['seo']['demo_module_custom_field'];
        $idWkProduct = $params['id_product'];
        Configuration::updateValue('wk_price_data_' . $idWkProduct, $demoPrice);
        Configuration::updateValue('wk_seo_data_' . $idWkProduct, $demoSEOText);
    }

To avoid wasting the information of Merchandise you should utilize your personal outlined desk or you possibly can act utilizing enter knowledge like ship the e-mail or the rest. We’ve saved the information within the configuration desk for instance solely.

Step 3: You’ll be able to show these saved values by setting the values within the modify() operate of the ProductFormModifier class.

<module-name>/src/Kind/Modifier/ProductFormModifier.php

    /**
     * @param ProductId|null $productId
     * @param FormBuilderInterface $productFormBuilder
     */
    public operate modify(
        ?ProductId $productId,
        FormBuilderInterface $productFormBuilder
    ): void {
        $idWkProduct = $productId->getValue();
        $knowledge['seo'] = Configuration::get('wk_seo_data_' . $idWkProduct);
        $knowledge['price'] = Configuration::get('wk_price_data_' . $idWkProduct);
        $this->modifyDescriptionTab($knowledge, $productFormBuilder);
    }

You’re going to get the outcome as follows after save the customized type subject.

save custom form field of Pricing tab
save custom form field of SEO tab

That’s all.

In case you are dealing with any points or doubts within the above course of, please be at liberty to contact us within the remark part.

I’d be pleased to assist.

Additionally, you possibly can discover our PrestaShop Growth Providers and a wide variety of high quality PrestaShop Modules.

author-thumb

Ravindra Gautam
3 Badges

27 December 2023

For a contemporary replace, our expert crew regularly refreshes the content material.

  • 27 Dec, 2023

    Created by – Ravindra Gautam

  • View Historical past



    Source link

    Tags: CustomDisplayFieldformHookPrestaShopSave
    Previous Post

    Minor update for Vivaldi iOS Browser 6.5

    Next Post

    OpenFeature feature flagging API becomes a CNCF incubating project

    Related Posts

    Fixes, Polish, and security updates – Vivaldi Browser snapshot 3813.3
    Softwares

    Fixes, Polish, and security updates – Vivaldi Browser snapshot 3813.3

    by admin
    September 19, 2025
    Fintech Software Development in 2025: Your Complete Guide
    Softwares

    Fintech Software Development in 2025: Your Complete Guide

    by admin
    September 20, 2025
    User Guide for Odoo Zoho Analytics Connector
    Softwares

    User Guide for Odoo Zoho Analytics Connector

    by admin
    September 16, 2025
    30+ Best Business & Corporate Report Templates for InDesign & Photoshop in 2025 — Speckyboy
    Softwares

    30+ Best Business & Corporate Report Templates for InDesign & Photoshop in 2025 — Speckyboy

    by admin
    September 18, 2025
    Software tool turns everyday objects into animated, eye-catching displays—without electronics
    Softwares

    Software tool turns everyday objects into animated, eye-catching displays—without electronics

    by admin
    September 17, 2025
    Next Post
    OpenFeature feature flagging API becomes a CNCF incubating project

    OpenFeature feature flagging API becomes a CNCF incubating project

    Igor Morozov Has Made a Career Out of Bridging Tech and Dreams

    Igor Morozov Has Made a Career Out of Bridging Tech and Dreams

    • Trending
    • Comments
    • Latest
    I Only Have More Questions After Another Bizarre Outing With The Harrigans

    I Only Have More Questions After Another Bizarre Outing With The Harrigans

    April 20, 2025
    Google’s AI Ambitions An ‘Existential Crisis’ For News Online

    Google’s AI Ambitions An ‘Existential Crisis’ For News Online

    September 6, 2025
    Amazon Forgot to Take the 2024 MacBook Air Off Sale After Their Big Spring Event

    Amazon Forgot to Take the 2024 MacBook Air Off Sale After Their Big Spring Event

    April 4, 2025
    Ecca Vandal’s “CRUISING TO SELF SOOTHE” video is an ode to skate culture

    Ecca Vandal’s “CRUISING TO SELF SOOTHE” video is an ode to skate culture

    March 10, 2025
    Instagram Adds New Teleprompter Tool To Edits

    Instagram Adds New Teleprompter Tool To Edits

    June 11, 2025
    Easy Blueberry Scones (With Frozen Blueberries)

    Easy Blueberry Scones (With Frozen Blueberries)

    April 10, 2025
    Acyan's "Ghost Town" EP Is Bass Music Storytelling at Its Most Ominous

    Acyan's "Ghost Town" EP Is Bass Music Storytelling at Its Most Ominous

    May 18, 2025
    Where will Prince Harry stay during UK visit without Meghan Markle?

    Where will Prince Harry stay during UK visit without Meghan Markle?

    September 8, 2025
    Tips To Create App In 8 Easy Steps

    Tips To Create App In 8 Easy Steps

    September 21, 2025
    From the ‘devil’s interval’ to ‘Louie Louie’: Crazy moments in music censorship – National

    From the ‘devil’s interval’ to ‘Louie Louie’: Crazy moments in music censorship – National

    September 21, 2025
    10 Naruto Characters the Anime Failed

    10 Naruto Characters the Anime Failed

    September 21, 2025
    Nothing Ear (3) Earphones Launch With Super Mic Feature And Higher Price

    Nothing Ear (3) Earphones Launch With Super Mic Feature And Higher Price

    September 21, 2025
    The ‘Lego Batman’ Devs Want to Make a New, Definitive Bat-Game

    The ‘Lego Batman’ Devs Want to Make a New, Definitive Bat-Game

    September 20, 2025
    Natalie Wood’s lookalike daughter and granddaughter stun in new photos inspired by the late star

    Natalie Wood’s lookalike daughter and granddaughter stun in new photos inspired by the late star

    September 20, 2025
    Win An Iconic Luxury Watch With The Premium Time Company

    Win An Iconic Luxury Watch With The Premium Time Company

    September 20, 2025
    Alabama Barker Reveals She Was Pregnant But ‘Lost’ The Baby In Deleted TikTok! Oh No!

    Alabama Barker Reveals She Was Pregnant But ‘Lost’ The Baby In Deleted TikTok! Oh No!

    September 20, 2025
    New Self New Life

    Your source for entertainment news, celebrities, celebrity news, and Music, Cinema, Digital Lifestyle and Social Media and More !

    Categories

    • Celebrity
    • Cinema
    • Devices
    • Digital Lifestyle
    • Entertainment
    • Music
    • Social Media
    • Softwares
    • Uncategorized

    Recent Posts

    • Tips To Create App In 8 Easy Steps
    • From the ‘devil’s interval’ to ‘Louie Louie’: Crazy moments in music censorship – National
    • 10 Naruto Characters the Anime Failed
    • Home
    • Disclaimer
    • DMCA
    • Privacy Policy
    • Cookie Privacy Policy
    • Terms and Conditions
    • Contact us

    Copyright © 2021 New Self New Life.
    New Self New Life is not responsible for the content of external sites. slotsfree  creator solana token

    No Result
    View All Result
    • Home
    • Entertainment
    • Celebrity
    • Cinema
    • Music
    • Digital Lifestyle
    • Social Media
    • Softwares
    • Devices

    Copyright © 2021 New Self New Life.
    New Self New Life is not responsible for the content of external sites.

    New Self New Life