2

I have the below code in my custom module, at App/Code/Ibex/Options/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php and added a "weight" column to catalog_product_option_type_value in the database. Locally, this works great, but weight fields are not saving in the database when trying it on the dev site. Is there something else I'm not considering? Odd that it works locally.

<?php /** * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace Ibex\Options\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Catalog\Model\ProductOptions\ConfigInterface; use Magento\Catalog\Model\Config\Source\Product\Options\Price as ProductOptionsPrice; use Magento\Framework\UrlInterface; use Magento\Framework\Stdlib\ArrayManager; use Magento\Ui\Component\Modal; use Magento\Ui\Component\Container; use Magento\Ui\Component\DynamicRows; use Magento\Ui\Component\Form\Fieldset; use Magento\Ui\Component\Form\Field; use Magento\Ui\Component\Form\Element\Input; use Magento\Ui\Component\Form\Element\Select; use Magento\Ui\Component\Form\Element\Checkbox; use Magento\Ui\Component\Form\Element\ActionDelete; use Magento\Ui\Component\Form\Element\DataType\Text; use Magento\Ui\Component\Form\Element\DataType\Number; use Magento\Framework\Locale\CurrencyInterface; class CustomOptions extends \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions { /**#@+ * Field values * */ const FIELD_WEIGHT_NAME = 'weight'; /** * Get config for grid for "select" types * * @param int $sortOrder * @return array */ protected function getSelectTypeGridConfig($sortOrder) { return [ 'arguments' => [ 'data' => [ 'config' => [ 'addButtonLabel' => __('Add Value'), 'componentType' => DynamicRows::NAME, 'component' => 'Magento_Ui/js/dynamic-rows/dynamic-rows', 'additionalClasses' => 'admin__field-wide', 'deleteProperty' => static::FIELD_IS_DELETE, 'deleteValue' => '1', 'renderDefaultRecord' => false, 'sortOrder' => $sortOrder, ], ], ], 'children' => [ 'record' => [ 'arguments' => [ 'data' => [ 'config' => [ 'componentType' => Container::NAME, 'component' => 'Magento_Ui/js/dynamic-rows/record', 'positionProvider' => static::FIELD_SORT_ORDER_NAME, 'isTemplate' => true, 'is_collection' => true, ], ], ], 'children' => [ static::FIELD_TITLE_NAME => $this->getTitleFieldConfig(10), static::FIELD_PRICE_NAME => $this->getPriceFieldConfig(20), static::FIELD_PRICE_TYPE_NAME => $this->getPriceTypeFieldConfig(30, ['fit' => true]), static::FIELD_SKU_NAME => $this->getSkuFieldConfig(40), static::FIELD_SORT_ORDER_NAME => $this->getPositionFieldConfig(50), static::FIELD_WEIGHT_NAME => $this->getWeightFieldConfig(55), static::FIELD_IS_DELETE => $this->getIsDeleteFieldConfig(60) ] ] ] ]; } /** * Get config for "Weight" fields * * @param $sortOrder * @param array $options * @return array */ protected function getWeightFieldConfig($sortOrder, array $options = []) { return array_replace_recursive( [ 'arguments' => [ 'data' => [ 'config' => [ 'label' => __('Weight'), 'addafter' => __('lbs.'), 'componentType' => Field::NAME, 'formElement' => Input::NAME, 'dataScope' => static::FIELD_WEIGHT_NAME, 'dataType' => Text::NAME, 'sortOrder' => $sortOrder, ], ], ], ], $options ); } } 

1 Answer 1

0

Weird, once I changed const FIELD_WEIGHT_NAME to 'custom_weight' it started to work. I think I may have initially set up the 'weight' column incorrect (or something) so maybe some database litter was interfering.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.