Esempio n. 1
0
 /**
  * Set current attribute to entry (for specified product)
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Varien_Gdata_Gshopping_Entry $entry
  * @return Varien_Gdata_Gshopping_Entry
  */
 public function convertAttribute($product, $entry)
 {
     $url = $product->getProductUrl(false);
     if ($url) {
         if (!Mage::getStoreConfigFlag('web/url/use_store')) {
             $urlInfo = parse_url($url);
             $store = $product->getStore()->getCode();
             if (isset($urlInfo['query']) && $urlInfo['query'] != '') {
                 $url .= '&___store=' . $store;
             } else {
                 $url .= '?___store=' . $store;
             }
         }
         $links = $entry->getLink();
         if (!is_array($links)) {
             $links = array();
         }
         $link = $entry->getService()->newLink();
         $link->setHref($url);
         $link->setRel('alternate');
         $link->setType('text/html');
         if ($product->getName()) {
             $link->setTitle($product->getName());
         }
         $links[0] = $link;
         $entry->setLink($links);
     }
     return $entry;
 }
 /**
  * Returns the formatted string for the quantity chosen for the given selection
  *
  * @param Mage_Catalog_Model_Product $_selection
  * @param bool                       $includeContainer
  * @return string
  */
 public function getSelectionQtyTitlePrice(Mage_Catalog_Model_Product $_selection, $includeContainer = true)
 {
     if ($this->isGuestView()) {
         return $_selection->getSelectionQty() * 1 . ' x ' . $this->escapeHtml($_selection->getName());
     }
     return parent::getSelectionQtyTitlePrice($_selection, $includeContainer);
 }
Esempio n. 3
0
 public function getItemBaseInfo()
 {
     $helper = Mage::helper('catalog/image');
     $helper->init($this->product, $this->getProductImageType())->keepAspectRatio($this->_keepAspectRatio)->keepFrame($this->_keepFrame);
     $this->item['item_id'] = $this->product->getId();
     $this->item['item_title'] = $this->product->getName();
     $this->item['item_url'] = $this->product->getProductUrl();
     $this->item['cid'] = $this->product->getCategoryIds();
     $this->item['qty'] = $this->product->getStockItem()->getQty();
     $this->item['thumbnail_pic_url'] = (string) $helper->resize($this->thumbnail_with, $this->thumbnail_height);
     $this->item['main_pic_url'] = (string) $helper->resize($this->main_with, $this->main_height);
     $this->item['is_virtual'] = $this->product->isVirtual();
     $this->item['item_status'] = $this->product->isSaleable() ? 'instock' : 'outofstock';
     if (!$this->product->getRatingSummary()) {
         Mage::getModel('review/review')->getEntitySummary($this->product, Mage::app()->getStore()->getId());
     }
     $this->item['allow_add_to_cart'] = !$this->HasOptions();
     $this->item['rating_score'] = round((int) $this->product->getRatingSummary()->getRatingSummary() / 20);
     $this->item['rating_count'] = $this->product->getRatingSummary()->getReviewsCount();
     $this->item['sales_type'] = $this->product->isInStock() ? 'stock' : 'distribute';
     $this->item['qty_min_unit'] = 1;
     $stockItem = $this->product->getStockItem();
     if ($stockItem) {
         if ($stockItem->getMinSaleQty() && $stockItem->getMinSaleQty() > 0) {
             $this->item['qty_min_unit'] = $stockItem->getMinSaleQty();
         }
     }
     $this->item['item_type'] = $this->product->getTypeId();
     return $this->item;
 }
 /**
  * Purge product
  *
  * @param Mage_Catalog_Model_Product $product
  * @param bool $purgeParentProducts
  * @param bool $purgeCategories
  * @return Phoenix_VarnishCache_Model_Control_Catalog_Product
  */
 public function purge(Mage_Catalog_Model_Product $product, $purgeParentProducts = false, $purgeCategories = false)
 {
     if ($this->_canPurge()) {
         $idsToPurge = array();
         $categoryIdsToPurge = array();
         $idsToPurge[] = $product->getId();
         $this->_getSession()->addSuccess(Mage::helper('varnishcache')->__('Varnish cache for "%s" has been purged.', $product->getName()));
         if ($purgeParentProducts) {
             // purge parent products
             $productRelationCollection = $this->_getProductRelationCollection()->filterByChildId($product->getId());
             foreach ($productRelationCollection as $productRelation) {
                 $idsToPurge[] = $productRelation->getParentId();
             }
             // purge categories of parent products
             if ($purgeCategories) {
                 $categoryProductCollection = $this->_getCategoryProductRelationCollection()->filterAllByProductIds($productRelationCollection->getAllIds());
                 foreach ($categoryProductCollection as $categoryProduct) {
                     $categoryIdsToPurge[] = $categoryProduct->getCategoryId();
                 }
             }
         }
         $this->_purgeByIds($idsToPurge);
         if ($purgeCategories) {
             foreach ($product->getCategoryCollection() as $category) {
                 $categoryIdsToPurge[] = $category->getId();
             }
             $this->_getSession()->addSuccess(Mage::helper('varnishcache')->__('Varnish cache for the product\'s categories has been purged.'));
         }
         $this->_purgeCategoriesByIds($categoryIdsToPurge);
     }
     return $this;
 }
 /**
  * Processes the product and its options before adding it to a quote or a wishlist
  *
  * @param Varien_Object              $buyRequest  request object
  * @param Mage_Catalog_Model_Product $product     product ibject
  * @param string                     $processMode process mode: strict for cart, lite for wishlist
  *
  * @return array|string
  */
 protected function _prepareProduct(Varien_Object $buyRequest, $product, $processMode)
 {
     if ($this->_isStrictProcessMode($processMode)) {
         return Mage::helper('solvingmagento_affiliateproduct')->__('Affiliate product %s cannot be added to cart. ' . ' On the product detail page click the "Go to parent site" button to access the product.', $product->getName());
     }
     return parent::_prepareProduct($buyRequest, $product, $processMode);
 }
Esempio n. 6
0
 /**
  * Collect the basic information about the product and return it as an array.
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 protected function _collectProductInfo(Mage_Catalog_Model_Product $product)
 {
     //basic product info, same for every possible product type
     $productInfo = array('id' => $product->getId(), 'type' => $product->getTypeId(), 'name' => $product->getName(), 'saleable' => $product->isSaleable(), 'price' => Mage::helper('tax')->getPrice($product, $product->getFinalPrice()), 'priceTemplate' => $this->getPriceTemplate());
     $manufacturer = $this->_getManufacturer($product);
     if ($manufacturer) {
         $productInfo['manufacturer'] = $manufacturer;
     }
     //if product has active special price
     if ($oldPrice = $this->getOldPrice($product)) {
         $productInfo['oldPrice'] = $oldPrice;
     }
     //allowed sale quantities
     if ($qtyLimits = $this->getProductQtyLimits($product)) {
         list($minQty, $maxQty) = $qtyLimits;
         if ($minQty !== null) {
             $productInfo['minqty'] = $minQty;
         }
         if ($maxQty !== null) {
             $productInfo['maxqty'] = $maxQty;
         }
     }
     //add product tax info
     if ($taxInfo = $this->getProductTax($product)) {
         $productInfo['tax'] = $taxInfo;
     }
     //get additional info, if possible
     //this may be different for various product types
     $productInfo = $this->_collectAdditionalProductInfo($product, $productInfo);
     return $productInfo;
 }
Esempio n. 7
0
 public function getUpdateListingWrapper(Mage_Catalog_Model_Product $product)
 {
     $reverbListingWrapper = Mage::getModel('reverbSync/wrapper_listing');
     $sku = $product->getSku();
     // $condition = $this->_getCondition();
     $fieldsArray = array('sku' => $sku);
     if ($this->_getListingsUpdateSyncHelper()->isTitleUpdateEnabled()) {
         $fieldsArray['title'] = $product->getName();
     }
     if ($this->_getListingsUpdateSyncHelper()->isPriceUpdateEnabled()) {
         $fieldsArray['price'] = $this->getProductPrice($product);
     }
     if ($this->_getListingsUpdateSyncHelper()->isDescriptionUpdateEnabled()) {
         $fieldsArray['description'] = $this->getProductDescription($product);
     }
     if ($this->_getListingsUpdateSyncHelper()->isInventoryQtyUpdateEnabled()) {
         $hasInventory = $this->_getHasInventory();
         $fieldsArray['has_inventory'] = $hasInventory;
         $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
         $fieldsArray['inventory'] = $stock->getQty();
     }
     $this->_addMappedAttributes($fieldsArray, $product);
     $this->_addArbitraryMappedAttributes($fieldsArray, $product);
     $this->_addProductAcceptOffers($fieldsArray, $product);
     $this->addCategoryToFieldsArray($fieldsArray, $product);
     $this->addProductConditionIfSet($fieldsArray, $product);
     $reverbListingWrapper->setApiCallContentData($fieldsArray);
     $reverbListingWrapper->setMagentoProduct($product);
     return $reverbListingWrapper;
 }
Esempio n. 8
0
 /**
  * Retrieve product attributes as xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param string $itemNodeName
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function productToXmlObject(Mage_Catalog_Model_Product $product, $itemNodeName = 'item')
 {
     /** @var $item Mage_XmlConnect_Model_Simplexml_Element */
     $item = Mage::getModel('xmlconnect/simplexml_element', '<' . $itemNodeName . '></' . $itemNodeName . '>');
     if ($product && $product->getId()) {
         $item->addChild('entity_id', $product->getId());
         $item->addChild('name', $item->escapeXml($product->getName()));
         $item->addChild('entity_type', $product->getTypeId());
         $item->addChild('short_description', $item->escapeXml($product->getShortDescription()));
         $description = Mage::helper('xmlconnect')->htmlize($item->xmlentities($product->getDescription()));
         $item->addChild('description', $description);
         $item->addChild('link', $product->getProductUrl());
         if ($itemNodeName == 'item') {
             $imageToResize = Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small');
             $propertyToResizeName = 'small_image';
         } else {
             $imageToResize = Mage::helper('xmlconnect/image')->getImageSizeForContent('product_big');
             $propertyToResizeName = 'image';
         }
         $icon = clone Mage::helper('catalog/image')->init($product, $propertyToResizeName)->resize($imageToResize);
         $iconXml = $item->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
         $item->addChild('in_stock', (int) $product->getIsInStock());
         $item->addChild('is_salable', (int) $product->isSalable());
         /**
          * By default all products has gallery (because of collection not load gallery attribute)
          */
         $hasGallery = 1;
         if ($product->getMediaGalleryImages()) {
             $hasGallery = sizeof($product->getMediaGalleryImages()) > 0 ? 1 : 0;
         }
         $item->addChild('has_gallery', $hasGallery);
         /**
          * If product type is grouped than it has options as its grouped items
          */
         if ($product->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE || $product->getTypeId() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) {
             $product->setHasOptions(true);
         }
         $item->addChild('has_options', (int) $product->getHasOptions());
         if ($minSaleQty = $this->_getMinimalQty($product)) {
             $item->addChild('min_sale_qty', (int) $minSaleQty);
         }
         if (!$product->getRatingSummary()) {
             Mage::getModel('review/review')->getEntitySummary($product, Mage::app()->getStore()->getId());
         }
         $item->addChild('rating_summary', round((int) $product->getRatingSummary()->getRatingSummary() / 10));
         $item->addChild('reviews_count', $product->getRatingSummary()->getReviewsCount());
         if ($this->getChild('product_price')) {
             $this->getChild('product_price')->setProduct($product)->setProductXmlObj($item)->collectProductPrices();
         }
         if ($this->getChild('additional_info')) {
             $this->getChild('additional_info')->addAdditionalData($product, $item);
         }
     }
     return $item;
 }
Esempio n. 9
0
 /**
  * set name
  */
 public function setName()
 {
     $parentName = Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_PARENT_PRODUCT_NAME);
     if ($parentName && $this->_parent != null) {
         $name = $this->_parent->getName();
     } else {
         $name = $this->item->getName();
     }
     parent::setName($name);
 }
Esempio n. 10
0
 /**
  * Import item data from product model object
  *
  * @param   Mage_Catalog_Model_Product $product
  * @return  Mage_Sales_Model_Quote_Item
  */
 public function importCatalogProduct(Mage_Catalog_Model_Product $product)
 {
     $this->setProductId($product->getId())->setSku($product->getSku())->setName($product->getName())->setWeight($product->getWeight())->setTaxClassId($product->getTaxClassId())->setCost($product->getCost())->setIsQtyDecimal($product->getIsQtyDecimal());
     if ($product->getSuperProduct()) {
         $this->setSuperProductId($product->getSuperProduct()->getId());
         if ($product->getSuperProduct()->isConfigurable()) {
             $this->setName($product->getSuperProduct()->getName());
         }
     }
     $this->setProduct($product);
     return $this;
 }
Esempio n. 11
0
 /**
  * Format url_key value
  *
  * @param Mage_Catalog_Model_Product $object
  * @return Mage_Catalog_Model_Product_Attribute_Backend_Urlkey
  */
 public function beforeSave($object)
 {
     $attributeName = $this->getAttribute()->getName();
     $urlKey = $object->getData($attributeName);
     if ($urlKey === false) {
         return $this;
     }
     if ($urlKey == '') {
         $urlKey = $object->getName();
     }
     $urlKey = $object->formatUrlKey($urlKey);
     if (empty($urlKey)) {
         $urlKey = Mage::helper('core')->uniqHash();
     }
     $object->setData($attributeName, $urlKey);
     $this->_validateUrlKey($object);
     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);
     }
 }
Esempio n. 13
0
 /**
  * Return current category path or get it from current category
  * and creating array of categories|product paths for breadcrumbs
  *
  * @return string
  */
 protected function _getBreadcrumbPath()
 {
     $path = array();
     if ($category = $this->_getProductBreadcrumbCategory()) {
         $pathInStore = $category->getPathInStore();
         $pathIds = array_reverse(explode(',', $pathInStore));
         $categories = $category->getParentCategories();
         // add category path breadcrumb
         foreach ($pathIds as $categoryId) {
             if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
                 $path['category' . $categoryId] = array('label' => $categories[$categoryId]->getName(), 'link' => $categories[$categoryId]->getUrl());
             }
         }
     }
     if ($this->_currentProduct) {
         $path['product'] = array('label' => $this->_currentProduct->getName());
     }
     $this->_categoryPath = $path;
     return $this->_categoryPath;
 }
Esempio n. 14
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;
 }
Esempio n. 15
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;
 }
 /**
  * Add product data to stock item
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_CatalogInventory_Model_Stock_Item
  */
 public function setProduct($product)
 {
     $this->setProductId($product->getId())->setProductName($product->getName())->setStoreId($product->getStoreId())->setProductName($product->getName())->setProductTypeId($product->getTypeId())->setProductStatusChanged($product->dataHasChangedFor('status'))->setProductChangedWebsites($product->getIsChangedWebsites());
     $this->_productInstance = $product;
     return $this;
 }
 /**
  * Set product attributes to item
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Enterprise_GiftRegistry_Model_Item
  */
 public function setProduct($product)
 {
     $this->setName($product->getName());
     $this->setData('product', $product);
     return $this;
 }
Esempio n. 18
0
 function getName()
 {
     $name = parent::getName();
     $this->setFitFromGlobalIfNoLocalFitment();
     if (!$this->rewritesOn() || !$this->fitsSelection()) {
         return $name;
     }
     $template = $this->getConfig()->seo->productNameTemplate;
     if (empty($template)) {
         $template = '_product_ for _vehicle_';
     }
     $find = array('_product_', '_vehicle_');
     $replace = array($name, (string) $this->currentlySelectedFit());
     return str_replace($find, $replace, $template);
 }
Esempio n. 19
0
 /**
  * Implementation of product specify logic of which product needs to be assigned to option.
  * For example if product which was added to option already removed from catalog.
  *
  * @param  Mage_Catalog_Model_Product $optionProduct
  * @param  Mage_Sales_Model_Quote_Item_Option $option
  * @param  Mage_Catalog_Model_Product $product
  * @return Mage_Catalog_Model_Product_Type_Abstract
  */
 public function assignProductToOption($optionProduct, $option, $product)
 {
     if ($optionProduct) {
         $option->setProduct($optionProduct);
     } else {
         $option->getItem()->setHasError('error');
         $message = Mage::helper('Mage_Catalog_Helper_Data')->__('Selected configuration is not available.', $product->getName());
         $option->getItem()->addMessage($message);
     }
     return $this;
 }
Esempio n. 20
0
 public function getName()
 {
     return parent::getName() . ' - changed name';
 }
 /**
  * @param Mage_Catalog_Model_Product $product
  * @param array                      $input
  * @param                            $weight
  * @return array
  */
 protected function _getNameSuggestFieldArray(Mage_Catalog_Model_Product $product, array $input, $weight)
 {
     return array("input" => $input, "output" => $product->getName(), "weight" => (int) $weight, "payload" => array("id" => $product->getEntityId(), "path" => $this->_getProductUrlPath($product)));
 }
Esempio n. 22
0
 /**
  * Import product recurring profile information
  * Returns false if it cannot be imported
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_Payment_Model_Recurring_Profile|false
  */
 public function importProduct(Mage_Catalog_Model_Product $product)
 {
     if ($product->isRecurring() && is_array($product->getRecurringProfile())) {
         // import recurring profile data
         $this->addData($product->getRecurringProfile());
         // automatically set product name if there is no schedule description
         if (!$this->hasScheduleDescription()) {
             $this->setScheduleDescription($product->getName());
         }
         // collect start datetime from the product options
         $options = $product->getCustomOption(self::PRODUCT_OPTIONS_KEY);
         if ($options) {
             $options = unserialize($options->getValue());
             if (is_array($options)) {
                 if (isset($options['start_datetime'])) {
                     $startDatetime = new Zend_Date($options['start_datetime'], Varien_Date::DATETIME_INTERNAL_FORMAT);
                     $this->setNearestStartDatetime($startDatetime);
                 }
             }
         }
         return $this->_filterValues();
     }
     return false;
 }
Esempio n. 23
0
 public function getProductHtml(Mage_Catalog_Model_Product $product, $extraClass = '')
 {
     $productName = $product->getName();
     $productName = htmlspecialchars($productName);
     $productShortName = strlen($productName) > 100 ? substr($productName, 0, 100) . '...' : $productName;
     $productId = $product->getId();
     $productType = $product->getTypeId();
     $productSku = $product->getSku();
     $productData = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
     $qtyinc = 1;
     if ($productData->getQtyIncrements()) {
         $qtyinc = $productData->getQtyIncrements();
     }
     $priceAndTaxData = $this->getProductPriceAndTaxData($product);
     $finalPrice = $priceAndTaxData['finalPrice'];
     $tax_amount = $priceAndTaxData['tax_amount'];
     $price = $priceAndTaxData['price'];
     $priceInclTax = $priceAndTaxData['priceInclTax'];
     $tax = $priceAndTaxData['tax'];
     $includeTax = $priceAndTaxData['includeTax'];
     $productPrice = $priceAndTaxData['productPrice'];
     if ($includeTax == true) {
         //$tax = 0;
         //$finalPrice = $price;
     }
     $storeId = $this->_store_id;
     $store = Mage::getModel('core/store')->load($storeId);
     $imgPath = Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(120);
     $productOptions = $options = $customOptions = $groupedChilds = $bundleChilds = $storeCreditOptions = array();
     $priceConditions = '';
     $productOptions = $this->getProductOptions($product);
     $hasOption = $this->isProductHasOptions($product);
     $hasOptionString = $hasOption == true ? 'hasOption' : '0';
     if (isset($productOptions['bundle']) && count($productOptions['bundle']) > 0) {
         $bundleChilds = $productOptions['bundle'];
         $isBundle = true;
         $totalDefault = 0;
         foreach ($bundleChilds as $childId => $childData) {
             $items = $childData['items'];
             if (count($items) > 0) {
                 foreach ($items as $itemId => $itemData) {
                     //if ($itemData['is_default'] == '1') {
                     $totalDefault += $itemData['price'] * $itemData['qty'];
                     //}
                 }
             }
         }
     }
     $priceDisplay = $isBundle == true ? $store->formatPrice($totalDefault) : $store->formatPrice($finalPrice);
     $html = "<div qtyinc='" . $qtyinc . "' tax_amount='" . $tax_amount . "' class='product " . $extraClass . " col-lg-3 col-md-3 col-sm-3 col-xs-3' id='prd_" . $productId . "' prd_type='" . $product->getTypeID() . "' hasoption='" . $hasOptionString . "'>\r\n\t\t\t\t\t<div class='item' hasoption=" . $hasOptionString . " prdid='" . $productId . "' onclick=\"addProduct('" . $productId . "', '" . $finalPrice . "', '" . $imgPath . "')\">\r\n\t\t\t\t\t\t<div class='img-product'>\r\n\t\t\t\t\t\t\t<div class='prd_sku'>" . $productSku . "</div>\r\n\t\t\t\t\t\t\t<div class='prd_price_bg'></div>\r\n\t\t\t\t\t\t\t<div class='prd_price'>" . $priceDisplay . "</div>\r\n\t\t\t\t\t\t\t<img class='product_image' src='' imgpath='" . $imgPath . "'/>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<h2 id='prd_name_" . $productId . "'>" . $productShortName . "</h2>\r\n\t\t\t\t\t\t<p id='prd_fullname_" . $productId . "' class='hide'>" . $productName . "</p>\r\n\t\t\t\t\t</div>";
     if (isset($productOptions['configurable']) && count($productOptions['configurable']) > 0 || isset($productOptions['custom_options']) && count($productOptions['custom_options']) > 0 || isset($productOptions['grouped']) && count($productOptions['grouped']) > 0 || isset($productOptions['bundle']) && count($productOptions['bundle']) > 0 || isset($productOptions['customercredit']) && count($productOptions['customercredit']) > 0) {
         if (isset($productOptions['configurable']) && count($productOptions['configurable']) > 0) {
             $options = $productOptions['configurable'];
             if (isset($options['price_condition'])) {
                 $priceConditions = $options['price_condition'];
             }
         }
         if (isset($productOptions['custom_options']) && count($productOptions['custom_options']) > 0) {
             $customOptions = $productOptions['custom_options'];
         }
         if (isset($productOptions['grouped']) && count($productOptions['grouped']) > 0) {
             $groupedChilds = $productOptions['grouped'];
             $isGrouped = true;
         }
         if (isset($productOptions['bundle']) && count($productOptions['bundle']) > 0) {
             $bundleChilds = $productOptions['bundle'];
             $isBundle = true;
         }
         if (isset($productOptions['customercredit']) && count($productOptions['customercredit']) > 0) {
             $storeCreditOptions = $productOptions['customercredit'];
         }
         $totalDefault = $store->formatPrice($finalPrice);
         $options_label = 'Select Options';
         $option_value_label = "Price <span finalprice='" . $finalPrice . "' id='totals_price_" . $productId . "' class='bundle_price'>" . $totalDefault . "<span>";
         if (isset($isGrouped) && $isGrouped == true) {
             $options_label = 'Select Child';
             $option_value_label = 'Qty';
         }
         if (isset($isBundle) && $isBundle == true) {
             $totalDefault = 0;
             foreach ($bundleChilds as $childId => $childData) {
                 $items = $childData['items'];
                 if (count($items) > 0) {
                     foreach ($items as $itemId => $itemData) {
                         if ($itemData['is_default'] == '1') {
                             $totalDefault += $itemData['price'] * $itemData['qty'];
                         }
                     }
                 }
             }
             $totalDefault = $store->formatPrice($totalDefault);
             $options_label = 'Select childs';
             $option_value_label = "Price <span finalprice='" . $finalPrice . "' id='totals_price_" . $productId . "' class='bundle_price'>" . $totalDefault . "<span>";
         }
         $html .= "<div class='product_options hide' id='" . $productId . "_options_popup' price_condition='" . $priceConditions . "'>\r\n\t\t\t\t\t\t<ul>\r\n\t\t\t\t\t\t\t<div class='product-name col-lg-12 col-md-12 col-sm-12 col-xs-12' style='padding:0'>\r\n\t\t\t\t\t\t\t\t<h2>" . $productShortName . "<button type='button' class='btn btn-warning' onclick=\"addProductWidthOptions('" . $productId . "','" . $product->getFinalPrice() . "','" . Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(120) . "')\">" . $this->__('Add to Cart') . "</button></h2>\r\n\t\t\t\t\t\t\t</div>\t\t\t\t\t\t\t\t\t  \r\n\t\t\t\t\t\t\t<div class='col-lg-12 col-md-12 col-sm-12 col-xs-12' style='padding:0'>\r\n\t\t\t\t\t\t\t\t<div class='col col-lg-6 col-md-6 col-sm-6 col-xs-6'>\r\n\t\t\t\t\t\t\t\t\t<div class='pospanel panel-default'>\r\n\t\t\t\t\t\t\t\t\t\t<div class='panel-heading'>" . $this->__($options_label) . "</div>\r\n\t\t\t\t\t\t\t\t\t\t\t<div class='options'>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<ul>";
         $countOption = 1;
         if (count($options) > 0) {
             foreach ($options as $optionCode => $optionValues) {
                 if ($optionCode == 'price_condition') {
                     continue;
                 }
                 $optionActive = $countOption == 1 ? 'option_active' : '';
                 $html .= "<li optiontype='configurable' id='" . $productId . "_" . $optionCode . "' onclick=\"showProductOptions('" . $productId . "','" . $optionCode . "')\"  class='" . $productId . "_options_label " . $optionActive . "'>\r\n\t\t\t\t\t\t\t\t<span>" . $optionValues['optionLabel'] . "<span class='required'>*</span></span><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>\r\n\t\t\t\t\t\t\t</li>";
                 $countOption++;
             }
         }
         if (count($customOptions) > 0) {
             foreach ($customOptions as $option) {
                 if ($option['price'] > 0) {
                     if ($option['price_type'] == 'fixed') {
                         $priceFormated = ' +' . $store->formatPrice($option['price']);
                     } else {
                         $priceFormated = ' +' . $store->formatPrice($option['price'] * $product->getFinalPrice() / 100);
                     }
                 } else {
                     $priceFormated = '';
                 }
                 $optionActive = $countOption == 1 ? 'option_active' : '';
                 $optionTitle = $option['is_require'] == '1' ? $option['title'] . "<span class='required'>*</span>" : $option['title'];
                 $html .= "<li optiontype='custom' id='" . $productId . "_co_" . $option['option_id'] . "' onclick=\"showProductOptions('" . $productId . "', '" . $option['option_id'] . "')\" value='" . $productId . "_co_" . $option['option_id'] . "' class='" . $productId . "_options_label " . $optionActive . "'>\r\n\t\t\t\t\t\t\t\t<span>" . $optionTitle . $priceFormated . "</span><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>\r\n\t\t\t\t\t\t\t</li>";
                 $countOption++;
             }
         }
         if (count($groupedChilds) > 0) {
             foreach ($groupedChilds as $childId => $childData) {
                 $optionActive = $countOption == 1 ? 'option_active' : '';
                 $html .= "<li optiontype='grouped' id='" . $productId . "_grouped_" . $childId . "' onclick=\"showProductOptions('" . $productId . "', '" . $childId . "')\" value='" . $productId . "_grouped_" . $childId . "' class='" . $productId . "_options_label grouped_label " . $optionActive . "'>\r\n\t\t\t\t\t<span>" . $childData['name'] . "</span><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>\r\n\t\t\t\t</li>";
                 $countOption++;
             }
         }
         if (count($bundleChilds) > 0) {
             foreach ($bundleChilds as $childId => $childData) {
                 $optionActive = $countOption == 1 ? 'option_active' : '';
                 $childName = $childData['required'] == '1' ? $childData['title'] . "<span class='required'>*</span>" : $childData['title'];
                 $html .= "<li optiontype='bundle' id='" . $productId . "_bundle_" . $childId . "' onclick=\"showProductOptions('" . $productId . "', '" . $childId . "')\" value='" . $productId . "_bundle_" . $childId . "' class='" . $productId . "_options_label bundle_label " . $optionActive . "'>\r\n\t\t\t\t\t<span>" . $childName . "</span><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>\r\n\t\t\t\t</li>";
                 $countOption++;
             }
         }
         if (count($storeCreditOptions) > 0) {
             $optionActive = 'option_active';
             $childName = $this->__('Credit option');
             $html .= "<li optiontype='storecredit' id='" . $productId . "_storecredit_' onclick=\"showProductOptions('" . $productId . "', '')\" value='" . $productId . "_storecredit_' class='" . $productId . "_options_label " . $optionActive . "'>\r\n\t\t\t\t\t<span>" . $childName . "</span><span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>\r\n\t\t\t\t</li>";
         }
         $html .= "</ul></div></div></div>\r\n                     <div class='col col-value col-lg-6 col-md-6 col-sm-6 col-xs-6'>\r\n\t\t\t\t\t\t<div class='pospanel panel-default'>\r\n\t\t\t\t\t\t\t<div class='panel-heading'><span>" . $this->__($option_value_label) . "</span></div>\r\n\t\t\t\t\t\t\t\t<div class='options'>";
         $numberOption = 1;
         if (count($options) > 0) {
             foreach ($options as $optionCode => $optionValues) {
                 if ($optionCode == 'price_condition') {
                     continue;
                 }
                 $onlyOption = false;
                 $onlyOptionValue = '';
                 $onlyOptionLabel = '';
                 if (count($optionValues) == 3) {
                     $onlyOption = true;
                     foreach ($optionValues as $optionValue => $optionLabel) {
                         if ($optionValue == 'optionId' || $optionValue == 'optionLabel') {
                             continue;
                         }
                         $onlyOptionValue = $optionValue;
                         $onlyOptionLabel = "optionLabel='" . $optionLabel . "'";
                     }
                 }
                 $hideClass = $numberOption != 1 ? 'hide' : '';
                 $hideOnlyClass = !$onlyOption ? 'hide' : '';
                 $html .= "<ul id='" . $productId . "_" . $optionCode . "_values' class='" . $productId . "_option_values " . $hideClass . "'>\r\n\t\t\t\t\t\t\t\t<input " . $onlyOptionLabel . " type='hidden' optionCode='" . $optionCode . "' optionId='" . $optionValues['optionId'] . "'  id='" . $productId . "_" . $optionCode . "_value' class='input_options input_options_" . $productId . "' value='" . $onlyOptionValue . "'/>";
                 foreach ($optionValues as $optionValue => $optionLabel) {
                     if ($optionValue == 'optionId' || $optionValue == 'optionLabel') {
                         continue;
                     }
                     $html .= "<li onclick=\"selectProductOption('" . $productId . "', '" . $optionCode . "', '" . $optionValue . "', '" . $optionLabel . "')\" value='" . $optionValue . "'>" . $optionLabel . "\r\n\t\t\t\t\t\t\t\t\t<span class='glyphicon glyphicon-ok prd_options_selected_icon prd_options_selected_icon_" . $optionCode . " " . $hideOnlyClass . "' id='" . $product->getId() . "_" . $optionCode . "_" . $optionValue . "_selected_icon'></span>\r\n\t\t\t\t\t\t\t\t\t</li>";
                     $numberOption++;
                 }
                 $html .= "</ul>";
             }
         }
         if (count($customOptions) > 0) {
             foreach ($customOptions as $option) {
                 $hideClass = $numberOption != 1 ? 'hide' : '';
                 $html .= "<ul id='" . $productId . "_co_" . $option['option_id'] . "_values' class='" . $productId . "_option_values custom_options_values  " . $hideClass . "'>\r\n\t\t\t\t\t\t\t\t<li>";
                 $html .= $this->getCustomOptionHtml($option);
                 $html .= "<span class='glyphicon glyphicon-ok prd_options_selected_icon prd_options_selected_icon_" . $optionCode . " hide' id='" . $productId . "_" . $optionCode . "_" . $optionValue . "_selected_icon'></span>\r\n                               </li>\r\n                               </ul>";
                 $numberOption++;
             }
         }
         if (count($storeCreditOptions) > 0) {
             $html .= "<ul id='" . $productId . "_storecredit__values' class='" . $productId . "_option_values custom_options_values '><li>";
             $html .= $this->getStoreCreditOptionHtml($product, $storeCreditOptions);
             $html .= "</li></ul>";
         }
         if (count($groupedChilds) > 0) {
             $hideClass = $numberOption != 1 ? 'hide' : '';
             $html .= "<ul id='" . $productId . "_grouped_qtys' class='" . $productId . "_option_values grouped_childs_qty  " . $hideClass . "'>";
             foreach ($groupedChilds as $childId => $childData) {
                 $html .= "<li class='grouped_qty_area'>\r\n\t\t\t\t\t\t\t\t<p id='prd_fullname_" . $childId . "' class='hide'>" . $childData['name'] . "</p>\r\n\t\t\t\t\t\t\t\t<img id='grouped_child_imgpath_" . $childId . "' src='" . $childData['imgpath'] . "'/>\r\n\t\t\t\t\t\t\t\t<input id='grouped_child_price_" . $childId . "' value='" . $childData['price'] . "' class='hide'/>\r\n\t\t\t\t\t\t\t\t<input value='0' childid='" . $childId . "' class='" . $productId . "_grouped_childs_qty'/>\r\n\t\t\t\t\t\t\t\t<span class='price'>" . Mage::helper('core')->currency($childData['price'], true, false) . "</span>\r\n\t\t\t\t\t\t\t\t<span class='glyphicon glyphicon-ok prd_options_selected_icon prd_options_selected_icon_" . $optionCode . " hide' id='" . $productId . "_" . $optionCode . "_" . $optionValue . "_selected_icon'></span>\r\n\t\t\t\t\t\t\t\t</li>";
                 $numberOption++;
             }
             $html .= "</ul>";
         }
         if (count($bundleChilds) > 0) {
             foreach ($bundleChilds as $childId => $childData) {
                 $hideClass = $numberOption != 1 ? 'hide' : '';
                 $html .= "<ul id='" . $productId . "_bundle_" . $childId . "_values' class='" . $productId . "_option_values bundle_childs_values  " . $hideClass . "'>\r\n\t\t\t\t\t\t\t\t<li>";
                 $html .= $this->getBundleSelectionHtml($childData);
                 $html .= "</li>\r\n                               </ul>";
                 $numberOption++;
             }
         }
         $html .= "</div>\r\n                               </div>\r\n                            </div>\r\n                        </div>\r\n                     </ul>\r\n                 </div>";
         if ($extraClass == '') {
             $html .= "<script type='text/javascript'>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t</script> ";
         }
     }
     $html .= " </div>";
     return $html;
 }
 public function getObject(Mage_Catalog_Model_Product $product)
 {
     $type = $this->config->getMappedProductType($product->getTypeId());
     $this->logger->start('CREATE RECORD ' . $product->getId() . ' ' . $this->logger->getStoreName($product->storeId));
     $this->logger->log('Product type (' . $product->getTypeId() . ', mapped to: ' . $type . ')');
     $defaultData = array();
     $transport = new Varien_Object($defaultData);
     Mage::dispatchEvent('algolia_product_index_before', array('product' => $product, 'custom_data' => $transport));
     $defaultData = $transport->getData();
     $defaultData = is_array($defaultData) ? $defaultData : explode('|', $defaultData);
     $visibility = (int) $product->getVisibility();
     /** @var Mage_Catalog_Model_Product_Visibility $catalogProductVisibility */
     $catalogProductVisibility = Mage::getSingleton('catalog/product_visibility');
     $visibleInCatalog = $catalogProductVisibility->getVisibleInCatalogIds();
     $visibleInSearch = $catalogProductVisibility->getVisibleInSearchIds();
     $customData = array('objectID' => $product->getId(), 'name' => $product->getName(), 'url' => $product->getProductUrl(), 'visibility_search' => (int) in_array($visibility, $visibleInSearch), 'visibility_catalog' => (int) in_array($visibility, $visibleInCatalog));
     $additionalAttributes = $this->config->getProductAdditionalAttributes($product->getStoreId());
     $groups = null;
     if ($this->isAttributeEnabled($additionalAttributes, 'description')) {
         $customData['description'] = $product->getDescription();
     }
     $categories = array();
     $categories_with_path = array();
     $_categoryIds = $product->getCategoryIds();
     if (is_array($_categoryIds) && count($_categoryIds) > 0) {
         $categoryCollection = Mage::getResourceModel('catalog/category_collection')->addAttributeToSelect('name')->addAttributeToFilter('entity_id', $_categoryIds)->addFieldToFilter('level', array('gt' => 1))->addIsActiveFilter();
         if ($this->config->showCatsNotIncludedInNavigation($product->getStoreId()) == false) {
             $categoryCollection->addAttributeToFilter('include_in_menu', '1');
         }
         $rootCat = Mage::app()->getStore($product->getStoreId())->getRootCategoryId();
         /** @var Mage_Catalog_Model_Category $category */
         foreach ($categoryCollection as $category) {
             // Check and skip all categories that is not
             // in the path of the current store.
             $path = $category->getPath();
             $path_parts = explode('/', $path);
             if (isset($path_parts[1]) && $path_parts[1] != $rootCat) {
                 continue;
             }
             $categoryName = $category->getName();
             if ($categoryName) {
                 $categories[] = $categoryName;
             }
             $category->getUrlInstance()->setStore($product->getStoreId());
             $path = array();
             foreach ($category->getPathIds() as $treeCategoryId) {
                 $name = $this->getCategoryName($treeCategoryId, $product->getStoreId());
                 if ($name) {
                     $path[] = $name;
                 }
             }
             $categories_with_path[] = $path;
         }
     }
     if ($this->config->indexWholeCategoryTree($product->getStoreId())) {
         foreach ($categories_with_path as $result) {
             for ($i = count($result) - 1; $i > 0; $i--) {
                 $categories_with_path[] = array_slice($result, 0, $i);
             }
         }
     }
     $categories_with_path = array_intersect_key($categories_with_path, array_unique(array_map('serialize', $categories_with_path)));
     $categories_hierarchical = array();
     $mainCategories = array();
     $level_name = 'level';
     /** @var array $category */
     foreach ($categories_with_path as $category) {
         $categoriesCount = count($category);
         for ($i = 0; $i < $categoriesCount; $i++) {
             if (isset($categories_hierarchical[$level_name . $i]) === false) {
                 $categories_hierarchical[$level_name . $i] = array();
             }
             $mainCategories[$level_name . $i][] = $category[$i];
             if ($this->config->indexWholeCategoryTree($product->getStoreId())) {
                 $categories_hierarchical[$level_name . $i][] = implode(' /// ', array_slice($category, 0, $i + 1));
             } else {
                 if ($i === $categoriesCount - 1) {
                     $categories_hierarchical[$level_name . $i][] = implode(' /// ', $category);
                 }
             }
         }
     }
     foreach ($categories_hierarchical as &$level) {
         $level = array_values(array_unique($level));
     }
     foreach ($mainCategories as &$level) {
         $level = array_values(array_unique($level));
     }
     foreach ($categories_with_path as &$category) {
         $category = implode(' /// ', $category);
     }
     $customData['categories'] = $categories_hierarchical;
     $customData['categories_without_path'] = $categories;
     if ($this->isAttributeEnabled($additionalAttributes, 'main_categories')) {
         $customData['main_categories'] = $mainCategories;
     }
     /** @var Algolia_Algoliasearch_Helper_Image $imageHelper */
     $imageHelper = Mage::helper('algoliasearch/image');
     if (false === isset($defaultData['thumbnail_url'])) {
         /** @var Algolia_Algoliasearch_Helper_Image $thumb */
         $thumb = $imageHelper->init($product, 'thumbnail')->resize(75, 75);
         try {
             $customData['thumbnail_url'] = $thumb->toString();
         } catch (\Exception $e) {
             $this->logger->log($e->getMessage());
             $this->logger->log($e->getTraceAsString());
             $placeholderUrl = Mage::getDesign()->getSkinUrl($thumb->getPlaceholder());
             $customData['thumbnail_url'] = $imageHelper->removeProtocol($placeholderUrl);
         }
     }
     if (false === isset($defaultData['image_url'])) {
         /** @var Algolia_Algoliasearch_Helper_Image $image */
         $image = $imageHelper->init($product, $this->config->getImageType())->resize($this->config->getImageWidth(), $this->config->getImageHeight());
         try {
             $customData['image_url'] = $image->toString();
         } catch (\Exception $e) {
             $this->logger->log($e->getMessage());
             $this->logger->log($e->getTraceAsString());
             $placeholderUrl = Mage::getDesign()->getSkinUrl($image->getPlaceholder());
             $customData['image_url'] = $imageHelper->removeProtocol($placeholderUrl);
         }
         if ($this->isAttributeEnabled($additionalAttributes, 'media_gallery')) {
             $product->load('media_gallery');
             $customData['media_gallery'] = array();
             foreach ($product->getMediaGalleryImages() as $image) {
                 $customData['media_gallery'][] = $imageHelper->removeProtocol($image->getUrl());
             }
         }
     }
     $sub_products = null;
     $ids = null;
     if ($type == 'configurable' || $type == 'grouped' || $type == 'bundle') {
         if ($type == 'bundle') {
             $ids = array();
             $selection = $product->getTypeInstance(true)->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
             foreach ($selection as $option) {
                 $ids[] = $option->product_id;
             }
         }
         if ($type == 'configurable' || $type == 'grouped') {
             $ids = $product->getTypeInstance(true)->getChildrenIds($product->getId());
             $ids = call_user_func_array('array_merge', $ids);
         }
         if (count($ids)) {
             $collection = $this->getProductCollectionQuery($product->getStoreId(), $ids, false);
             $sub_products = $collection->load();
         } else {
             $sub_products = array();
         }
     }
     if (false === isset($defaultData['in_stock'])) {
         $stockItem = $product->getStockItem();
         $customData['in_stock'] = (int) $stockItem->getIsInStock();
     }
     // skip default calculation if we have provided these attributes via the observer in $defaultData
     if (false === isset($defaultData['ordered_qty']) && $this->isAttributeEnabled($additionalAttributes, 'ordered_qty')) {
         $customData['ordered_qty'] = (int) $product->getOrderedQty();
     }
     if (false === isset($defaultData['total_ordered']) && $this->isAttributeEnabled($additionalAttributes, 'total_ordered')) {
         $customData['total_ordered'] = (int) $product->getTotalOrdered();
     }
     if (false === isset($defaultData['stock_qty']) && $this->isAttributeEnabled($additionalAttributes, 'stock_qty')) {
         $customData['stock_qty'] = (int) $product->getStockQty();
     }
     if (Mage::helper('core')->isModuleEnabled('Mage_Review')) {
         if ($this->isAttributeEnabled($additionalAttributes, 'rating_summary')) {
             $customData['rating_summary'] = (int) $product->getRatingSummary();
         }
     }
     $this->setNoAttributes($additionalAttributes);
     foreach ($additionalAttributes as $attribute) {
         $attribute_name = $attribute['attribute'];
         if (isset($customData[$attribute_name])) {
             continue;
         }
         $value = $product->getData($attribute_name);
         /** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute_resource */
         $attribute_resource = $product->getResource()->getAttribute($attribute_name);
         if ($attribute_resource) {
             $attribute_resource->setStoreId($product->getStoreId());
             /**
              * if $value is missing or if the attribute is SKU,
              * use values from child products.
              */
             if (($value === null || 'sku' == $attribute_name) && ($type == 'configurable' || $type == 'grouped' || $type == 'bundle')) {
                 if ($value === null) {
                     $values = array();
                 } else {
                     $values = array($this->getValueOrValueText($product, $attribute_name, $attribute_resource));
                 }
                 $all_sub_products_out_of_stock = true;
                 if ($type !== 'bundle' || in_array($attribute_name, $this->excludedAttrsFromBundledProducts, true) === false) {
                     foreach ($sub_products as $sub_product) {
                         $isInStock = (int) $sub_product->getStockItem()->getIsInStock();
                         if ($isInStock == false && $this->config->indexOutOfStockOptions($product->getStoreId()) == false) {
                             continue;
                         }
                         $all_sub_products_out_of_stock = false;
                         $value = $sub_product->getData($attribute_name);
                         if ($value) {
                             $values[] = $this->getValueOrValueText($sub_product, $attribute_name, $attribute_resource);
                         }
                     }
                 }
                 if (is_array($values) && count($values) > 0) {
                     $customData[$attribute_name] = array_values(array_unique($values, SORT_REGULAR));
                 }
                 // Set main product out of stock if all
                 // sub-products are out of stock.
                 if ($customData['in_stock'] && $all_sub_products_out_of_stock) {
                     $customData['in_stock'] = 0;
                 }
             } elseif (!is_array($value)) {
                 $value = $this->getValueOrValueText($product, $attribute_name, $attribute_resource);
             }
             if ($value && !isset($customData[$attribute_name])) {
                 $customData[$attribute_name] = $value;
             }
         }
     }
     $msrpEnabled = method_exists(Mage::helper('catalog'), 'canApplyMsrp') ? (bool) Mage::helper('catalog')->canApplyMsrp($product) : false;
     if (false === $msrpEnabled) {
         $this->handlePrice($product, $sub_products, $customData);
     } else {
         unset($customData['price']);
     }
     $transport = new Varien_Object($customData);
     Mage::dispatchEvent('algolia_subproducts_index', array('custom_data' => $transport, 'sub_products' => $sub_products));
     $customData = $transport->getData();
     $customData = array_merge($customData, $defaultData);
     $customData['type_id'] = $type;
     $this->castProductObject($customData);
     $customData = $this->clearNoValues($customData);
     $this->logger->stop('CREATE RECORD ' . $product->getId() . ' ' . $this->logger->getStoreName($product->storeId));
     return $customData;
 }
Esempio n. 25
0
 function getName()
 {
     return $this->vf_product->getName(parent::getName());
 }
Esempio n. 26
0
 public function testGetImageLabel()
 {
     $this->assertEquals($this->_product->getName(), $this->_block->getImageLabel());
 }
 /**
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getProductData(Mage_Catalog_Model_Product $product)
 {
     $id = $product->getId();
     if (!$this->helper()->shouldUseRealProductId()) {
         $id = $product->getSku() ? $product->getSku() : md5($id);
     }
     $data = array('id' => $id, 'url' => $product->getProductUrl(), 'name' => $product->getName(), 'unit_price' => (double) $product->getPrice(), 'unit_sale_price' => (double) $product->getFinalPrice(), 'currency' => $this->_getCurrency(), 'description' => strip_tags($product->getShortDescription()), 'sku_code' => $product->getSku());
     if ($this->helper()->shouldShowProductStockInfo()) {
         $data['stock'] = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
     }
     $catIndex = $catNames = array();
     $limit = 2;
     $k = 0;
     foreach ($product->getCategoryIds() as $catId) {
         if (++$k > $limit) {
             break;
         }
         if (!isset($catIndex[$catId])) {
             $catIndex[$catId] = Mage::getModel('catalog/category')->load($catId);
         }
         $catNames[] = $catIndex[$catId]->getName();
     }
     if (isset($catNames[0])) {
         $data['category'] = $catNames[0];
     }
     if (isset($catNames[1])) {
         $data['subcategory'] = $catNames[1];
     }
     return $data;
 }
 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;
         }
     }
 }
Esempio n. 29
0
 /**
  * get product name
  *
  * @param Mage_Catalog_Model_Product $product
  *
  * @return string
  */
 public function getProductName($product)
 {
     return trim($product->getName());
 }
Esempio n. 30
0
 public function getObject(Mage_Catalog_Model_Product $product, $group_id = null)
 {
     $defaultData = array();
     $transport = new Varien_Object($defaultData);
     Mage::dispatchEvent('algolia_product_index_before', array('product' => $product, 'custom_data' => $transport));
     $defaultData = $transport->getData();
     $defaultData = is_array($defaultData) ? $defaultData : explode("|", $defaultData);
     $customData = array('objectID' => $product->getId(), 'name' => $product->getName(), 'price' => $product->getPrice(), 'price_with_tax' => Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, false), 'url' => $product->getProductUrl(), 'description' => $product->getDescription());
     $special_price = $product->getFinalPrice();
     /**
      * Handle group price
      */
     if ($group_id !== null) {
         $discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(Mage::app()->getLocale()->storeTimeStamp($product->getStoreId()), Mage::app()->getStore($product->getStoreId())->getWebsiteId(), $group_id, $product->getId());
         if ($discounted_price !== false) {
             $special_price = $discounted_price;
         }
     }
     if ($special_price != $customData['price']) {
         $customData['special_price_from_date'] = strtotime($product->getSpecialFromDate());
         $customData['special_price_to_date'] = strtotime($product->getSpecialToDate());
         $customData['special_price'] = $special_price;
         $customData['special_price_with_tax'] = Mage::helper('tax')->getPrice($product, $special_price, true, null, null, null, null, false);
         $customData['special_price_formated'] = Mage::helper('core')->formatPrice($customData['special_price'], false);
         $customData['special_price_with_tax_formated'] = Mage::helper('core')->formatPrice($customData['special_price_with_tax'], false);
     }
     $customData['price_formated'] = Mage::helper('core')->formatPrice($customData['price'], false);
     $customData['price_with_tax_formated'] = Mage::helper('core')->formatPrice($customData['price_with_tax'], false);
     $categories = array();
     $categories_with_path = array();
     foreach ($this->getProductActiveCategories($product, $product->getStoreId()) as $categoryId) {
         $category = Mage::getModel('catalog/category')->load($categoryId);
         $categoryName = $category->getName();
         if ($categoryName) {
             $categories[] = $categoryName;
         }
         $category->getUrlInstance()->setStore($product->getStoreId());
         $path = array();
         foreach ($category->getPathIds() as $treeCategoryId) {
             $name = $this->getCategoryName($treeCategoryId, $product->getStoreId());
             if ($name) {
                 $path[] = $name;
             }
         }
         $categories_with_path[] = $path;
     }
     foreach ($categories_with_path as $result) {
         for ($i = count($result) - 1; $i > 0; $i--) {
             $categories_with_path[] = array_slice($result, 0, $i);
         }
     }
     $categories_with_path = array_intersect_key($categories_with_path, array_unique(array_map('serialize', $categories_with_path)));
     $categories_hierarchical = array();
     $level_name = 'level';
     foreach ($categories_with_path as $category) {
         for ($i = 0; $i < count($category); $i++) {
             if (isset($categories_hierarchical[$level_name . $i]) === false) {
                 $categories_hierarchical[$level_name . $i] = array();
             }
             $categories_hierarchical[$level_name . $i][] = implode(' /// ', array_slice($category, 0, $i + 1));
         }
     }
     foreach ($categories_hierarchical as &$level) {
         $level = array_unique($level);
     }
     foreach ($categories_with_path as &$category) {
         $category = implode(' /// ', $category);
     }
     $customData['categories'] = $categories_hierarchical;
     //array_values($categories_with_path);
     $customData['categories_without_path'] = $categories;
     if (false === isset($defaultData['thumbnail_url'])) {
         try {
             $customData['thumbnail_url'] = $product->getThumbnailUrl();
             $customData['thumbnail_url'] = str_replace(array('https://', 'http://'), '//', $customData['thumbnail_url']);
         } catch (\Exception $e) {
         }
     }
     if (false === isset($defaultData['image_url'])) {
         try {
             $customData['image_url'] = $product->getImageUrl();
             $customData['image_url'] = str_replace(array('https://', 'http://'), '//', $customData['image_url']);
         } catch (\Exception $e) {
         }
     }
     $additionalAttributes = $this->config->getProductAdditionalAttributes($product->getStoreId());
     $sub_products = null;
     if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped') {
         if ($product->getTypeId() == 'grouped') {
             $sub_products = $product->getTypeInstance(true)->getAssociatedProducts($product);
         }
         if ($product->getTypeId() == 'configurable') {
             $sub_products = $product->getTypeInstance(true)->getUsedProducts(null, $product);
         }
         $min = PHP_INT_MAX;
         $max = 0;
         $min_with_tax = PHP_INT_MAX;
         $max_with_tax = 0;
         foreach ($sub_products as $sub_product) {
             $sub_product = Mage::getModel('catalog/product')->load($sub_product->getId());
             $price = $sub_product->getPrice();
             $price_with_tax = Mage::helper('tax')->getPrice($sub_product, $price, true, null, null, null, null, false);
             $min = min($min, $price);
             $max = max($max, $price);
             $min_with_tax = min($min_with_tax, $price_with_tax);
             $max_with_tax = max($max_with_tax, $price_with_tax);
         }
         $customData['min_formated'] = Mage::helper('core')->formatPrice($min, false);
         $customData['max_formated'] = Mage::helper('core')->formatPrice($max, false);
         $customData['min_with_tax_formated'] = Mage::helper('core')->formatPrice($min_with_tax, false);
         $customData['max_with_tax_formated'] = Mage::helper('core')->formatPrice($max_with_tax, false);
     }
     if (false === isset($defaultData['in_stock'])) {
         $stockItem = $product->getStockItem();
         $customData['in_stock'] = (int) $stockItem->getIsInStock();
     }
     // skip default calculation if we have provided these attributes via the observer in $defaultData
     if (false === isset($defaultData['ordered_qty']) && false === isset($defaultData['stock_qty'])) {
         $ordered_qty = Mage::getResourceModel('reports/product_collection')->addOrderedQty()->addAttributeToFilter('sku', $product->getSku())->setOrder('ordered_qty', 'desc')->getFirstItem()->ordered_qty;
         $customData['ordered_qty'] = (int) $ordered_qty;
         $customData['stock_qty'] = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
         if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped') {
             $ordered_qty = 0;
             $stock_qty = 0;
             foreach ($sub_products as $sub_product) {
                 $stock_qty += (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($sub_product)->getQty();
                 $ordered_qty += (int) $this->getReportForProduct($sub_product)->ordered_qty;
             }
             $customData['ordered_qty'] = $ordered_qty;
             $customData['stock_qty'] = $stock_qty;
         }
         if ($this->isAttributeEnabled($additionalAttributes, 'ordered_qty') == false) {
             unset($customData['ordered_qty']);
         }
         if ($this->isAttributeEnabled($additionalAttributes, 'stock_qty') == false) {
             unset($customData['stock_qty']);
         }
     }
     if ($this->isAttributeEnabled($additionalAttributes, 'rating_summary')) {
         $summaryData = Mage::getModel('review/review_summary')->setStoreId($product->getStoreId())->load($product->getId());
         if ($summaryData['rating_summary']) {
             $customData['rating_summary'] = $summaryData['rating_summary'];
         }
     }
     foreach ($additionalAttributes as $attribute) {
         if (isset($customData[$attribute['attribute']])) {
             continue;
         }
         $value = $product->getData($attribute['attribute']);
         $attribute_ressource = $product->getResource()->getAttribute($attribute['attribute']);
         if ($attribute_ressource) {
             $attribute_ressource = $attribute_ressource->setStoreId($product->getStoreId());
             if ($value === null) {
                 /** Get values as array in children */
                 if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped') {
                     $values = array();
                     foreach ($sub_products as $sub_product) {
                         $sub_product = Mage::getModel('catalog/product')->load($sub_product->getId());
                         $value = $sub_product->getData($attribute['attribute']);
                         if ($value) {
                             $value_text = $sub_product->getAttributeText($attribute['attribute']);
                             if ($value_text) {
                                 $values[] = $value_text;
                             } else {
                                 $values[] = $attribute_ressource->getFrontend()->getValue($sub_product);
                             }
                         }
                     }
                     if (count($values) > 0) {
                         $customData[$attribute['attribute']] = $values;
                     }
                 }
             } else {
                 $value_text = $product->getAttributeText($attribute['attribute']);
                 if ($value_text) {
                     $value = $value_text;
                 } else {
                     $attribute_ressource = $attribute_ressource->setStoreId($product->getStoreId());
                     $value = $attribute_ressource->getFrontend()->getValue($product);
                 }
                 if ($value) {
                     $customData[$attribute['attribute']] = $value;
                 }
             }
         }
     }
     $customData = array_merge($customData, $defaultData);
     $customData['type_id'] = $product->getTypeId();
     $this->castProductObject($customData);
     return $customData;
 }