Option
Magento\Catalog\Model\Product\Option
What it does
This class represents customizable product options in Magento 2, such as text fields, dropdowns, file uploads, and date pickers that customers can select when purchasing a product.
Developers use this class to programmatically create, manage, and retrieve custom options for products, including their values, pricing, and validation rules.
It handles the business logic for different option types like text, select, file, and date groups.
Public Methods
- addValue()
- getValueById()
- hasValues()
- getValues()
- getValueInstance()
- addOption()
- getOptions()
- setOptions()
- unsetOptions()
- getProduct()
- setProduct()
- getGroupByType()
- groupFactory()
- beforeSave()
- afterSave()
- getPrice()
- deletePrices()
- deleteTitles()
- getProductOptions()
- getValuesCollection()
- getOptionValuesByOptionId()
- duplicate()
- getSearchableData()
- getProductSku()
- getOptionId()
- getTitle()
- getType()
- getSortOrder()
- getIsRequire()
- getPriceType()
- getSku()
- getFileExtension()
- getMaxCharacters()
- getImageSizeX()
- getImageSizeY()
- setProductSku()
- setOptionId()
- setTitle()
- setType()
- setSortOrder()
- setIsRequire()
- setPrice()
- setPriceType()
- setSku()
- setFileExtension()
- setMaxCharacters()
- setImageSizeX()
- setImageSizeY()
- setValues()
- getExtensionAttributes()
- getRegularPrice()
- getProductOptionCollection()
- setExtensionAttributes()