Calculate Length in Custom Attribute Magento - magento

I'm killing myself trying to find the right solution for this problem. Here is my issue:
Selling Wires:
We will say a wire is $5.00
If you want 1 foot its $5.00
If you want 2 feet its $10.00
...
Each foot isn't a separate SKU. Its a recalculation of the total. Thats it. Really easy, but for some reason incredibly difficult in Magento.
How would I code this? Any ideas?
****UPDATE***
These are configurable products. Didn't think of that in the beginning.

One way to do this without adding additional attributes or logic is sell by the foot.
Have your SKU as wire-1-foot for example and use Magento's built-in tier pricing to customise your pricing for multiple quantities, aka multiple feet of wire.
You will probably also want to customise the block around the quantity field to make this a clearer for customers.
EDIT:
You could also consider grouped products as they behave slightly differently, e.g. http://www.webshopapps.com/blog/2010/11/tiered-pricing-on-configurable-products/

Related

One large attribute set or many smaller ones?

I have about 100 special attributes in the default attribute set.
Would I have better or worse performances if I would create about 200 attribute sets (nearly one for each category) and spread the special attributes in those?
Knowing that one special attribute may be in 1 or many attribute sets.
Did someone already made a benchmark for this, or the changes on the performances of the application would be insignificant?
Thank you.
You need to think about the information architecture of your site so that it is efficient and befitting your products. Some consideration is also needed for how you get your data into the database.
For instance, say you sold clothes. You could have different attributes for size, e.g. 'shoe size', 'waist size', 'glove size', 'collar size' and so on. You could then make different attribute sets for 'shoes' where you would just have the 'shoe size' attribute and not the other 'size' attributes. You could also have a 'shoe width' attribute on the 'shoe' attribute set. This would give you fine control over the presentation of the product on the front end, however, when importing data from some supplier CSV you would need to make sure that the attribute set was imported/set too. This may not be operationally sensible if importing thousands of sku's, some of which are shoes, some of which are coats etc.
Some catalogues just have the one attribute set and just the one 'size' attribute, this becomes hard to manage if there are lots of sizes, e.g. trousers can come in lots of lengths and widths and you need attributes like '32W 32L', '32W 34L' and so on, bulking up the attribute option values.
Once you get too many attribute option values it becomes impossible to change/amend them in admin and it becomes impractical to list them in the front end. Performance problems in terms of loading the catalogue can be mitigated against by Magento tricks, e.g. cache, however, if it is operationally possible to use as many attribute sets as are needed to model your products in the best way, then go for it, the pay off will be in improved performance.
There is also a side benefit in that if you do have lots of attribute sets then you can send layout handles to the front end based on attribute set. For instance, if you wanted to show a size guide then you could base that off the attribute set, so 'shirts' would have a different guide to 'shoes'. (In reality you would probably want to make size guides brand specific, but shipping, returns policy and other product content could change based on attribute set as far as front end presentation is concerned).

Magento - How to only allow one free product in a basket

The shop I'm working on sells desks. We also sell pens.
If you buy a Desk, I'd like to give you a pen for free. any further pens you add to your basket need to be paid for.
Currently, I have a Shopping Basket price rule that says the following:
CONDITIONS:
If an item is found in the cart with All of these conditions true:
Category is 3 (desk category)
Apply percent of product price discount: 100%
ACTIONS:
If All of these conditions are true:
SKU is one of pen1, pen2, pen3, etc...
I only ever want one free item in the basket though. I've tried just about every combination of conditions I can think of, but the simple fact is that Magento does not have an XOR or "run this action only once" condition.
I've even tried setting up three identical price rules, one for each pen, with "Stop further rules processing" set to "Yes". Each rule still processes in turn.
The closest I've come is adding a condition that says
If total quantity is 1 for a subselection of items in cart matching ANY of these conditions:
SKU is one of pen1, pen2, pen3
This condition allows one free pen in the basket, but removed the discount entirely if a second pen is added to the basket.
Can you improve on this rule?
It's not perfect, but I've got something that works for me.
I'm adding one rule per free pen. Each rule has an exclusion clause on it that says
If an item is NOT FOUND in the cart with ANY of these conditions true:
SKU is one of: pen1, pen2, pen3
It takes some playing with, and it's too complicated to run with any really complicated promotion, but it works for short, simple promotions. After much research I honestly think it's the best way of doing this in Magento.

How to stop magento from removing tiers that are more than or equal to the default price?

In magento i have my tiers set like so...
Regular Price: £8.99
Special Price: £3.75
Tiers
Buy 5-9 for £3.22 each
Buy 10-19 for £3.22 each
Buy 20-49 for £3.22 each
Buy 50-99 for £2.80 each
Buy 100 for £2.58 each
100+ Call For Pricing
With a minimum quantity set at 5 and also the regular and special price reflecting a qty > of 5.
The problem with the above being magento hides my first two tiers.
After debugging it i have found magento hides any tiers that are more than or equal to the default price / special price.
So i suppose my question is how do i stop magento from removing the tiers that are more than or equal to the price.
Thanks
Use $_tierPrices = $_product->getData('tier_price');
All of your tiers appear to be lower than the special price. Is that a typo?
Either way I think you need to look in the /app/code/core/Mage/Catalog/Model/Product/Type/Price.php file. Specifically in the getTierPrice() function.
That is pretty much where all the magic happens (and where your prices are being removed). You may have to make changes in 2 spots in this function as part of it is used for the product page and the other for the checkout process.

Solution for Magento mass actions and large number of records problem?

Currently Magento has a problem with the way it handles mass actions. It returns a bit of JS that contains EVERY db id for the current collection and filter, regardless of pagination. This is to support the 'Select All' vs. 'Select All Visible' option in the grid header. This isn't such a problem when you have a smaller number of records, but if you have 850k records (orders in this case) it becomes a serious problem.
My question is, does anyone have an elegant solution to this problem?
I can think of several solutions, each with its own drawbacks, but I'm hoping someone has solved this in a simple manner that works as an add-on module. Paid or Open-Source solutions are both welcome suggestions.
Clarification:
I'm looking for an elegant/drop-in solution to the problem of 850k+ records using the grid widget in Magento. The stock Magento code makes the bone headed decision to return the id for every record that is matched by the current filter, even if they are not being displayed. This is not about offline processing of records, it's about using the grid widget for daily admin tasks.
One possible solution would be to store the results of the filtered search in a temp table and return a reference to the search result. Then you could change it from using the actual ids on a 'Select All' to using a specific callback for the action using the reference. This would preserve the current behavior.
So, to ask again, does anyone have a good solution to this already created?
I'm running heavy operations from within a shell script. I have a generic iterator (in my case products, but can be done with everything else), and I only implement a class that does the action on the product. My product_iterator shell script takes care of looping over the products, while processing only x products at once (to avoid memory leaks).
Well, the least invasive solution to the problem is to turn off the 'Select All' option for grids with large numbers of records. This is easily accomplished by extending the grid class and adding the following code:
protected function _prepareMassaction()
{
$this->getMassactionBlock()->setUseSelectAll(false);
return parent::_prepareMassaction();
}
I think that fbmc has the right general approach. Clearly, even if you did find a way to send back all 850k records, the framework would have a heart attack attempting to deal with them all. Run the logic in a shell script if this is what you need. For some jobs, you may even need to run them in batches or move down to actual SQL logic.
Unfortunately, some parts of the framework were not made to handle this kind of scale. You've found one of them.
Hope that helps!
Thanks,
Joe
Recently i have written an article about 'Adding new mass action to admin grid in Magento',
Hopefully you will like it:
http://www.blog.magepsycho.com/adding-new-mass-action-to-admin-grid-in-magento/
It describes the two way for adding Mass Action
1> Extending Grid Layouts _prepareMassaction() method
2> Using event: core_block_abstract_prepare_layout_before (more upgrade proof way)
Thanks
Regards

Tag/Keyword based recommendation

I am wondering what algorithm would be clever to use for a tag driven e-commerce enviroment:
Each item has several tags. IE:
Item name: "Metallica - Black Album CD", Tags: "metallica", "black-album", "rock", "music"
Each user has several tags and friends(other users) bound to
them. IE:
Username: "testguy", Interests: "python", "rock", "metal", "computer-science"
Friends: "testguy2", "testguy3"
I need to generate recommendations to such users by checking their interest tags and generating recommendations in a sophisticated way.
Ideas:
A Hybrid recommendation algorithm can be used as each user has friends.(mixture of collaborative + context based recommendations).
Maybe using user tags, similar users (peers) can be found to generate recommendations.
Maybe directly matching tags between users and items via tags.
Any suggestion is welcome. Any python based library is also welcome as I will be doing this experimental engine on python language.
1) Weight your tags.
Tags fall into several groups of interest:
My tags that none of my friends share
Tags a number of my friends share, but I don't
My tags that are shared by a number of my friends.
(sometimes you may want to consider friend-of-a-friend tags too, but in my experience the effort hasn't been worth it. YMMV.)
Identify all tags that the person and/or the person's friends have in interests, and attach a weight to the tags for this individual. One simple possible formula for tag weight is
(tag_is_in_my_list) * 2 + (friends_with_tag)/(number_of_friends)
Note the magic number 2, which makes your own opinion worth twice as much as that of all of your friends put together. Feel free to tweak :-)
2) Weight your items
For each item that has any of the tags in your list, just add up all of the weighted values of the tags. A higher value = more interest.
3) Apply a threshold.
The simplest way is to show the user the top n results.
More sophisticated systems also apply anti-tags (i.e. topics of non-interest) and do many other things, but I have found this simple formula effective and quick.
If you can, track down a copy of O'Reilly's Programming Collective Intelligence, by Toby Segaran. There's a model solution in it for exactly this problem (with a whole bunch of really, really good other stuff).
Your problem is similar to product recommendation engines, such as Amazon's well publicized site. These use a learning algorithm called association rules, which basically build a conditional probability of user X buying product Y based on common features Z between the user and product. A lot of open source toolkits implement association rules, such as Orange and Weka.
You can use the Python Semantic module for Drools to specify your rules in python scripting language. You can accomplish this easily using Drools. It is a terrific rules engine that we used to solve several recommendation engines.
I would use a Restricted Boltzmann Machine. Gets around the problem of similar but not identical tags quite neatly.

Resources