| @@ 830-840 (lines=11) @@ | ||
| 827 | /** |
|
| 828 | * returns variation |
|
| 829 | */ |
|
| 830 | public function getVariation($id = 0) |
|
| 831 | { |
|
| 832 | $gateway = new Intraface_modules_product_Variation_Gateway($this); |
|
| 833 | if (intval($id) > 0) { |
|
| 834 | return $gateway->findById($id); |
|
| 835 | } |
|
| 836 | $object = $gateway->getObject(); |
|
| 837 | unset($gateway); |
|
| 838 | $object->product_id = $this->getId(); |
|
| 839 | return $object; |
|
| 840 | } |
|
| 841 | ||
| 842 | /** |
|
| 843 | * Returns variation on the basis of attributes |
|
| @@ 168-192 (lines=25) @@ | ||
| 165 | * |
|
| 166 | * @todo The variations should be loaded in the ProductGateway instead of here. |
|
| 167 | */ |
|
| 168 | public function getVariation($id = 0) |
|
| 169 | { |
|
| 170 | $gateway = new Intraface_modules_product_Variation_Gateway($this); |
|
| 171 | if (intval($id) > 0) { |
|
| 172 | return $gateway->findById($id); |
|
| 173 | } |
|
| 174 | $object = $gateway->getObject(); |
|
| 175 | unset($gateway); |
|
| 176 | $object->product_id = $this->getId(); |
|
| 177 | return $object; |
|
| 178 | ||
| 179 | /*if ($id != 0) { |
|
| 180 | foreach ($this->variation AS $variation) { |
|
| 181 | if ($variation->getId() == $id) { |
|
| 182 | return $variation; |
|
| 183 | } |
|
| 184 | } |
|
| 185 | throw new Exception('Unable to find variation with id '.$id); |
|
| 186 | } |
|
| 187 | ||
| 188 | $variation = $this->variation->get(NULL); // returns empty variation; |
|
| 189 | $variation->product_id = $this->getId(); |
|
| 190 | return $variation; |
|
| 191 | */ |
|
| 192 | } |
|
| 193 | ||
| 194 | /** |
|
| 195 | * Returns whether product is active |
|