/** * 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; }
/** * 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; }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
public static function getNewInstance(Category $category) { $instance = parent::getNewInstance(__CLASS__); $instance->category->set($category); return $instance; }
/** * Get new instance of FilterGroup record * * @return ActiveRecord */ public static function getNewInstance(SpecField $specField) { $inst = parent::getNewInstance(__CLASS__); $inst->specField->set($specField); return $inst; }
/** * 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; }
public static function getNewInstance(ProductVariationType $type) { $instance = parent::getNewInstance(__CLASS__); $instance->type->set($type); return $instance; }
public static function getNewInstance() { return parent::getNewInstance(__CLASS__); }
/** * 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; }
public static function getNewInstance($className, $sourceFilePath, $fileName, $pathOrUrl = null) { $fileInstance = parent::getNewInstance($className); $fileInstance->storeFile($sourceFilePath, $fileName, $pathOrUrl); return $fileInstance; }
public static function getNewInstance(Product $product) { $instance = parent::getNewInstance(__CLASS__); $instance->product->set($product); return $instance; }