public function isSalable() { Mage::dispatchEvent('catalog_product_is_salable_before', array('product' => $this)); $salable = $this->isAvailable(); $object = new Varien_Object(array('product' => $this, 'is_salable' => $salable)); Mage::dispatchEvent('catalog_product_is_salable_after', array('product' => $this, 'salable' => $object)); $_product = Mage::getModel('catalog/product')->load($this->getId()); $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); $restrictedCustomerGroups = $_product->getRestrictGroups(); if (empty($restrictedCustomerGroups) || count($restrictedCustomerGroups) == 1 && ($restrictedCustomerGroups[0] == '0' || $restrictedCustomerGroups[0] == '')) { $allowAddToCart = true; } else { if (in_array($groupId, $restrictedCustomerGroups)) { $allowAddToCart = false; } else { $allowAddToCart = true; } } if (!$allowAddToCart) { $object->setIsSalable($allowAddToCart); } return $object->getIsSalable(); }
/** * Check is product available for sale * * @return bool */ public function isSalable() { Mage::dispatchEvent('catalog_product_is_salable_before', array('product' => $this)); $salable = $this->isAvailable(); $object = new Varien_Object(array('product' => $this, 'is_salable' => $salable)); Mage::dispatchEvent('catalog_product_is_salable_after', array('product' => $this, 'salable' => $object)); return $object->getIsSalable(); }
/** * Check is product available for sale * * @return bool */ public function isSalable() { AO::dispatchEvent('catalog_product_is_salable_before', array('product' => $this)); $salable = $this->getTypeInstance(true)->isSalable($this); $object = new Varien_Object(array('product' => $this, 'is_salable' => $salable)); AO::dispatchEvent('catalog_product_is_salable_after', array('product' => $this, 'salable' => $object)); return $object->getIsSalable(); }
/** * Check is product available for sale * * @return bool */ public function isSalable() { //function modified to store answers in the magento registry if (is_null(Mage::registry('isSaleable' . $this->getId()))) { Mage::dispatchEvent('catalog_product_is_salable_before', array('product' => $this)); $salable = $this->isAvailable(); $object = new Varien_Object(array('product' => $this, 'is_salable' => $salable)); Mage::dispatchEvent('catalog_product_is_salable_after', array('product' => $this, 'salable' => $object)); Mage::register('isSaleable' . $this->getId(), $object->getIsSalable(), true); } return Mage::registry('isSaleable' . $this->getId()); }