organicinternet / magento-configurable-simple

Enhancement to Magento to allow simple product prices to be used instead of the default special-case configurable product prices
http://organicinternet.co.uk/
283 stars 266 forks source link

SCP -> Custom Options #41

Open pbaum83 opened 13 years ago

pbaum83 commented 13 years ago

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

toasty commented 13 years ago

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.

pbaum83 commented 13 years ago

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;
}
sriramvt commented 13 years ago

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

pbaum83 commented 13 years ago

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.

toasty commented 13 years ago

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.

sriramvt commented 13 years ago

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..??

pbaum83 commented 13 years ago

@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 commented 13 years ago

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 commented 13 years ago

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

sriramvt commented 13 years ago

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

pbaum83 commented 13 years ago

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.

sriramvt commented 13 years ago

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

pbaum83 commented 13 years ago

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.

rafal-kos commented 13 years ago

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

pbaum83 commented 13 years ago

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

sriramvt commented 13 years ago

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 commented 13 years ago

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

pbaum83 commented 13 years ago

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

sriramvt commented 13 years ago

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 commented 13 years ago

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

mikeunb commented 13 years ago

@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.

vincepettit commented 12 years ago

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.

seasightmedia commented 12 years ago

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

wintertong commented 12 years ago

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

vincepettit commented 12 years ago

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

wintertong commented 12 years ago

Hi,

Thanks for the response! it is gareth.winterton@gmail.com.

Kind regards Gareth

wintertong commented 12 years ago

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

surflibre commented 12 years ago

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,

GirishAssudani commented 12 years ago

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...

ajaymakwana commented 12 years ago

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:- ajay.makwana@rightwaysolution.com

Thanks in advance, Ajay

ajaymakwana commented 12 years ago

Hi Please provide me the ZIP folder for custom option with price in admin area. Thanks, Ajay

wintertong commented 12 years ago

Hi,

You probably have this by now but if not, here it is.

Regards Gareth

On Fri, Dec 16, 2011 at 10:50 PM, surflibre < reply@reply.github.com

wrote:

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,


Reply to this email directly or view it on GitHub:

https://github.com/organicinternet/magento-configurable-simple/issues/41#issuecomment-3183713

eyecatchin.co.uk Web Design, Development and Internet Solutions. mobile: 07595 778097 web: www.eyecatchin.co.uk email: sales@eyecatchin.co.uk email: gareth.winterton@gmail.com

wintertong commented 12 years ago

Hi,

You probably have this by now but if not, here it is.

Regards Gareth

On Wed, Jan 4, 2012 at 6:46 AM, GirishAssudani < reply@reply.github.com

wrote:

the download link: http://baumanator.com/simple_configurable_products.zipdoesn'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...


Reply to this email directly or view it on GitHub:

https://github.com/organicinternet/magento-configurable-simple/issues/41#issuecomment-3351235

eyecatchin.co.uk Web Design, Development and Internet Solutions. mobile: 07595 778097 web: www.eyecatchin.co.uk email: sales@eyecatchin.co.uk email: gareth.winterton@gmail.com

surflibre commented 12 years ago

Hi,

....here it is ...? Where is it? Thx,

pbaum83 commented 12 years ago

Hey All,

I realize people have been wondering what happened to the file. My server had a hardware failure and I haven't gotten around to fixing it. Additionally, I have been doing a lot of work on the extension to make it usable with lots of traffic. The main problem is the install has become quite complex. After using the plugin on our site I found several bottle-necks that were causing the site to come to a crawl. This is mainly caused by the URL rewrites in Magneto. Please realize the code that is existing here may work, but is not very efficient when you have several thousand products. I worked on a cron job script and made changes to the way the cart works that enabled me to get this working for our high traffic site, but setting that up isn't simple and requires a lot of additional things. Performance is really awesome this way. better than the default magento install even, but I haven't come up with a solution that will work for Magento as it is default that doesn't use a cron job.

I will hopefully be able to release an update that has acceptable performance with scaling soon.

Regards, -Paul

wintertong commented 12 years ago

Thanks, I have it working ok and we have 20000 products.

Gareth Winterton Digital Manager www.standoutuk.com

On 3 Feb 2012, at 18:49, pbaum83reply@reply.github.com wrote:

Hey All,

I realize people have been wondering what happened to the file. My server had a hardware failure and I haven't gotten around to fixing it. Additionally, I have been doing a lot of work on the extension to make it usable with lots of traffic. The main problem is the install has become quite complex. After using the plugin on our site I found several bottle-necks that were causing the site to come to a crawl. This is mainly caused by the URL rewrites in Magneto. Please realize the code that is existing here may work, but is not very efficient when you have several thousand products. I worked on a cron job script and made changes to the way the cart works that enabled me to get this working for our high traffic site, but setting that up isn't simple and requires a lot of additional things. Performance is really awesome this way. better than the default magento install even, but I haven't come up with a solution that will work for Magento as it is default that doesn't use a cron job.

I will hopefully be able to release an update that has acceptable performance with scaling soon.

Regards, -Paul


Reply to this email directly or view it on GitHub: https://github.com/organicinternet/magento-configurable-simple/issues/41#issuecomment-3801983

Viroide commented 12 years ago

Hi & thanks!

It's running ok in the frontend but not in the backend or the mails. I have change de config.xml but stills continues without running.

Do anyone have a proper config.xml ??

digitaldisseny commented 12 years ago

Hi can say me where download the last patch? The link http://baumanator.com/simple_configurable_products.zip don't work.

Thanks!

jpomer commented 12 years ago

Helo

Please, I need the code patch but i don't know where download it.

I copy and paste the code for frontend and works fine but not with FILE custom fields.

Great patch!

Thanks

bombicri commented 12 years ago

I have SCP installed on Magento 1.6.2 and works great. The name and price are updated instantly in the main product page after making a selection. I need, near name of product, in catalog page as well as in main product page, to have SKU. The SKU of the configurable product is showing up now on these pages with:

    __('SKU')?>: htmlEscape($_product->getSku()) ?>
but after making the selection SKU is not updated with the SKU of the simple product selected. How to make the SKU to be apdated in the same way the name and price is?
bombicri commented 12 years ago

Is possible to have radio buttons instead of dropdown in SCP? Is possible to use with SCP the modification proposed in: http://inchoo.net/ecommerce/magento/configurable-product-modification-in-magento/? I am interested if someone tried it and if there are no conflicts. Thanks,

vincepettit commented 12 years ago

Just to let you know I've uploaded the patched zip file to http://www.mediafire.com/?815e0mhd43oldz9

surflibre commented 12 years ago

Hi Vince,

mage 1.5.1

I've tested your fix but my website crash when I add to cart :

a:5:{i:0;s:79:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'toto' in 'where clause'";i:1;s:6363:"#0 ...Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT title FR...', Array) .... OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item/Renderer.php(102) ...

toto is the value of the custom field "name" of my configurable product

Do you think it's serious Dr?

regards,

vincepettit commented 12 years ago

I can't take credit for the patch, I've simply uploaded it :)

Unfortunately it's actually been a while since I've worked with Magento so not too sure, sorry I can't be of help

surflibre commented 12 years ago

Hi vince,

Have you got an url for seeing this module working with your patch ? Have you got other modules in websites which could overwrite the functions of the module ?

Actually I work with this version : organicinternet-magento-configurable-simple-c137e4b 1.5.1 and 1.6.2 are ok. Custom option work if I configure them in the simple products. It's not appear on the product page, but after submiting the differents select options...a good start, but not finished.

regards,

spiralmind commented 12 years ago

Thanks this worked great, tho only problem is that you dont see the custom option in the client area when you view order or in the order email the customer receives, but you do see it in admin and the shopping cart. Any idea what to tweak to allow the custom option to show in email after order and also in clients area when viewing order..?

Thanks

surflibre commented 12 years ago

Hi, Yes, I can see the custom options in the email and in the account's order....no pb (I'have set the customs options in my simples products) regards,

AyyaduraiS commented 11 years ago

Hi, The Options is showing in cart and admin order page, But it is not displayed in order email. Please can anyone help me to fix this. Thanks is advance.

BigBlack commented 9 years ago

Hi guys, I've read all the discussioni, but still have some problems... These are my steps.. -Installed SCP

The option price were added but after selecting none it remain added...

Then downloaded this packet http://www.mediafire.com/?815e0mhd43oldz9 overwrited all my files in the root directory

Position of my custom option drop down changed.. It take the first position, but selecting them, no one add the price needed to total. In The cart, the price is without addition, but the option selected is visible...

Where's I'm wrong?

P.S. I've installed also the last packet 0.8.2 but it's the same...

jenithagile commented 7 years ago

Options is show in cart and admin order page, but not displayed in email. Anyone please Help.