I have a Magento shop with 2 simple products
Great Red Cup
Great Blue Cup
and a configurable product
Great Cup
with those cups assigned.
The Red and Blue cups are visible in the search.
If the use clicks one of those simple products, the configurable product should be opened instead, but the right color should be preselected.
I am aware that a simple product can be assigned to multiple configurable products, so I would log an exception if two matching configurable products are found an just take the first one.
I think I have to catch the predispatch event of catalog/product/view and somehow replace the simple product by the configurable one.
How can I now pre-configure the right simple product one?
Is there an elegant solution for this?
I found a solution:
register observer on controller_action_predispatch_catalog_product_view
check if we have a simple product with a parent that is a configurable product
create a array that contains the configuration data of the simple product
pass this data to Mage::helper('catalog/product_view')->prepareAndRender() (third parameter)
stop dispatching by setting the FLAG_NO_DISPATCH on the front action
Full code is available in the Mestrona_ForwardToConfigurable module on github.
To preselect a simple product in a configurable product, the address of a simple product should look like this for example:
/mona-pullover-hoodlie.html#143=167&93=53
where
/mona-pullover-hoodlie.html - configurable product URL
143, 93 - attribute IDs
167, 53 - option IDs.
In order to change the URL of simple products, you can create a Plugin (Interceptor) for Magento\Catalog\Model\Product::getProductUrl(), where to generate the URL as in the example above.
Product selection using URL parameters from example above is already implemented in Magento out of the box.
I made VCT Simple Product URl module on Magento Marketplace that solves this problem with the choice of the first configurable product if there are several.
One idea would be to redirect to the configurable product if the simple products meets somes requirements :
have a new attribute "should_redirect_to_parent" to True (optionnal)
have at least a parent product (for that point, I let you follow the link of Alex)
ps: if you don't want to do a parent product lookup you could add a new attribute like "redirect_sku" or "redirect_product_id" in order to directly make a redirection on that product
For the redirection you should use the event catalog_controller_product_init_after and if the two previous conditions match you redirect the user to the configurable product.
ps: for performance optimisation, you could use instead the catalog_controller_product_init_before which would save an expansive and useless Product::load() but it requires that you build custom SQL queries to search for a parent product
Tell if you want some code examples
Related
I am not a coder, and I am working for a company involved in e-commerce activities, so please help me!
Currently we are looking to merge two different aspects of the business, where we will have the other company arms website detailing the product variations (i.e. Product A in sizes 1, 2, 3 and 4) on their page as separate enteries as part of their mission driven section, which link directly to our product page.
The issue we have is, on our website we have a drop down menu, and what we want to achieve is for the when the visitor selects the buy on the product page for Product A in Size 2 it links directly to our ecommerce page with a pre filled in drop down menu for that exact product selection.
Does anyone know how we could achieve this in Magento? Could this be done in custom URLs?
Thanks in advance!!
To preselect a simple product in a configurable product, the address of a simple product should look like this for example:
/mona-pullover-hoodlie.html#143=167&93=53
where /mona-pullover-hoodlie.html - configurable product URL,
143, 93 - attributes IDs,
167, 53 - option IDs.
In order to change the URL of simple products, you can create a Plugin (Interceptor) for Magento\Catalog\Model\Product::getProductUrl(), where to generate the URL as in the example above.
I made VCT Simple Product URL module on Magento Marketplace that solves this problem.
This is a very similar question to this:
Preselect configurable product options by simple product URL
But the important part of the answer just points to a dead link.
There are a million pages that explain how to get the configurable product from the simple product, but not the configurable product with the options set to what would produce the simple product.
I need this for a couple areas. First, there's a section of the site that will programatically add the product to the cart based on SKU. It finds the simple product via SKU, and I can get its parent product, but I can't add that to the cart with the options that will point it to the simple product.
Secondly, I need the link that's generated for the simple product to show the page for it's configurable product, with the appropriate options selected since we're generating links for an external service that gets the links to all the simple product pages which are currently disabled.
I've looked everywhere but can't find how to get the configurable product options selected.
Hi we are using magento for a wholesale site, in which every product can be ordered in two ways:
1)carton(small-box)
2)Pallet(larger-one)
Now as per magento rules we achieved the same by creating a bundle product for each product, but in doing so we need to add 3-products for a single product, also the SKU is actually the same for all!
Is there any better solution to this other than bundle?
I tried with the configurable option too, but same problem of adding 3-products for a single product.
Thanks.
Creating a bundle product is the correct way to deal with this. In your case, the carton and the pallet are two separate products (from Magento's point of view).
I created a configurable product and went to the associated products tab and used the quick create product feature to create a bunch of products based on my configurations. However non of these products appear in the list of associated products.
I noticed that the attributes I created don't even show up on the edit product page, on either the simple, or the configurable product.
I started first by creating 3 new attributes for a configurable product I want to add, I setup the options for each one and created a new attribute set based on default that included the new attributes I created.
When I create a new simple product or configurable product, you cannot see the attributes I have created. I have tried with the attributes in the general tab as well as on their own tab. But they are never visible when you try to edit the product.
I'm suspecting the reason I can't associate the products is due to this strange problem
I'm using 1.4.2
[edited to add my work flow/screen grabs]
http://www.buggyonpurpose.com/magento/configurable_products/01-attirubte_set.png
http://www.buggyonpurpose.com/magento/configurable_products/02-create_configurable.png
http://www.buggyonpurpose.com/magento/configurable_products/03-setup_configurable.png
http://www.buggyonpurpose.com/magento/configurable_products/04-quick_create.png
http://www.buggyonpurpose.com/magento/configurable_products/05-associate_product.png
http://www.buggyonpurpose.com/magento/configurable_products/06-manage_products.png
http://www.buggyonpurpose.com/magento/configurable_products/07-edit_product.png
It took a while but finally figured it out. When I created my attributes, in Attribute Properties where it says "Apply To:" I had only assigned it to configurable products, but you must also assign to simple products as well. (or just apply to all)
Keep in mind you will have to recreate your original configurable product before it will work.
Assuming you have created attributes with options and attribute set.
Can you please createConfigurable product again
Manage products -> Add Product select your default attribute set and Configurable product option.
The next window will be to choose the attributes that you have have created.
Lets say that there are three attributes color, fragrance, and volume as three different attributes and you pick fragrance here to associate the Configurables to the simples which you will be creating.
After you successfully created the Configurable product.
Create simple products based on the same attribute set default
you must be able to see all the attributes you created(color, fragrance, and volume).
Please pick any option for the Fragrance attribute.
Go to the Manage Products ->select to edit the Configurable product you have just created.
Go to the "Associated Products" tab and select "Any" from the drop down on the extreme left.
You must be able to see the Simple which you have created now
you must also be able to see the parent-child linking attribute "fragrance" present above the grid of products.
Make sure the simple is in "In stock" before you see whether they appear in front end.
Its not necessary for the attribute to appear in the Configurable product edit page.
Follow the above steps, hope it will guide you.
Please let me know if you unable to follow any of the above steps.
You can also read the below link, which is very useful to create a config product.
http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-configurable-product/
Cheers
I had the same issue.
A possible workaround is to add the attributes in the single products and after they become available through the configurable product at "Apply To:".
Actually i am using Elias_configurablebundle plugin for the configurable product as associated of the Bundle Product and to display GRID* for the configurable associated products i am using magento mechanics grid. here i have merged both of the extensions it showing GRID on bundle view page but showing Please specify the product's option(s)* on click of the **Add To Cart.
Although everything is fine, no required field left to fill out, i have applied any single custom options for any of the product.
so here i want to remove this validation so then it will directly redirect to shopping cart page.
Thanks
Configurable products need to have their options chosen (say, color or size) in order to be added to the cart. Otherwise, there is no way to decide which simple product should be decremented from the inventory. So there is no way for you to "skip" selecting this information, other than hardcoding the selections for the configurable product.
If you do that, just use the simple products instead, and skip all the headache.
Thanks,
Joe
Another thing to check is that the options fields are actually inside the tags. Its fairly easy in Magento to move the option selects to a different column and not realize that you are moving them outside the add to cart form tags.
if the options are selected outside the form tags, then as far as the form is concerned no options have been selected.
Hope this helps someone down the road.