public static function getNewInstance(ProductList $productList, Product $product) { $instance = parent::getNewInstance(__CLASS__); $instance->productList->set($productList); $instance->product->set($product); return $instance; }
public static function getNewInstance(OrderedItem $item, ProductFile $file) { $instance = parent::getNewInstance(__CLASS__); $instance->orderedItem->set($item); $instance->productFile->set($file); return $instance; }
public function setUp() { parent::setUp(); ActiveRecordModel::executeUpdate('DELETE FROM ClonedStore'); $this->usd = ActiveRecordModel::getNewInstance('Currency'); $this->usd->setID('ZZZ'); $this->usd->save(ActiveRecord::PERFORM_INSERT); @unlink(ClonedStoreUpdater::getTimestampFile()); @unlink(ClonedStoreUpdater::getIDFile()); // create stores for ($k = 0; $k <= 0; $k++) { $this->stores[$k] = ClonedStore::getNewInstance(); $this->stores[$k]->domain->set($k); $this->stores[$k]->save(); echo $this->stores[$k]->lastImport->get(); } // create categories $root = Category::getRootNode(); for ($k = 0; $k <= 5; $k++) { $this->categories[] = $this->createCategory($root, $k); } $this->categories['1.1'] = $this->createCategory($this->categories[1], '1.1'); $this->categories['1.2'] = $this->createCategory($this->categories[1], '1.2'); $this->categories['1.2.1'] = $this->createCategory($this->categories['1.2'], '1.2.1'); $this->categories['1.2.2'] = $this->createCategory($this->categories['1.2'], '1.2.2'); usleep(1500000); }
public static function getNewInstance(OrderedItem $item, ProductOptionChoice $choice) { $instance = parent::getNewInstance(__CLASS__); $instance->orderedItem->set($item); $instance->choice->set($choice); return $instance; }
public static function getNewInstance($className, User $user, UserAddress $userAddress) { $instance = parent::getNewInstance($className); $instance->user->set($user); $instance->userAddress->set($userAddress); return $instance; }
public static function getNewInstance(CustomerOrder $order, $code) { $instance = parent::getNewInstance(__CLASS__); $instance->order->set($order); $instance->couponCode->set($code); return $instance; }
public static function getNewInstance($keywords, $ipAddress) { $instance = parent::getNewInstance(__CLASS__); $instance->keywords->set($keywords); $instance->ip->set(ip2long($ipAddress)); return $instance; }
public static function getNewInstance(CustomerOrder $order, User $user) { $instance = parent::getNewInstance(__CLASS__); $instance->order->set($order); $instance->user->set($user); return $instance; }
public static function getInstanceByIdentifier($stringIdentifier) { $instance = parent::getNewInstance(__CLASS__); $instance->classID->set(0); $instance->setStringIdentifier($stringIdentifier); return $instance; }
public static function getNewInstanceByUser(NewsletterMessage $message, User $user) { $instance = parent::getNewInstance(__CLASS__); $instance->message->set($message); $instance->user->set($user); return $instance; }
/** * Create new campaign */ public static function getNewInstance(Category $category, ClonedStore $store) { $instance = parent::getNewInstance(__CLASS__); $instance->category->set($category); $instance->store->set($store); return $instance; }
public static function getNewInstance(Product $product, ProductVariation $variation) { $instance = parent::getNewInstance(__CLASS__); $instance->product->set($product); $instance->variation->set($variation); return $instance; }
public static function getNewInstance(DiscountCondition $condition, $className = 'RuleActionPercentageDiscount') { $instance = parent::getNewInstance(__CLASS__); $instance->condition->set($condition); $instance->actionClass->set($className); return $instance; }
public static function getNewInstance(Category $category, Category $relatedCategory) { $instance = parent::getNewInstance(__CLASS__); $instance->category->set($category); $instance->relatedCategory->set($relatedCategory); return $instance; }
/** * Create new advertiser */ public static function getNewInstance(ClonedStore $store, $type) { $instance = parent::getNewInstance(__CLASS__); $instance->store->set($store); $instance->type->set($type); return $instance; }
public function testSimpleImport() { $lv = ActiveRecordModel::getNewInstance('Language'); $lv->setID('xx'); $lv->save(); $profile = new CsvImportProfile('Product'); $profile->setField(0, 'Product.sku'); $profile->setField(1, 'Product.name', array('language' => 'en')); $profile->setField(2, 'Product.name', array('language' => 'xx')); $profile->setField(3, 'Product.shippingWeight'); $profile->setParam('delimiter', ';'); $csvFile = ClassLoader::getRealPath('cache.') . 'testDataImport.csv'; file_put_contents($csvFile, 'test; "Test Product"; "Parbaudes Produkts"; 15' . "\n" . 'another; "Another Test"; "Vel Viens"; 12.44'); $import = new ProductImport($this->getApplication()); $csv = $profile->getCsvFile($csvFile); $cnt = $import->importFile($csv, $profile); $this->assertEquals($cnt, 2); $test = Product::getInstanceBySKU('test'); $this->assertTrue($test instanceof Product); $this->assertEquals($test->shippingWeight->get(), '15'); $this->assertEquals($test->getValueByLang('name', 'en'), 'Test Product'); $another = Product::getInstanceBySKU('another'); $this->assertEquals($another->getValueByLang('name', 'xx'), 'Vel Viens'); unlink($csvFile); }
public function save() { $validator = $this->createValidator(); if (!$validator->isValid()) { return new JSONResponse(array('errors' => $validator->getErrorList(), 'failure')); } if ($id = $this->request->get('id')) { $newsletter = ActiveRecordModel::getInstanceByID('NewsletterMessage', $id); } else { $newsletter = ActiveRecordModel::getNewInstance('NewsletterMessage'); } $format = $this->request->get('newsletter_' . $id . '_format'); if ($format == self::FORMAT_TEXT) { $this->request->set('html', ''); } else { if ($format == self::FORMAT_HTML) { $this->request->set('text', ''); } } $newsletter->loadRequestData($this->request); $newsletter->save(); if ($this->request->get('sendFlag')) { return $this->send($newsletter); } return new JSONResponse($newsletter->toArray()); }
public static function getNewInstance(Product $product, ProductRatingType $type = null) { $instance = parent::getNewInstance(__CLASS__); $instance->product->set($product); $instance->ratingType->set($type); return $instance; }
/** * Creates a new related product * * @param Product $product * @param Category $category * * @return ProductCategory */ public static function getNewInstance(Product $product, Category $category) { $instance = parent::getNewInstance(__CLASS__); $instance->product->set($product); $instance->category->set($category); return $instance; }
public static function getNewInstance(CustomerOrder $order, ExpressPayment $handler) { $instance = parent::getNewInstance(__CLASS__); $instance->order->set($order); $instance->method->set(get_class($handler)); return $instance; }
/** * Get anonymous user * @return User */ public function getAnonymousUser() { static $instance; if (!$instance) { $instance = ActiveRecordModel::getNewInstance('User'); $instance->setID(User::ANONYMOUS_USER_ID); } return $instance; }
/** * Create a new instance * * @return ShipmentTax */ public static function getNewInstance(TaxRate $taxRate, Shipment $shipment, $type) { $instance = ActiveRecordModel::getNewInstance(__CLASS__); $instance->taxRate->set($taxRate); $instance->shipment->set($shipment); $instance->type->set($type); $instance->recalculateAmount(null); return $instance; }
public static function getNewInstance($userID, $token) { $instance = parent::getNewInstance(__CLASS__); if (isset($userID)) { $instance->userID->set($userID); } $instance->token->set($token); $instance->dateCreated->set(new ARSerializableDateTime()); return $instance; }
public static function getNewInstance(Product $product, User $user) { $instance = parent::getNewInstance(__CLASS__); $instance->product->set($product); if ($user && $user->isAnonymous()) { $user = null; } $instance->user->set($user); return $instance; }
/** * Creates a new bundle relation * * @param Product $product * @param Product $relatedProduct * * @return ProductRelationship */ public static function getNewInstance(Product $product, Product $related) { if (null == $product || null == $related || $product === $related || $product->getID() == $related->getID()) { return null; } $relationship = parent::getNewInstance(__CLASS__); $relationship->product->set($product); $relationship->relatedProduct->set($related); return $relationship; }
public static function getNewInstance(ActiveRecordModel $parent) { $instance = parent::getNewInstance(__CLASS__); if ($parent instanceof Category) { $instance->category->set($parent); } else { $instance->product->set($parent); } return $instance; }
public static function getNewInstance(Product $product, Currency $currency, $recurring = null, $type = 0) { $instance = parent::getNewInstance(__CLASS__); $instance->product->set($product); $instance->currency->set($currency); $instance->type->set($type); if ($recurring != null) { $instance->recurring->set($recurring); } return $instance; }
/** * @role update */ public function save() { $validator = $this->buildValidator(); if (!$validator->isValid()) { return new JSONResponse(array('err' => $validator->getErrorList())); } $post = $this->request->get('id') ? ActiveRecordModel::getInstanceById('NewsPost', $this->request->get('id'), ActiveRecordModel::LOAD_DATA) : ActiveRecordModel::getNewInstance('NewsPost'); $post->loadRequestData($this->request); $post->save(); return new JSONResponse($post->toArray()); }
public static function getNewInstance(DiscountCondition $condition, ActiveRecordModel $record) { $instance = parent::getNewInstance(__CLASS__); $instance->condition->set($condition); $class = get_class($record); $field = strtolower(substr($class, 0, 1)) . substr($class, 1); if (!$instance->{$field}) { throw new ApplicationException($class . ' is not a valid instance for ' . __CLASS__); } $instance->{$field}->set($record); return $instance; }
/** * Create new user * * @param string $email Email * @param string $password Password * @param UserGroup $userGroup User group * * @return User */ public static function getNewInstance($email, $password = null, UserGroup $userGroup = null) { $instance = parent::getNewInstance(__CLASS__); $instance->email->set($email); $instance->dateCreated->set(new ARSerializableDateTime()); if ($userGroup) { $instance->userGroup->set($userGroup); } if ($password) { $instance->setPassword($password); } return $instance; }