Esempio n. 1
0
 /**
  * Converts a shop doctrine model to a shop struct
  * @param \Shopware\Models\Shop\Shop $shop
  * @return Struct\Shop
  */
 public function convertShop(Models\Shop\Shop $shop)
 {
     $struct = new Struct\Shop();
     $struct->setId($shop->getId());
     $struct->setName($shop->getName());
     $struct->setHost($shop->getHost());
     $struct->setPath($shop->getBasePath());
     $struct->setUrl($shop->getBaseUrl());
     $struct->setSecure($shop->getSecure());
     $struct->setSecureHost($shop->getSecureHost());
     $struct->setSecurePath($struct->getSecurePath());
     if ($shop->getCategory()) {
         $struct->setCategory($this->convertCategory($shop->getCategory()));
     }
     return $struct;
 }
Esempio n. 2
0
 /**
  * @param ShopwareShop $shop
  * @param ShopwareConfig $config
  * @return Context
  */
 public static function createFromShop(ShopwareShop $shop, ShopwareConfig $config)
 {
     $self = new self($shop->getHost(), $shop->getBaseUrl(), $shop->getAlwaysSecure() || $shop->getSecure(), []);
     $self->setShopId($shop->getId());
     $self->setUrlToLower($config->get('routerToLower'));
     $self->setBaseFile($config->get('baseFile'));
     $self->setAlwaysSecure($shop->getAlwaysSecure());
     $self->setRemoveCategory((bool) $config->get('routerRemoveCategory'));
     return $self;
 }
Esempio n. 3
0
 /**
  * @param ShopEntity $shop
  * @return Shop
  */
 public static function createFromShopEntity(ShopEntity $shop)
 {
     $struct = new self();
     $struct->setId($shop->getId());
     $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());
     $struct->setIsDefault($shop->getDefault());
     $struct->setName($shop->getName());
     $struct->setHost($shop->getHost());
     $struct->setPath($shop->getBasePath());
     $struct->setUrl($shop->getBaseUrl());
     $struct->setSecure($shop->getSecure());
     $struct->setSecureHost($shop->getSecureHost());
     $struct->setSecurePath($shop->getSecureBasePath());
     if ($shop->getCategory()) {
         $struct->setCategory(Category::createFromCategoryEntity($shop->getCategory()));
     }
     if ($shop->getFallback()) {
         $struct->setFallbackId($shop->getFallback()->getId());
     }
     return $struct;
 }
Esempio n. 4
0
 /**
  * Returns a query which selects the revenue of each referrer.
  * @param Shop $shop
  * @param \DateTime $from
  * @param \DateTime $to
  * @return DBALQueryBuilder
  */
 protected function createReferrerRevenueBuilder(Shop $shop = null, \DateTime $from = null, \DateTime $to = null)
 {
     $builder = $builder = $this->connection->createQueryBuilder();
     $builder->select(array('ROUND(orders.invoice_amount / orders.currencyFactor, 2) AS turnover', 'users.id as userID', 'orders.referer AS referrer', 'DATE(users.firstlogin) as firstLogin', 'DATE(orders.ordertime) as orderTime'))->from('s_order', 'orders')->innerJoin('orders', 's_user', 'users', 'orders.userID = users.id')->where('orders.status != 4 AND orders.status != -1')->andWhere("orders.referer LIKE 'http%//%'")->orderBy('turnover');
     $this->addDateRangeCondition($builder, $from, $to, 'orders.ordertime');
     if ($shop instanceof Shop && $shop->getHost()) {
         $builder->andWhere("orders.referer NOT LIKE :hostname")->setParameter(':hostname', '%' . $shop->getHost() . '%');
     }
     return $builder;
 }
Esempio n. 5
0
 /**
  * @param Request $request
  * @param Shop $newShop
  * @return string
  */
 protected function getNewShopUrl(Request $request, Shop $newShop)
 {
     $repository = Shopware()->Models()->getRepository('Shopware\\Models\\Shop\\Shop');
     $requestShop = $repository->getActiveByRequest($request);
     // Remove baseUrl from request url
     $url = $request->getRequestUri();
     if ($requestShop && strpos($url, $requestShop->getBaseUrl()) === 0) {
         $url = substr($url, strlen($requestShop->getBaseUrl()));
     }
     $baseUrl = $request->getBaseUrl();
     if (strpos($url, $baseUrl) === 0) {
         $url = substr($url, strlen($baseUrl));
     }
     $basePath = $newShop->getBasePath();
     if (strpos($url, $basePath) === 0) {
         $url = substr($url, strlen($basePath));
     }
     $host = $newShop->getHost();
     $baseUrl = $newShop->getBaseUrl() ?: $request->getBasePath();
     if ($request->isSecure()) {
         $host = $newShop->getSecureHost() ?: $newShop->getHost();
         if ($newShop->getSecureBaseUrl()) {
             $baseUrl = $newShop->getSecureBaseUrl();
         } elseif ($newShop->getBaseUrl()) {
             $baseUrl = $newShop->getBaseUrl();
         } else {
             $baseUrl = $request->getBaseUrl();
         }
     }
     $host = trim($host, '/');
     $baseUrl = trim($baseUrl, '/');
     if (!empty($baseUrl)) {
         $baseUrl = '/' . $baseUrl;
     }
     $url = ltrim($url, '/');
     if (!empty($url)) {
         $url = '/' . $url;
     }
     //build full redirect url to allow host switches
     return sprintf('%s://%s%s%s', $request->getScheme(), $host, $baseUrl, $url);
 }