Example #1
0
$GLOBALS['TL_MODELS'][\Isotope\Model\Config::getTable()] = 'Isotope\\Model\\Config';
$GLOBALS['TL_MODELS'][\Isotope\Model\Document::getTable()] = 'Isotope\\Model\\Document';
$GLOBALS['TL_MODELS'][\Isotope\Model\Download::getTable()] = 'Isotope\\Model\\Download';
$GLOBALS['TL_MODELS'][\Isotope\Model\Gallery::getTable()] = 'Isotope\\Model\\Gallery';
$GLOBALS['TL_MODELS'][\Isotope\Model\Group::getTable()] = 'Isotope\\Model\\Group';
$GLOBALS['TL_MODELS'][\Isotope\Model\Label::getTable()] = 'Isotope\\Model\\Label';
$GLOBALS['TL_MODELS'][\Isotope\Model\OrderStatus::getTable()] = 'Isotope\\Model\\OrderStatus';
$GLOBALS['TL_MODELS'][\Isotope\Model\Payment::getTable()] = 'Isotope\\Model\\Payment';
$GLOBALS['TL_MODELS'][\Isotope\Model\Product::getTable()] = 'Isotope\\Model\\Product';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCategory::getTable()] = 'Isotope\\Model\\ProductCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollection::getTable()] = 'Isotope\\Model\\ProductCollection';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionDownload::getTable()] = 'Isotope\\Model\\ProductCollectionDownload';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionItem::getTable()] = 'Isotope\\Model\\ProductCollectionItem';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionSurcharge::getTable()] = 'Isotope\\Model\\ProductCollectionSurcharge';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductPrice::getTable()] = 'Isotope\\Model\\ProductPrice';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCache::getTable()] = 'Isotope\\Model\\ProductCache';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductType::getTable()] = 'Isotope\\Model\\ProductType';
$GLOBALS['TL_MODELS'][\Isotope\Model\RelatedCategory::getTable()] = 'Isotope\\Model\\RelatedCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\RelatedProduct::getTable()] = 'Isotope\\Model\\RelatedProduct';
$GLOBALS['TL_MODELS'][\Isotope\Model\RequestCache::getTable()] = 'Isotope\\Model\\RequestCache';
$GLOBALS['TL_MODELS'][\Isotope\Model\Shipping::getTable()] = 'Isotope\\Model\\Shipping';
$GLOBALS['TL_MODELS'][\Isotope\Model\TaxClass::getTable()] = 'Isotope\\Model\\TaxClass';
$GLOBALS['TL_MODELS'][\Isotope\Model\TaxRate::getTable()] = 'Isotope\\Model\\TaxRate';
/**
 * Checkout steps
 */
$GLOBALS['ISO_CHECKOUTSTEP'] = array('address' => array('\\Isotope\\CheckoutStep\\BillingAddress', '\\Isotope\\CheckoutStep\\ShippingAddress'), 'shipping' => array('\\Isotope\\CheckoutStep\\ShippingMethod'), 'payment' => array('\\Isotope\\CheckoutStep\\PaymentMethod'), 'review' => array('\\Isotope\\CheckoutStep\\OrderConditionsOnTop', '\\Isotope\\CheckoutStep\\OrderInfo', '\\Isotope\\CheckoutStep\\OrderConditionsBeforeProducts', '\\Isotope\\CheckoutStep\\OrderProducts', '\\Isotope\\CheckoutStep\\OrderConditionsAfterProducts'));
/**
 * Permissions are access settings for user and groups (fields in tl_user and tl_user_group)
 */
$GLOBALS['TL_PERMISSIONS'][] = 'iso_modules';
Example #2
0
 /**
  * Truncate the product cache table if a product is changed
  * Second parameter and return value is to use the method as save_callback
  *
  * @param mixed $varValue
  *
  * @return mixed
  */
 public static function truncateProductCache($varValue = null)
 {
     ProductCache::purge();
     return $varValue;
 }
Example #3
0
 /**
  * Compile product list.
  *
  * This function is specially designed so you can keep it in your child classes and only override findProducts().
  * You will automatically gain product caching (see class property), grid classes, pagination and more.
  */
 protected function compile()
 {
     // return message if no filter is set
     if ($this->iso_emptyFilter && !\Input::get('isorc') && !\Input::get('keywords')) {
         $this->Template->message = $this->replaceInsertTags($this->iso_noFilter);
         $this->Template->type = 'noFilter';
         $this->Template->products = array();
         return;
     }
     global $objPage;
     $intPage = $this->iso_category_scope == 'article' ? $GLOBALS['ISO_CONFIG']['current_article']['pid'] : $objPage->id;
     $arrProducts = null;
     $arrCacheIds = null;
     // Try to load the products from cache
     if ($this->blnCacheProducts && ($objCache = ProductCache::findForPageAndModule($intPage, $this->id)) !== null) {
         $arrCacheIds = $objCache->getProductIds();
         // Use the cache if keywords match. Otherwise we will use the product IDs as a "limit" for findProducts()
         if ($objCache->keywords == \Input::get('keywords')) {
             $arrCacheIds = $this->generatePagination($arrCacheIds);
             $objProducts = Product::findAvailableByIds($arrCacheIds, array('order' => \Database::getInstance()->findInSet(Product::getTable() . '.id', $arrCacheIds)));
             $arrProducts = null === $objProducts ? array() : $objProducts->getModels();
             // Cache is wrong, drop everything and run findProducts()
             if (count($arrProducts) != count($arrCacheIds)) {
                 $arrCacheIds = null;
                 $arrProducts = null;
             }
         }
     }
     if (!is_array($arrProducts)) {
         // Display "loading products" message and add cache flag
         if ($this->blnCacheProducts) {
             $blnCacheMessage = (bool) $this->iso_productcache[$intPage][(int) \Input::get('isorc')];
             if ($blnCacheMessage && !\Input::get('buildCache')) {
                 // Do not index or cache the page
                 $objPage->noSearch = 1;
                 $objPage->cache = 0;
                 $this->Template = new \Isotope\Template('mod_iso_productlist_caching');
                 $this->Template->message = $GLOBALS['TL_LANG']['MSC']['productcacheLoading'];
                 return;
             }
             // Start measuring how long it takes to load the products
             $start = microtime(true);
             // Load products
             $arrProducts = $this->findProducts($arrCacheIds);
             // Decide if we should show the "caching products" message the next time
             $end = microtime(true) - $start;
             $this->blnCacheProducts = $end > 1 ? true : false;
             $arrCacheMessage = $this->iso_productcache;
             if ($blnCacheMessage != $this->blnCacheProducts) {
                 $arrCacheMessage[$intPage][(int) \Input::get('isorc')] = $this->blnCacheProducts;
                 \Database::getInstance()->prepare("UPDATE tl_module SET iso_productcache=? WHERE id=?")->execute(serialize($arrCacheMessage), $this->id);
             }
             // Do not write cache if table is locked. That's the case if another process is already writing cache
             if (ProductCache::isWritable()) {
                 \Database::getInstance()->lockTables(array(ProductCache::getTable() => 'WRITE', 'tl_iso_product' => 'READ'));
                 $arrIds = array();
                 foreach ($arrProducts as $objProduct) {
                     $arrIds[] = $objProduct->id;
                 }
                 // Delete existing cache if necessary
                 ProductCache::deleteForPageAndModuleOrExpired($intPage, $this->id);
                 $objCache = ProductCache::createForPageAndModule($intPage, $this->id);
                 $objCache->expires = $this->getProductCacheExpiration();
                 $objCache->setProductIds($arrIds);
                 $objCache->save();
                 \Database::getInstance()->unlockTables();
             }
         } else {
             $arrProducts = $this->findProducts();
         }
         if (!empty($arrProducts)) {
             $arrProducts = $this->generatePagination($arrProducts);
         }
     }
     // No products found
     if (!is_array($arrProducts) || empty($arrProducts)) {
         $this->compileEmptyMessage();
         return;
     }
     $arrBuffer = array();
     $arrDefaultOptions = $this->getDefaultProductOptions();
     /** @var \Isotope\Model\Product\Standard $objProduct */
     foreach ($arrProducts as $objProduct) {
         $arrConfig = array('module' => $this, 'template' => $this->iso_list_layout ?: $objProduct->getRelated('type')->list_template, 'gallery' => $this->iso_gallery ?: $objProduct->getRelated('type')->list_gallery, 'buttons' => deserialize($this->iso_buttons, true), 'useQuantity' => $this->iso_use_quantity, 'jumpTo' => $this->findJumpToPage($objProduct));
         if (\Environment::get('isAjaxRequest') && \Input::post('AJAX_MODULE') == $this->id && \Input::post('AJAX_PRODUCT') == $objProduct->getProductId()) {
             $objResponse = new HtmlResponse($objProduct->generate($arrConfig));
             $objResponse->send();
         }
         $objProduct->mergeRow($arrDefaultOptions);
         // Must be done after setting options to generate the variant config into the URL
         if ($this->iso_jump_first && \Haste\Input\Input::getAutoItem('product', false, true) == '') {
             \Controller::redirect($objProduct->generateUrl($arrConfig['jumpTo']));
         }
         $arrCSS = deserialize($objProduct->cssID, true);
         $arrBuffer[] = array('cssID' => $arrCSS[0] != '' ? ' id="' . $arrCSS[0] . '"' : '', 'class' => trim('product ' . ($objProduct->isNew() ? 'new ' : '') . $arrCSS[1]), 'html' => $objProduct->generate($arrConfig), 'product' => $objProduct);
     }
     // HOOK: to add any product field or attribute to mod_iso_productlist template
     if (isset($GLOBALS['ISO_HOOKS']['generateProductList']) && is_array($GLOBALS['ISO_HOOKS']['generateProductList'])) {
         foreach ($GLOBALS['ISO_HOOKS']['generateProductList'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $arrBuffer = $objCallback->{$callback}[1]($arrBuffer, $arrProducts, $this->Template, $this);
         }
     }
     RowClass::withKey('class')->addCount('product_')->addEvenOdd('product_')->addFirstLast('product_')->addGridRows($this->iso_cols)->addGridCols($this->iso_cols)->applyTo($arrBuffer);
     $this->Template->products = $arrBuffer;
 }
Example #4
0
 private function purgeCaches()
 {
     ProductCache::purge();
     RequestCache::purge();
 }
Example #5
0
 /**
  * Truncate the product cache table if a product is changed
  * Second parameter and return value is to use the method as save_callback
  * @param mixed
  * @return mixed
  */
 public static function truncateProductCache($varValue = null)
 {
     \Isotope\Model\ProductCache::purge();
     return $varValue;
 }
Example #6
0
 private function purgeCaches()
 {
     \Isotope\Model\ProductCache::purge();
     \Isotope\Model\RequestCache::purge();
 }