/** * Returns true if the product is available * ALMOST THE SAME AS THE PARENT, EXCEPT WE DON'T CHECK FOR PRICE * * @param IsotopeProductCollection|\Isotope\Model\ProductCollection $objCollection * * @return bool */ public function isAvailableForCollection(IsotopeProductCollection $objCollection) { if ($objCollection->isLocked()) { return true; } if (BE_USER_LOGGED_IN !== true && !$this->isPublished()) { return false; } // Show to guests only if ($this->arrData['guests'] && $objCollection->member > 0 && BE_USER_LOGGED_IN !== true && !$this->arrData['protected']) { return false; } // Protected product if (BE_USER_LOGGED_IN !== true && $this->arrData['protected']) { if ($objCollection->member == 0) { return false; } $groups = deserialize($this->arrData['groups']); $memberGroups = deserialize($objCollection->getRelated('member')->groups); if (!is_array($groups) || empty($groups) || !is_array($memberGroups) || empty($memberGroups) || !count(array_intersect($groups, $memberGroups))) { return false; } } // Check that the product is in any page of the current site if (count(\Isotope\Frontend::getPagesInCurrentRoot($this->getCategories(), $objCollection->getRelated('member'))) == 0) { return false; } // Check if "advanced price" is available //if (null === $this->getPrice($objCollection) && (in_array('price', $this->getAttributes()) || $this->hasVariantPrices())) { // return false; //} return true; }
/** * Returns true if the product is available * * @param IsotopeProductCollection|\Isotope\Model\ProductCollection $objCollection * * @return bool */ public function isAvailableForCollection(IsotopeProductCollection $objCollection) { if ($objCollection->isLocked()) { return true; } if (isset($GLOBALS['ISO_HOOKS']['productIsAvailable']) && is_array($GLOBALS['ISO_HOOKS']['productIsAvailable'])) { foreach ($GLOBALS['ISO_HOOKS']['productIsAvailable'] as $callback) { $objCallback = \System::importStatic($callback[0]); $available = $objCallback->{$callback}[1]($this, $objCollection); // If return value is boolean then we accept it as result if (true === $available || false === $available) { return $available; } } } if (BE_USER_LOGGED_IN !== true && !$this->isPublished()) { return false; } // Show to guests only if ($this->arrData['guests'] && $objCollection->member > 0 && BE_USER_LOGGED_IN !== true && !$this->arrData['protected']) { return false; } // Protected product if (BE_USER_LOGGED_IN !== true && $this->arrData['protected']) { if ($objCollection->member == 0) { return false; } $groups = deserialize($this->arrData['groups']); $memberGroups = deserialize($objCollection->getRelated('member')->groups); if (!is_array($groups) || empty($groups) || !is_array($memberGroups) || empty($memberGroups) || !count(array_intersect($groups, $memberGroups))) { return false; } } // Check that the product is in any page of the current site if (count(\Isotope\Frontend::getPagesInCurrentRoot($this->getCategories(), $objCollection->getRelated('member'))) == 0) { return false; } // Check if "advanced price" is available if (null === $this->getPrice($objCollection) && (in_array('price', $this->getAttributes()) || $this->hasVariantPrices())) { return false; } return true; }
/** * Find jumpTo page for current category scope * * @param \Isotope\Model\Product\Standard $objProduct * * @return \PageModel */ protected function findJumpToPage($objProduct) { global $objPage; global $objIsotopeListPage; $productCategories = $objProduct->getCategories(true); $arrCategories = array(); if ($this->iso_category_scope != 'current_category' && $this->iso_category_scope != '' && $objPage->alias != 'index') { $arrCategories = array_intersect($productCategories, $this->findCategories()); } // If our current category scope does not match with any product category, // use the first allowed product category in the current root page if (empty($arrCategories)) { $arrCategories = $productCategories; } $arrCategories = Frontend::getPagesInCurrentRoot($arrCategories, \FrontendUser::getInstance()); if (!empty($arrCategories) && ($objCategories = \PageModel::findMultipleByIds($arrCategories)) !== null) { $blnMoreThanOne = $objCategories->count() > 1; foreach ($objCategories as $objCategory) { if ($objCategory->alias == 'index' && $blnMoreThanOne) { continue; } return $objCategory; } } return $objIsotopeListPage ?: $objPage; }