My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 12 attachment: variation.rb (909 bytes)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Holds information about how the product varies.
#
class Variation < Item
belongs_to :product

#############################################################################
# CALLBACKS
#############################################################################

after_save :update_parent_quantity
def update_parent_quantity
self.product.update_attribute('variation_quantity', self.product.variations.sum('quantity'))
end

#############################################################################
# CLASS METHODS
#############################################################################

# References parent product images collection.
#
def images
self.product.images
end

# Display name...includes product name as well
def name
"#{self.product.name} - #{self.attributes['name']}"
end

def short_name
self.attributes['name']
end

end
Powered by Google Project Hosting