本文整理汇总了PHP中Shopware函数的典型用法代码示例。如果您正苦于以下问题:PHP Shopware函数的具体用法?PHP Shopware怎么用?PHP Shopware使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Shopware函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$order = $eventArgs->getEntity();
if (!$order instanceof \Shopware\Models\Order\Order) {
return;
}
//order or payment status changed?
if ($eventArgs->hasChangedField('paymentStatus') || $eventArgs->hasChangedField('orderStatus')) {
$historyData = array('userID' => null, 'change_date' => date('Y-m-d H:i:s'), 'orderID' => $order->getId());
if (Shopware()->Auth()->getIdentity() && Shopware()->Auth()->getIdentity()->id) {
$user = $eventArgs->getEntityManager()->find('Shopware\\Models\\User\\User', Shopware()->Auth()->getIdentity()->id);
$historyData['userID'] = $user->getId();
}
//order status changed?
if ($eventArgs->hasChangedField('orderStatus')) {
$historyData['previous_order_status_id'] = $eventArgs->getOldValue('orderStatus')->getId();
$historyData['order_status_id'] = $eventArgs->getNewValue('orderStatus')->getId();
} else {
$historyData['previous_order_status_id'] = $order->getOrderStatus()->getId();
$historyData['order_status_id'] = $order->getOrderStatus()->getId();
}
//payment status changed?
if ($eventArgs->hasChangedField('paymentStatus')) {
$historyData['previous_payment_status_id'] = $eventArgs->getOldValue('paymentStatus')->getId();
$historyData['payment_status_id'] = $eventArgs->getNewValue('paymentStatus')->getId();
} else {
$historyData['previous_payment_status_id'] = $order->getPaymentStatus()->getId();
$historyData['payment_status_id'] = $order->getPaymentStatus()->getId();
}
$eventArgs->getEntityManager()->getConnection()->insert('s_order_history', $historyData);
}
}
示例2: getListAction
/**
* Event listener method which fires when the order store is loaded. Returns an array of order data
* which displayed in an Ext.grid.Panel. The order data contains all associations of an order (positions, shop, customer, ...).
* The limit, filter and order parameter are used in the id query. The result of the id query are used
* to filter the detailed query which created over the getListQuery function.
*/
public function getListAction()
{
//read store parameter to filter and paginate the data.
$limit = $this->Request()->getParam('limit', 20);
$offset = $this->Request()->getParam('start', 0);
$sort = $this->Request()->getParam('sort', null);
$filter = $this->Request()->getParam('filter', array());
$orderId = $this->Request()->getParam('orderID');
if(!is_null($orderId)) {
$orderIdFilter = array('property' => 'orders.id', 'value' => $orderId);
$filter[] = $orderIdFilter;
}
$builder = Shopware()->Models()->createQueryBuilder();
$builder->select(array('payment.id'))
->from('Shopware\Models\Payment\Payment', 'payment')
->where('payment.name = :name')
->setParameter('name', 'BuiswPaymentPayone')
->setFirstResult(0)
->setMaxResults(1);
$payOneId = $builder->getQuery()->getOneOrNullResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
if (!empty($payOneId)) {
$filter[] = array('property' => 'payment.id', 'value' => $payOneId['id']);
}
$list = $this->getList($filter, $sort, $offset, $limit);
$this->View()->assign($list);
}
示例3: factory
/**
* @param Container $container
* @return \Enlight_Components_Session_Namespace
*/
public function factory(Container $container)
{
$sessionOptions = Shopware()->getOption('session', array());
if (!empty($sessionOptions['unitTestEnabled'])) {
\Enlight_Components_Session::$_unitTestEnabled = true;
}
unset($sessionOptions['unitTestEnabled']);
if (\Enlight_Components_Session::isStarted()) {
\Enlight_Components_Session::writeClose();
}
/** @var $shop \Shopware\Models\Shop\Shop */
$shop = $container->get('Shop');
$name = 'session-' . $shop->getId();
$sessionOptions['name'] = $name;
if (!isset($sessionOptions['save_handler']) || $sessionOptions['save_handler'] == 'db') {
$config_save_handler = array('db' => $container->get('Db'), 'name' => 's_core_sessions', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'expiry');
\Enlight_Components_Session::setSaveHandler(new \Enlight_Components_Session_SaveHandler_DbTable($config_save_handler));
unset($sessionOptions['save_handler']);
}
\Enlight_Components_Session::start($sessionOptions);
$container->set('SessionID', \Enlight_Components_Session::getId());
$namespace = new \Enlight_Components_Session_Namespace('Shopware');
$namespace->offsetSet('sessionId', \Enlight_Components_Session::getId());
return $namespace;
}
示例4: exportProductFiles
/**
* starts all product export for all active product feeds
*
* @throws RuntimeException
* @return string
*/
public function exportProductFiles()
{
$productFeedRepository = Shopware()->Models()->getRepository('Shopware\\Models\\ProductFeed\\ProductFeed');
$activeFeeds = $productFeedRepository->getActiveListQuery()->getResult();
$export = Shopware()->Modules()->Export();
$export->sSYSTEM = Shopware()->System();
$sSmarty = Shopware()->Template();
$cacheDir = Shopware()->Container()->getParameter('kernel.cache_dir');
$cacheDir .= '/productexport/';
if (!is_dir($cacheDir)) {
if (false === @mkdir($cacheDir, 0777, true)) {
throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", "Productexport", $cacheDir));
}
} elseif (!is_writable($cacheDir)) {
throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", "Productexport", $cacheDir));
}
foreach ($activeFeeds as $feedModel) {
/** @var $feedModel Shopware\Models\ProductFeed\ProductFeed */
if ($feedModel->getInterval() == 0) {
continue;
}
$export->sFeedID = $feedModel->getId();
$export->sHash = $feedModel->getHash();
$export->sInitSettings();
$export->sSmarty = clone $sSmarty;
$export->sInitSmarty();
$fileName = $feedModel->getHash() . '_' . $feedModel->getFileName();
$handleResource = fopen($cacheDir . $fileName, 'w');
$export->executeExport($handleResource);
}
return true;
}
示例5: buildAction
/**
* This controller action is used to build the search index.
*/
public function buildAction()
{
@set_time_limit(1200);
$adapter = new Shopware_Components_Search_Adapter_Default(Shopware()->Db(), Shopware()->Cache(), new Shopware_Components_Search_Result_Default(), Shopware()->Config());
$adapter->buildSearchIndex();
$this->View()->assign(array('success' => true));
}
示例6: import
/**
* Does the actual import
*/
public function import()
{
$row = Shopware()->Db()->fetchAll('
SELECT *
FROM plenty_mapping_category
WHERE plentyID LIKE "' . $this->Category->CategoryID . ';%"
LIMIT 1
');
if (!$row) {
// PyLog()->message('Sync:Item:Category', 'Skipping the category »' . $this->Category->Name . '« (not found)');
return;
}
$index = explode(PlentymarketsMappingEntityCategory::DELIMITER, $row[0]['shopwareID']);
$categoryId = $index[0];
/** @var Shopware\Models\Category\Category $Category */
$Category = Shopware()->Models()->find('Shopware\\Models\\Category\\Category', $categoryId);
// If the shopware category wasn't found, something is terribly wrong
if (!$Category) {
PyLog()->message('Sync:Item:Category', 'Skipping the category »' . $this->Category->Name . '« (not found)');
return;
}
// Update the category only if the name's changed
if ($Category->getName() != $this->Category->Name || $Category->getPosition() != $this->Category->Position) {
PyLog()->message('Sync:Item:Category', 'Updating the category »' . $this->Category->Name . '«');
$Category->setName($this->Category->Name);
$Category->setPosition($this->Category->Position);
Shopware()->Models()->persist($Category);
Shopware()->Models()->flush();
}
}
开发者ID:bcremer,项目名称:plentymarkets-shopware-connector,代码行数:33,代码来源:PlentymarketsImportEntityItemCategory.php
示例7: getRepository
/**
* Internal helper function to get access to the form repository.
*
* @return Shopware\Models\Form\Repository
*/
private function getRepository()
{
if ($this->repository === null) {
$this->repository = Shopware()->Models()->getRepository('Shopware\\Models\\Form\\Form');
}
return $this->repository;
}
示例8: nextSequenceNumber
/**
*
* @param string $txid
* @return int
*/
public function nextSequenceNumber($txid) {
$sql = 'select max(sequencenumber) from ' . self::TABLE_NAME .
' where transaction_no="' . $txid . '"';
$res = Shopware()->Db()->fetchOne($sql);
return (int) ($res ? $res + 1 : 1);
}
示例9: smarty_function_compileLess
/**
* @param $params
* @param $template
* @return void
* @throws Exception
*/
function smarty_function_compileLess($params, $template)
{
$time = $params['timestamp'];
$output = $params['output'];
/**@var $pathResolver \Shopware\Components\Theme\PathResolver*/
$pathResolver = Shopware()->Container()->get('theme_path_resolver');
/**@var $shop \Shopware\Models\Shop\Shop*/
$shop = Shopware()->Container()->get('shop');
/**@var $settings \Shopware\Models\Theme\Settings*/
$settings = Shopware()->Container()->get('theme_service')->getSystemConfiguration(\Doctrine\ORM\AbstractQuery::HYDRATE_OBJECT);
/** @var $front Enlight_Controller_Front */
$front = Enlight_Application::Instance()->Front();
$secure = $front->Request()->isSecure();
$file = $pathResolver->getCssFilePath($shop, $time);
$url = $pathResolver->formatPathToUrl($file, $shop, $secure);
if (!$settings->getForceCompile() && file_exists($file)) {
// see: http://stackoverflow.com/a/9473886
$template->assign($output, [$url]);
return;
}
/**@var $compiler \Shopware\Components\Theme\Compiler*/
$compiler = Shopware()->Container()->get('theme_compiler');
$compiler->compileLess($time, $shop->getTemplate(), $shop);
$template->assign($output, [$url]);
}
示例10: factory
/**
* Loads the Zend resource and initials the Enlight_Controller_Front class.
* After the front resource is loaded, the controller path is added to the
* front dispatcher. After the controller path is set to the dispatcher,
* the plugin namespace of the front resource is set.
*
* @param Container $container
* @param \Shopware_Bootstrap $bootstrap
* @param \Enlight_Event_EventManager $eventManager
* @param array $options
* @throws \Exception
* @return \Enlight_Controller_Front
*/
public function factory(Container $container, \Shopware_Bootstrap $bootstrap, \Enlight_Event_EventManager $eventManager, array $options)
{
/** @var $front \Enlight_Controller_Front */
$front = \Enlight_Class::Instance('Enlight_Controller_Front', array($eventManager));
$front->setDispatcher($container->get('Dispatcher'));
$front->Dispatcher()->addModuleDirectory(Shopware()->AppPath('Controllers'));
$front->setRouter($container->get('Router'));
$front->setParams($options);
/** @var $plugins \Enlight_Plugin_PluginManager */
$plugins = $container->get('Plugins');
$plugins->registerNamespace($front->Plugins());
$front->setParam('bootstrap', $bootstrap);
if (!empty($options['throwExceptions'])) {
$front->throwExceptions((bool) $options['throwExceptions']);
}
try {
$container->load('Cache');
$container->load('Db');
$container->load('Plugins');
} catch (\Exception $e) {
if ($front->throwExceptions()) {
throw $e;
}
$front->Response()->setException($e);
}
return $front;
}
示例11: setUp
/**
* Standard set up for every test - just disable auth
*/
public function setUp()
{
parent::setUp();
// disable auth and acl
Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
Shopware()->Plugins()->Backend()->Auth()->setNoAcl();
}
示例12: includeAction
/**
* Load action for the script renderer.
*/
public function includeAction()
{
$oldPath = Shopware()->OldPath('engine');
$module = basename($this->Request()->getParam('includeDir'));
$module = preg_replace('/[^a-z0-9_.:-]/i', '', $module);
if ($module !== '') {
$module .= '/';
}
$include = (string) $this->Request()->getParam('include', 'skeleton.php');
$query = parse_url($include, PHP_URL_QUERY);
$include = parse_url($include, PHP_URL_PATH);
$include = preg_replace('/[^a-z0-9\\/\\\\_.:-]/i', '', $include);
if (file_exists($oldPath . 'local_old/modules/' . $module . $include)) {
$location = 'engine/local_old/modules/' . $module . $include;
} elseif (file_exists($oldPath . 'backend/modules/' . $module . $include)) {
$location = 'engine/backend/modules/' . $module . $include;
}
if (!empty($location)) {
if (!empty($query)) {
$location .= '?' . $query;
} elseif ($this->Request()->isPost()) {
$location .= '?' . http_build_query($this->Request()->getPost(), '', '&');
}
$this->redirect($location);
} else {
$this->Response()->setHttpResponseCode(404);
}
}
示例13: indexAction
public function indexAction()
{
if (Shopware()->Shop()->get('esi')) {
$getMetaFields = Shopware()->Db()->fetchRow('
SELECT seo_keywords, seo_description, name FROM s_emotion WHERE id = ?
', array($this->Request()->getParam('emotionId')));
//$this->View()->extendsBlock('frontend_index_header_title', $getMetaFields['name'], null);
$this->View()->assign('sBreadcrumb', array(0 => array('name' => $getMetaFields['name'])));
$this->View()->assign('seo_keywords', $getMetaFields['seo_keywords']);
$this->View()->assign('seo_description', $getMetaFields['seo_description']);
$this->View()->assign('emotionId', intval($this->Request()->getParam('emotionId')));
} else {
// @deprecated - support for shopware 3.x campaigns
$campaignId = (int)$this->Request()->sCampaign;
if (empty($$campaignId)) {
return $this->forward('index', 'index');
}
$campaign = Shopware()->Modules()->Marketing()->sCampaignsGetDetail($campaignId);
if (empty($campaign['id'])) {
return $this->forward('index', 'index');
}
$this->View()->loadTemplate("frontend/campaign/old.tpl");
$this->View()->sCampaign = $campaign;
}
}
示例14: defaultSearchAction
/**
* Default search
*/
public function defaultSearchAction()
{
if (!$this->Request()->has('sSort')) {
$this->Request()->setParam('sSort', 7);
}
$term = $this->getSearchTerm();
// Check if we have a one to one match for ordernumber, then redirect
$location = $this->searchFuzzyCheck($term);
if (!empty($location)) {
return $this->redirect($location);
}
$this->View()->loadTemplate('frontend/search/fuzzy.tpl');
$minLengthSearchTerm = $this->get('config')->get('minSearchLenght');
if (strlen($term) < (int) $minLengthSearchTerm) {
return;
}
/**@var $context ProductContextInterface*/
$context = $this->get('shopware_storefront.context_service')->getProductContext();
$criteria = Shopware()->Container()->get('shopware_search.store_front_criteria_factory')->createSearchCriteria($this->Request(), $context);
/**@var $result ProductSearchResult*/
$result = $this->get('shopware_search.product_search')->search($criteria, $context);
$articles = $this->convertProducts($result);
if ($this->get('config')->get('traceSearch', true)) {
$this->get('shopware_searchdbal.search_term_logger')->logResult($criteria, $result, $context->getShop());
}
$pageCounts = $this->get('config')->get('fuzzySearchSelectPerPage');
$request = $this->Request()->getParams();
$request['sSearchOrginal'] = $term;
/** @var $mapper \Shopware\Components\QueryAliasMapper */
$mapper = $this->get('query_alias_mapper');
$this->View()->assign(array('term' => $term, 'criteria' => $criteria, 'facets' => $result->getFacets(), 'sPage' => $this->Request()->getParam('sPage', 1), 'sSort' => $this->Request()->getParam('sSort', 7), 'sTemplate' => $this->Request()->getParam('sTemplate'), 'sPerPage' => array_values(explode("|", $pageCounts)), 'sRequests' => $request, 'shortParameters' => $mapper->getQueryAliases(), 'pageSizes' => array_values(explode("|", $pageCounts)), 'ajaxCountUrlParams' => ['sCategory' => $context->getShop()->getCategory()->getId()], 'sSearchResults' => array('sArticles' => $articles, 'sArticlesCount' => $result->getTotalCount()), 'productBoxLayout' => $this->get('config')->get('searchProductBoxLayout')));
}
示例15: uninstall
public function uninstall()
{
$cacheManager = Shopware()->Container()->get('shopware.cache_manager');
$cacheManager->clearThemeCache();
$this->secureUninstall();
return true;
}