Ejemplo n.º 1
0
 /**
  * Decorate status column values
  *
  * @param  string                                   $value Check result
  * @param  Mage_Catalog_Model_Product|Varien_Object $row   Current row
  * @return string                                   Cell content
  */
 public function decorateStatus($value, $row)
 {
     $class = '';
     if ($row->getStatus()) {
         $cell = '<span class="grid-severity-notice"><span>' . $value . '</span></span>';
     } else {
         $cell = '<span class="grid-severity-critical"><span>' . $value . '</span></span>';
     }
     return $cell;
 }
 /**
  * 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);
     }
 }
Ejemplo n.º 3
0
 protected function _isObjectIndexable(Mage_Catalog_Model_Product $object)
 {
     if ($object->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
         return false;
     }
     if ($object->getVisibility() != Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG && $object->getVisibility() != Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) {
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
 private function _isPurchasable(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $parent = null)
 {
     if ($product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_ENABLED) {
         return "false";
     }
     if ($parent == null) {
         return Mage::getSingleton('listrak/product_purchasable_visibility')->isProductPurchasableBySetting(Mage::getStoreConfig('remarketing/productcategories/purchasable_visibility'), $product) ? "true" : "false";
     } else {
         return $parent->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED && Mage::getSingleton('listrak/product_purchasable_visibility')->isProductPurchasableBySetting(Mage::getStoreConfig('remarketing/productcategories/purchasable_visibility'), $parent) ? "true" : "false";
     }
 }
Ejemplo n.º 5
0
 /**
  * Check is product available for sale
  *
  * @param Mage_Catalog_Model_Product $product
  * @return bool
  */
 public function isSalable($product)
 {
     $salable = $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
     if ($salable && $product->hasData('is_salable')) {
         $salable = $product->getData('is_salable');
     }
     return (bool) (int) $salable;
 }
Ejemplo n.º 6
0
 /**
  * Returns whether the product is enabled in the catalog
  *
  * @param Mage_Catalog_Model_Product $product Current product
  *
  * @return bool
  */
 private function _isEnabled(Mage_Catalog_Model_Product $product)
 {
     return $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
 }
 public function __construct(Mage_Catalog_Model_Product $product)
 {
     $this->id = $product->getId();
     $this->sku = $product->getSku();
     $this->name = $product->getName();
     $statuses = Mage::getModel('catalog/product_status')->getOptionArray();
     $this->status = $statuses[$product->getStatus()];
     $options = Mage::getModel('catalog/product_visibility')->getOptionArray();
     $this->visibility = $options[$product->getVisibility()];
     $this->price = (double) number_format($product->getPrice(), 2, '.', '');
     $this->specialPrice = (double) number_format($product->getSpecialPrice(), 2, '.', '');
     $this->url = $product->getProductUrl();
     $this->imagePath = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getSmallImage());
     $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
     $this->stock = (double) number_format($stock->getQty(), 2, '.', '');
     $short_description = $product->getShortDescription();
     //limit short description
     if (strlen($short_description) > 250) {
         $short_description = substr($short_description, 0, 250);
     }
     $this->short_description = $short_description;
     //category data
     $count = 0;
     $categoryCollection = $product->getCategoryCollection()->addNameToResult();
     foreach ($categoryCollection as $cat) {
         $this->categories[$count]['Id'] = $cat->getId();
         $this->categories[$count]['Name'] = $cat->getName();
         $count++;
     }
     //website data
     $count = 0;
     $websiteIds = $product->getWebsiteIds();
     foreach ($websiteIds as $websiteId) {
         $website = Mage::app()->getWebsite($websiteId);
         $this->websites[$count]['Id'] = $website->getId();
         $this->websites[$count]['Name'] = $website->getName();
         $count++;
     }
     //bundle product options
     if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
         $optionCollection = $product->getTypeInstance()->getOptionsCollection();
         $selectionCollection = $product->getTypeInstance()->getSelectionsCollection($product->getTypeInstance()->getOptionsIds());
         $options = $optionCollection->appendSelections($selectionCollection);
         foreach ($options as $option) {
             $count = 0;
             $title = str_replace(' ', '', $option->getDefaultTitle());
             $selections = $option->getSelections();
             $sOptions = array();
             foreach ($selections as $selection) {
                 $sOptions[$count]['name'] = $selection->getName();
                 $sOptions[$count]['sku'] = $selection->getSku();
                 $sOptions[$count]['id'] = $selection->getProductId();
                 $sOptions[$count]['price'] = (double) number_format($selection->getPrice(), 2, '.', '');
                 $count++;
             }
             $this->{$title} = $sOptions;
         }
     }
     //configurable product options
     if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
         $productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
         foreach ($productAttributeOptions as $productAttribute) {
             $count = 0;
             $label = strtolower(str_replace(' ', '', $productAttribute['label']));
             $options = array();
             foreach ($productAttribute['values'] as $attribute) {
                 $options[$count]['option'] = $attribute['default_label'];
                 $options[$count]['price'] = (double) number_format($attribute['pricing_value'], 2, '.', '');
                 $count++;
             }
             $this->{$label} = $options;
         }
     }
 }
Ejemplo n.º 8
0
 public function testGetStatus()
 {
     $this->assertEquals(Mage_Catalog_Model_Product_Status::STATUS_ENABLED, $this->_model->getStatus());
     $this->_model->setStatus(Mage_Catalog_Model_Product_Status::STATUS_DISABLED);
     $this->assertEquals(Mage_Catalog_Model_Product_Status::STATUS_DISABLED, $this->_model->getStatus());
 }
Ejemplo n.º 9
0
 /**
  * Checks that the configurable product exists and can be show to the
  * customer
  * 
  * @return bool
  */
 protected function _canRedirect()
 {
     return $this->_product && $this->_product->getId() && $this->_product->getStatus() != Mage_Catalog_Model_Product_Status::STATUS_DISABLED && $this->_product->getVisibility() != Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
 }