Magento - Get Custom Option Value details from Option Value ID

Magento - Get Custom Option Value details from Option Value ID

July 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Get Custom Option Value details from Option Value ID

Understanding Magento Custom Options

Magento’s Confusion: Options vs Custom Options

Magento often confuses developers with its use of both options and custom_options properties for products in various modules. However, under the hood, there is only one class handling these - Mage_Catalog_Model_Product_Option.

While the documentation might seem to suggest two different types, they essentially refer to the same thing: Custom Options. The options property typically refers to system-defined options like size or color, while custom_options usually refers to admin-defined custom attributes added by store owners.

Fetching Custom Option Details from Ordered Items

Your primary challenge lies in fetching full details of a Custom Option Value chosen during checkout. Magento only stores the Option Value ID (in the option_value field) for ordered items and doesn’t include price or price type information directly.

Understanding Magento’s Storage Mechanism

To clarify, Magento uses different tables to store option and option value prices:

  • catalog_product_option_price: Stores prices related to options.
  • catalog_product_option_type_price: Stores prices related to option values.

Your Current Approach: Flawed and Inefficient

Your current code attempts to load an Option Value using the chosen Option Value ID. However, this is a flawed approach for several reasons:

  1. It assumes that all Custom Options are of type drop_down, which isn’t always true.
  2. Loading models directly by ID can be inefficient if done in a loop.

The Correct Approach: Using Resource Model

To fetch the correct Option Value details including price and price type, you should use the resource model to load data from the database directly:

$optionValue = Mage::getResourceModel('catalog/product_option_value_collection')
    ->addOptionFilter($_eachOption['option_id'])
    ->getFirstItem();

print_r($optionValue->getData());

This code creates a new collection for Option Values, filters it by the provided option ID (from your loop), and retrieves the first matching item. This approach is more efficient because it avoids unnecessary model loading.

Linking to LaravelCompany for Further Learning

For a deeper dive into Magento’s Custom Options system, including how to create custom options programmatically and handle them in the checkout process, I recommend checking out our comprehensive guide on Managing Custom Options in Magento.

Conclusion: A New Perspective on Custom Options

Magento’s terminology can be confusing at first, but understanding that both options and custom_options refer to the same thing under the hood helps clarify the architecture.

When fetching option value details from ordered items, it’s crucial to use efficient database queries instead of loading models directly. The resource model provides a more performant way to retrieve data.

Remember, each project may have unique requirements, so always adapt your approach based on your specific needs and Magento version you’re working with. Stay up-to-date with the latest documentation and best practices for optimal performance and security.

Happy coding!

Checkout Catalog Database Extensions

Our network