/**
  * @param Mage_Catalog_Model_Product $child
  * @return $this
  * @throws InvalidArgumentException
  */
 public function setPriceFromChild(Mage_Catalog_Model_Product $child)
 {
     if ($child === null) {
         throw new InvalidArgumentException("Product passed is a non-object");
     }
     $price = $child->getPrice();
     $specialPrice = $child->getSpecialPrice();
     $specialFrom = $child->getSpecialFromDate();
     $specialTo = $child->getSpecialToDate();
     $this->setPrice($price, $specialPrice, $specialFrom, $specialTo);
     $this->_priceChild = $child;
     return $this;
 }
 /**
  * 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
 /**
  * Apply special price for product if not return price that was before
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   float $finalPrice
  * @return  float
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     return $this->calculateSpecialPrice($finalPrice, $product->getSpecialPrice(), $product->getSpecialFromDate(), $product->getSpecialToDate(), $product->getStore());
 }
Ejemplo n.º 4
0
 public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
 {
     $result = array();
     $result['entity_id'] = $product->getEntityId();
     $result['sku'] = $product->getSku();
     $result['name'] = $product->getName();
     $result['price'] = $product->getPrice();
     $result['special_price'] = $product->getSpecialPrice();
     $result['special_from_date'] = $product->getSpecialFromDate();
     $result['special_to_date'] = $product->getSpecialToDate();
     $result['cost'] = $product->getCost();
     $result['description'] = $product->getDescription();
     $result['short_description'] = $product->getShortDescription();
     $result['weight'] = $product->getWeight();
     if ($product->isVisibleInSiteVisibility()) {
         $result['url_path'] = $this->_getProductUrlWithCache($product);
     }
     $parentProduct = $this->_getParentProduct($product);
     if ($parentProduct != null) {
         $result['parent_id'] = $parentProduct->getEntityId();
         $result['parent_sku'] = $parentProduct->getSku();
         if (!$product->isVisibleInSiteVisibility()) {
             $result['name'] = $parentProduct->getName();
             if ($parentProduct->isVisibleInSiteVisibility()) {
                 $result['url_path'] = $this->_getProductUrlWithCache($parentProduct);
             }
         }
         if ($includeExtras && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId()) {
             $result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
             $attributes = $parentProduct->getTypeInstance(true)->getUsedProductAttributes($parentProduct);
             $freshProduct = null;
             foreach ($attributes as $attribute) {
                 if (!array_key_exists('configurable_attributes', $result)) {
                     $result['configurable_attributes'] = array();
                 }
                 $attr = array();
                 $attr['attribute_name'] = $attribute->getFrontend()->getLabel();
                 $attr['value'] = $product->getAttributeText($attribute->getAttributeCode());
                 if (empty($attr['value'])) {
                     // use the EAV tables only if the flat table doesn't work
                     if ($freshProduct == null) {
                         $freshProduct = Mage::getModel('catalog/product')->load($product->getEntityId());
                     }
                     $attr['value'] = $attribute->getFrontend()->getValue($freshProduct);
                 }
                 $result['configurable_attributes'][] = $attr;
             }
         }
     }
     if (!isset($result['purchasable'])) {
         $result['purchasable'] = $this->_isPurchasable($product);
     }
     $images = $this->_getProductImages($product);
     if (isset($images['image'])) {
         $result['image'] = $images['image'];
     }
     if (isset($images['small_image'])) {
         $result['small_image'] = $images['small_image'];
     }
     if (isset($images['thumbnail'])) {
         $result['thumbnail'] = $images['thumbnail'];
     }
     if ($includeExtras) {
         // Metas
         $metas = $this->_getMetas($storeId, $product, $parentProduct);
         if ($metas != null) {
             //if(isset($metas['meta1'])) $result['meta1'] = $metas['meta1'];
             //if(isset($metas['meta2'])) $result['meta2'] = $metas['meta2'];
             //if(isset($metas['meta3'])) $result['meta3'] = $metas['meta3'];
             //if(isset($metas['meta4'])) $result['meta4'] = $metas['meta4'];
             if (isset($metas['meta5'])) {
                 $result['meta5'] = $metas['meta5'];
             }
         }
         //Custom For ST Bernard Sports
         // Set IsNew Flag if product is less then 45 days old.
         $result['meta4'] = strtotime($product->getCreatedAt()) + 45 * 24 * 60 * 60 < time() ? "False" : "True";
         // Brand and Category
         $brandAndCategoryProduct = !$parentProduct || $product->isVisibleInSiteVisibility() ? $product : $parentProduct;
         $setSettings = $this->_getProductAttributeSetSettings($brandAndCategoryProduct);
         if ($setSettings['brandAttribute'] != null) {
             $result['brand'] = $brandAndCategoryProduct->getAttributeText($setSettings['brandAttribute']);
         }
         if ($setSettings['catFromMagento']) {
             $cats = $this->_getCategoryInformation($storeId, $brandAndCategoryProduct);
             if (isset($cats['category'])) {
                 $result['category'] = $cats['category'];
             }
             if (isset($cats['sub_category'])) {
                 $result['sub_category'] = $cats['sub_category'];
             }
             //Custom For ST Bernard Sports
             if (isset($cats['third_category'])) {
                 $result['meta3'] = $cats['third_category'];
             }
         } else {
             if ($setSettings['catFromAttributes']) {
                 if ($setSettings['categoryAttribute'] != null) {
                     $result['category'] = $brandAndCategoryProduct->getAttributeText($setSettings['categoryAttribute']);
                 }
                 if ($setSettings['subcategoryAttribute'] != null) {
                     $result['sub_category'] = $brandAndCategoryProduct->getAttributeText($setSettings['subcategoryAttribute']);
                 }
             }
         }
         // Inventory
         $result['in_stock'] = $product->isAvailable() ? "true" : "false";
         $stockItem = $product->getStockItem();
         if ($stockItem) {
             $result['qty_on_hand'] = $stockItem->getStockQty();
         }
         // Related Products
         $result['links'] = $this->_getProductLinks($product);
     }
     $result['type'] = $product->getTypeId();
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Get product final price
  *
  * @param double $qty
  * @param Mage_Catalog_Model_Product $product
  * @return double
  */
 public function getFinalPrice($qty = null, $product)
 {
     /**
      * Calculating final price for item of configurable product
      */
     if ($product->getSuperProduct() && $product->getSuperProduct()->isConfigurable()) {
         $finalPrice = $product->getSuperProduct()->getFinalPrice($qty);
         $attributes = $product->getSuperProduct()->getTypeInstance()->getConfigurableAttributes();
         foreach ($attributes as $attribute) {
             $value = $this->getValueByIndex($attribute->getPrices(), $product->getData($attribute->getProductAttribute()->getAttributeCode()));
             if ($value) {
                 if ($value['pricing_value'] != 0) {
                     $finalPrice += $product->getSuperProduct()->getPricingValue($value);
                 }
             }
         }
     } else {
         $finalPrice = $product->getPrice();
         $tierPrice = $product->getTierPrice($qty);
         if (is_numeric($tierPrice)) {
             $finalPrice = min($finalPrice, $tierPrice);
         }
         $specialPrice = $product->getSpecialPrice();
         if (is_numeric($specialPrice)) {
             $today = floor(time() / 86400) * 86400;
             #echo " TEST:"; echo date('Y-m-d H:i:s', $today).' , '.$product->getSpecialToDate();
             if ($product->getSpecialFromDate() && $today < strtotime($product->getSpecialFromDate())) {
                 #echo ' test1: '.$product->getSpecialFromDate();
             } elseif ($product->getSpecialToDate() && $today > strtotime($product->getSpecialToDate())) {
                 #echo ' test2: '.$product->getSpecialToDate();
             } else {
                 $finalPrice = min($finalPrice, $specialPrice);
             }
         }
     }
     $product->setFinalPrice($finalPrice);
     Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product));
     return $product->getData('final_price');
 }
Ejemplo n.º 6
0
 /**
  * Inflate an API object from a product object
  *
  * @param Mage_Catalog_Model_Product $product       Product
  * @param int                        $storeId       Magento store ID
  * @param bool                       $includeExtras Retrieve all information
  *
  * @return array
  */
 public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
 {
     $result = array();
     $result['entity_id'] = $product->getEntityId();
     $result['sku'] = $product->getSku();
     $result['name'] = $product->getName();
     $result['price'] = $product->getPrice();
     $result['special_price'] = $product->getSpecialPrice();
     $result['special_from_date'] = $product->getSpecialFromDate();
     $result['special_to_date'] = $product->getSpecialToDate();
     $result['cost'] = $product->getCost();
     $result['description'] = $product->getDescription();
     $result['short_description'] = $product->getShortDescription();
     $result['weight'] = $product->getWeight();
     if ($product->isVisibleInSiteVisibility()) {
         $result['url_path'] = $this->_getProductUrlWithCache($product);
     }
     $parentProduct = $this->_getParentProduct($product);
     if ($parentProduct != null) {
         $result['parent_id'] = $parentProduct->getEntityId();
         $result['parent_sku'] = $parentProduct->getSku();
         if (!$product->isVisibleInSiteVisibility()) {
             $result['name'] = $parentProduct->getName();
             if ($parentProduct->isVisibleInSiteVisibility()) {
                 $result['url_path'] = $this->_getProductUrlWithCache($parentProduct);
             }
         }
         if ($includeExtras && $this->_isConfigurableProduct($parentProduct)) {
             $result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
             /* @var Mage_Catalog_Model_Product_Type_Configurable $typeInst */
             $typeInst = $parentProduct->getTypeInstance(true);
             $attributes = $typeInst->getUsedProductAttributes($parentProduct);
             /* @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute */
             foreach ($attributes as $attribute) {
                 if (!array_key_exists('configurable_attributes', $result)) {
                     $result['configurable_attributes'] = array();
                 }
                 $result['configurable_attributes'][] = array('attribute_name' => $attribute->getAttributeCode());
             }
         }
     }
     if (!isset($result['purchasable'])) {
         $result['purchasable'] = $this->_isPurchasable($product);
     }
     $images = $this->_getProductImages($product);
     if (isset($images['image'])) {
         $result['image'] = $images['image'];
     }
     if (isset($images['small_image'])) {
         $result['small_image'] = $images['small_image'];
     }
     if (isset($images['thumbnail'])) {
         $result['thumbnail'] = $images['thumbnail'];
     }
     if ($includeExtras) {
         $metas = $this->_getMetas($storeId, $product, $parentProduct);
         if ($metas != null) {
             /*if (isset($metas['meta3'])) {
                   $result['meta3'] = $metas['meta3'];
               }*/
             if (isset($metas['meta4'])) {
                 $result['meta4'] = $metas['meta4'];
             }
             if (isset($metas['meta5'])) {
                 $result['meta5'] = $metas['meta5'];
             }
         }
         //Custom for Sportys
         $stores = array();
         foreach ($product->getStoreIds() as $storeID) {
             $store = Mage::getModel('core/store')->load($storeID);
             $stores[] = $store->getCode();
         }
         $result["meta3"] = implode(',', $stores);
         // Brand and Category
         $brandCatProduct = $product;
         if ($parentProduct && !$product->isVisibleInSiteVisibility()) {
             $brandCatProduct = $parentProduct;
         }
         $setSettings = $this->_getProductAttributeSetSettings($brandCatProduct);
         if ($setSettings['brandAttribute'] != null) {
             $result['brand'] = $this->_getProductAttribute($brandCatProduct, $setSettings['brandAttribute']);
         }
         if ($setSettings['catFromMagento']) {
             $cats = $this->_getCategoryInformation($storeId, $brandCatProduct);
             if (isset($cats['category'])) {
                 $result['category'] = $cats['category'];
             }
             if (isset($cats['sub_category'])) {
                 $result['sub_category'] = $cats['sub_category'];
             }
         } else {
             if ($setSettings['catFromAttributes']) {
                 if ($setSettings['categoryAttribute'] != null) {
                     $result['category'] = $this->_getProductAttribute($brandCatProduct, $setSettings['categoryAttribute']);
                 }
                 if ($setSettings['subcategoryAttribute'] != null) {
                     $result['sub_category'] = $this->_getProductAttribute($brandCatProduct, $setSettings['subcategoryAttribute']);
                 }
             }
         }
         $result['attributes'] = $this->_getProductAttributes($product);
         // Inventory
         $result['in_stock'] = $product->isAvailable() ? "true" : "false";
         /* @var Mage_Cataloginventory_Model_Stock_Item $stockItem */
         $stockItem = $product->getStockItem();
         if ($stockItem) {
             $result['qty_on_hand'] = $stockItem->getStockQty();
         }
         // Related Products
         $result['links'] = $this->_getProductLinks($product);
     }
     $result['type'] = $product->getTypeId();
     return $result;
 }
Ejemplo n.º 7
0
 /**
  * Apply special price for product if not return price that was before
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   double $finalPrice
  * @return  double
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     $specialPrice = $product->getSpecialPrice();
     if (is_numeric($specialPrice)) {
         $storeDate = Mage::app()->getLocale()->storeDate($product->getStore());
         $fromDate = Mage::app()->getLocale()->date($product->getSpecialFromDate(), null, null, false);
         $toDate = Mage::app()->getLocale()->date($product->getSpecialToDate(), null, null, false);
         if ($product->getSpecialFromDate() && $storeDate->compare($fromDate, Zend_Date::DATES) < 0) {
         } elseif ($product->getSpecialToDate() && $storeDate->compare($toDate, Zend_Date::DATES) > 0) {
         } else {
             $finalPrice = min($finalPrice, $specialPrice);
         }
     }
     return $finalPrice;
 }
Ejemplo n.º 8
0
 /**
  * Apply special price for bundle
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   decimal $finalPrice
  * @return  decimal
  */
 protected function _applySpecialPrice($product, $finalPrice)
 {
     $specialPrice = $product->getSpecialPrice();
     if (is_numeric($specialPrice)) {
         $storeDate = Mage::app()->getLocale()->storeDate($product->getStore());
         $fromDate = Mage::app()->getLocale()->date($product->getSpecialFromDate(), null, null, false);
         $toDate = Mage::app()->getLocale()->date($product->getSpecialToDate(), null, null, false);
         if ($product->getSpecialFromDate() && $storeDate->compare($fromDate) < 0) {
         } elseif ($product->getSpecialToDate() && $storeDate->compare($toDate) > 0) {
         } else {
             // special price in percents
             $specialPrice = $finalPrice * $specialPrice / 100;
             $finalPrice = min($finalPrice, $specialPrice);
         }
     }
     return $finalPrice;
 }
 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.º 10
0
 /**
  * Checks if the special price has expired
  *
  * @param Mage_Catalog_Model_Product $product
  * @param int | null $store
  * @return string | null special price or null if the special price has expired
  */
 protected function _getValidSpecialPrice(Mage_Catalog_Model_Product $product, $store = null)
 {
     $price = null;
     $fromDate = $product->getSpecialFromDate();
     $toDate = $product->getSpecialToDate();
     if (Mage::app()->getLocale()->isStoreDateInInterval($store, $fromDate, $toDate)) {
         $price = $product->getSpecialPrice();
     }
     return $price;
 }
Ejemplo n.º 11
0
 /**
  * Returns final price of a child product
  *
  * @param Mage_Catalog_Model_Product $product
  * @param float                      $productQty
  * @param Mage_Catalog_Model_Product $childProduct
  * @param float                      $childProductQty
  * @return decimal
  */
 public function getChildFinalPrice($product, $productQty, $childProduct, $childProductQty, $totalChildPrice, $itemCount)
 {
     static $mYcount = 0;
     static $counter = 0;
     Mage::log($itemCount, null, 'mri.log');
     $counter = $counter + 1;
     //==================================================================================================
     if ($product->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
         $bundleSplPrice = $product->getSpecialPrice();
         $selectPrice = $childProduct->getSpecialPrice();
         $myFinalPrice = $bundleSplPrice * $selectPrice / $totalChildPrice;
         $myFinalPrice = round($myFinalPrice, 2);
         if ($itemCount == $counter) {
             $lastPrice = $bundleSplPrice - $mYcount;
             $mYcount = 0;
             $counter = 0;
             return $lastPrice;
         } else {
             $mYcount = $mYcount + $myFinalPrice;
             return $myFinalPrice;
         }
     } else {
         return $this->getSelectionFinalTotalPrice($product, $childProduct, $productQty, $childProductQty, false);
     }
     //==================================================================================================
     //return $this->getSelectionFinalTotalPrice($product, $childProduct, $productQty, $childProductQty, false);
 }
Ejemplo n.º 12
0
 public function getProductEntity(Mage_Catalog_Model_Product $product, $storeId, $includeExtras = true)
 {
     $result = array();
     $result['entity_id'] = $product->getEntityId();
     $result['sku'] = $product->getSku();
     $result['name'] = $product->getName();
     $result['price'] = $product->getPrice();
     $result['special_price'] = $product->getSpecialPrice();
     $result['special_from_date'] = $product->getSpecialFromDate();
     $result['special_to_date'] = $product->getSpecialToDate();
     $result['cost'] = $product->getCost();
     $result['description'] = $product->getDescription();
     $result['short_description'] = $product->getShortDescription();
     $result['weight'] = $product->getWeight();
     if ($product->isVisibleInSiteVisibility()) {
         $prodUrlStr = $product->getProductUrl();
         $prodUrl = Mage::getSingleton('core/url')->parseUrl($prodUrlStr);
         $result['url_path'] = substr($prodUrl->getPath(), 1);
     }
     $parentProduct = $this->_getParentProduct($product);
     if ($parentProduct != null) {
         $result['parent_id'] = $parentProduct->getEntityId();
         $result['parent_sku'] = $parentProduct->getSku();
         if (!$product->isVisibleInSiteVisibility()) {
             $result['name'] = $parentProduct->getName();
             if ($parentProduct->isVisibleInSiteVisibility()) {
                 $prodUrlStr = $parentProduct->getProductUrl();
                 $prodUrl = Mage::getSingleton('core/url')->parseUrl($prodUrlStr);
                 $result['url_path'] = substr($prodUrl->getPath(), 1);
             }
         }
         if ($includeExtras && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId()) {
             $result['purchasable'] = $this->_isPurchasable($product, $parentProduct);
             $attributes = $parentProduct->getTypeInstance(true)->getUsedProductAttributes($parentProduct);
             foreach ($attributes as $attribute) {
                 if (!array_key_exists('configurable_attributes', $result)) {
                     $result['configurable_attributes'] = array();
                 }
                 $attr = array();
                 $attr['attribute_name'] = $attribute->getFrontend()->getLabel();
                 $attr['value'] = $product->getAttributeText($attribute->getAttributeCode());
                 $result['configurable_attributes'][] = $attr;
             }
         }
     }
     if (!isset($result['purchasable'])) {
         $result['purchasable'] = $this->_isPurchasable($product);
     }
     $images = $this->_getProductImages($product);
     if (isset($images['image'])) {
         $result['image'] = $images['image'];
     }
     if (isset($images['small_image'])) {
         $result['small_image'] = $images['small_image'];
     }
     if (isset($images['thumbnail'])) {
         $result['thumbnail'] = $images['thumbnail'];
     }
     if ($includeExtras) {
         // Metas
         $metas = $this->_getMetas($storeId, $product, $parentProduct);
         if ($metas != null) {
             //if(isset($metas['meta1'])) $result['meta1'] = $metas['meta1'];
             //if(isset($metas['meta2'])) $result['meta2'] = $metas['meta2'];
             if (isset($metas['meta3'])) {
                 $result['meta3'] = $metas['meta3'];
             }
             if (isset($metas['meta4'])) {
                 $result['meta4'] = $metas['meta4'];
             }
             if (isset($metas['meta5'])) {
                 $result['meta5'] = $metas['meta5'];
             }
         }
         // Brand and Category
         $brandAndCategoryProduct = !$parentProduct || $product->isVisibleInSiteVisibility() ? $product : $parentProduct;
         $setSettings = $this->_getProductAttributeSetSettings($brandAndCategoryProduct);
         if ($setSettings['brandAttribute'] != null) {
             $result['brand'] = $brandAndCategoryProduct->getAttributeText($setSettings['brandAttribute']);
         }
         if ($setSettings['catFromMagento']) {
             $cats = $this->_getCategoryInformation($storeId, $brandAndCategoryProduct);
             if (isset($cats['category'])) {
                 $result['category'] = $cats['category'];
             }
             if (isset($cats['sub_category'])) {
                 $result['sub_category'] = $cats['sub_category'];
             }
         } else {
             if ($setSettings['catFromAttributes']) {
                 if ($setSettings['categoryAttribute'] != null) {
                     $result['category'] = $brandAndCategoryProduct->getAttributeText($setSettings['categoryAttribute']);
                 }
                 if ($setSettings['subcategoryAttribute'] != null) {
                     $result['sub_category'] = $brandAndCategoryProduct->getAttributeText($setSettings['subcategoryAttribute']);
                 }
             }
         }
         // Inventory
         $result['in_stock'] = $product->isAvailable() ? "true" : "false";
         $stockItem = $product->getStockItem();
         if ($stockItem) {
             $result['qty_on_hand'] = $stockItem->getStockQty();
         }
         // Related Products
         $result['links'] = $this->_getProductLinks($product);
     }
     $result['type'] = $product->getTypeId();
     return $result;
 }
 /**
  * @param Mage_Catalog_Model_Product $product
  * @return bool
  */
 public function isActualPriceSpecial(Mage_Catalog_Model_Product $product)
 {
     return $product->getSpecialPrice() && Mage::app()->getLocale()->isStoreDateInInterval(Mage::app()->getStore(), $product->getSpecialFromDate(), $product->getSpecialToDate());
 }
 /**
  * check if product has special price
  * @param Mage_Catalog_Model_Product $product
  * @return bool
  */
 protected function _hasSpecialPrice(Mage_Catalog_Model_Product $product)
 {
     return (double) $product->getSpecialPrice() > 0;
 }