Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 899
  • Last Modified:

How to get custom options from a Magento model?

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.
0
darrenl
Asked:
darrenl
  • 4
  • 3
1 Solution
 
p_nutsCommented:
how does the garbage look .. you might need unserialize it
0
 
darrenlAuthor Commented:
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.
0
 
p_nutsCommented:
can you post an example
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
darrenlAuthor Commented:
This is my custom extension:
<?php
class IdeaExpress_SetupFee_Model_Quote_item extends Mage_Sales_Model_Quote_Item {
      public function calcRowTotal() {
            parent::calcRowTotal();
            
            $product = $this->getProduct();
            $product->load($product->getId());
                        
            $baseTotal = $this->getBaseRowTotal() + $product->getSetupFee();
            
            $total = $this->getStore()->convertPrice($baseTotal);
            $this->setRowTotal($this->getStore()->roundPrice($total));
            $this->setBaseRowTotal($this->getStore()->roundPrice($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.

Thanks,
Darren
0
 
p_nutsCommented:
no I mean the print_r
0
 
darrenlAuthor Commented:
The print_r was printing the wrong variable. Do you know the correct way to get custom product options in Magento?
0
 
miked2004Commented:
have you tried:
1. $product->getOptions();
2. $product->getCustomOptions();

Look at /app/code/core/Mage?catalog/Model/product.php
0
 
darrenlAuthor Commented:
This involves a lot more than these methods.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now