/**
  * Get the size attribute value of a product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return string
  */
 protected function getSize($product)
 {
     $size = $product->getAttributeText('shoe_size');
     $size = trim($size);
     return $size;
 }
 private function getProduttoreProdotto(Mage_Catalog_Model_Product $product)
 {
     if ($product->getAttributeText(Mage::helper('itserv_analytics')->getBrandAttributeCode())) {
         return $product->getAttributeText(Mage::helper('itserv_analytics')->getBrandAttributeCode());
     } else {
         return '';
     }
 }
Exemple #3
0
 /**
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 protected function _createProduct(Mage_Catalog_Model_Product $product)
 {
     $brand = null;
     if ($product->hasData('brand')) {
         $brand = $product->getAttributeText('brand');
     }
     $manufacturer = null;
     if ($product->hasData('manufacturer')) {
         $manufacturer = $product->getAttributeText('manufacturer');
     }
     $data = array('id' => $product->getEntityId(), 'productTypeId' => $this->_getProductTypeId($product), 'name' => array($this->_createLocalizedValue($product->getName())), 'shortDescription' => array($this->_createLocalizedValue($product->getShortDescription())), 'description' => array($this->_createLocalizedValue($product->getDescription())), 'GTIN' => $product->hasData('gtin') ? $product->getAttributeText('gtin') : null, 'brand' => !empty($brand) ? array($this->_createLocalizedValue($brand)) : null, 'manufacturer' => !empty($manufacturer) ? array($this->_createLocalizedValue($manufacturer)) : null, 'MPN' => $product->hasData('mpn') ? $product->getAttributeText('mpn') : null, 'MSRP' => $this->_getMsrp($product), 'MAP' => $product->hasData('map') ? $this->_getCurrencyAmount($product->getAttributeText('map')) : null, 'images' => $this->_createImageUrls($product), 'attributes' => $this->_createAttributes($product), 'variationFactors' => $this->_createVariationFactors($product), 'skuList' => $this->_createSkus($product));
     return $data;
 }
 /**
  * @param Mage_Catalog_Model_Product $product
  */
 protected function _attributes(Mage_Catalog_Model_Product &$product)
 {
     $_attributes = $product->getAttributes();
     /** @var Mage_Eav_Model_Entity_Attribute $attribute */
     foreach ($_attributes as $attribute) {
         if ($attribute->getBackendType() == self::ATTRIBUTE_TYPE_TO_PREPARE) {
             $attributeText = $product->getAttributeText($attribute->getAttributeCode());
             //getting attribute value
             $product->setData($attribute->getAttributeCode(), $attributeText);
             //setting this to product  (override existing integer value)
         }
     }
 }
 /**
  * Encodes a single Magento Product.
  *
  * @param Mage_Catalog_Model_Product $product
  *
  * @return RTDProduct
  */
 protected function _encodeProduct(Mage_Catalog_Model_Product $product)
 {
     $encodedProduct = new RTDProduct();
     $customMapping = Mage::getConfig()->getNode('rtd_mappings/product/export');
     $attributeTypes = array('multiselect', 'dropdown');
     foreach ($customMapping->asArray() as $magentoKey => $rtdKey) {
         try {
             $attribute = $product->getResource()->getAttribute($magentoKey);
             if ($attribute != false && in_array($attribute->getFrontendInput(), $attributeTypes)) {
                 $encodedProduct->setParam($rtdKey, $product->getAttributeText($magentoKey));
             } else {
                 $encodedProduct->setParam($rtdKey, $product->{'get' . $magentoKey}());
             }
         } catch (Exception $ex) {
             Mage::log($ex->getMessage(), null, 'realtimedespatch.log');
         }
     }
     if (Mage::getStoreConfigFlag('sixbysix_realtimedespatch/product_export/image_export')) {
         $this->_swapPlaceholderWithParentImage($product, $encodedProduct);
     }
     return $encodedProduct;
 }
Exemple #6
0
 /**
  * @param $type
  * @param $result
  */
 protected function _getIdentifierByType($type, &$result)
 {
     $typeLabel = '';
     switch ($type) {
         case 'ean':
             $attributeCode = Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EAN_ATTR_CODE);
             $typeLabel = 'EAN';
             break;
         case 'upc':
             $attributeCode = Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_UPC_ATTR_CODE);
             $typeLabel = 'UPC';
             break;
     }
     if (!empty($attributeCode)) {
         $textValue = $this->item->getAttributeText($attributeCode);
         $attributeValue = $this->item->getData($attributeCode);
         if (!empty($value) || !empty($attributeValue)) {
             $identifierItemObject = new Shopgate_Model_Catalog_Identifier();
             $identifierItemObject->setType($typeLabel);
             $identifierItemObject->setValue($textValue ? $textValue : $attributeValue);
             $result[] = $identifierItemObject;
         }
     }
 }
 /**
  * Retrieve configurable settings
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 public function getConfigurableSettings($product)
 {
     $data = array();
     $attributes = $this->_getProduct()->getTypeInstance(true)->getUsedProductAttributes($this->_getProduct());
     foreach ($attributes as $attribute) {
         $data[] = array('attribute_id' => $attribute->getId(), 'label' => $product->getAttributeText($attribute->getAttributeCode()), 'value_index' => $product->getData($attribute->getAttributeCode()));
     }
     return $data;
 }
Exemple #8
0
 /**
  * Check is virtual product
  *
  * @param Mage_Catalog_Model_Product $product
  * @return bool
  */
 public function isVirtual($product = null)
 {
     if (!$product) {
         return false;
     }
     if ($product->getCustomOption('card_type')) {
         $type = $product->getCustomOption('card_type')->getValue();
     } else {
         $type = $product->getAttributeText('wts_gc_type');
     }
     if ($product && $type == 'offline') {
         return false;
     } else {
         return true;
     }
 }
Exemple #9
0
 protected function _writeOrderProductAttribute(Mage_Catalog_Model_Product $product, XMLWriter $xml, $storeId = null)
 {
     // custom attributes are specified in Admin > Configuration > Sales > Auctane Shipstation API
     // static because attributes can be cached, they do not change during a request
     static $attrs = null;
     if (is_null($attrs)) {
         $attrs = Mage::getResourceModel('eav/entity_attribute_collection');
         $attrIds = explode(',', Mage::getStoreConfig('sales/auctaneapi/customattributes', $storeId));
         $attrs->addFieldToFilter('attribute_id', $attrIds);
     }
     /* @var $attr Mage_Eav_Model_Entity_Attribute */
     foreach ($attrs as $attr) {
         if ($product->hasData($attr->getName())) {
             // if an attribute has options/labels
             if (in_array($attr->getFrontendInput(), array('select', 'multiselect'))) {
                 $value = $product->getAttributeText($attr->getName());
                 if (is_array($value)) {
                     $value = implode(',', $value);
                 }
             } else {
                 $value = $product->getDataUsingMethod($attr->getName());
             }
             // fake an item option
             $option = array('value' => $value, 'label' => $attr->getFrontendLabel());
             $this->_writeOrderItemOption($option, $xml, $storeId);
         }
     }
 }
 protected function getValueOrValueText(Mage_Catalog_Model_Product $product, $name, Mage_Catalog_Model_Resource_Eav_Attribute $resource)
 {
     $value_text = $product->getAttributeText($name);
     if (!$value_text) {
         $value_text = $resource->getFrontend()->getValue($product);
     }
     return $value_text;
 }
 private function _getProductAttribute(Mage_Catalog_Model_Product $product, $attributeName)
 {
     if (!$this->_retrieveAttributes) {
         return $product->getAttributeText($attributeName);
     } else {
         $value = $this->_getAttributeValue($product, $attributeName);
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         return $value;
     }
 }
 public function testGetAttributeText()
 {
     $this->assertNull($this->_model->getAttributeText('status'));
     $this->_model->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
     $this->assertEquals('Enabled', $this->_model->getAttributeText('status'));
 }
 private function getAttributeValue(Mage_Catalog_Model_Product $product, $attributeName)
 {
     $attribute = $product->getResource()->getAttribute($attributeName);
     if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute) {
         $attribute_data = $product->getData($attributeName);
         $attribute_value = $product->getAttributeText($attributeName);
         if (empty($attribute_value) && is_scalar($attribute_data)) {
             $attribute_value = $attribute_data;
         }
     } else {
         $attribute_value = null;
     }
     return trim($attribute_value);
 }
 /**
  * Amends the product attributes to tags array if attributes are defined
  * and are present in product
  *
  * @param Mage_Catalog_Model_Product $product the product model.
  * @param Mage_Core_Model_Store      $store the store model.
  *
  */
 protected function amendAttributeTags(Mage_Catalog_Model_Product $product, Mage_Core_Model_Store $store)
 {
     $product_attributes = $product->getAttributes();
     /* @var Nosto_Tagging_Helper_Data $nosto_helper */
     $nosto_helper = Mage::helper("nosto_tagging");
     foreach (Nosto_Tagging_Helper_Data::$validTags as $tag_id) {
         $attributes_to_tag = $nosto_helper->getAttributesToTag($tag_id, $store->getId());
         if (empty($attributes_to_tag) || !is_array($attributes_to_tag)) {
             continue;
         }
         /* @var Mage_Catalog_Model_Resource_Eav_Attribute $product_attribute*/
         foreach ($product_attributes as $key => $product_attribute) {
             if (in_array($key, $attributes_to_tag)) {
                 try {
                     $attribute_data = $product->getData($key);
                     $attribute_value = $product->getAttributeText($key);
                     if (!$attribute_value && is_scalar($attribute_data)) {
                         $attribute_value = $attribute_data;
                     }
                     $attribute_value = trim($attribute_value);
                     if (!empty($attribute_value)) {
                         $this->_tags[$tag_id][] = sprintf('%s:%s', $key, $attribute_value);
                     }
                 } catch (Exception $e) {
                     Mage::log(sprintf('Failed to add attribute %s to tags. Error message was: %s', $key, $e->getMessage()), Zend_Log::WARN, Nosto_Tagging_Model_Base::LOG_FILE_NAME);
                 }
             }
         }
     }
 }
Exemple #15
0
 /**
  * Add required custom attributes which were not mapped
  *
  * @param array $mappedAttributes
  * @param Mage_Catalog_Model_Product $product
  * @return Xcom_Mapping_Model_Mapper
  */
 protected function _addRequiredCustomAttributes($mappedAttributes, $product)
 {
     $requiredCustomAttributes = $this->_requiredCustomAttributes;
     // except all required custom attributes which were already mapped
     foreach ($mappedAttributes as $attribute) {
         $key = array_search($attribute['attribute_code'], $requiredCustomAttributes);
         if ($key !== false) {
             unset($requiredCustomAttributes[$key]);
         }
     }
     // add all not mapped required custom attributes to options
     foreach ($requiredCustomAttributes as $attributeCode) {
         $value = $product->getAttributeText($attributeCode);
         if (!empty($value)) {
             $this->_options[$attributeCode] = $value;
         }
     }
     return $this;
 }
 /**
  * Pass the Catalog Class value, ensuring to return 'regular' as the default value if no value is set
  * @param  string                              $attrValue
  * @param  string                              $attribute
  * @param  Mage_Catalog_Model_Product          $product
  * @param  DOMDocument         $doc
  * @return DOMNode
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function passCatalogClass($attrValue, $attribute, Mage_Catalog_Model_Product $product, DOMDocument $doc)
 {
     $catalogClass = empty($attrValue) ? 'regular' : strtolower($product->getAttributeText($attribute));
     return $this->passString($catalogClass, $attribute, $product, $doc);
 }