/**
  * Get default image
  *
  * @return bool|\Pimcore\Model\Asset
  */
 public function getDefaultImage()
 {
     $config = Config::getConfig();
     $config = $config->toArray();
     $image = Image::getByPath($config['category']['default-image']);
     if ($image instanceof Image) {
         return $image;
     }
     return false;
 }
 public function setAction()
 {
     $values = \Zend_Json::decode($this->getParam("data"));
     // convert all special characters to their entities so the xml writer can put it into the file
     $values = array_htmlspecialchars($values);
     // email settings
     $oldConfig = Config::getConfig();
     $oldValues = $oldConfig->toArray();
     $settings = array("base" => array("base-currency" => $values["base.base-currency"]), "product" => array("default-image" => $values["product.default-image"], "days-as-new" => $values["product.days-as-new"]), "category" => array("default-image" => $values["category.default-image"]));
     $config = new \Zend_Config($settings, true);
     $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => CORESHOP_CONFIGURATION));
     $writer->write();
     $this->_helper->json(array("success" => true));
 }
Example #3
0
 /**
  * Converts value from currency to currency
  *
  * @param $value
  * @param Currency|null $toCurrency
  * @param Currency|null $fromCurrency
  * @return mixed
  */
 public static function convertToCurrency($value, Currency $toCurrency = null, Currency $fromCurrency = null)
 {
     $config = Config::getConfig();
     $configArray = $config->toArray();
     if (!$fromCurrency instanceof Currency) {
         $fromCurrency = Currency::getById($configArray['base']['base-currency']);
     }
     if (!$toCurrency instanceof Currency) {
         $toCurrency = Tool::getCurrency();
     }
     if ($fromCurrency instanceof Currency) {
         if ($toCurrency instanceof Currency && $toCurrency->getId() != $fromCurrency->getId()) {
             return $value * $toCurrency->getExchangeRate();
         }
     }
     return $value;
 }
Example #4
0
 /**
  * @static
  * @param  $sourceClassName
  * @return string
  */
 public static function getModelClassMapping($sourceClassName, $interfaceToImplement = null)
 {
     $targetClassName = $sourceClassName;
     if (!$interfaceToImplement) {
         $interfaceToImplement = $targetClassName;
     }
     if ($map = \CoreShop\Config::getModelClassMappingConfig()) {
         $tmpClassName = $map->{$sourceClassName};
         if ($tmpClassName) {
             if (\Pimcore\Tool::classExists($tmpClassName)) {
                 if (is_subclass_of($tmpClassName, $interfaceToImplement)) {
                     $targetClassName = $tmpClassName;
                 } else {
                     \Logger::error("Classmapping for " . $sourceClassName . " failed. '" . $tmpClassName . " is not a subclass of '" . $interfaceToImplement . "'. " . $tmpClassName . " has to extend " . $interfaceToImplement);
                 }
             } else {
                 \Logger::error("Classmapping for " . $sourceClassName . " failed. Cannot find class '" . $tmpClassName . "'");
             }
         }
     }
     return $targetClassName;
 }
 /**
  * Get Product is new
  *
  * @return bool
  */
 public function getIsNew()
 {
     $config = Config::getConfig();
     $configArray = $config->toArray();
     if ($configArray['product']['days-as-new'] > 0) {
         $creationDate = new \Zend_Date($this->getCreationDate());
         $nowDate = new \Zend_Date();
         $diff = $nowDate->sub($creationDate)->toValue();
         $days = ceil($diff / 60 / 60 / 24) + 1;
         if ($days <= $configArray['product']['days-as-new']) {
             return true;
         }
     }
     return false;
 }