Magento2 : How to get product custom option Title from its IDGet all Custom OptionCustom Option text field value from order idMagento2 : How to add a new product custom option type?Retrieve product custom optionAdd new drop-down custom option typeFetch a custom Product Option from the titleMagento 2 custom option not showing created programmaticallyEditing Title of Existing Custom OptionHow to get custom option value and title from ids in magento 2
Will this tire fail its MOT?
A verb to describe specific positioning of three layers
How could an animal "smell" carbon monoxide?
Vienna To Graz By Rail
How fast does a character need to move to be effectively invisible?
Intel 8080-based home computers
Why is Google approaching my VPS machine?
Sending a photo of my bank account card to the future employer
Is it ethical for a company to ask its employees to move furniture on a weekend?
How can electric field be defined as force per charge, if the charge makes its own, singular electric field?
How to remove the first colon ':' from a timestamp?
How to find location on Cambridge-Mildenhall railway that still has tracks/rails?
What is the point of a constraint expression on a non-templated function?
Is it okay for a chapter's POV to shift as it progresses?
What is the meaning of [[:space:]] in bash?
How can I help our ranger feel special about her beast companion?
Jump back to the position I started a search
How was Peter Parker able to use EDITH in the end?
Is there an English equivalent for "Les carottes sont cuites", while keeping the vegetable reference?
What does it actually mean to have two time dimensions?
Is there a typesafe way to get a Database.QueryLocator?
Is the purpose of sheet music to be played along to? Or a guide for learning and reference during playing?
Is this Android phone Android 9.0 or Android 6.0?
Interviewing with an unmentioned 9 months of sick leave taken during a job
Magento2 : How to get product custom option Title from its ID
Get all Custom OptionCustom Option text field value from order idMagento2 : How to add a new product custom option type?Retrieve product custom optionAdd new drop-down custom option typeFetch a custom Product Option from the titleMagento 2 custom option not showing created programmaticallyEditing Title of Existing Custom OptionHow to get custom option value and title from ids in magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...
$option_id=13;
$option_Title=$this->..->getTitle($option_id);
magento2 custom-options title
add a comment |
In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...
$option_id=13;
$option_Title=$this->..->getTitle($option_id);
magento2 custom-options title
add a comment |
In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...
$option_id=13;
$option_Title=$this->..->getTitle($option_id);
magento2 custom-options title
In a magento2 plugin I would like to get the product custom options title from the option ID, but I do not know what injection to make in the constructor and what functions to use to achieve that...
$option_id=13;
$option_Title=$this->..->getTitle($option_id);
magento2 custom-options title
magento2 custom-options title
edited Dec 6 '18 at 7:54
Murtuza Zabuawala
12.6k7 gold badges33 silver badges63 bronze badges
12.6k7 gold badges33 silver badges63 bronze badges
asked Aug 3 '17 at 7:06
AlexglvrAlexglvr
8901 gold badge11 silver badges39 bronze badges
8901 gold badge11 silver badges39 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can do this with collection, my solution:
protected $_storeManager;
protected $_options;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoBundleModelResourceModelOptionCollectionFactory $options,
MagentoStoreModelStoreManagerInterface $_storeManager
)
$this->_storeManager = $_storeManager;
$this->_options = $options;
parent::__construct($context);
public function getOption($optionId)
return $this->appendSelections(
$this->_options->create()
->addFieldToFilter('option_id', $optionId)
->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
->joinValues($this->_storeManager->getStore()->getId()) // this will append title
->getFirstItem(),
$this->getProduct()
);
protected function appendSelections(MagentoBundleModelOption $option, $product)
if($option->getOptionId())
$typeInstance = $product->getTypeInstance();
$selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
$option->setData('selections', $selections);
return $option;
With "Repository":
$this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
$productSku,
$optionId
);
This solution for bundle options but in custom options will be similar...
add a comment |
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%2f187640%2fmagento2-how-to-get-product-custom-option-title-from-its-id%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do this with collection, my solution:
protected $_storeManager;
protected $_options;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoBundleModelResourceModelOptionCollectionFactory $options,
MagentoStoreModelStoreManagerInterface $_storeManager
)
$this->_storeManager = $_storeManager;
$this->_options = $options;
parent::__construct($context);
public function getOption($optionId)
return $this->appendSelections(
$this->_options->create()
->addFieldToFilter('option_id', $optionId)
->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
->joinValues($this->_storeManager->getStore()->getId()) // this will append title
->getFirstItem(),
$this->getProduct()
);
protected function appendSelections(MagentoBundleModelOption $option, $product)
if($option->getOptionId())
$typeInstance = $product->getTypeInstance();
$selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
$option->setData('selections', $selections);
return $option;
With "Repository":
$this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
$productSku,
$optionId
);
This solution for bundle options but in custom options will be similar...
add a comment |
You can do this with collection, my solution:
protected $_storeManager;
protected $_options;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoBundleModelResourceModelOptionCollectionFactory $options,
MagentoStoreModelStoreManagerInterface $_storeManager
)
$this->_storeManager = $_storeManager;
$this->_options = $options;
parent::__construct($context);
public function getOption($optionId)
return $this->appendSelections(
$this->_options->create()
->addFieldToFilter('option_id', $optionId)
->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
->joinValues($this->_storeManager->getStore()->getId()) // this will append title
->getFirstItem(),
$this->getProduct()
);
protected function appendSelections(MagentoBundleModelOption $option, $product)
if($option->getOptionId())
$typeInstance = $product->getTypeInstance();
$selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
$option->setData('selections', $selections);
return $option;
With "Repository":
$this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
$productSku,
$optionId
);
This solution for bundle options but in custom options will be similar...
add a comment |
You can do this with collection, my solution:
protected $_storeManager;
protected $_options;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoBundleModelResourceModelOptionCollectionFactory $options,
MagentoStoreModelStoreManagerInterface $_storeManager
)
$this->_storeManager = $_storeManager;
$this->_options = $options;
parent::__construct($context);
public function getOption($optionId)
return $this->appendSelections(
$this->_options->create()
->addFieldToFilter('option_id', $optionId)
->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
->joinValues($this->_storeManager->getStore()->getId()) // this will append title
->getFirstItem(),
$this->getProduct()
);
protected function appendSelections(MagentoBundleModelOption $option, $product)
if($option->getOptionId())
$typeInstance = $product->getTypeInstance();
$selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
$option->setData('selections', $selections);
return $option;
With "Repository":
$this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
$productSku,
$optionId
);
This solution for bundle options but in custom options will be similar...
You can do this with collection, my solution:
protected $_storeManager;
protected $_options;
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoBundleModelResourceModelOptionCollectionFactory $options,
MagentoStoreModelStoreManagerInterface $_storeManager
)
$this->_storeManager = $_storeManager;
$this->_options = $options;
parent::__construct($context);
public function getOption($optionId)
return $this->appendSelections(
$this->_options->create()
->addFieldToFilter('option_id', $optionId)
->addFieldToFilter('parent_id', $this->getProduct()->getEntityId())
->joinValues($this->_storeManager->getStore()->getId()) // this will append title
->getFirstItem(),
$this->getProduct()
);
protected function appendSelections(MagentoBundleModelOption $option, $product)
if($option->getOptionId())
$typeInstance = $product->getTypeInstance();
$selections = $typeInstance->getSelectionsCollection([$option->getOptionId()], $product);
$option->setData('selections', $selections);
return $option;
With "Repository":
$this->_objectManager->get('MagentoBundleModelOptionRepository')->get(
$productSku,
$optionId
);
This solution for bundle options but in custom options will be similar...
edited Nov 1 '17 at 2:33
answered Oct 22 '17 at 1:50
Slava YurthevSlava Yurthev
828 bronze badges
828 bronze badges
add a comment |
add a comment |
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%2f187640%2fmagento2-how-to-get-product-custom-option-title-from-its-id%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