Solved

How to get custom options from a Magento model?

Posted on 2010-09-13
8
869 Views
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.
0
Comment
Question by:darrenl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 13

Expert Comment

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

Author Comment

by:darrenl
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.
0
 
LVL 13

Expert Comment

by:p_nuts
ID: 33665658
can you post an example
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:darrenl
ID: 33665721
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
 
LVL 13

Expert Comment

by:p_nuts
ID: 33665804
no I mean the print_r
0
 

Author Comment

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

Accepted Solution

by:
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
0
 

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn about the eCommerce marketing trends for the year ahead.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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