0

I am having some trouble here. I need to extend private function getTierPriceStructure($tierPricePath) in class \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing.

How do I achieve this?

PS: I am trying to add new field in tier_price section of product edit page.

enter image description here

This is what I want to do:

private function getTierPriceStructure($tierPricePath)
{
    //since below line is calling parent's private function, it will throw error.
    $result = $this->getTierPriceStructure($tierPricePath); //this is private function
    $newColumn = [
        'children' => [
            'record' => [
                'children' => [
                    'value_cost' => [
                        'arguments' => [
                            'data' => [
                                'config' => [
                                    'componentType' => Field::NAME,
                                    'formElement' => Input::NAME,
                                    'dataType' => Price::NAME,
                                    'label' => __('Cost'),
                                    'enableLabel' => true,
                                    'dataScope' => 'value_cost',
                                    'addbefore' => $this->locator->getStore()
                                                                 ->getBaseCurrency()
                                                                 ->getCurrencySymbol(),
                                    'sortOrder' => 80,
                                    'validation' => [
                                        'required-entry' => true,
                                        'validate-greater-than-zero' => true,
                                        'validate-number' => true,
                                    ],
                                    'imports' => [
                                        'priceValueCost' => '${ $.provider }:data.product.value_cost',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ];
    $result = $result + $newColumn;

    return $result;
}
  • No way. You need to duplicate this method in your extended class. – Sohel Rana Feb 12 '19 at 4:40
  • Then pretty much all the functions will be extended. Is there another way, maybe from ui? – Adarsh Khatri Feb 12 '19 at 5:07
1

I think you can try a plugin after the public method \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing::modifyMeta() and manipulate the return value.

The return value should contain the complete array structure and you might be able to add your data to the right position. Since that is the only place the data is provided to objects from outside the class, it could work.

| improve this answer | |

Your Answer

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

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