コード例 #1
0
 /**
  * Test.
  */
 public function test()
 {
     $criteria = Beans::getBean('ZMSearchCriteria');
     //$criteria->setIncludeTax(true);
     $criteria->setCategoryId(3);
     $criteria->setIncludeSubcategories(true);
     $criteria->setPriceFrom(20);
     $criteria->setKeywords('dvd');
     $search = Beans::getBean('ZMProductFinder');
     // should there be a criteria method to set the currency?
     global $currencies;
     $currencyRate = $currencies->get_value($_SESSION['currency']);
     if ($currencyRate) {
         // adjust currency
         $criteria->setPriceFrom($criteria->getPriceFrom() / $currencyRate);
         $criteria->setPriceTo($criteria->getPriceTo() / $currencyRate);
     }
     /*
      */
     $search->setCriteria($criteria);
     $search->setSortId('name');
     $search->setDescending(true);
     $queryDetails = $search->execute();
     $results = $queryDetails->query();
     $productIds = array();
     foreach ($results as $result) {
         $productIds[] = $result['productId'];
     }
     $expected = array(7, 9, 10, 19, 4, 6, 17, 18, 14, 13, 15, 11, 12, 16, 5, 20, 8);
     $this->assertEquals($expected, $productIds);
 }
コード例 #2
0
ファイル: RpcController.php プロジェクト: zenmagick/zenmagick
 /**
  * {@inheritDoc}
  */
 public function processAction(Request $request)
 {
     $format = $this->container->get('settingsService')->get('zenmagick.mvc.rpc.format', 'JSON');
     $rpcRequest = Beans::getBean('ZMRpcRequest' . $format);
     $rpcRequest->setRequest($request);
     $method = $sacsMethod = $rpcRequest->getMethod();
     $rpcResponse = null;
     $sacsManager = $this->container->get('sacsManager');
     // check access on controller level
     if (!$sacsManager->authorize($request, $request->getRequestId(), $this->getUser(), false)) {
         $rpcResponse = $this->invalidCredentials($rpcRequest);
     }
     // (re-)check on method level if mapping exists
     $methodRequestId = $request->getRequestId() . '#' . $sacsMethod;
     if ($sacsManager->hasMappingForRequestId($methodRequestId)) {
         if (!$sacsManager->authorize($request, $methodRequestId, $this->getUser(), false)) {
             $rpcResponse = $this->invalidCredentials($rpcRequest);
         }
     }
     if (!$rpcResponse) {
         if (method_exists($this, $method) || in_array($method, $this->getAttachedMethods())) {
             $this->get('logger')->debug('calling method: ' . $method);
             $rpcResponse = $this->{$method}($rpcRequest);
         } else {
             $rpcResponse = $rpcRequest->createResponse();
             $rpcResponse->setStatus(false);
             $this->container->get('logger')->err("Invalid request - method '" . $request->getParameter('method') . "' not found!");
         }
     }
     $response = new Response();
     $response->headers->set('Content-Type', $rpcResponse->getContentType());
     $response->setContent($rpcResponse);
     return $response;
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function execute()
 {
     if (!$plugin || !$plugin->isEnabled()) {
         return true;
     }
     $plugin = $this->getPlugin();
     $scheduledOrders = self::findScheduledOrders();
     $scheduleEmailTemplate = Runtime::getSettings()->get('plugins.subscriptions.email.templates.schedule', 'checkout');
     $orderService = $this->container->get('orderService');
     $translator = $this->container->get('translator');
     foreach ($scheduledOrders as $scheduledOrderId) {
         // 1) copy
         $newOrder = self::copyOrder($scheduledOrderId);
         // load the new order as proper ZenMagick\StoreBundle\Entity\Order\Order instance for further use
         $order = $orderService->getOrderForId($newOrder->getOrderId(), $this->container->get('session')->getLanguageId());
         if (null === $order) {
             $this->container->get('logger')->err('copy order failed for scheduled order: ' . $scheduledOrderId);
             continue;
         }
         // 2) update shipping/billing from account to avoid stale addresses
         if ('account' == $plugin->get('addressPolicy')) {
             $account = $this->container->get('accountService')->getAccountForId($order->getAccountId());
             if (null === $account) {
                 $this->container->get('logger')->warn('invalid accountId on order: ' . $order->getId());
                 continue;
             }
             $defaultAddressId = $account->getDefaultAddressId();
             $defaultAddress = $this->container->get('addressService')->getAddressForId($defaultAddressId);
             $order->setShippingAddress($defaultAddress);
             $orderService->updateOrder($order);
         }
         // 3) update subscription specific data
         $order->set('subscriptionOrderId', $scheduledOrderId);
         $order->set('subscription', false);
         $order->setStatus($plugin->get('orderStatus'));
         $orderService->updateOrder($order);
         // 4) Create history entry if enabled
         if (Toolbox::asBoolean($plugin->get('orderHistory'))) {
             $status = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Order\\OrderStatusHistory');
             $status->setId($plugin->get('orderStatus'));
             $status->setOrderId($order->getId());
             $status->setOrderStatusId($order->getOrderStatusId());
             $status->setCustomerNotified(!Toolbox::isEmpty($scheduleEmailTemplate));
             $comment = $translator->trans('Scheduled order for subscription #%s', array('%id%' => $scheduledOrderId));
             $status->setComment($comment);
             $orderService->createOrderStatusHistory($status);
         }
         // 5) Update subscription order with next schedule date
         // calculate new subscription_next_order based on current subscription_next_order, as we might not run on the same day
         $sql = "UPDATE %table.orders%\n                    SET subscription_next_order = DATE_ADD(subscription_next_order, INTERVAL " . zm_subscriptions::schedule2SQL($order->get('schedule')) . ")\n                    WHERE orders_id = :orderId";
         $args = array('orderId' => $scheduledOrderId);
         ZMRuntime::getDatabase()->updateObj($sql, $args, 'orders');
         if (!Toolbox::isEmpty($scheduleEmailTemplate)) {
             $this->sendOrderEmail($order, $scheduleEmailTemplate);
         }
         // event
         $this->container->get('event_dispatcher')->dispatch('create_order', new GenericEvent($this, array('orderId' => $order->getId())));
     }
     return true;
 }
コード例 #4
0
 /**
  * Create new shipping method.
  *
  * @param ZMShippingProvider provider The shipping provider for this method.
  * @param array zenMethod The zen-cart method infos.
  */
 public function __construct($provider, $zenMethod)
 {
     parent::__construct();
     $this->provider = $provider;
     $this->zenMethod = $zenMethod;
     $this->taxRate = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\TaxRate');
 }
コード例 #5
0
 /**
  * {@inheritDoc}
  */
 public function processPost($request)
 {
     $adminUserService = $this->container->get('adminUserService');
     if (null != ($editUserId = $request->request->get('adminUserId'))) {
         $adminUserForm = $this->getFormData($request);
         $user = Beans::getBean('ZenMagick\\AdminBundle\\Entity\\AdminUser');
         $user->setId($adminUserForm->getAdminUserId());
         $user->setUsername($adminUserForm->getUsername());
         $user->setEmail($adminUserForm->getEmail());
         $user->setRoles($adminUserForm->getRoles());
         $clearPassword = $adminUserForm->getPassword();
         $current = $adminUserService->getUserForId($user->getId());
         if (empty($clearPassword) && null != $current) {
             // keep
             $encodedPassword = $current->getPassword();
         } else {
             $encoder = $this->get('security.encoder_factory')->getEncoder($user);
             $encodedPassword = $encoder->encodePassword($clearPassword);
         }
         $user->setPassword($encodedPassword);
         if (0 < $user->getId()) {
             $adminUserService->updateUser($user);
             $this->get('session.flash_bag')->success($this->get('translator')->trans('Details updated.'));
         } else {
             $adminUserService->createUser($user);
             $this->get('session.flash_bag')->success($this->get('translator')->trans('User created.'));
         }
     } elseif (null != ($deleteUserId = $request->request->get('deleteUserId'))) {
         $adminUserService->deleteUserForId($deleteUserId);
         $this->get('session.flash_bag')->success($this->get('translator')->trans('User deleted.'));
     }
     return $this->findView('success');
 }
コード例 #6
0
 /**
  * Estimate shipping.
  *
  * @param ZenMagick\Http\Request request The current request.
  * @deprecated Use AjaxCheckoutController instead
  */
 public function estimateShippingJSON($request)
 {
     $shoppingCart = $this->get('shoppingCart');
     $shippingEstimator = Beans::getBean("ZMShippingEstimator");
     $shippingEstimator->prepare();
     $response = array();
     $utilsTool = $this->container->get('utilsTool');
     $address = $shippingEstimator->getAddress();
     if (null == $address) {
         $address = $shoppingCart->getShippingAddress();
     }
     if (null != $address) {
         $response['address'] = $this->flattenObject($address, $this->get('ajaxAddressMap'));
     }
     $methods = array();
     if (null != $address && !$shoppingCart->isEmpty()) {
         foreach ($this->container->get('shippingProviderService')->getShippingProviders(true) as $provider) {
             foreach ($provider->getShippingMethods($shoppingCart, $address) as $shippingMethod) {
                 $id = 'ship_' . $shippingMethod->getId();
                 $ma = array();
                 $ma['id'] = $id;
                 $ma['name'] = $provider->getName() . " " . $shippingMethod->getName();
                 $ma['cost'] = $utilsTool->formatMoney($shippingMethod->getCost());
                 $methods[] = $ma;
             }
         }
     }
     $response['methods'] = $methods;
     $flatObj = $this->flattenObject($response);
     $json = json_encode($flatObj);
     $this->setJSONHeader($json);
 }
コード例 #7
0
 /**
  * {@inheritDoc}
  */
 public function calculate($request, ShoppingCart $shoppingCart)
 {
     $paymentType = $shoppingCart->getSelectedPaymentType();
     // iterate over all conditions
     $output = array();
     foreach ($this->container->get('settingsService')->get('plugins.paymentSurcharge.conditions', array()) as $condition) {
         if ($paymentType->getId() == $condition['code'] || null === $condition['code']) {
             // payment module match
             if (null != $condition['cvalue']) {
                 $cvalueToken = explode(':', $condition['cvalue']);
                 if (2 == count($cvalueToken)) {
                     $cvalueType = $cvalueToken[0];
                     $cvalueName = $cvalueToken[1];
                 } else {
                     $cvalueType = 'field';
                     $cvalueName = $cvalueToken[0];
                 }
                 // evaluate the value to use with the regexp
                 $cvalueNames = explode(';', $cvalueName);
                 switch ($cvalueType) {
                     case 'field':
                         $cvalue = null;
                         foreach ($cvalueNames as $name) {
                             if (isset($payment->{$name})) {
                                 $cvalue = $payment->{$name};
                             } else {
                                 $cvalue = $request->getParameter($name, null);
                             }
                             if (null !== $cvalue) {
                                 break;
                             }
                         }
                         break;
                     default:
                         $this->container->get('logger')->err('invalid condition value type: ' . $cvalueType);
                         return null;
                 }
             }
             // check eregexp
             if (null == $condition['cvalue'] && null == $condition['regexp'] || ereg($condition['regexp'], $cvalue)) {
                 // match, so apply condition
                 // evaluate the condition's value
                 $amount = 0;
                 if (is_numeric($condition['value'])) {
                     $amount = (double) $condition['value'];
                 }
                 if (0 === strpos($condition['value'], '%:')) {
                     $amount = trim(str_replace('%:', '', $condition['value']));
                     $amount = $shoppingCart->getSubtotal() * ($amount / 100);
                 }
                 $details = Beans::getBean('ZMOrderTotalLineDetails');
                 $details->setTitle($condition['title']);
                 $details->setAmount($amount);
                 $details->setDisplayValue($amount);
                 $output[] = $details;
             }
         }
     }
     return $output;
 }
コード例 #8
0
 /**
  * {@inheritDoc}
  */
 public function getResults($reload = false)
 {
     if ($reload || null === $this->results) {
         $finder = Beans::getBean('ZMProductFinder');
         $finder->setCriteria($this->criteria);
         if (null !== $this->resultList) {
             // try to set the first active sorter
             foreach ($this->resultList->getSorters() as $sorter) {
                 if ($sorter->isActive()) {
                     $finder->setSortId($sorter->getSortId());
                     $finder->setDescending($sorter->isDescending());
                     break;
                 }
             }
         }
         $queryDetails = $finder->execute();
         $queryPager = Beans::getBean('ZenMagick\\Base\\Database\\QueryPager');
         $queryPager->setQueryDetails($queryDetails);
         $productIds = array();
         foreach ($queryPager->getResults($this->resultList->getPageNumber(), $this->resultList->getPagination()) as $result) {
             $productIds[] = $result['productId'];
         }
         $this->results = $this->container->get('productService')->getProductsForIds($productIds, true, $this->criteria->getLanguageId());
         $this->totalNumberOfResults = $queryPager->getTotalNumberOfResults();
     }
     return $this->results;
 }
コード例 #9
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $orderStatusId = $request->getParameter('orderStatusId');
     //TODO: languageId
     $languageId = 1;
     // get the corresponding orderStatus
     $orderStatusList = $this->container->get('orderService')->getOrderStatusList($languageId);
     $orderStatus = null;
     foreach ($orderStatusList as $tmp) {
         if ($tmp->getOrderStatusId() == $orderStatusId) {
             $orderStatus = $tmp;
             break;
         }
     }
     if (null != $orderStatus) {
         $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\Entity\\Order\\Order', 'orderService', "getOrdersForStatusId", array($orderStatusId, $languageId));
     } else {
         $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\Entity\\Order\\Order', 'orderService', "getAllOrders", array($languageId));
     }
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->get('page', 1));
     $data = array('accountService' => $this->get('accountService'), 'resultList' => $resultList, 'orderStatus' => $orderStatus);
     return $this->findView(null, $data);
 }
コード例 #10
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\entities\\catalog\\Review', 'reviewService', "getAllReviews", array($request->getSession()->getLanguageId()));
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->getInt('page'));
     return $this->findView(null, array('resultList' => $resultList));
 }
コード例 #11
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\Entity\\Order\\Order', 'orderService', "getOrdersForAccountId", array($this->getUser()->getId(), $request->getSession()->getLanguageId()));
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->getInt('page'));
     return $this->findView(null, array('resultList' => $resultList));
 }
コード例 #12
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\Entity\\Account', 'accountService', "getAllAccounts");
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->get('page', 1));
     $data = array('resultList' => $resultList);
     return $this->findView(null, $data);
 }
コード例 #13
0
 /**
  * {@inheritDoc}
  */
 public function getViewData($request)
 {
     $sql = "SELECT s.sources_name AS name, s.sources_id as sourceId\n                FROM %table.sources% s\n                ORDER BY s.sources_name ASC";
     $sourceStats = \ZMRuntime::getDatabase()->fetchAll($sql, array(), array('sources'), 'ZenMagick\\Base\\ZMObject');
     $resultSource = new ZMArrayResultSource('ZenMagick\\Base\\ZMObject', $sourceStats);
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->get('page', 1));
     return array('resultList' => $resultList);
 }
コード例 #14
0
 /**
  * Test regular cron run.
  */
 public function testRegularCronRun()
 {
     if (!interface_exists('ZenMagick\\plugins\\cron\\jobs\\CronJobInterface')) {
         $this->skipIf(true, 'Cron not available');
         return;
     }
     $job = Beans::getBean('ZenMagick\\plugins\\subscriptions\\cron\\UpdateSubscriptionsCronJob');
     $this->assertNotNull($job);
     $status = $job->execute();
     $this->assertTrue($status);
 }
コード例 #15
0
 /**
  * Create test account.
  */
 public function createAccount($data)
 {
     $account = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Account');
     foreach ($data as $key => $value) {
         $method = 'set' . ucwords($key);
         if ('Dob' == $key) {
             $value = DateTime::createFromFormat('d/m/y', $value);
         }
         $account->{$method}($value);
     }
     return $account;
 }
コード例 #16
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $viewName = 'error';
     $method = null;
     $args = null;
     $data = array();
     $languageId = $request->getSession()->getLanguageId();
     // get category
     // decide what to do
     if ($request->attributes->has('cPath')) {
         $method = "getProductsForCategoryId";
         $args = array($request->attributes->get('categoryId'), true, $request->getSession()->getLanguageId());
         $viewName = 'category_list';
         if (null == ($category = $this->container->get('categoryService')->getCategoryForId($request->attributes->get('categoryId'), $languageId)) || !$category->isActive()) {
             return $this->findView('category_not_found');
         }
     } elseif ($request->query->has('manufacturers_id')) {
         $method = "getProductsForManufacturerId";
         $args = array($request->query->getInt('manufacturers_id'), true, $languageId);
         $viewName = 'manufacturer';
         if (null == ($manufacturer = $this->container->get('manufacturerService')->getManufacturerForId($request->query->getInt('manufacturers_id'), $languageId))) {
             return $this->findView('manufacturer_not_found');
         }
     }
     $settingsService = $this->container->get('settingsService');
     $resultList = null;
     if (null !== $method) {
         $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\Entity\\Product', 'productService', $method, $args);
         $resultList = Beans::getBean('ZMResultList');
         $resultList->setResultSource($resultSource);
         foreach (explode(',', $settingsService->get('resultListProductFilter')) as $filter) {
             $resultList->addFilter(Beans::getBean($filter));
         }
         foreach (explode(',', $settingsService->get('resultListProductSorter')) as $sorter) {
             $resultList->addSorter(Beans::getBean($sorter));
         }
         $resultList->setPageNumber($request->query->getInt('page'));
         $data['resultList'] = $resultList;
     }
     if ($viewName == "category_list" && ((null == $resultList || !$resultList->hasResults() || null != $category && $category->hasChildren()) && $settingsService->get('isUseCategoryPage'))) {
         $viewName = 'category';
     }
     if (null != $category) {
         $data['currentCategory'] = $category;
     }
     if (null != $resultList && 1 == $resultList->getNumberOfResults() && $settingsService->get('isSkipSingleProductCategory')) {
         $results = $resultList->getResults();
         $product = array_pop($results);
         $request->query->set('productId', $product->getId());
         $viewName = 'product_info';
     }
     return $this->findView($viewName, $data);
 }
コード例 #17
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $fromDate = $request->query->get('fromDate');
     $toDate = $request->query->get('toDate');
     $exportFormat = $request->query->get('exportFormat');
     $viewData = array();
     if (null != $fromDate) {
         $dateFormat = $this->getDateFormat();
         $orderDateFrom = \DateTime::createFromFormat($dateFormat . ' H:i:s', $fromDate . ' 00:00:00');
         if (!empty($toDate)) {
             $orderDateTo = \DateTime::createFromFormat($dateFormat . ' H:i:s', $toDate . ' 00:00:00');
         } else {
             $orderDateTo = new \DateTime();
             $toDate = $orderDateTo->format($dateFormat);
         }
         // TODO: use new ZMOrders method
         $sql = "SELECT o.*, s.orders_status_name, ots.value as shippingValue\n                    FROM %table.orders% o, %table.orders_total% ot, %table.orders_status% s, %table.orders_total% ots\n                    WHERE date_purchased >= :1#orderDate AND date_purchased < :2#orderDate\n                      AND o.orders_id = ot.orders_id\n                      AND ot.class = 'ot_total'\n                      AND o.orders_id = ots.orders_id\n                      AND ots.class = 'ot_shipping'\n                      AND o.orders_status = s.orders_status_id\n                      AND s.language_id = :languageId\n                    ORDER BY orders_id DESC";
         $args = array('languageId' => 1, '1#orderDate' => $orderDateFrom, '2#orderDate' => $orderDateTo);
         // load as array to save memory
         $results = \ZMRuntime::getDatabase()->fetchAll($sql, $args, array('orders', 'orders_total', 'orders_status'));
         // prepare data
         $header = array('Date', 'Order Id', 'Customer Name', 'Shipping Country', 'Products Ordered', 'Quantity', 'Unit Products Net Price', 'Products Line Net Total', 'Products Net Total', 'Shipping Cost', 'Discount Amount', 'Discount Coupon', 'Gift Voucher Amount', 'Payment Type', 'Order Tax', 'Order Total');
         $rows = array();
         $order = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Order\\Order');
         foreach ($results as $ii => $orderData) {
             $order->reset();
             Beans::setAll($order, $orderData);
             $rows[] = $this->processOrder($order);
         }
         // additional view data
         $viewData = array('header' => $header, 'rows' => $rows, 'toDate' => $toDate);
         if ('csv' == $exportFormat) {
             // @todo should use StreamedResponse
             $response = new Response();
             $d = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'orders.csv');
             $response->headers->set('Content-Type', 'application/csv');
             $response->headers->set('Content-Disposition', $d);
             ob_start();
             $fp = fopen('php://output', 'w');
             fputcsv($fp, $header);
             foreach ($rows as $orderRows) {
                 foreach ($orderRows as $row) {
                     fputcsv($fp, $row);
                 }
             }
             fclose($fp);
             $response->setContent(ob_get_clean());
             return $response;
         }
     }
     return $this->findView(null, $viewData);
 }
コード例 #18
0
ファイル: Dashboard.php プロジェクト: zenmagick/zenmagick
 /**
  * Get the configured widgets for the given column.
  *
  * @param int adminId The admin id.
  * @param int column The column.
  * @return array List of widgets.
  */
 public function getWidgetsForColumn($adminId, $column)
 {
     $config = $this->getConfig($adminId);
     $widgets = array();
     foreach ($config['widgets'][$column] as $def) {
         $widget = Beans::getBean($def);
         // adjust id
         $token = explode('#', $def);
         $widget->setId($token[0]);
         $widgets[] = $widget;
     }
     return $widgets;
 }
コード例 #19
0
 /**
  * Callback to *create* results.
  *
  * @param string resultClass The class of the results; default is <em>ZenMagick\StoreBundle\Entity\Product</em>.
  * @param int size The number of results to be returned by the source.
  * @return array List of objects of class <em>resultClass</em>.
  */
 public function getResults($resultClass, $size)
 {
     $results = array();
     for ($ii = 0; $ii < $size; ++$ii) {
         $result = Beans::getBean($resultClass);
         // assume products...
         $result->setId($ii + 1);
         $result->setName('product-' . ($ii + 1));
         $result->setModel('model-' . ($ii + 1));
         $results[] = $result;
     }
     return $results;
 }
コード例 #20
0
ファイル: ZMAccountForm.php プロジェクト: zenmagick/zenmagick
 /**
  * Get a populated <code>ZenMagick\StoreBundle\Entity\Account</code> instance.
  *
  * @return ZenMagick\StoreBundle\Entity\Account An account.
  */
 public function getAccount()
 {
     $account = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Account');
     $properties = $this->getProperties();
     // TODO: see comment in c'tor
     // don't need these
     foreach (array('formId', 'action') as $name) {
         unset($properties[$name]);
     }
     // special treatment
     $properties['dob'] = \DateTime::createFromFormat($this->container->get('localeService')->getFormat('date', 'short'), $properties['dob']);
     $account = Beans::setAll($account, $properties);
     return $account;
 }
コード例 #21
0
 /**
  * {@inheritDoc}
  */
 public function processPost($request)
 {
     $productGroupPricing = Beans::getBean('ZenMagick\\plugins\\productGroupPricing\\model\\ProductGroupPricing');
     $productGroupPricingService = $this->container->get('productGroupPricingService');
     $productGroupPricing->populate($request);
     if (0 == $productGroupPricing->getId()) {
         // create
         $productGroupPricing = $productGroupPricingService->createProductGroupPricing($productGroupPricing);
     } else {
         // update
         $productGroupPricing = $productGroupPricingService->updateProductGroupPricing($productGroupPricing);
     }
     return $this->findView('catalog-redirect');
 }
コード例 #22
0
 /**
  * Get a populated <code>ZenMagick\StoreBundle\Entity\Address</code> instance.
  *
  * @return ZenMagick\StoreBundle\Entity\Address An address.
  */
 public function getAddress()
 {
     $address = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Address');
     $properties = $this->getProperties();
     // don't need these
     foreach (array('formId', 'action', 'password', 'confirmation') as $name) {
         unset($properties[$name]);
     }
     // special treatment
     if (empty($properties['countryId'])) {
         $properties['countryId'] = 0;
     }
     $address = Beans::setAll($address, $properties);
     return $address;
 }
コード例 #23
0
 /**
  * {@inheritDoc}
  */
 public function getViewData($request)
 {
     // need themes initialized
     $this->container->get('themeService')->initThemes();
     $blocks = array();
     $blockManager = $this->container->get('blockManager');
     foreach ($blockManager->getProviders() as $provider) {
         foreach ($provider->getBlockList() as $def) {
             $widget = Beans::getBean($def);
             $blocks[$def] = $widget->getTitle();
         }
     }
     $groupName = $request->query->get('groupName');
     return array('allBlocks' => $blocks, 'blocks' => $blockManager->getBlocksForId($request, $groupName), 'groupName' => $groupName);
 }
コード例 #24
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $settingsService = $this->container->get('settingsService');
     $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\Entity\\Product', 'productService', "getFeaturedProducts", array($request->attributes->get('categoryId'), 0));
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     foreach (explode(',', $settingsService->get('resultListProductFilter')) as $filter) {
         $resultList->addFilter(Beans::getBean($filter));
     }
     foreach (explode(',', $settingsService->get('resultListProductSorter')) as $sorter) {
         $resultList->addSorter(Beans::getBean($sorter));
     }
     $resultList->setPageNumber($request->query->getInt('page'));
     return $this->findView(null, array('resultList' => $resultList));
 }
コード例 #25
0
 /**
  * {@inheritDoc}
  */
 public function processGet($request)
 {
     $product = $this->container->get('productService')->getProductForId($request->query->get('productId'), $request->getSession()->getLanguageId());
     if (null == $product) {
         return $this->findView('product_not_found');
     }
     $data = array();
     $data['currentProduct'] = $product;
     $resultSource = new \ZMObjectResultSource('ZenMagick\\StoreBundle\\entities\\catalog\\Review', 'reviewService', "getReviewsForProductId", array($product->getId(), $request->getSession()->getLanguageId()));
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->getInt('page'));
     $data['resultList'] = $resultList;
     return $this->findView(null, $data);
 }
コード例 #26
0
 /**
  * Returns a list of all available filter values.
  *
  * @return array An array of string values.
  */
 public function getOptions()
 {
     $options = array();
     foreach ($this->list->getAllResults() as $result) {
         $manufacturer = $result->getManufacturer();
         if (null != $manufacturer) {
             $option = Beans::getBean('ZMFilterOption');
             $option->setId($manufacturer->getId());
             $option->setName($manufacturer->getName());
             $option->setActive($manufacturer->getId() == $this->filterValues[0]);
             $options[$option->getId()] = $option;
         }
     }
     return $options;
 }
コード例 #27
0
 /**
  * Returns a list of all available filter values.
  *
  * @return array An array of string values.
  */
 public function getOptions()
 {
     $options = array();
     foreach ($this->list->getAllResults() as $result) {
         $category = $result->getDefaultCategory($this->container->get('session')->getLanguageId());
         if (null != $category) {
             $option = Beans::getBean('ZMFilterOption');
             $option->setId($category->getId());
             $option->setName($category->getName());
             $option->setActive($category->getId() == $this->filterValues[0]);
             $options[$option->getId()] = $option;
         }
     }
     return $options;
 }
コード例 #28
0
 /**
  * Test manufacturer without info record.
  */
 public function testNoInfo()
 {
     // create new manufacturer without info record
     $newManufacturer = Beans::getBean('ZenMagick\\StoreBundle\\Entity\\Catalog\\Manufacturer');
     $newManufacturer->setName('Foo');
     $newManufacturer->setDateAdded(new \DateTime());
     $newManufacturer->setLastModified(new \DateTime());
     $newManufacturer = \ZMRuntime::getDatabase()->createModel('manufacturers', $newManufacturer);
     $manufacturer = $this->get('manufacturerService')->getManufacturerForId($newManufacturer->getId(), 1);
     if ($this->assertNotNull($manufacturer)) {
         $this->assertEquals($newManufacturer->getId(), $manufacturer->getId());
         $this->assertEquals('Foo', $manufacturer->getName());
     }
     // remove again
     \ZMRuntime::getDatabase()->removeModel('manufacturers', $newManufacturer);
 }
コード例 #29
0
 /**
  * {@inheritDoc}
  */
 public function getViewData($request)
 {
     if (!Toolbox::asBoolean($request->getParameter('other', false))) {
         $sql = "SELECT count(ci.customers_info_source_id) AS count, s.sources_name AS name, s.sources_id as sourceId\n                    FROM %table.customers_info% ci LEFT JOIN %table.sources% s ON s.sources_id = ci.customers_info_source_id\n                    GROUP BY s.sources_id\n                    ORDER BY ci.customers_info_source_id DESC";
         $isOther = false;
     } else {
         $sql = "SELECT count(ci.customers_info_source_id) as count, so.sources_other_name as name\n                  FROM %table.customers_info% ci, %table.sources_other% so\n                  WHERE ci.customers_info_source_id = " . ID_SOURCE_OTHER . " AND so.customers_id = ci.customers_info_id\n                  GROUP BY so.sources_other_name\n                  ORDER BY so.sources_other_name DESC";
         $isOther = true;
     }
     $sourceStats = \ZMRuntime::getDatabase()->fetchAll($sql, array(), array('sources'), 'ZenMagick\\Base\\ZMObject');
     $resultSource = new ZMArrayResultSource('ZenMagick\\Base\\ZMObject', $sourceStats);
     $resultList = Beans::getBean('ZMResultList');
     $resultList->setResultSource($resultSource);
     $resultList->setPageNumber($request->query->get('page', 1));
     return array('resultList' => $resultList, 'isOther' => $isOther);
 }
コード例 #30
0
 /**
  * Load all patches.
  */
 public function loadPatches()
 {
     $path = __DIR__ . '/Patches';
     $ext = '.php';
     $this->patches = array();
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)) as $filename => $fileInfo) {
         if ($fileInfo->isFile() && $ext == substr($fileInfo->getFilename(), -strlen($ext))) {
             $filename = $fileInfo->getPathname();
             $parent = basename(dirname($filename));
             if (in_array($parent, array('File', 'Sql'))) {
                 $class = sprintf('ZenMagick\\AdminBundle\\Installation\\Patches\\%s\\%s', $parent, substr($fileInfo->getFilename(), 0, strlen($fileInfo->getFilename()) - strlen($ext)));
                 $patch = Beans::getBean($class);
                 $this->patches[$patch->getId()] = $patch;
             }
         }
     }
 }