/** * {@inheritdoc} */ public function getPersistedFilterParameters() { $employee = \ContextCore::getContext()->employee; $shop = \ContextCore::getContext()->shop; $filter = $this->entityManager->getRepository('PrestaShopBundle:AdminFilter')->findOneBy(array('employee' => $employee->id ?: 0, 'shop' => $shop->id ?: 0, 'controller' => 'ProductController', 'action' => 'catalogAction')); /* @var $filter AdminFilter */ if (!$filter) { return AdminFilter::getProductCatalogEmptyFilter(); } return $filter->getProductCatalogFilter(); }
/** * Set the Catalog filters values and redirect to the catalogAction. * * URL example: /product/catalog_filters/42/last/32 * * @param integer|string $quantity The quantity to set on the catalog filters persistence. * @param string $active The activation state to set on the catalog filters persistence. * @return void (redirection) */ public function catalogFiltersAction($quantity = 'none', $active = 'none') { $quantity = urldecode($quantity); $productProvider = $this->container->get('prestashop.core.admin.data_provider.product_interface'); /* @var $productProvider ProductInterfaceProvider */ // we merge empty filter set with given values, to reset the other filters! $productProvider->persistFilterParameters(array_merge(AdminFilter::getProductCatalogEmptyFilter(), ['filter_column_sav_quantity' => $quantity == 'none' ? '' : $quantity, 'filter_column_active' => $active == 'none' ? '' : $active])); return $this->redirectToRoute('admin_product_catalog'); }