I have created Custom form field for product creation and edit time, i want save my price.i have created one new tab for product form .i want save my custom price same as price option. my input field is display on product creation form.

inside my observer i have added code

namespace Custom\Myprice\Observer;

use \Magento\Framework\Event\ObserverInterface;
use \Magento\Framework\Event\Observer as EventObserver;
use  Custom\Myprice\Ui\DataProvider\Product\Form\Modifier\CustomFieldset;

**class implements ObserverInterface
    protected $request;
    protected $resource;
    public function __construct(
    \Magento\Framework\App\RequestInterface $request, \Magento\Framework\App\ResourceConnection $resource
    ) {
            $this->request = $request;
            $this->resource = $resource;
        public function execute(\Magento\Framework\Event\Observer $observer)
            $data = $this->request->getPostValue();
            if (isset($data['product']['myprice']))
                $exampleTextField =   $product->getData(CustomFieldset::FIELD_NAME_TEXT);
                what should i do for save price in field

I have create my-price custom product attribute from back-end same as form name fields for save price in database table "catalog_product_entity_decimal"

is it necessary to create custom product attribute for save value in database table "catalog_product_entity_decimal" My observer is called and post value inside observer but not able to save in table

how to save my custom field value in database table "catalog_product_entity_decimal" give me solution.

  • I have solved issue for created form field i have created same product attribute from back-end and assign to attribute set. i have added code inside execute function <pre> $product = $observer->getProduct(); $exampleTextField = $product->getData(CustomFieldset::FIELD_NAME_TEXT); if($exampleTextField !='') { $product->setData('myprice', $exampleTextField); $product->getResource()->saveAttribute($product, 'myprice'); } </pre> able to save value for table catalog_product_entity_decimal now i want get price and disply for input. – Web developer Oct 16 '18 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.