Ejemplo n.º 1
0
 /**
  * Get a new EavFieldCommon instance
  *
  * @param string $className Instance class name
  * @param int $dataType Data type code (ex: self::DATATYPE_TEXT)
  * @param int $type Field type code (ex: self::TYPE_TEXT_SIMPLE)
  *
  * @return  EavFieldCommon
  */
 public static function getNewInstance($className, $dataType = false, $type = false)
 {
     $field = parent::getNewInstance($className);
     if ($dataType) {
         $field->dataType->set($dataType);
         $field->type->set($type);
     }
     return $field;
 }
Ejemplo n.º 2
0
 /**
  *  Get new instance of specification field value
  *
  *	@param SpecField $field Instance of SpecField (must be a selector field)
  *  @return SpecFieldValue
  */
 public static function getNewInstance($className, EavFieldCommon $field)
 {
     if (!in_array($field->type->get(), array(EavFieldCommon::TYPE_NUMBERS_SELECTOR, EavFieldCommon::TYPE_TEXT_SELECTOR))) {
         throw new Exception('Cannot create a ' . $className . ' for non-selector field!');
     }
     $instance = parent::getNewInstance($className);
     $instance->getField()->set($field);
     return $instance;
 }
Ejemplo n.º 3
0
 /**
  * Create new shipping service
  *
  * @param DeliveryZone $deliveryZone Delivery zone
  * @param string $defaultLanguageName Service name in default language
  * @param integer $calculationCriteria Shipping price calculation criteria. 0 for weight based calculations, 1 for subtotal based calculations
  * @return ShippingService
  */
 public static function getNewInstance(DeliveryZone $deliveryZone = null, $defaultLanguageName, $calculationCriteria)
 {
     $instance = parent::getNewInstance(__CLASS__);
     if ($deliveryZone) {
         $instance->deliveryZone->set($deliveryZone);
     }
     $instance->setValueByLang('name', null, $defaultLanguageName);
     $instance->rangeType->set($calculationCriteria);
     return $instance;
 }
Ejemplo n.º 4
0
 public static function getNewInstance(CustomerOrder $order, Product $product, $count = 1)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->customerOrder->set($order);
     $instance->product->set($product);
     $instance->count->set($count);
     if ($order->isFinalized->get()) {
         $instance->price->set($instance->getItemPrice(false));
     }
     return $instance;
 }
Ejemplo n.º 5
0
 /**
  * Creates a new option instance
  *
  * @param Category $category
  *
  * @return Product
  */
 public static function getNewInstance(ActiveRecordModel $parent)
 {
     $option = parent::getNewInstance(__CLASS__);
     if ($parent instanceof Product) {
         $option->product->set($parent);
     } else {
         if ($parent instanceof Category) {
             $option->category->set($parent);
         } else {
             throw new ApplicationException('ProductOption parent must be either Product or Category');
         }
     }
     return $option;
 }
Ejemplo n.º 6
0
 /**
  * Creates a new product instance
  *
  * @param Category $category
  *
  * @return Product
  */
 public static function getNewInstance(Category $category, $name = '')
 {
     $product = parent::getNewInstance(__CLASS__);
     $product->category->set($category);
     $product->setValueByLang('name', null, $name);
     return $product;
 }
Ejemplo n.º 7
0
 public static function getNewInstance(Category $category)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->category->set($category);
     return $instance;
 }
Ejemplo n.º 8
0
 /**
  * Get new instance of FilterGroup record
  *
  * @return ActiveRecord
  */
 public static function getNewInstance(SpecField $specField)
 {
     $inst = parent::getNewInstance(__CLASS__);
     $inst->specField->set($specField);
     return $inst;
 }
Ejemplo n.º 9
0
 /**
  * Creates a new option instance that is assigned to a category
  *
  * @param Category $category
  *
  * @return Product
  */
 public static function getNewInstance(ProductOption $option)
 {
     $choice = parent::getNewInstance(__CLASS__);
     $choice->option->set($option);
     return $choice;
 }
Ejemplo n.º 10
0
 public static function getNewInstance(ProductVariationType $type)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->type->set($type);
     return $instance;
 }
Ejemplo n.º 11
0
 public static function getNewInstance()
 {
     return parent::getNewInstance(__CLASS__);
 }
Ejemplo n.º 12
0
 /**
  * Get new instance of Filter active record
  *
  * @return Filter
  */
 public static function getNewInstance(FilterGroup $filterGroup)
 {
     $inst = parent::getNewInstance(__CLASS__);
     $inst->filterGroup->set($filterGroup);
     return $inst;
 }
Ejemplo n.º 13
0
 public static function getNewInstance($className, $sourceFilePath, $fileName, $pathOrUrl = null)
 {
     $fileInstance = parent::getNewInstance($className);
     $fileInstance->storeFile($sourceFilePath, $fileName, $pathOrUrl);
     return $fileInstance;
 }
Ejemplo n.º 14
0
 public static function getNewInstance(Product $product)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->product->set($product);
     return $instance;
 }