magento-configurable-simple icon indicating copy to clipboard operation
magento-configurable-simple copied to clipboard

SCP -> Custom Options

Open pbaum83 opened this issue 14 years ago • 52 comments

When building a configurable product if you add a custom option to the configurable product the custom options associated with that configurable do not work. I'm not sure if this is desired or required because of the way the extension works, but it would be great if you didn't lose that capability by adding SCP to your site.

Thanks, Paul

pbaum83 avatar Jun 23 '11 20:06 pbaum83

It's mentioned in the readme that adding custom options to the configurable product is something you shouldn't do with SCP. However, I agree that it would be very nice if you could, but I've just never come up with a way to do it that wouldn't be a lot of work.

toasty avatar Jun 24 '11 09:06 toasty

Thanks for the reply Simon. I just wrote this update to the front-end Renderer.php script.

I see this updates the cart and the checkout pages with the option and label, but it's missing from the back-end of the admin. Have you looked into that much? I'm wondering if that data is really there, just not displaying like it was in the front-end.

Thanks again for all your time and work on this discussion.

public function getOptionList()
{
    $options = false;

    if (Mage::getStoreConfig('SCP_options/cart/show_custom_options')) {
        $options = parent::getOptionList();
    }

    if (Mage::getStoreConfig('SCP_options/cart/show_config_product_options')) {
        if ($this->getConfigurableProductParentId()) {
            $attributes = $this->getConfigurableProductParent()
                ->getTypeInstance()
                ->getUsedProductAttributes();
            foreach($attributes as $attribute) {
                $options[] = array(
                    'label' => $attribute->getFrontendLabel(),
                    'value' => $this->getProduct()->getAttributeText($attribute->getAttributeCode()),
                    'option_id' => $attribute->getId(),
                );
            }
        }
    }

    ################################################################################
    # Associate the configurable products custom options with the simple product
    # that was added to the cart (sales_quote_order_item)
    ################################################################################

    $_cart_request = $this->getItem()->getBuyRequest();

    if ( isset($_cart_request->_data['options']) == true )
    {
        $_prodcut_options = $_cart_request->_data['options'];

        $_product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($this->getConfigurableProductParentId());

        foreach ( $_prodcut_options as $_option => $_id )
        {
            foreach ($_product->getOptions() as $o)
            {
                $values = $o->getValues();

                foreach ($values as $v)
                {
                    $option = $v->getData();
                    if ( $_id == $option['option_type_id'] )
                    {
                        $options[] = array(
                            'label' => $o->getTitle(),
                            'value' => $option['title'],
                            'option_id' => $_option,
                        );
                    }
                }
            }
        }
    }


    ################################################################################

    return $options;
}

pbaum83 avatar Jun 24 '11 17:06 pbaum83

I didnot read the readme file. However, having this option would be really good... @pbaum83 : Wil the code that you have posted fix the issue..?? Else what exactly did you try to do with that update to the code..? Thanks

Sriram

sriramvt avatar Jun 28 '11 17:06 sriramvt

The code that I added does work. The problem is that is only adds the custom option label to the front-end and there is still nothing visible in the back-end for the custom option that is selected. That is the next step to get this updated.

pbaum83 avatar Jun 28 '11 20:06 pbaum83

A long time ago when I tried to do something similar I came across many parts of the core Magento code that validated that the custom options that a product had genuinely belonged to it, and stripped them out if they didn't. There were so many places that I'd have had to change I gave up on the approach, and have never thought of a smarter way to do it since.

toasty avatar Jun 29 '11 15:06 toasty

Thanks Guys for your reply.. @pbaum83 : Quick question. Does the code above even update the price in the cart on the frontend... am new to magento so any help/guide on where to add this code and stuff would be highly appreciated. And secondly, am also struck with the same issue with admin... as mentioned in the SCP readme, i went and created custom options for each simple product... that works fine in the frontend... but when i goto create order in the backend.. and try adding the configurable product... the custom options associated with the simple product is also not showing.. is this common with magento... or is it because of SCP..??

sriramvt avatar Jun 30 '11 16:06 sriramvt

@sriramvt I am still working on my modification to make this work. Currently I have made more modifications to the SCP module that allow more than just drop down type custom options to work which is what the above code does. This means it now can work with text boxes as well. Indeed the other issue is having the custom option values work in the admin area. I'm still working on getting that part working. I've had a few other projects with higher urgency so this has been sidelined for a while, but I should be getting back to it soon. I will post an update once I get this finished.

pbaum83 avatar Jul 19 '11 21:07 pbaum83

This is what I have added so far I believe. It's not done, but if someone else has time or energy for this have at it.

FILE: magento/app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php

public function getOptionList()
{
    $options = false;

    if (Mage::getStoreConfig('SCP_options/cart/show_custom_options')) {
        $options = parent::getOptionList();
    }

    if (Mage::getStoreConfig('SCP_options/cart/show_config_product_options')) {
        if ($this->getConfigurableProductParentId()) {
            $attributes = $this->getConfigurableProductParent()
                ->getTypeInstance()
                ->getUsedProductAttributes();
            foreach($attributes as $attribute) {
                $options[] = array(
                    'label' => $attribute->getFrontendLabel(),
                    'value' => $this->getProduct()->getAttributeText($attribute->getAttributeCode()),
                    'option_id' => $attribute->getId(),
                );
            }
        }
    }

    ################################################################################
    # Associate the configurable products custom options with the simple product
    # that was added to the cart (sales_quote_order_item)
    ################################################################################

    $_cart_request = $this->getItem()->getBuyRequest();

    if ( isset($_cart_request->_data['options']) == true )
    {
        $_prodcut_options = $_cart_request->_data['options'];

        $_product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($this->getConfigurableProductParentId());

        foreach ( $_prodcut_options as $_option => $_id )
        {
            foreach ($_product->getOptions() as $o)
            {
                $values = $o->getValues();

                foreach ($values as $v)
                {
                    $option = $v->getData();
                    if ( $_id == $option['option_type_id'] )
                    {
                        $options[] = array(
                            'label' => $o->getTitle(),
                            'value' => $option['title'],
                            'option_id' => $_option,
                        );
                    }
                }
            }
        }
    }


    ################################################################################

    return $options;
}

public function getProductOptions() {

    $options = array();

    ################################################################################
    # Associate the configurable products custom options with the simple product
    # that was added to the cart (sales_quote_order_item)
    ################################################################################

    $_cart_request = $this->getItem()->getBuyRequest();

    if ( isset($_cart_request->_data['options']) == true )
    {
        $_prodcut_options = $_cart_request->_data['options'];

        $_product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($this->getConfigurableProductParentId());

        foreach ($_product->getOptions() as $o)
        {
            # we only want to get the custom options that are of type text here
            if ( $o->getType() == "field" && $_prodcut_options[$o->getId()] != "" ) {

                $options[] = array(
                    'label' => $o->getTitle(),
                    'value' => $_prodcut_options[$o->getId()],
                    'option_id' => $_option,
                );
            }
        }
    }

    return $options;

}

pbaum83 avatar Jul 19 '11 21:07 pbaum83

Just an update.

I've finished updating the extension to include the line items with details in the shopping cart, checkout process, and in the order details in the admin. I have some testing to do still, but I should have a patch in the next week or two.

The patch hasn't been tested much at this point, but I think it's a good start. It's been working well on our installation.

Thanks, -Paul

pbaum83 avatar Aug 15 '11 22:08 pbaum83

Hi Paul,

Thank you very much for the update. After you gave me the initial code. I was also working on it. But am quite slow as am new to magento and i had to understand the core files.

Is there a way i can get hold of the updated codes and procedures.

Regards, Sriram

sriramvt avatar Aug 22 '11 15:08 sriramvt

I will post an update once I have it tested with Magento 1.6. They just released the new version and I got sick over the weekend so I haven't had the time to test it, but I will try to get something posted this week.

pbaum83 avatar Aug 22 '11 21:08 pbaum83

Hi Paul,

Thanks for the quick response. Hope you are feeling better now. Am still using 1.5.1.0 and actively working on adding products using SCP.

If you need any help in testing.. i can do that coz i know exactly what problems we are facing. Do let me know.

Regards, Sri

sriramvt avatar Aug 23 '11 16:08 sriramvt

It's really late here now, but I think I have everything working finally. Everything seems to be working well with Magento 1.6 and Enterprise.

I decided to add the custom options sku part to the simple products Sku that is listed in the order items displayed in the admin. I figure that is more useful than only having a static Sku from the simple. There is a new option in the SCP admin area if you would rather not use the functionality.

I have not done a lot of testing on attribute types other than drop-downs so I can't tell you if those will work yet.

I have the file hosted on my site for now here: http://baumanator.com/simple_configurable_products.zip

If you have issues please post them here and I will try to fix them.

pbaum83 avatar Aug 27 '11 08:08 pbaum83

Som rewrites wasn't defined in config xml, so for example custom options weren't diplayed in order view in backoffice, same issue with email templates send to customers.

Here is working config.xml : https://gist.github.com/1178126

rafal-kos avatar Aug 29 '11 10:08 rafal-kos

Thanks. I have been using the extension on the latest 1.6 stable edition and enterprise. It is loading the custom options into the back office in most of the places like order view, invoice, and credit memos. If you are not seeing them loading anywhere you may have installed correctly. I did not update the email templates though which is a good idea. I'll try to get that into an update.

Regards, -Paul

pbaum83 avatar Aug 29 '11 15:08 pbaum83

Hi Paul,

Thank you very much for the update on the SCP patch.. appreciate it...

But am facing quite difficulty in getting it to work. Am currently on 1.5.1.0

  1. The layout of the Custom Options are messed up and weird.
  2. Once i choose a Simple product, the prices of the Custom Options (of configurable product) is over ridden by the price of the simple product and only the price of the simple product shows up in the cart.

What am i doing wrong.? I just uploaded the patch you coded to my existing installation. Is that the correct way to update SCP with your code or do i have to do it through Magento Connect.

I have messaged you on github with the link to my website...

Any help would be appreciated.

Regards, Sri

sriramvt avatar Aug 29 '11 19:08 sriramvt

I tried it on a test installation with Magento 1.6. The get the same exact problem as i mentioned above.

Am not sure if am installing the patch Paul has written properly. Am just replacing the original files of SCP with the new ones written by Paul through FTP..

Is that the right way to do it..?

Regards, Sri

sriramvt avatar Aug 30 '11 18:08 sriramvt

Hi Sri,

You are doing nothing wrong. The custom option problem was actually caused by the way I updated it. I haven't finished updating the price that is shown in the cart for custm options. Also the fact that I updated the java-script to show the price updating was probably not the best idea as you noticed the actual price of the product in the cart doesn't affect the simple product price. That is the whole reason to use this extension I believe. Maybe I am wrong? The other thought I had was that it works better to build off of the simple products price and add the custom options price on to that instead of a configurable which doesn't handle dependencies well. Either way it looks like I have some more work to go to support pricing updates by custom options. That was sort of a last minute thing i decided to add in. The way I have been using custom options wasn't to change the price at all so it works fine for my store, but I see the problem you are explaining.

Sorry if my message is hard to follow.

Regards, -Paul

pbaum83 avatar Aug 30 '11 18:08 pbaum83

Hi Paul,

Thanks for the update. I guessed so that that you might be using it where custom options doesnot have prices.

How do i get the prices of the custom options added to the cart.. can you guide me or help me out with this..??

Thanks Sri

sriramvt avatar Aug 30 '11 18:08 sriramvt

Hi Paul,

I was playing around with the patch to match the requirements that i mentioned.

Basically now my setup is as below

  1. All simple products will have the custom options in them.. (its a laborious process but can live with it)
  2. You code for the custom options to show up on the checkout, cart and admin works great.
  3. But one issue is, i need to have the custom option with file upload in there. It is not working. it throws an exception. what do i need to do to fix it. I remember that it was working with just the SCP.. but then i need that file to show in the cart, and also in the admin order view which was solved with the patch you coded..

Any help would be appreciated.

Regards, Sri

sriramvt avatar Aug 31 '11 17:08 sriramvt

@Paul the download link: http://baumanator.com/simple_configurable_products.zip doesn't work for me atm, is there any chance you could post the code or host elsewhere?

@Sri Did you manage to get the options prices to show up in the cart at all?

I desperately need this feature. At the moment I'm just using the latest SCP and I can have custom options as long as they're on the associated simple products. The price shown on the configurable product view page updates to reflect the custom options chosen, but this price doesn't get carried over to the cart page. The price that shows up in cart is just the base price for whichever associated simple product ended up being chosen.

The store I am working on is for a printing studio, and ideally they want to have the option of attaching a jpg as a file upload (for designs). In theory this would be a custom option that adds e.g. +£49 to the price. However as the store also uses SCP I was willing to settle for a workaround where we would just use a drop-down.

What's essential though is the price, and it seems that doesn't work at all.

I'm also pretty new to magento but I would be willing to spend some time on this if I can get the code. At the very least I can help with testing.

mikeunb avatar Sep 08 '11 10:09 mikeunb

Is it just the magento/app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php page that has been updated in the patch?

Just wondering as only wanted to update the files that have been changed.

vincepettit avatar Oct 19 '11 15:10 vincepettit

Hi there, for me everything worked for me after installing the update here. However, the functionality in the sales emails did not work yet. I did place the adjusted code from rafal-kos into the config.xml file of the extension, but no success. I only pasted this bit:


            [sales]
                [rewrite]
                    [order_item]OrganicInternet_SimpleConfigurableProducts_Sales_Model_Order_Item[/order_item]
                [/rewrite]                
            [/sales]

I replaced the opening and closing tags to display them here

Is there a way to make this work? Thanks in advance, Kenneth

seasightmedia avatar Nov 07 '11 11:11 seasightmedia

Hi,

I have just installed the scp module for a new website I am building and need this fix to get around the fact I need custom options on the configurable products. The link provided does not work anymore. Does anyone have a fix for this???

Any help would be greatly received.

Kind regards gareth

wintertong avatar Nov 09 '11 13:11 wintertong

Gareth, message me your email address and I'll send you over the ZIP we downloaded

vincepettit avatar Nov 09 '11 13:11 vincepettit

Hi,

Thanks for the response! it is [email protected].

Kind regards Gareth

wintertong avatar Nov 09 '11 13:11 wintertong

Hi,

I have kindly been given the module fix and I have applied it. All the frontend works perfectly. However, viewing an order breaks in the admin area.

Any ideas? Regards Gareth

wintertong avatar Nov 09 '11 15:11 wintertong

Hi,

I've got this module installed since 2 months, and I saw the bug today,

Symptom : I create a custom option in my configurable (in my case a text area-required), I can see it in the product view.

But the option doesn't display in the cart, and so in the order.

is it possible to get the zip file with the fix.

Thanks,

Regards,

surflibre avatar Dec 16 '11 22:12 surflibre

the download link: http://baumanator.com/simple_configurable_products.zip doesn't work, is there any chance to get the zip. I want to use it for my magento ver 1.6.0.0

Can anyone help on this...

GirishAssudani avatar Jan 04 '12 06:01 GirishAssudani

Hi, I have got the selected custom option from product to the cart but the price with custom option doesn't update with the price. So please help me on this and if possible then please send me the renderer file with update price. Below is my email address:- [email protected]

Thanks in advance, Ajay

ajaymakwana avatar Jan 17 '12 06:01 ajaymakwana