|
@@ 173-205 (lines=33) @@
|
| 170 |
|
* @param Mage_Catalog_Model_Product $oProduct |
| 171 |
|
* @return bool |
| 172 |
|
*/ |
| 173 |
|
public function isProductActive(Mage_Catalog_Model_Product $oProduct) |
| 174 |
|
{ |
| 175 |
|
$bIsProductActive = true; |
| 176 |
|
if ($this->isExtensionActive() === true) { |
| 177 |
|
$bCheckCategory = $this->isExtensionActiveByCategory(); |
| 178 |
|
$bCheckUser = $this->isExtensionActivatedByCustomerGroup(); |
| 179 |
|
$bIsCustomerLoggedIn = $this->isCustomerLoggedIn(); |
| 180 |
|
|
| 181 |
|
/** @var Sitewards_B2BProfessional_Helper_Category $oCategoryHelper */ |
| 182 |
|
$oCategoryHelper = Mage::helper('sitewards_b2bprofessional/category'); |
| 183 |
|
/** @var Sitewards_B2BProfessional_Helper_Customer $oCustomerHelper */ |
| 184 |
|
$oCustomerHelper = Mage::helper('sitewards_b2bprofessional/customer'); |
| 185 |
|
|
| 186 |
|
$bIsCategoryEnabled = $oCategoryHelper->isCategoryActiveByProduct($oProduct); |
| 187 |
|
$bIsCustomerGroupEnabled = $oCustomerHelper->isCustomerGroupActive(); |
| 188 |
|
|
| 189 |
|
if ($bCheckCategory && $bCheckUser) { |
| 190 |
|
$bIsProductActive = !($bIsCategoryEnabled && $bIsCustomerGroupEnabled); |
| 191 |
|
} elseif ($bCheckUser) { |
| 192 |
|
$bIsProductActive = !$bIsCustomerGroupEnabled; |
| 193 |
|
} elseif ($bCheckCategory) { |
| 194 |
|
if ($bIsCustomerLoggedIn) { |
| 195 |
|
$bIsProductActive = true; |
| 196 |
|
} else { |
| 197 |
|
$bIsProductActive = !$bIsCategoryEnabled; |
| 198 |
|
} |
| 199 |
|
} else { |
| 200 |
|
$bIsProductActive = $bIsCustomerLoggedIn; |
| 201 |
|
} |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
return $bIsProductActive; |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
/** |
| 208 |
|
* From an array of category ids check to see if any are enabled via the extension to hide prices |
|
@@ 213-244 (lines=32) @@
|
| 210 |
|
* @param int[] $aCategoryIds |
| 211 |
|
* @return bool |
| 212 |
|
*/ |
| 213 |
|
public function hasEnabledCategories($aCategoryIds) |
| 214 |
|
{ |
| 215 |
|
$bHasCategories = false; |
| 216 |
|
if ($this->isExtensionActive() === true) { |
| 217 |
|
$bCheckCategory = $this->isExtensionActiveByCategory(); |
| 218 |
|
$bCheckUser = $this->isExtensionActivatedByCustomerGroup(); |
| 219 |
|
$bIsCustomerLoggedIn = $this->isCustomerLoggedIn(); |
| 220 |
|
|
| 221 |
|
/** @var Sitewards_B2BProfessional_Helper_Category $oCategoryHelper */ |
| 222 |
|
$oCategoryHelper = Mage::helper('sitewards_b2bprofessional/category'); |
| 223 |
|
/** @var Sitewards_B2BProfessional_Helper_Customer $oCustomerHelper */ |
| 224 |
|
$oCustomerHelper = Mage::helper('sitewards_b2bprofessional/customer'); |
| 225 |
|
|
| 226 |
|
$bHasActiveCategories = $oCategoryHelper->hasActiveCategory($aCategoryIds); |
| 227 |
|
$bIsUserGroupActive = $oCustomerHelper->isCustomerGroupActive(); |
| 228 |
|
|
| 229 |
|
if ($bCheckCategory && $bCheckUser) { |
| 230 |
|
$bHasCategories = $bHasActiveCategories && $bIsUserGroupActive; |
| 231 |
|
} elseif ($bCheckUser) { |
| 232 |
|
$bHasCategories = $bIsUserGroupActive; |
| 233 |
|
} elseif ($bCheckCategory) { |
| 234 |
|
if ($bIsCustomerLoggedIn) { |
| 235 |
|
$bHasCategories = false; |
| 236 |
|
} else { |
| 237 |
|
$bHasCategories = $bHasActiveCategories; |
| 238 |
|
} |
| 239 |
|
} else { |
| 240 |
|
$bHasCategories = !$bIsCustomerLoggedIn; |
| 241 |
|
} |
| 242 |
|
} |
| 243 |
|
return $bHasCategories; |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
/** |
| 247 |
|
* Check if the customer is logged in |