Question

Is there a way I could retrieve all the custom options and their values? (not from a specific product, but just all of the options)

Was it helpful?

Solution

I found this solution:

    $tableName = $this->_resourceConnection->getTableName('catalog_product_option_type_title');

    $connection = $this->_resourceConnection->getConnection();
    $query = "SELECT * FROM " . $tableName;
    $resultOptions = $connection->fetchAll($query);

OTHER TIPS

If you are trying to retrieve custom options and their values for one time you can use mysql query else you can have your own kind of implementations based on the below sql.

mysql> select t4.title as 'Custom Option', t3.Custom_Option_Values from (select t2.option_id, t1.option_type_id,t1.title as 'Custom_Option_Values' from catalog_product_option_type_title t1 left join catalog_product_option_type_value t2 on t1.option_type_id = t2.option_type_id) t3 left join catalog_product_option_title t4 on t3.option_id = t4.option_id;
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top