Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7665395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:33:15+00:00 2026-05-31T14:33:15+00:00

I have a Magento instance and I am using the following code: include_once ‘../app/Mage.php’;

  • 0

I have a Magento instance and I am using the following code:

include_once '../app/Mage.php';
Mage::app();

try{

     $product_id = '';

     // get query string
     if (!isset($_GET['product_id'])) { $product_id = ''; } else { $product_id = $_GET['product_id']; }
     if (!isset($_GET['qty'])) { $qty = '1'; } else { $qty = $_GET['qty']; }

     $product = Mage::getModel('catalog/product')->load($product_id);

     $session = Mage::getSingleton('core/session', array('name'=>'frontend'));
     $cart = Mage::helper('checkout/cart')->getCart();

     $cart->addProduct($product, $qty);

     $session->setLastAddedProductId($product->getId());
     $session->setCartWasUpdated(true);

     $cart->save();

     $result = "{'result':'success'}";
     echo $result;

} catch (Exception $e) {
     $result = "{'result':'error'";
     $result .= ", 'message': '".$e->getMessage()."'}";
     echo $result;
}

However, I get an error that says ‘Please specify the product required option(s).’
How do I set an attributes called “Colors” and default to “black” in the previous code?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:33:16+00:00Added an answer on May 31, 2026 at 2:33 pm

    To add configurable to shopping cart you need to specify params for its attributes.
    Data Example:

            [product] => 3
            [related_product] => 
            [super_attribute] => Array
                (
                    [75] => 20
                    [85] => 15
                )
    
            [qty] => 1
    

    Here 75 – is “color” attribute_id, 20 -> ‘option_id’ of color “Black”
    85 – is “Size” attribute_id, 15 -> option_id of size ‘Big’.
    So check in your database what is attribute_id of Color attribute and option_id of ‘Black’ color.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On my iPhone app I have a UIImage instance. I want to get a
I have created my first Magento widget on a test site (same code and
I have a Magento site using JS (prototype) to display tabbed content on product
I'm using TinyMCE on the text-areas in my Magento admin section. I have my
I have a magento site running on nginx with php-fcgi. I have set up
i have a Magento shop and want to do the following: Some of the
This is for MySQL and PHP I have a table that contains the following
I have a Magento order model that I create like this: $order = Mage::getModel('sales/order')->load($orderId);
I currently have Magento set up on a development server (remote, SSH access) and
I have a Magento store which needs different prices for each site, which restricts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.