public function __construct(array $data = array()) { $this->_helper = isset($data['helper']) ? $data['helper'] : Mage::helper('Mage_Catalog_Helper_Product'); $this->_virtual = isset($data['element']) ? $data['element'] : Mage::getModel('Varien_Data_Form_Element_Checkbox'); $this->_virtual->setId(self::VIRTUAL_FIELD_HTML_ID)->setName('is_virtual')->setLabel($this->_helper->getTypeSwitcherControlLabel()); parent::__construct($data); }
/** * Normally this methods check to see whether the product is configured * to be visible on the frontend. We're overloading that so that * the product will actually show up as long as the url hash key * is correct. * * @param int|Mage_Catalog_Model_Product $product * @param string $where * @return bool */ public function canShow($product, $where = 'catalog') { if ($this->_validateUrlHash()) { return true; } return parent::canShow($product, $where); }
public function testPrepareProductOptions() { $product = new Mage_Catalog_Model_Product(); $buyRequest = new Varien_Object(array('qty' => 100, 'options' => array('option' => 'value'))); $this->_helper->prepareProductOptions($product, $buyRequest); $result = $product->getPreconfiguredValues(); $this->assertInstanceOf('Varien_Object', $result); $this->assertEquals(100, $result->getQty()); $this->assertEquals(array('option' => 'value'), $result->getOptions()); }
function canShow($product, $where = 'catalog') { $isVisible = parent::canShow($product, $where); if (!$isVisible && Mage::app()->getRequest()->getParam('pid') > 0) { $product = Mage::getModel('catalog/product')->load(Mage::app()->getRequest()->getParam('pid')); foreach ($product->getTypeInstance(true)->getUsedProducts(null, $product) as $childProduct) { $childIds[] = $childProduct->getId(); } if (in_array(Mage::app()->getRequest()->getParam('id'), $childIds)) { $isVisible = true; } } return $isVisible; }