How to get custom options from a Magento model?

Posted on 2010-09-13
Last Modified: 2012-05-10
I have tried to use getCustomOptions but it returns a bunch of garbage. Does anyone know how I can get the custom options from a product being added to the cart? I am making a custom module and need to check if certain custom options were chosen to calculate my final cost.
Question by:darrenl
  • 4
  • 3
LVL 13

Expert Comment

ID: 33665177
how does the garbage look .. you might need unserialize it

Author Comment

ID: 33665200
I have used print_r on it. I am trying to get the product's custom options that are defined when I created the product.
LVL 13

Expert Comment

ID: 33665658
can you post an example

Author Comment

ID: 33665721
This is my custom extension:
class IdeaExpress_SetupFee_Model_Quote_item extends Mage_Sales_Model_Quote_Item {
      public function calcRowTotal() {
            $product = $this->getProduct();
            $baseTotal = $this->getBaseRowTotal() + $product->getSetupFee();
            $total = $this->getStore()->convertPrice($baseTotal);
            return $this;

I want to add logic so if a custom option is set I can multiple $product->getSetupFee.

The custom options are product options.

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 13

Expert Comment

ID: 33665804
no I mean the print_r

Author Comment

ID: 33666164
The print_r was printing the wrong variable. Do you know the correct way to get custom product options in Magento?
LVL 12

Accepted Solution

miked2004 earned 500 total points
ID: 33672325
have you tried:
1. $product->getOptions();
2. $product->getCustomOptions();

Look at /app/code/core/Mage?catalog/Model/product.php

Author Closing Comment

ID: 33703556
This involves a lot more than these methods.

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now