Solved

How to get custom options from a Magento model?

Posted on 2010-09-13
8
860 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

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

Technology Partners: 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

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…

733 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