0

In magento 2 admin, when we edit product page. Product price field is read only for configurable product.

So that Admin can't change product price for configurable product.

I want to make change so that admin can change product price from admin for configurable product.

enter image description here

I have created module Mymodule_ConfigurablePrice. So, I created product_form.xml file at app/code/Mymodule/ConfigurablePrice/view/adminhtml/ui_component directory.

code in product_form.xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="product-details">
        <field name="price">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="disabled" xsi:type="boolean">false</item>
                </item>
            </argument>
        </field>
    </fieldset>
</form>

Questions:

  • fieldset name is correct? if not, please suggest.
  • code for xml is correct? if not, please suggest.
  • Else please suggest best way to achieve this.
6
  • What is your purpose of assigning configurable product price? Each configurable product's child product has their own attributes (price, quantity, etc.), that child product attributes are used in quote, order, etc. Apr 26, 2017 at 6:46
  • Currently as a magento default. It is showing lowest price of simple product of Configurable product price on list page. I want ot change it so it will display whatever admin entered in configurable product. Configurable product => $12..... (1). Simple Product 1=> $12...... (2). Simple Product 2=> $10...... (3). Simple Product 3=> $14...... Now it will display price $10 on listing page. I want it so it will display $12(Whatever entered from configurable product). I had a log customization and based on that this is my requirement to display custom added price on front-end.
    – gks
    Apr 26, 2017 at 11:07
  • @GopalKacha Did you get the solution? or the full module? Please share.. I am stuck in the same problem
    – Jsparo30
    Apr 23, 2018 at 11:14
  • Yes, I have created module.. I will share with you.
    – gks
    Apr 24, 2018 at 15:14
  • 2
    I have solved this issue by creating plugin method of Magento2. You can get complete detail of the module at: kachagopal.blogspot.com/2018/08/…
    – gks
    Aug 1, 2018 at 21:13

2 Answers 2

2

SIMPLE WAY OF CHANGE ANY CONFIGURABLE PRODUCT PRICE IN MAGENTO 2 CE & EE

There is a simple way change configurable product price after created product and assign its simple products.

  1. firstly require to unassigned all simple products of configurable product and change price according to your choice.

  2. After change the price successfully and now assign its simple product and save it. you find change in your configurable prodot.

    I simple way work for me with testing another way i have not find on google.

All The Best.

2
  • 2
    I have solved this issue by creating plugin method of Magento2. You can get complete detail of the module at: kachagopal.blogspot.com/2018/08/…
    – gks
    Aug 1, 2018 at 21:11
  • @GopalKacha then I assume if the price of the simple products change, the admin then have to change the price of the configurable product manually? May 28, 2019 at 10:38
0

My solution rewrite Magento/ConfigurableProduct/js/components/price-configurable.js file in funtion handlePriceValue

handlePriceValue: function (isConfigurable) {
            this.disabled(!!this.isUseDefault() || isConfigurable);

            if (isConfigurable) {
                this.clear();
            }
        }

change into

handlePriceValue: function (isConfigurable) {
            /*this.disabled(!!this.isUseDefault() || isConfigurable);

            if (isConfigurable) {
                this.clear();
            }*/
        }

1- Create file requirejs-config.js in vendor/Module/view/adminhtml/requirejs-config.js

var config = {
    "map": {
        "*": {
            "Magento_ConfigurableProduct/js/components/price-configurable": "Vendor_Module/js/components/price-configurable",
        }
    }
}

2- Vendor/Module/js/components/price-configurable.js

/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
define([
    'underscore',
    'uiRegistry',
    'Magento_Ui/js/form/element/abstract'
], function (_, registry, Abstract) {
    'use strict';

    return Abstract.extend({
        defaults: {
            imports: {
                isConfigurable: '!ns = ${ $.ns }, index = configurable-matrix:isEmpty'
            },
            modules: {
                createConfigurableButton: '${$.createConfigurableButton}'
            }
        },

        /** @inheritdoc */
        initialize: function () {
            this._super();
            // resolve initial disable state
            this.handlePriceValue(this.isConfigurable);
            // add listener to track "configurable" type
            this.setListeners({
                isConfigurable: 'handlePriceValue'
            });

            return this;
        },

        /**
         * Calls 'initObservable' of parent
         *
         * @returns {Object} Chainable.
         */
        initObservable: function () {
            this._super()
                .observe(['content']);

            return this;
        },

        /**
         * Disable and clear price if product type changed to configurable
         *
         * @param {String} isConfigurable
         */
        handlePriceValue: function (isConfigurable) {
            /*this.disabled(!!this.isUseDefault() || isConfigurable);

            if (isConfigurable) {
                this.clear();
            }*/
        }
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.