Пример #1
0
 /**
  * Find one by record
  *
  * @param array                $data   Record
  * @param \XLite\Model\AEntity $parent Parent model OPTIONAL
  *
  * @return \XLite\Model\AEntity|void
  */
 public function findOneByRecord(array $data, \XLite\Model\AEntity $parent = null)
 {
     if (empty($data['code'])) {
         $data['code'] = \XLite\Model\Base\Translation::DEFAULT_LANGUAGE;
     }
     return isset($parent) ? $parent->getTranslation($data['code']) : parent::findOneByRecord($data, $parent);
 }
Пример #2
0
 /**
  * Modify money 
  * 
  * @param float                $value     Value
  * @param \XLite\Model\AEntity $model     Model
  * @param string               $property  Model's property
  * @param array                $behaviors Behaviors
  * @param string               $purpose   Purpose
  *  
  * @return void
  */
 public static function modifyMoney($value, \XLite\Model\AEntity $model, $property, array $behaviors, $purpose)
 {
     foreach ($model->getOptions() as $option) {
         if ($option->getOption() && $option->getOption()->hasActiveSurcharge('price')) {
             $value += $option->getOption()->getSurcharge('price')->getAbsoluteValue();
         }
     }
     return $value;
 }
Пример #3
0
 /**
  * Get column value
  *
  * @param array                $column Column
  * @param \XLite\Model\AEntity $entity Model
  *
  * @return mixed
  */
 protected function getColumnValue(array $column, \XLite\Model\AEntity $entity)
 {
     if (isset($column[static::COLUMN_PRODUCT_ATTRIBUTE])) {
         $result = $entity->getAttributeValue($column[static::COLUMN_PRODUCT_ATTRIBUTE]);
         $result = $result ? $result->asString() : '';
     } else {
         $result = parent::getColumnValue($column, $entity);
     }
     return $result;
 }
Пример #4
0
 /**
  * Check cache after enity persist or remove
  *
  * @return void
  */
 public function checkCache()
 {
     parent::checkCache();
     // Check translation owner cache
     if ($this->getOwner()) {
         $this->getOwner()->checkCache();
     }
 }
Пример #5
0
 /**
  * Update entity
  *
  * @param \XLite\Model\AEntity $entity Entity to update
  * @param array                $data   New values for entity properties
  * @param boolean              $flush  Flag OPTIONAL
  *
  * @return void
  */
 public function update(\XLite\Model\AEntity $entity, array $data = array(), $flush = self::FLUSH_BY_DEFAULT)
 {
     $name = null;
     foreach ($entity->getTranslations() as $translation) {
         if ($translation->getName()) {
             $name = $translation->getName();
             break;
         }
     }
     if ($name) {
         foreach ($entity->getTranslations() as $translation) {
             if (!$translation->getName()) {
                 $translation->setName($name);
             }
         }
     }
     parent::update($entity, $data, $flush);
 }
Пример #6
0
 /**
  * Is conflict in history
  *
  * @return bool
  */
 protected function isHistoryConflict()
 {
     return $this->hasConflict() && $this->conflict->getCleanURL() !== $this->getValue();
 }
Пример #7
0
 /**
  * Constructor
  *
  * @param array $data Entity properties OPTIONAL
  */
 public function __construct(array $data = array())
 {
     $this->addresses = new \Doctrine\Common\Collections\ArrayCollection();
     $this->roles = new \Doctrine\Common\Collections\ArrayCollection();
     parent::__construct($data);
 }
Пример #8
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $entity = parent::cloneEntity();
     foreach ($entity->getSoftTranslation()->getRepository()->findBy(array('owner' => $entity)) as $translation) {
         $newTranslation = $translation->cloneEntity();
         $newTranslation->setOwner($entity);
         $entity->addTranslations($newTranslation);
         \XLite\Core\Database::getEM()->persist($newTranslation);
     }
     return $entity;
 }
Пример #9
0
 /**
  * Constructor
  *
  * @param array $data Entity properties OPTIONAL
  *
  * @return void
  */
 public function __construct(array $data = array())
 {
     $this->parcelItems = new \Doctrine\Common\Collections\ArrayCollection();
     parent::__construct($data);
 }
Пример #10
0
 /**
  * Detach self
  *
  * @return void
  */
 public function detach()
 {
     parent::detach();
     foreach ($this->getTranslations() as $translation) {
         $translation->detach();
     }
 }
Пример #11
0
 /**
  * Return attribute values
  *
  * @param \XLite\Model\AEntity $model Model
  *
  * @return array
  */
 protected static function getAttributeValues(\XLite\Model\AEntity $model)
 {
     return $model instanceof \XLite\Module\XC\ProductVariants\Model\ProductVariant ? $model->getProduct()->getAttrValues() : parent::getAttributeValues($model);
 }
Пример #12
0
 /**
  * Check - remove entity or not
  *
  * @param \XLite\Model\AEntity $entity Entity
  *
  * @return boolean
  */
 protected function isAllowEntityRemove(\XLite\Model\AEntity $entity)
 {
     return $entity->isPersistent();
 }
Пример #13
0
 /**
  * Constructor
  *
  * @param array $data Entity properties (OPTIONAL)
  *
  * @return void
  */
 public function __construct(array $data = array())
 {
     $this->links = new \Doctrine\Common\Collections\ArrayCollection();
     $this->manifests = new \Doctrine\Common\Collections\ArrayCollection();
     parent::__construct($data);
 }
Пример #14
0
 /**
  * Constructor
  *
  * @param array $data Entity properties OPTIONAL
  *
  * @return void
  */
 public function __construct(array $data = array())
 {
     $this->productClasses = new \Doctrine\Common\Collections\ArrayCollection();
     $this->memberships = new \Doctrine\Common\Collections\ArrayCollection();
     $this->usedCoupons = new \Doctrine\Common\Collections\ArrayCollection();
     $this->categories = new \Doctrine\Common\Collections\ArrayCollection();
     parent::__construct($data);
 }
Пример #15
0
 /**
  * Create record in database
  *
  * @return boolean
  */
 public function create()
 {
     return $this->checkAddress() && parent::create();
 }
Пример #16
0
 /**
  * Get specific language help message
  *
  * @param \XLite\Model\AEntity $entity Language object
  *
  * @return string
  */
 protected function getLanguageHelpMessage(\XLite\Model\AEntity $entity)
 {
     $message = null;
     if ($entity->getValidModule()) {
         $moduleClass = \Includes\Utils\ModulesManager::getClassNameByModuleName($entity->getModule());
         $moduleName = sprintf('%s (%s)', $moduleClass::getModuleName(), $moduleClass::getAuthorName());
         $message = static::t('This language is added by module and cannot be removed.', array('module' => $moduleName));
     } elseif ('en' == $entity->getCode()) {
         $message = 'English language cannot be removed as it is primary language for all texts.';
     }
     return $message;
 }
Пример #17
0
 /**
  * Build metod name
  *
  * @param \XLite\Model\AEntity $entity  Entity
  * @param string               $pattern Pattern
  *
  * @return string
  */
 protected function buildMetodName(\XLite\Model\AEntity $entity, $pattern)
 {
     return static::TYPE_COUPONS == $entity->getId() ? sprintf($pattern, 'Coupons') : parent::buildMetodName($entity, $pattern);
 }
Пример #18
0
 /**
  * Link loaded entity to parent object
  *
  * @param \XLite\Model\AEntity $entity      Loaded entity
  * @param \XLite\Model\AEntity $parent      Entity parent callback
  * @param array                $parentAssoc Entity mapped propery method
  *
  * @return void
  */
 protected function linkLoadedEntity(\XLite\Model\AEntity $entity, \XLite\Model\AEntity $parent, array $parentAssoc)
 {
     if (!$parentAssoc['many'] || !$entity->getUniqueIdentifier() || !$parent->{$parentAssoc}['getter']()->contains($entity)) {
         // Add entity to parent
         $parent->{$parentAssoc}['setter']($entity);
         // Add parent to entity
         if ($parentAssoc['mappedSetter']) {
             $entity->{$parentAssoc}['mappedSetter']($parent);
         }
     }
 }
Пример #19
0
 /**
  * Delete single entity
  *
  * @param \XLite\Model\AEntity $entity Entity to detach
  *
  * @return void
  */
 protected function performDelete(\XLite\Model\AEntity $entity)
 {
     $entity->setOldPaymentStatus(null);
     $entity->setOldShippingStatus(null);
     parent::performDelete($entity);
 }
Пример #20
0
 /**
  * Disable removing special methods
  *
  * @param \XLite\Model\AEntity $entity Shipping method object
  *
  * @return boolean
  */
 protected function isAllowEntityRemove(\XLite\Model\AEntity $entity)
 {
     /** @var \XLite\Model\Shipping\Method $entity */
     return !$entity->getFree() && !$this->isFixedFeeMethod($entity);
 }
Пример #21
0
 /**
  * Get column value
  *
  * @param array                $column Column
  * @param \XLite\Model\AEntity $entity Model
  *
  * @return mixed
  */
 protected function getFraudInfoXpcTitle(\XLite\Model\AEntity $entity)
 {
     return $entity->getFraudStatusXpc();
 }
Пример #22
0
 /**
  * Validate order item
  *
  * @param \XLite\Model\AEntity $entity   Entity
  * @param boolean              $isUpdate True if entity is updated; false if created
  *
  * @return boolean
  */
 protected function validateOrderItem(\XLite\Model\AEntity $entity, $isUpdate = false)
 {
     $result = true;
     if ($isUpdate && !$this->getChangedFields($entity->getItemId())) {
         // Ignore order item validation if item was updated but was not changed
     } elseif (!$entity->isActualAttributes()) {
         $data = $this->getRequestData();
         if (isset($data['order_items'][$entity->getItemId()]['attribute_values'])) {
             $message = static::t('Order item attributes are out-of-date and cannot be edited');
         }
     } elseif (!$this->isValidEntity($entity)) {
         $result = false;
         $message = static::t('Product with selected properties cannot be purchased');
     } elseif (!$isUpdate && $entity->hasWrongAmount()) {
         $result = false;
         $message = static::t('The specified amount of product exceeds maximum amount of product in stock', array('value' => $entity->getAmount(), 'max' => $entity->getProductAvailableAmount()));
     } elseif ($isUpdate && $entity->isItemHasWrongAmount($entity)) {
         $result = false;
         $message = static::t('The specified amount of product exceeds maximum amount of product in stock', array('value' => $entity->getAmount(), 'max' => $entity->getProductAvailableAmount() + $this->orderItemsData[$entity->getItemId()]['amount']));
     }
     if (!$result) {
         $this->errorMessages[] = sprintf('[%s] %s: %s', static::t('Error'), $message, $this->formatItem($entity));
     } elseif (!empty($message)) {
         $this->warningMessages[] = sprintf('[%s] %s: %s', static::t('Warning'), $message, $this->formatItem($entity));
     }
     return $result;
 }
Пример #23
0
 /**
  * Build metod name
  *
  * @param \XLite\Model\AEntity $entity  Entity
  * @param string               $pattern Pattern
  *
  * @return string
  */
 protected function buildMetodName(\XLite\Model\AEntity $entity, $pattern)
 {
     return static::TYPE_DISCOUNTS == $entity->getId() ? sprintf($pattern, 'Discounts') : parent::buildMetodName($entity, $pattern);
 }
Пример #24
0
 /**
  * Constructor
  *
  * @param array $data Entity properties OPTIONAL
  */
 public function __construct(array $data = array())
 {
     parent::__construct($data);
     $config = \XLite\Core\Config::getInstance()->XC->AuctionInc;
     $this->setCalculationMethod($config->calculationMethod);
     $this->setPackage($config->package);
     $this->setInsurable($config->insurable);
     $this->setFixedFeeMode($config->fixedFeeMode);
     $this->setFixedFeeCode($config->fixedFeeCode);
     $this->setFixedFee1($config->fixedFee1);
     $this->setFixedFee2($config->fixedFee2);
 }
Пример #25
0
 /**
  * Constructor
  *
  * @param array $data Entity properties OPTIONAL
  *
  * @return void
  */
 public function __construct(array $data = array())
 {
     $this->zone_elements = new \Doctrine\Common\Collections\ArrayCollection();
     $this->shipping_markups = new \Doctrine\Common\Collections\ArrayCollection();
     parent::__construct($data);
 }
Пример #26
0
 /**
  * Modify money 
  * 
  * @param float                $value     Value
  * @param \XLite\Model\AEntity $model     Model
  * @param string               $property  Model's property
  * @param array                $behaviors Behaviors
  * @param string               $purpose   Purpose
  *  
  * @return void
  */
 public static function modifyMoney($value, \XLite\Model\AEntity $model, $property, array $behaviors, $purpose)
 {
     $obj = $model instanceof \XLite\Model\Product ? $model : $model->getProduct();
     return \XLite\Module\CDev\VAT\Logic\Product\Tax::getInstance()->deductTaxFromPrice($obj, $value);
 }
Пример #27
0
 /**
  * Return attribute values
  *
  * @param \XLite\Model\AEntity $model Model
  *
  * @return array
  */
 protected static function getAttributeValues(\XLite\Model\AEntity $model)
 {
     return $model instanceof \XLite\Model\Product ? $model->getAttrValues() : $model->getAttributeValues();
 }
Пример #28
0
 /**
  * Build entity page URL
  *
  * @param \XLite\Model\AEntity $entity Entity
  * @param array                $column Column data
  *
  * @return string
  */
 protected function buildEntityURL(\XLite\Model\AEntity $entity, array $column)
 {
     return \XLite\Core\Converter::buildURL($column[static::COLUMN_LINK], '', array('order_number' => $entity->getOrderNumber()));
 }
Пример #29
0
 /**
  * Clone
  *
  * @return \XLite\Model\AEntity
  */
 public function cloneEntity()
 {
     $newEntity = parent::cloneEntity();
     if ($this->getSku()) {
         $newEntity->setSku(\XLite\Core\Database::getRepo('XLite\\Module\\XC\\ProductVariants\\Model\\ProductVariant')->assembleUniqueSKU($this->getSku()));
     }
     return $newEntity;
 }
Пример #30
0
 /**
  * Constructor
  *
  * @param array $data Entity properties (OPTIONAL)
  *
  * @return void
  */
 public function __construct(array $data = array())
 {
     $this->deliveryOptions = new \Doctrine\Common\Collections\ArrayCollection();
     $this->significantEvents = new \Doctrine\Common\Collections\ArrayCollection();
     $this->files = new \Doctrine\Common\Collections\ArrayCollection();
     parent::__construct($data);
 }