예제 #1
0
 public static function load($thing)
 {
     $product = new Product();
     $product->thing = $thing;
     //members
     $fields_raw = $product->thing->getData();
     $tmpFields = array();
     foreach ($fields_raw as $field) {
         $tmpFields[$field->getKey()] = $field;
     }
     $product->fields = $tmpFields;
     //variants
     $thingVariants = $product->thing->getChildThings("variant");
     $variants = array();
     foreach ($thingVariants as $thingVariant) {
         $variants[] = Variant::load($thingVariant);
     }
     $product->variants = $variants;
     //options
     $thingOptions = $product->thing->getChildThings("option");
     $options = array();
     foreach ($thingOptions as $thingOptions) {
         $options[] = Option::load($thingOptions);
     }
     $product->options = $options;
     return $product;
 }
예제 #2
0
 public function getByProduct($product)
 {
     $this->db->select();
     $this->db->from('thing');
     $this->db->where('thing_id', $product->getThing()->getId());
     $query = $this->db->get();
     $thingOptions = array();
     foreach ($query->result() as $row) {
         $thingOptions[] = Thing::loadFromRow($row);
     }
     //get options
     $options = array();
     foreach ($thingOptions as $thingOptions) {
         $options[] = Option::load($thingOptions);
     }
     return $options;
 }