Filter Options value when creation configurable product magento 2main.CRITICAL: Plugin class doesn't existMagento 2.1 Create a filter in the product grid by new attributeMagento 2: Add a product to the cart programmaticallyMagento offline custom Payment method with drop down listHow to solve Front controller reached 100 router match iterations in magento2I have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?Get Out of Stock products to show in magento 2.3Magento 2.3 email attachment not working while sending custom email
Overprovisioning SSD on ubuntu. How? Ubuntu 19.04 Samsung SSD 860
What's the term for a group of people who enjoy literary works?
What is the most 'environmentally friendly' way to learn to fly?
What sort of solar system / atmospheric conditions, if any, would allow for a very cold planet that still receives plenty of light from its sun?
Protect a 6 inch air hose from physical damage
Why do player start with fighting for the corners in go?
Why are sugars in whole fruits not digested the same way sugars in juice are?
Heinlein story regarding suspended animation and reading newspapers?
Why is “deal 6 damage” a legit phrase?
Does the problem of P vs NP come under the category of Operational Research?
How long should I wait to plug in my refrigerator after unplugging it?
Define tcolorbox in math mode
Export economy of Mars
A conjectural trigonometric identity
How to structure presentation to avoid getting questions that will be answered later in the presentation?
Can the globes from multiple castings of the Otiluke's Freezing Sphere spell be stockpiled?
Matrix condition number and reordering
Does the use of a new concept require a prior definition?
Reasons for using monsters as bioweapons
Can it be useful for a player block with a hanging piece in a back rank mate situation?
Feedback diagram
Declaring a visitor to the UK as my "girlfriend" - effect on getting a Visitor visa?
How do I solve such questions on paramagnetism and ferromagnetism?
Transistor design with beta variation
Filter Options value when creation configurable product magento 2
main.CRITICAL: Plugin class doesn't existMagento 2.1 Create a filter in the product grid by new attributeMagento 2: Add a product to the cart programmaticallyMagento offline custom Payment method with drop down listHow to solve Front controller reached 100 router match iterations in magento2I have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?Get Out of Stock products to show in magento 2.3Magento 2.3 email attachment not working while sending custom email
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a custom attribute that i will create my product configurable according to it and every product has his specific values so i want to filter the options when creation product to just show me the associated option of this product. I tried this via Ui/DataProvider Modifier but nothing changed i still see all the options an d not filtered ones: Here is my code
<?php
namespace VendorMyModuleUiDataProviderProductFormModifier;
use MagentoCatalogApiDataProductAttributeInterface;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoFrameworkStdlibArrayManager;
use MagentoFrameworkUrlInterface;
use MagentoUiComponentFormField;
/**
* Data provider for "Custom Attribute" field of product page
*/
class PrixVente extends AbstractModifier
//const SUGGEST_FILTER_URI = 'Mdweb_ConfigAttribute/something/suggestCustomAttr';
/**
* @param LocatorInterface $locator
* @param UrlInterface $urlBuilder
* @param ArrayManager $arrayManager
*/
protected $eavConfig;
protected $registry;
public function __construct(
LocatorInterface $locator,
UrlInterface $urlBuilder,
ArrayManager $arrayManager,
MagentoEavModelConfig $eavConfig,
MagentoFrameworkRegistry $registry
)
$this->locator = $locator;
$this->urlBuilder = $urlBuilder;
$this->arrayManager = $arrayManager;
$this->_eavConfig = $eavConfig;
$this->registry = $registry;
/**
* @inheritdoc
*/
public function modifyMeta(array $meta)
$meta = $this->customiseCustomAttrField($meta);
return $meta;
/**
* @inheritdoc
*/
public function modifyData(array $data)
return $data;
/**
* Customise Custom Attribute field
*
* @param array $meta
*
* @return array
*/
protected function customiseCustomAttrField(array $meta)
$fieldCode = 'choix_prix_product'; //your custom attribute code
$elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children');
$containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children');
if (!$elementPath)
return $meta;
$meta = $this->arrayManager->merge(
$containerPath,
$meta,
[
'arguments' => [
'data' => [
'config' => [
'dataScope' => '',
'formElement' => 'container',
'componentType' => 'container',
'component' => 'Magento_Ui/js/form/components/group',
'scopeLabel' => __('[GLOBAL]'),
],
],
],
'children' => [
$fieldCode => [
'arguments' => [
'data' => [
'config' => [
'componentType' => Field::NAME,
'formElement' => 'select',
'options' => $this->getOptions(),
'config' => [
'dataScope' => $fieldCode,
],
],
],
],
]
]
]
);
return $meta;
/**
* Retrieve custom attribute collection
*
* @return array
*/
protected function toOptionArray()
// Get your options
$attributeCode = "choix_prix_product";
$attribute = $this->_eavConfig->getAttribute('catalog_product', $attributeCode);
$options = $attribute->getSource()->getAllOptions();
$_product = $this->registry->registry('current_product');
$idprod = $_product->getId();
$tab = [];
$_sku = $_product->getSku(); // for sku
$var1 = substr($_sku, 0, 1);
$var2 = substr($_sku, 1, 2);
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('table_prix');
$fields = array('prix_unitaire', 'prix_id');
$sql = $connection->select()
->from($tableName, $fields)
->where('code_famille' . '=?', $var1)
->where('code_nom_commercial' . '=?', $var2)
->join('table_choix',
'table_choix.choix_id = table_prix.code_choix',
[
'designation_choix'
]);
$result = $connection->fetchAll($sql);
foreach ($options as $option)
if ($result)
$i = 0;
foreach ($result as $elt)
if ($option['label'] == " Choix" . $elt['designation_choix'] . "-" . $elt['prix_unitaire'] . "£")
$tab[] = [['label' => $option['label'], 'value' => $option['value']]];
$i++;
return $tab;
public function getOptions()
return $this->toOptionArray();
any help please
magento2 data data-provider
add a comment |
I have a custom attribute that i will create my product configurable according to it and every product has his specific values so i want to filter the options when creation product to just show me the associated option of this product. I tried this via Ui/DataProvider Modifier but nothing changed i still see all the options an d not filtered ones: Here is my code
<?php
namespace VendorMyModuleUiDataProviderProductFormModifier;
use MagentoCatalogApiDataProductAttributeInterface;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoFrameworkStdlibArrayManager;
use MagentoFrameworkUrlInterface;
use MagentoUiComponentFormField;
/**
* Data provider for "Custom Attribute" field of product page
*/
class PrixVente extends AbstractModifier
//const SUGGEST_FILTER_URI = 'Mdweb_ConfigAttribute/something/suggestCustomAttr';
/**
* @param LocatorInterface $locator
* @param UrlInterface $urlBuilder
* @param ArrayManager $arrayManager
*/
protected $eavConfig;
protected $registry;
public function __construct(
LocatorInterface $locator,
UrlInterface $urlBuilder,
ArrayManager $arrayManager,
MagentoEavModelConfig $eavConfig,
MagentoFrameworkRegistry $registry
)
$this->locator = $locator;
$this->urlBuilder = $urlBuilder;
$this->arrayManager = $arrayManager;
$this->_eavConfig = $eavConfig;
$this->registry = $registry;
/**
* @inheritdoc
*/
public function modifyMeta(array $meta)
$meta = $this->customiseCustomAttrField($meta);
return $meta;
/**
* @inheritdoc
*/
public function modifyData(array $data)
return $data;
/**
* Customise Custom Attribute field
*
* @param array $meta
*
* @return array
*/
protected function customiseCustomAttrField(array $meta)
$fieldCode = 'choix_prix_product'; //your custom attribute code
$elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children');
$containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children');
if (!$elementPath)
return $meta;
$meta = $this->arrayManager->merge(
$containerPath,
$meta,
[
'arguments' => [
'data' => [
'config' => [
'dataScope' => '',
'formElement' => 'container',
'componentType' => 'container',
'component' => 'Magento_Ui/js/form/components/group',
'scopeLabel' => __('[GLOBAL]'),
],
],
],
'children' => [
$fieldCode => [
'arguments' => [
'data' => [
'config' => [
'componentType' => Field::NAME,
'formElement' => 'select',
'options' => $this->getOptions(),
'config' => [
'dataScope' => $fieldCode,
],
],
],
],
]
]
]
);
return $meta;
/**
* Retrieve custom attribute collection
*
* @return array
*/
protected function toOptionArray()
// Get your options
$attributeCode = "choix_prix_product";
$attribute = $this->_eavConfig->getAttribute('catalog_product', $attributeCode);
$options = $attribute->getSource()->getAllOptions();
$_product = $this->registry->registry('current_product');
$idprod = $_product->getId();
$tab = [];
$_sku = $_product->getSku(); // for sku
$var1 = substr($_sku, 0, 1);
$var2 = substr($_sku, 1, 2);
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('table_prix');
$fields = array('prix_unitaire', 'prix_id');
$sql = $connection->select()
->from($tableName, $fields)
->where('code_famille' . '=?', $var1)
->where('code_nom_commercial' . '=?', $var2)
->join('table_choix',
'table_choix.choix_id = table_prix.code_choix',
[
'designation_choix'
]);
$result = $connection->fetchAll($sql);
foreach ($options as $option)
if ($result)
$i = 0;
foreach ($result as $elt)
if ($option['label'] == " Choix" . $elt['designation_choix'] . "-" . $elt['prix_unitaire'] . "£")
$tab[] = [['label' => $option['label'], 'value' => $option['value']]];
$i++;
return $tab;
public function getOptions()
return $this->toOptionArray();
any help please
magento2 data data-provider
add a comment |
I have a custom attribute that i will create my product configurable according to it and every product has his specific values so i want to filter the options when creation product to just show me the associated option of this product. I tried this via Ui/DataProvider Modifier but nothing changed i still see all the options an d not filtered ones: Here is my code
<?php
namespace VendorMyModuleUiDataProviderProductFormModifier;
use MagentoCatalogApiDataProductAttributeInterface;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoFrameworkStdlibArrayManager;
use MagentoFrameworkUrlInterface;
use MagentoUiComponentFormField;
/**
* Data provider for "Custom Attribute" field of product page
*/
class PrixVente extends AbstractModifier
//const SUGGEST_FILTER_URI = 'Mdweb_ConfigAttribute/something/suggestCustomAttr';
/**
* @param LocatorInterface $locator
* @param UrlInterface $urlBuilder
* @param ArrayManager $arrayManager
*/
protected $eavConfig;
protected $registry;
public function __construct(
LocatorInterface $locator,
UrlInterface $urlBuilder,
ArrayManager $arrayManager,
MagentoEavModelConfig $eavConfig,
MagentoFrameworkRegistry $registry
)
$this->locator = $locator;
$this->urlBuilder = $urlBuilder;
$this->arrayManager = $arrayManager;
$this->_eavConfig = $eavConfig;
$this->registry = $registry;
/**
* @inheritdoc
*/
public function modifyMeta(array $meta)
$meta = $this->customiseCustomAttrField($meta);
return $meta;
/**
* @inheritdoc
*/
public function modifyData(array $data)
return $data;
/**
* Customise Custom Attribute field
*
* @param array $meta
*
* @return array
*/
protected function customiseCustomAttrField(array $meta)
$fieldCode = 'choix_prix_product'; //your custom attribute code
$elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children');
$containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children');
if (!$elementPath)
return $meta;
$meta = $this->arrayManager->merge(
$containerPath,
$meta,
[
'arguments' => [
'data' => [
'config' => [
'dataScope' => '',
'formElement' => 'container',
'componentType' => 'container',
'component' => 'Magento_Ui/js/form/components/group',
'scopeLabel' => __('[GLOBAL]'),
],
],
],
'children' => [
$fieldCode => [
'arguments' => [
'data' => [
'config' => [
'componentType' => Field::NAME,
'formElement' => 'select',
'options' => $this->getOptions(),
'config' => [
'dataScope' => $fieldCode,
],
],
],
],
]
]
]
);
return $meta;
/**
* Retrieve custom attribute collection
*
* @return array
*/
protected function toOptionArray()
// Get your options
$attributeCode = "choix_prix_product";
$attribute = $this->_eavConfig->getAttribute('catalog_product', $attributeCode);
$options = $attribute->getSource()->getAllOptions();
$_product = $this->registry->registry('current_product');
$idprod = $_product->getId();
$tab = [];
$_sku = $_product->getSku(); // for sku
$var1 = substr($_sku, 0, 1);
$var2 = substr($_sku, 1, 2);
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('table_prix');
$fields = array('prix_unitaire', 'prix_id');
$sql = $connection->select()
->from($tableName, $fields)
->where('code_famille' . '=?', $var1)
->where('code_nom_commercial' . '=?', $var2)
->join('table_choix',
'table_choix.choix_id = table_prix.code_choix',
[
'designation_choix'
]);
$result = $connection->fetchAll($sql);
foreach ($options as $option)
if ($result)
$i = 0;
foreach ($result as $elt)
if ($option['label'] == " Choix" . $elt['designation_choix'] . "-" . $elt['prix_unitaire'] . "£")
$tab[] = [['label' => $option['label'], 'value' => $option['value']]];
$i++;
return $tab;
public function getOptions()
return $this->toOptionArray();
any help please
magento2 data data-provider
I have a custom attribute that i will create my product configurable according to it and every product has his specific values so i want to filter the options when creation product to just show me the associated option of this product. I tried this via Ui/DataProvider Modifier but nothing changed i still see all the options an d not filtered ones: Here is my code
<?php
namespace VendorMyModuleUiDataProviderProductFormModifier;
use MagentoCatalogApiDataProductAttributeInterface;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoFrameworkStdlibArrayManager;
use MagentoFrameworkUrlInterface;
use MagentoUiComponentFormField;
/**
* Data provider for "Custom Attribute" field of product page
*/
class PrixVente extends AbstractModifier
//const SUGGEST_FILTER_URI = 'Mdweb_ConfigAttribute/something/suggestCustomAttr';
/**
* @param LocatorInterface $locator
* @param UrlInterface $urlBuilder
* @param ArrayManager $arrayManager
*/
protected $eavConfig;
protected $registry;
public function __construct(
LocatorInterface $locator,
UrlInterface $urlBuilder,
ArrayManager $arrayManager,
MagentoEavModelConfig $eavConfig,
MagentoFrameworkRegistry $registry
)
$this->locator = $locator;
$this->urlBuilder = $urlBuilder;
$this->arrayManager = $arrayManager;
$this->_eavConfig = $eavConfig;
$this->registry = $registry;
/**
* @inheritdoc
*/
public function modifyMeta(array $meta)
$meta = $this->customiseCustomAttrField($meta);
return $meta;
/**
* @inheritdoc
*/
public function modifyData(array $data)
return $data;
/**
* Customise Custom Attribute field
*
* @param array $meta
*
* @return array
*/
protected function customiseCustomAttrField(array $meta)
$fieldCode = 'choix_prix_product'; //your custom attribute code
$elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children');
$containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children');
if (!$elementPath)
return $meta;
$meta = $this->arrayManager->merge(
$containerPath,
$meta,
[
'arguments' => [
'data' => [
'config' => [
'dataScope' => '',
'formElement' => 'container',
'componentType' => 'container',
'component' => 'Magento_Ui/js/form/components/group',
'scopeLabel' => __('[GLOBAL]'),
],
],
],
'children' => [
$fieldCode => [
'arguments' => [
'data' => [
'config' => [
'componentType' => Field::NAME,
'formElement' => 'select',
'options' => $this->getOptions(),
'config' => [
'dataScope' => $fieldCode,
],
],
],
],
]
]
]
);
return $meta;
/**
* Retrieve custom attribute collection
*
* @return array
*/
protected function toOptionArray()
// Get your options
$attributeCode = "choix_prix_product";
$attribute = $this->_eavConfig->getAttribute('catalog_product', $attributeCode);
$options = $attribute->getSource()->getAllOptions();
$_product = $this->registry->registry('current_product');
$idprod = $_product->getId();
$tab = [];
$_sku = $_product->getSku(); // for sku
$var1 = substr($_sku, 0, 1);
$var2 = substr($_sku, 1, 2);
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('table_prix');
$fields = array('prix_unitaire', 'prix_id');
$sql = $connection->select()
->from($tableName, $fields)
->where('code_famille' . '=?', $var1)
->where('code_nom_commercial' . '=?', $var2)
->join('table_choix',
'table_choix.choix_id = table_prix.code_choix',
[
'designation_choix'
]);
$result = $connection->fetchAll($sql);
foreach ($options as $option)
if ($result)
$i = 0;
foreach ($result as $elt)
if ($option['label'] == " Choix" . $elt['designation_choix'] . "-" . $elt['prix_unitaire'] . "£")
$tab[] = [['label' => $option['label'], 'value' => $option['value']]];
$i++;
return $tab;
public function getOptions()
return $this->toOptionArray();
any help please
magento2 data data-provider
magento2 data data-provider
edited Jul 24 at 9:26
Rk Rathod
2,7453 silver badges23 bronze badges
2,7453 silver badges23 bronze badges
asked Jul 24 at 8:56
Developper Magento Developper Magento
6582 silver badges12 bronze badges
6582 silver badges12 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283119%2ffilter-options-value-when-creation-configurable-product-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f283119%2ffilter-options-value-when-creation-configurable-product-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown