/** * Check whether the stock alert data can be shown and prepare related data * * @return void */ public function prepareStockAlertData() { if (!$this->_getHelper()->isStockAlertAllowed() || !$this->_product || $this->_product->isAvailable()) { $this->setTemplate(''); return; } $this->setSignupUrl($this->_getHelper()->getSaveUrl('stock')); }
/** * Check whether the stock alert data can be shown and prepare related data */ public function prepareStockAlertData() { if (!Mage::getStoreConfigFlag(Mage_ProductAlert_Model_Observer::XML_PATH_STOCK_ALLOW) || !$this->_product || $this->_product->isAvailable()) { $this->setTemplate(''); return; } $this->setSignupUrl(Mage::helper('productalert')->getSaveUrl('stock')); }
/** * Check whether the stock alert data can be shown and prepare related data * * @return void */ public function prepareStockAlertData() { $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($this->_product); if (!$this->_getHelper()->isStockAlertAllowed() || !$this->_product || $this->_product->isAvailable() || $stock->getQty() != 0) { $this->setTemplate(''); return; } $this->setSignupUrl($this->_getHelper()->getSaveUrl('stock')); }
/** * @covers Mage_Catalog_Model_Product::isSalable * @covers Mage_Catalog_Model_Product::isSaleable * @covers Mage_Catalog_Model_Product::isAvailable * @covers Mage_Catalog_Model_Product::isInStock */ public function testIsSalable() { $this->_model->load(1); // fixture $this->assertTrue((bool) $this->_model->isSalable()); $this->assertTrue((bool) $this->_model->isSaleable()); $this->assertTrue((bool) $this->_model->isAvailable()); $this->assertTrue($this->_model->isInStock()); $this->_model->setStatus(0); $this->assertFalse((bool) $this->_model->isSalable()); $this->assertFalse((bool) $this->_model->isSaleable()); $this->assertFalse((bool) $this->_model->isAvailable()); $this->assertFalse($this->_model->isInStock()); }
/** * Create Product array from Mage_Catalog_Model_Product * * @param Mage_Catalog_Model_Product $product * @return array */ public function getProductData(Mage_Catalog_Model_Product $product) { try { $data = array('url' => $product->getProductUrl(), 'title' => htmlspecialchars($product->getName()), 'spider' => 1, 'price' => $product->getPrice(), 'description' => urlencode($product->getDescription()), 'tags' => htmlspecialchars($product->getMetaKeyword()), 'images' => array(), 'vars' => array('sku' => $product->getSku(), 'storeId' => '', 'typeId' => $product->getTypeId(), 'status' => $product->getStatus(), 'categoryId' => $product->getCategoryId(), 'categoryIds' => $product->getCategoryIds(), 'websiteIds' => $product->getWebsiteIds(), 'storeIds' => $product->getStoreIds(), 'groupPrice' => $product->getGroupPrice(), 'formatedPrice' => $product->getFormatedPrice(), 'calculatedFinalPrice' => $product->getCalculatedFinalPrice(), 'minimalPrice' => $product->getMinimalPrice(), 'specialPrice' => $product->getSpecialPrice(), 'specialFromDate' => $product->getSpecialFromDate(), 'specialToDate' => $product->getSpecialToDate(), 'relatedProductIds' => $product->getRelatedProductIds(), 'upSellProductIds' => $product->getUpSellProductIds(), 'getCrossSellProductIds' => $product->getCrossSellProductIds(), 'isSuperGroup' => $product->isSuperGroup(), 'isGrouped' => $product->isGrouped(), 'isConfigurable' => $product->isConfigurable(), 'isSuper' => $product->isSuper(), 'isSalable' => $product->isSalable(), 'isAvailable' => $product->isAvailable(), 'isVirtual' => $product->isVirtual(), 'isRecurring' => $product->isRecurring(), 'isInStock' => $product->isInStock(), 'weight' => $product->getSku())); // Add product images if (self::validateProductImage($product->getImage())) { $data['images']['full'] = array("url" => $product->getImageUrl()); } if (self::validateProductImage($product->getSmallImage())) { $data['images']['smallImage'] = array("url" => $product->getSmallImageUrl($width = 88, $height = 77)); } if (self::validateProductImage($product->getThumbnail())) { $data['images']['thumb'] = array("url" => $product->getThumbnailUrl($width = 75, $height = 75)); } return $data; return $data; } catch (Exception $e) { Mage::logException($e); } }
/** * Check if product can be configured * * @param Mage_Catalog_Model_Product $product * @return bool */ public function canConfigure($product = null) { return $product instanceof Mage_Catalog_Model_Product && $product->isAvailable() && parent::canConfigure(); }
/** * Builds the availability for the product. * * @param Mage_Catalog_Model_Product $product the product model. * * @return string */ protected function buildAvailability(Mage_Catalog_Model_Product $product) { $availability = self::OUT_OF_STOCK; if (!$product->isVisibleInSiteVisibility()) { $availability = self::INVISIBLE; } elseif ($product->isAvailable()) { $availability = self::IN_STOCK; } return $availability; }