public static function restoreInstance($className, ActiveRecordModel $owner, EavFieldCommon $field, $value)
 {
     $specItem = parent::getInstanceByID($className, array(call_user_func(array($className, 'getOwnerIDColumnName')) => $owner->getID(), call_user_func(array($className, 'getFieldIDColumnName')) => $field->getID()));
     $specItem->value->set($value);
     $specItem->resetModifiedStatus();
     return $specItem;
 }
 protected function save(ActiveRecordModel $listGroup)
 {
     $validator = $this->buildValidator();
     if ($validator->isValid()) {
         $listGroup->loadRequestData($this->request);
         $listGroup->save();
         return new JSONResponse(array('ID' => $listGroup->getID(), 'data' => $listGroup->toArray()), 'success');
     } else {
         return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure');
     }
 }
예제 #3
0
 public static function getNewInstance(Product $product, ProductVariation $variation)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->product->set($product);
     $instance->variation->set($variation);
     return $instance;
 }
예제 #4
0
파일: OrderNote.php 프로젝트: saiber/www
 public static function getNewInstance(CustomerOrder $order, User $user)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->order->set($order);
     $instance->user->set($user);
     return $instance;
 }
예제 #5
0
 /**
  * Create new advertiser
  */
 public static function getNewInstance(ClonedStore $store, $type)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->store->set($store);
     $instance->type->set($type);
     return $instance;
 }
예제 #6
0
 public function filter($emptyListIsException = false)
 {
     $request = $this->application->getRequest();
     $parser = $this->getParser();
     $apiFieldNames = $parser->getApiFieldNames();
     $parser->loadDataInRequest($request);
     $f = new ARSelectFilter();
     $id = $request->get('ID');
     if (!empty($id)) {
         $f->mergeCondition(new EqualsCond(new ARFieldHandle('ProductVariation', 'ID'), $id));
     } else {
         throw new Exception('Product variation ID is required');
     }
     $product_variations = ActiveRecordModel::getRecordSetArray('ProductVariation', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($emptyListIsException && count($product_variations) == 0) {
         throw new Exception('Product variation not found');
     }
     while ($variation = array_shift($product_variations)) {
         $xml = $response->addChild('product_variation');
         foreach ($variation as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xml->addChild($k, $v);
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
예제 #7
0
 public function setUp()
 {
     parent::setUp();
     $this->controller = new EavFieldController(self::getApplication());
     ActiveRecordModel::executeUpdate('DELETE FROM EavField');
     ActiveRecordModel::executeUpdate('DELETE FROM EavFieldGroup');
 }
예제 #8
0
 public function getUrl()
 {
     $params = array();
     // user name
     $params['merchant'] = $this->getConfigValue('merchant');
     if ($this->getConfigValue('test')) {
         $params['test'] = 'yes';
     }
     // A seller reference number for a transaction
     $params['orderid'] = $this->details->invoiceID->get();
     $params['uniqueoid'] = $this->details->invoiceID->get();
     // The payment amount
     $params['amount'] = $this->details->amount->get() * 100;
     // The currency code of the payment amount.
     $params['currency'] = $this->getCurrency($this->details->currency->get());
     //$this->notifyUrl = preg_replace('/currency\=[A-Z]{3}/', '', $this->notifyUrl);
     $params['callbackurl'] = $this->notifyUrl;
     $params['accepturl'] = $this->returnUrl;
     $params['cancelurl'] = $this->siteUrl;
     $params['lang'] = ActiveRecordModel::getApplication()->getLocaleCode();
     $params['skiplastpage'] = 1;
     $params['md5key'] = $this->getMd5Key($params);
     $pairs = array();
     foreach ($params as $key => $value) {
         $pairs[] = $key . '=' . urlencode($value);
     }
     return 'https://payment.architrade.com/paymentweb/start.action?' . implode('&', $pairs);
 }
예제 #9
0
 public function index()
 {
     $this->addIndexBreadCrumb();
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('NewsPost', 'isEnabled'), true));
     $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC');
     return new ActionResponse('news', ActiveRecordModel::getRecordSetArray('NewsPost', $f));
 }
예제 #10
0
 protected function getInstance($record, CsvImportProfile $profile)
 {
     $fields = $profile->getSortedFields();
     if (isset($fields['ProductReview']['ID'])) {
         $instance = ActiveRecordModel::getInstanceByID('ProductReview', $record[$fields['ProductReview']['ID']], true);
     } else {
         if (isset($fields['Product']['ID'])) {
             $parent = ActiveRecordModel::getInstanceByID('Product', $record[$fields['Product']['ID']], true);
         } else {
             if (isset($fields['Product']['sku'])) {
                 $parent = Product::getInstanceBySku($record[$fields['Product']['sku']]);
             } else {
                 return;
             }
         }
     }
     if (empty($instance) && empty($parent)) {
         return;
     }
     if (empty($instance)) {
         $instance = ProductReview::getNewInstance($parent, User::getNewInstance(''));
         $instance->isEnabled->set(true);
     }
     return $instance;
 }
예제 #11
0
 public function filter($emptyListIsException = false)
 {
     $request = $this->application->getRequest();
     $parser = $this->getParser();
     $apiFieldNames = $parser->getApiFieldNames();
     $parser->loadDataInRequest($request);
     $f = new ARSelectFilter();
     $ID = $request->get('ID');
     if (!empty($countryID)) {
         $f->mergeCondition(new EqualsCond(new ARFieldHandle('DeliveryZoneCountry', 'ID'), $ID));
     }
     $countryZones = ActiveRecordModel::getRecordSetArray('DeliveryZoneCountry', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($emptyListIsException && count($countryZones) == 0) {
         throw new Exception('DeliveryZoneCountry not found');
     }
     while ($country_zone = array_shift($countryZones)) {
         $xmlCountryZone = $response->addChild('delivery_zone_country');
         foreach ($country_zone as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xmlCountryZone->addChild($k, $v);
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
예제 #12
0
 public function index()
 {
     // get filter to select manufacturers of active products only
     $rootCat = Category::getRootNode();
     $f = new ARSelectFilter();
     $productFilter = new ProductFilter($rootCat, $f);
     $ids = $counts = array();
     foreach (ActiveRecordModel::getDataBySQL('SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID') as $row) {
         $ids[] = $row['manufacturerID'];
         $counts[$row['manufacturerID']] = $row['cnt'];
     }
     $f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids));
     $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
     $f->setOrder(new ARFieldHandle('Manufacturer', 'name'));
     $manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', $f);
     foreach ($manufacturers as &$manufacturer) {
         $manufacturer['url'] = $this->getManufacturerFilterUrl($manufacturer);
     }
     $this->addBreadCrumb($this->translate('_manufacturers'), '');
     $response = new ActionResponse();
     $response->setReference('manufacturers', $manufacturers);
     $response->set('counts', $counts);
     $response->set('rootCat', $rootCat->toArray());
     return $response;
 }
예제 #13
0
 /**
  * Reorder pages
  *
  * @role sort
  */
 public function reorder()
 {
     $inst = StaticPage::getInstanceById($this->request->get('id'), StaticPage::LOAD_DATA);
     $f = new ARSelectFilter();
     $handle = new ARFieldHandle('StaticPage', 'position');
     if ('down' == $this->request->get('order')) {
         $f->setCondition(new MoreThanCond($handle, $inst->position->get()));
         $f->setOrder($handle, 'ASC');
     } else {
         $f->setCondition(new LessThanCond($handle, $inst->position->get()));
         $f->setOrder($handle, 'DESC');
     }
     $f->setLimit(1);
     $s = ActiveRecordModel::getRecordSet('StaticPage', $f);
     if ($s->size()) {
         $pos = $inst->position->get();
         $replace = $s->get(0);
         $inst->position->set($replace->position->get());
         $replace->position->set($pos);
         $inst->save();
         $replace->save();
         return new JSONResponse(array('id' => $inst->getID(), 'order' => $this->request->get('order')), 'success');
     } else {
         return new JSONResponse(false, 'failure', $this->translate('_could_not_reorder_pages'));
     }
 }
예제 #14
0
 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);
 }
예제 #15
0
 public static function getNewInstance(OrderedItem $item, ProductFile $file)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->orderedItem->set($item);
     $instance->productFile->set($file);
     return $instance;
 }
 public function testClone()
 {
     $text = EavField::getNewInstance('User', EavField::DATATYPE_TEXT, EavField::TYPE_TEXT_SIMPLE);
     $text->save();
     $singleSel = EavField::getNewInstance('User', EavField::DATATYPE_NUMBERS, EavField::TYPE_NUMBERS_SELECTOR);
     $singleSel->handle->set('single.sel');
     $singleSel->setValueByLang('name', 'en', 'Select one value');
     $singleSel->save();
     $value1 = EavValue::getNewInstance($singleSel);
     $value1->setValueByLang('value', 'en', $firstValue = '20');
     $value1->save();
     $value2 = EavValue::getNewInstance($singleSel);
     $value2->setValueByLang('value', 'en', $secValue = '30');
     $value2->save();
     $user = User::getNewInstance('*****@*****.**');
     $user->save();
     $spec = $user->getSpecification();
     $spec->setAttributeValueByLang($text, 'en', 'text');
     $spec->setAttributeValue($singleSel, $value1);
     $user->save();
     $cloned = clone $user;
     $cloned->email->set('*****@*****.**');
     $cloned->save();
     $this->assertNotSame($cloned->getSpecification(), $user->getSpecification());
     $this->assertEquals($cloned->getSpecification()->getAttribute($text)->getValueByLang('value', 'en'), 'text');
     ActiveRecordModel::clearPool();
     $reloaded = ActiveRecordModel::getInstanceByID('User', $cloned->getID(), true);
     $this->assertEquals($reloaded->getSpecification()->getAttribute($text)->getValueByLang('value', 'en'), 'text');
     $this->assertEquals($reloaded->getSpecification()->getAttribute($singleSel)->getValue()->get()->getID(), $value1->getID());
 }
예제 #17
0
 public function getNumber()
 {
     $config = ActiveRecordModel::getApplication()->getConfig();
     $startAt = $config->get('SequentialInvoiceNumber_START_AT');
     $prefix = $config->get('SequentialInvoiceNumber_PREFIX');
     $suffix = $config->get('SequentialInvoiceNumber_SUFFIX');
     // get last finalized order
     $last = array_pop(ActiveRecord::getRecordSetArray('CustomerOrder', $this->getSelectFilter()));
     $lastNumber = $last ? $last['invoiceNumber'] : $startAt;
     if (substr($lastNumber, 0, strlen($prefix)) == $prefix) {
         $lastNumber = substr($lastNumber, strlen($prefix));
     }
     if (substr($lastNumber, -1 * strlen($suffix)) == $suffix) {
         $lastNumber = substr($lastNumber, 0, -1 * strlen($suffix));
     }
     preg_match('/[0-9]+/', $lastNumber, $matches);
     $lastNumber = array_shift($matches);
     if ($lastNumber < $startAt) {
         $lastNumber = $startAt;
     }
     // avoid selecting the same order if the invoice number is already taken
     $this->getSelectFilter()->mergeCondition(neq('CustomerOrder.ID', $last['ID']));
     $lastNumber += max($config->get('SequentialInvoiceNumber_STEP'), 1);
     $lastNumber = str_pad($lastNumber, $config->get('SequentialInvoiceNumber_MIN_LENGTH'), '0', STR_PAD_LEFT);
     $lastNumber = $prefix . $lastNumber . $suffix;
     return $lastNumber;
 }
예제 #18
0
 public function getTopCustomers()
 {
     $this->setDateHandle(new ARFieldHandle('CustomerOrder', 'dateCompleted'));
     $this->setChartType(self::TABLE);
     $q = $this->getQuery('ROUND(SUM(CustomerOrder.totalAmount * ' . $this->getCurrencyMultiplier() . '), 2)');
     $f = $q->getFilter();
     $f->resetOrder();
     $f->resetGrouping();
     $f->setOrder(new ARExpressionHandle('cnt'), 'DESC');
     $q->addField('userID');
     $f->setGrouping(new ARExpressionHandle('userID'));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), 1));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isCancelled'), 0));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isPaid'), 1));
     $f->setLimit(self::TABLE_LIMIT);
     $q->joinTable('CustomerOrder', 'User', 'userID', 'ID');
     $this->getReportData($q);
     $ids = array();
     foreach ($this->values as $product) {
         $ids[$product['userID']] = $product['cnt'];
     }
     // fetch user details
     $fields = array_flip(array('fullName', 'cnt'));
     foreach (ActiveRecordModel::getRecordSetArray('User', new ARSelectFilter(new INCond(new ARFieldHandle('User', 'ID'), array_keys($ids)))) as $user) {
         $user['cnt'] = $ids[$user['ID']];
         $ids[$user['ID']] = array_merge($fields, array_intersect_key($user, $fields));
     }
     $this->values = $ids;
 }
예제 #19
0
파일: LoadMirror.php 프로젝트: saiber/www
 public function process()
 {
     if (!$this->response instanceof ActionResponse) {
         return;
     }
     $products = $this->response->get('products');
     $ids = array();
     foreach ($products as $key => $product) {
         $ids[$product['ID']] = !empty($product['parentID']) ? $product['parentID'] : $product['ID'];
     }
     if (!$ids) {
         return;
     }
     $f = select(in(f('ProductImage.productID'), array_values($ids)), new LikeCond(f('ProductImage.title'), '%Virtual Mirror%'));
     $hasMirror = array();
     foreach (ActiveRecordModel::getRecordSetArray('ProductImage', $f) as $mirror) {
         $hasMirror[$mirror['productID']] = true;
     }
     foreach ($ids as $realID => $parentID) {
         if (!empty($hasMirror[$parentID])) {
             $hasMirror[$realID] = true;
         }
     }
     foreach ($products as $key => $product) {
         if ($hasMirror[$product['ID']]) {
             $products[$key]['hasMirror'] = true;
         }
     }
     $this->response->set('hasMirror', $hasMirror);
     $this->response->set('products', $products);
 }
예제 #20
0
 public static function getNewInstance(CustomerOrder $order, $code)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->order->set($order);
     $instance->couponCode->set($code);
     return $instance;
 }
예제 #21
0
 private function getLanguageIDs()
 {
     if (!$this->langIDs) {
         $this->langIDs = ActiveRecordModel::getApplication()->getLanguageArray(true);
     }
     return $this->langIDs;
 }
예제 #22
0
 /**
  * Creates array representation
  *
  * @return array
  */
 protected static function transformArray($array, ARSchema $schema)
 {
     if (!empty($array['serializedData'])) {
         $array['serializedData'] = unserialize($array['serializedData']);
     }
     return parent::transformArray($array, $schema);
 }
예제 #23
0
파일: ObjectImage.php 프로젝트: saiber/www
 public static function deleteByID($className, $id, $foreignKeyName)
 {
     $inst = ActiveRecordModel::getInstanceById($className, $id, ActiveRecordModel::LOAD_DATA);
     $inst->getOwner()->load();
     $inst->deleteImageFiles();
     // check if main image is being deleted
     $owner = $inst->getOwner();
     $owner->load(array(get_class($inst)));
     if ($owner->defaultImage->get()->getID() == $id) {
         // set next image (by position) as the main image
         $f = new ARSelectFilter();
         $cond = new EqualsCond(new ARFieldHandle(get_class($inst), $foreignKeyName), $owner->getID());
         $cond->addAND(new NotEqualsCond(new ARFieldHandle(get_class($inst), 'ID'), $inst->getID()));
         $f->setCondition($cond);
         $f->setOrder(new ARFieldHandle(get_class($inst), 'position'));
         $f->setLimit(1);
         $newDefaultImage = ActiveRecordModel::getRecordSet(get_class($inst), $f);
         if ($newDefaultImage->size() > 0) {
             $owner->defaultImage->set($newDefaultImage->get(0));
             $owner->save();
         }
     }
     ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0');
     ActiveRecordModel::executeUpdate('UPDATE ' . $className . ' SET ' . $foreignKeyName . '=NULL , protectedFields="|' . $foreignKeyName . '|" WHERE ID=' . $id);
     //return parent::deleteByID($className, $id);
 }
예제 #24
0
 public static function getNewInstance(Product $product, ProductRatingType $type = null)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->product->set($product);
     $instance->ratingType->set($type);
     return $instance;
 }
예제 #25
0
 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);
 }
예제 #26
0
 public function getSelectFilter($disableFilters = false)
 {
     $selectFilter = $this->category->getProductsFilter($this, false);
     $selectFilter->merge($this->productFilter);
     $cond = null;
     if ($disableFilters == false) {
         $list = array();
         // group filters by class
         foreach ($this->filters as $filter) {
             $id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : '';
             $list[get_class($filter) . '_' . $id][] = $filter->getCondition();
             $filter->defineJoin($selectFilter);
         }
         // convert filter group to OrChainCondition
         foreach ($list as &$filterGroup) {
             $filterGroup = new OrChainCondition($filterGroup);
         }
         if ($fCond = $selectFilter->getCondition()) {
             $list[] = $fCond;
         }
         $selectFilter->setCondition(new AndChainCondition($list));
         // all merged with and
     }
     ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter);
     return $selectFilter;
 }
예제 #27
0
파일: NewsPostApi.php 프로젝트: saiber/www
 public function filter($emptyListIsException = false)
 {
     $request = $this->application->getRequest();
     $parser = $this->getParser();
     $apiFieldNames = $parser->getApiFieldNames();
     $parser->loadDataInRequest($request);
     $f = new ARSelectFilter();
     $id = $request->get('ID');
     if (intval($id) > 0) {
         $f->mergeCondition(new EqualsCond(new ARFieldHandle('NewsPost', 'ID'), $id));
     }
     $f->setOrder(new ARExpressionHandle('NewsPost.ID'), 'DESC');
     $newspost = ActiveRecordModel::getRecordSetArray('NewsPost', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($emptyListIsException && count($newspost) == 0) {
         throw new Exception('News post not found');
     }
     while ($category = array_shift($newspost)) {
         $xmlNewsPost = $response->addChild('newspost');
         foreach ($category as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xmlNewsPost->addChild($k, htmlentities($v));
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
예제 #28
0
 public static function getNewInstanceByUser(NewsletterMessage $message, User $user)
 {
     $instance = parent::getNewInstance(__CLASS__);
     $instance->message->set($message);
     $instance->user->set($user);
     return $instance;
 }
예제 #29
0
 public static function getOrderFiles(ARSelectFilter $f)
 {
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isCancelled'), 0));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isPaid'), true));
     //$f->mergeCondition(new EqualsCond(new ARFieldHandle('Product', 'type'), Product::TYPE_DOWNLOADABLE));
     $f->setOrder(new ARFieldHandle('CustomerOrder', 'ID'), 'DESC');
     $downloadable = ActiveRecordModel::getRecordSet('OrderedItem', $f, array('Product', 'CustomerOrder'));
     $fileArray = array();
     foreach ($downloadable as &$item) {
         $files = $item->getProduct()->getFiles();
         $itemFiles = array();
         foreach ($files as $file) {
             if ($item->isDownloadable($file)) {
                 $itemFiles[] = $file->toArray();
             }
         }
         if (!$itemFiles) {
             continue;
         }
         $array = $item->toArray();
         $array['Product']['Files'] = ProductFileGroup::mergeGroupsWithFields($item->getProduct()->getFileGroups()->toArray(), $itemFiles);
         foreach ($array['Product']['Files'] as $key => $file) {
             if (!isset($file['ID'])) {
                 unset($array['Product']['Files'][$key]);
             }
         }
         $fileArray[] = $array;
     }
     return $fileArray;
 }
예제 #30
0
 /**
  * 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;
 }