Ejemplo n.º 1
0
 public function testGetAllowProducts()
 {
     $products = $this->_block->getAllowProducts();
     $this->assertGreaterThanOrEqual(2, count($products));
     foreach ($products as $product) {
         $this->assertInstanceOf('Mage_Catalog_Model_Product', $product);
     }
 }
 /**
  * Get Allowed Products
  *
  * @return array
  */
 public function getAllowProducts()
 {
     if (!$this->hasAllowProducts()) {
         $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
         Mage::helper('catalog/product')->setSkipSaleableCheck(true);
         parent::getAllowProducts();
         Mage::helper('catalog/product')->setSkipSaleableCheck($skipSaleableCheck);
     }
     return $this->getData('allow_products');
 }
Ejemplo n.º 3
0
 /**
  * Retrieve all products associated with a configurable product
  *
  * @param int $parentId
  * @return array
  */
 public function getChildrenFromConfigurableProduct()
 {
     // result
     $result = array();
     // get loaded product
     $product = $this->getProduct();
     if ($product->getId()) {
         // retrieve associated products
         if (version_compare(Mage::getVersion(), '1.3.0.0', '>=')) {
             $children = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
             if (count($children)) {
                 foreach ($children as $arr) {
                     $result = $arr;
                     break;
                 }
             }
         } else {
             if (version_compare(Mage::getVersion(), '1.1.3.0', '>=')) {
                 $result = array();
                 // get new config block
                 $configBlock = new Mage_Catalog_Block_Product_View_Type_Configurable();
                 // load product into config block
                 $configBlock->setProduct($product);
                 // get child products
                 $options = $configBlock->getAllowProducts();
                 // loop options
                 if (count($options)) {
                     foreach ($options as $o) {
                         $result[] = $o;
                     }
                 }
                 // save memory
                 unset($configBlock);
             }
         }
     }
     return $result;
 }