Skip to content

Instantly share code, notes, and snippets.

@zandzpider
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zandzpider/8b13c5fe693138ee5c10 to your computer and use it in GitHub Desktop.
Save zandzpider/8b13c5fe693138ee5c10 to your computer and use it in GitHub Desktop.
<?php
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());
}
<?php
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment