当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Product::getAttributes方法代码示例

本文整理汇总了PHP中Mage_Catalog_Model_Product::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Product::getAttributes方法的具体用法?PHP Mage_Catalog_Model_Product::getAttributes怎么用?PHP Mage_Catalog_Model_Product::getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Catalog_Model_Product的用法示例。


在下文中一共展示了Mage_Catalog_Model_Product::getAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canConfigure

 /**
  * Check if product is configurable
  *
  * @param Mage_Catalog_Model_Product $product
  * @return bool
  */
 public function canConfigure($product = null)
 {
     if (isset($product->getAttributes()['adyen_subscription_type'])) {
         if ($product->getData('adyen_subscription_type') != Adyen_Subscription_Model_Product_Subscription::TYPE_DISABLED) {
             return true;
         }
     }
     return false;
 }
开发者ID:sandermangel,项目名称:adyen-magento-subscription,代码行数:15,代码来源:Simple.php

示例2: testGetAttributes

 public function testGetAttributes()
 {
     // fixture required
     $this->_model->load(1);
     $attributes = $this->_model->getAttributes();
     $this->assertArrayHasKey('name', $attributes);
     $this->assertArrayHasKey('sku', $attributes);
     $this->assertInstanceOf('Mage_Catalog_Model_Resource_Eav_Attribute', $attributes['sku']);
 }
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:9,代码来源:ProductGetters.php

示例3: getProductAttribute

 /**
  * Return Product attribute by attribute's ID
  *
  * @param Mage_Catalog_Model_Product $product
  * @param int $attributeId
  * @return null|Mage_Catalog_Model_Entity_Attribute Product's attribute
  */
 public function getProductAttribute(Mage_Catalog_Model_Product $product, $attributeId)
 {
     if (!isset($this->_productAttributes[$product->getId()])) {
         $attributes = $product->getAttributes();
         foreach ($attributes as $attribute) {
             $this->_productAttributes[$product->getId()][$attribute->getAttributeId()] = $attribute;
         }
     }
     return isset($this->_productAttributes[$product->getId()][$attributeId]) ? $this->_productAttributes[$product->getId()][$attributeId] : null;
 }
开发者ID:shakhawat4g,项目名称:MagentoExtensions,代码行数:17,代码来源:Product.php

示例4: getAttributes

 public function getAttributes($groupId = null, $skipSuper = false)
 {
     $attributes = parent::getAttributes($groupId, $skipSuper);
     foreach ($attributes as $k => $attr) {
         if ($attr->getAttributeCode() == 'downloads_title') {
             unset($attributes[$k]);
             break;
         }
     }
     return $attributes;
 }
开发者ID:commercekitchen,项目名称:dualeyewear-magento,代码行数:11,代码来源:Product.php

示例5: _attributes

 /**
  * @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)
         }
     }
 }
开发者ID:sereban,项目名称:magento-marketo-integration,代码行数:16,代码来源:Product.php

示例6: setProperties

 /**
  * set properties
  */
 public function setProperties()
 {
     if (empty($this->_ignoredProductAttributeCodes)) {
         $ignoredProductAttributeCodes = array("manufacturer", "model");
         $ignoredProperties = explode(",", Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_FILTER_PROPERTIES));
         $ignoredProductAttributeCodes = array_merge($ignoredProductAttributeCodes, $ignoredProperties);
         $this->_ignoredProductAttributeCodes = array_unique($ignoredProductAttributeCodes);
     }
     if (empty($this->_forcedProductAttributeCodes)) {
         $forcedProperties = explode(",", Mage::getStoreConfig(Shopgate_Framework_Model_Config::XML_PATH_SHOPGATE_EXPORT_FORCE_PROPERTY_EXPORT));
         $this->_forcedProductAttributeCodes = array_unique($forcedProperties);
     }
     $result = array();
     $cacheKey = 'product_type_' . $this->item->getTypeId() . '_attributes_' . $this->item->getAttributeSetId();
     $cache = Mage::app()->getCacheInstance();
     $value = $cache->load($cacheKey);
     if ($value !== false) {
         $attributes = unserialize($value);
     } else {
         $attributes = $this->item->getAttributes();
         $attrCache = array();
         foreach ($attributes as $attribute) {
             $code = $attribute->getAttributeCode();
             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
             if ($attribute && $attribute->getIsVisibleOnFront() || in_array($code, $this->_forcedProductAttributeCodes)) {
                 if (in_array($code, $this->_ignoredProductAttributeCodes) && !in_array($code, $this->_forcedProductAttributeCodes)) {
                     continue;
                 }
                 $attrCache[$code] = array('id' => $attribute->getId(), 'label' => $attribute->getStoreLabel($this->_getConfig()->getStoreViewId()));
             }
         }
         $attributes = $attrCache;
         $cache->save(serialize($attrCache), $cacheKey, array('shopgate_export', Mage_Core_Model_Mysql4_Collection_Abstract::CACHE_TAG, Mage_Catalog_Model_Resource_Eav_Attribute::CACHE_TAG), 60);
     }
     foreach ($attributes as $code => $data) {
         $value = $this->item->getResource()->getAttribute($code)->getFrontend()->getValue($this->item);
         if (!empty($value) && !is_array($value)) {
             $propertyItemObject = new Shopgate_Model_Catalog_Property();
             $propertyItemObject->setUid($data['id']);
             $propertyItemObject->setLabel($data['label']);
             $propertyItemObject->setValue($value);
             $result[] = $propertyItemObject;
         }
     }
     parent::setProperties($result);
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:49,代码来源:Xml.php

示例7: getProductSubscription

 /**
  * Retrieve product subscription, if product is a subscription, else false
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Adyen_Subscription_Model_Product_Subscription|false
  */
 public function getProductSubscription($product)
 {
     if (isset($product->getAttributes()['adyen_subscription_type'])) {
         if ($product->getData('adyen_subscription_type') != Adyen_Subscription_Model_Product_Subscription::TYPE_DISABLED) {
             $option = $product->getCustomOption('additional_options');
             if ($option) {
                 $additionalOptions = unserialize($option->getValue());
                 foreach ($additionalOptions as $additional) {
                     if ($additional['code'] == 'adyen_subscription') {
                         if ($additional['option_value'] != 'none') {
                             $subscription = Mage::getModel('adyen_subscription/product_subscription')->load($additional['option_value']);
                             if (!$subscription->getId()) {
                                 return false;
                             }
                             return $subscription;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:Adyen,项目名称:adyen-magento-subscription,代码行数:29,代码来源:Quote.php

示例8: _getProductProperties

 /**
  * Fetches attributes for properties column and filters by ignored attributes.
  *
  * @param Mage_Catalog_Model_Product $product
  * @param                            $ignoredProductAttributeCodes
  * @param array                      $forcedProductAttributeCodes
  *
  * @return array
  */
 protected function _getProductProperties($product, $ignoredProductAttributeCodes, $forcedProductAttributeCodes = array())
 {
     $properties = array();
     $cacheKey = 'product_type_' . $product->getTypeId() . '_attributes_' . $product->getAttributeSetId();
     $cache = Mage::app()->getCacheInstance();
     $value = $cache->load($cacheKey);
     if ($value !== false) {
         $attributes = unserialize($value);
     } else {
         $attributes = $product->getAttributes();
         $attrCache = array();
         foreach ($attributes as $attribute) {
             $code = $attribute->getAttributeCode();
             $isFilterable = Mage::getStoreConfigFlag('shopgate/export/filterable_attributes') ? $attribute->getIsFilterable() : false;
             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
             if ($attribute && ($attribute->getIsVisibleOnFront() || $isFilterable || in_array($code, $forcedProductAttributeCodes))) {
                 if (in_array($code, $ignoredProductAttributeCodes) && !in_array($code, $forcedProductAttributeCodes)) {
                     continue;
                 }
                 $attrCache[$code] = array('id' => $attribute->getId(), 'label' => $attribute->getStoreLabel($this->_getConfig()->getStoreViewId()));
             }
         }
         $attributes = $attrCache;
         $cache->save(serialize($attrCache), $cacheKey, array('shopgate_export', Mage_Core_Model_Mysql4_Collection_Abstract::CACHE_TAG, Mage_Catalog_Model_Resource_Eav_Attribute::CACHE_TAG), 3600);
     }
     foreach ($attributes as $code => $data) {
         $value = $product->getResource()->getAttribute($code)->getFrontend()->getValue($product);
         if ($value) {
             $properties[$code] = "{$data['label']}=>{$value}";
         }
     }
     return $properties;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:42,代码来源:Product.php

示例9: _getMageImageViewMap

 /**
  * Searches for all media_image type attributes for this product's attribute set, and creates a hash matching
  * the attribute code to its value, which is a media path. The attribute code is used as the
  * image 'view', and we use array_search to match based on media path.
  * @param Mage_Catalog_Model_Product $mageProduct
  * @return array of view_names => image_paths
  */
 protected function _getMageImageViewMap(Mage_Catalog_Model_Product $mageProduct)
 {
     $attributes = $mageProduct->getAttributes();
     return array_reduce(array_keys($attributes), function ($result = [], $key) use($attributes, $mageProduct) {
         if (!strcmp($attributes[$key]->getFrontendInput(), EbayEnterprise_ProductImageExport_Model_Image_Export::FRONTEND_INPUT)) {
             $result[$key] = $mageProduct->getData($key);
         }
         return $result;
     });
 }
开发者ID:sirishreddyg,项目名称:magento-retail-order-management,代码行数:17,代码来源:Export.php

示例10: checkProductAttributesRequired

 protected function checkProductAttributesRequired(Mage_Catalog_Model_Product $product)
 {
     $haystack = $product->getAttributes();
     $target = array(Lema21_Nfe_Model_TransformToXML::ATTR_CODIGO_NCM, Lema21_Nfe_Model_TransformToXML::ATTR_CODIGO_ORIGEM, Lema21_Nfe_Model_TransformToXML::ATTR_OPERATION_NAME, Lema21_Nfe_Model_TransformToXML::ATTR_OPERATION_UNIT);
     if (count(array_intersect($haystack, $target)) == count($target)) {
         return true;
     }
     return false;
 }
开发者ID:robsonximenes,项目名称:magento-nfe-bling,代码行数:9,代码来源:TransformToXML.php

示例11: catalogProductLoadAfter

 /**
  * Catalog product initialize after loading
  *
  * @param Mage_Catalog_Model_Product $model
  * @return void
  */
 public function catalogProductLoadAfter($model)
 {
     if (!$model->getId()) {
         return;
     }
     if (!$this->_role->hasWebsiteAccess($model->getWebsiteIds())) {
         $this->_throwLoad();
     }
     //var_dump($this->_role->hasExclusiveAccess($model->getWebsiteIds()));
     //echo "|";
     if (!$this->_role->hasExclusiveAccess($model->getWebsiteIds())) {
         //echo "here?";
         $model->unlockAttributes();
         $attributes = $model->getAttributes();
         foreach ($attributes as $attribute) {
             /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */
             if ($attribute->isScopeGlobal() || $attribute->isScopeWebsite() && count($this->_role->getWebsiteIds()) == 0 || !in_array($model->getStore()->getId(), $this->_role->getStoreIds())) {
                 $model->lockAttribute($attribute->getAttributeCode());
             }
         }
         $model->setInventoryReadonly(true);
         $model->setRelatedReadonly(true);
         $model->setCrosssellReadonly(true);
         $model->setUpsellReadonly(true);
         $model->setWebsitesReadonly(true);
         $model->lockAttribute('website_ids');
         $model->setOptionsReadonly(true);
         $model->setCompositeReadonly(true);
         if (!in_array($model->getStore()->getId(), $this->_role->getStoreIds())) {
             $model->setAttributesConfigurationReadonly(true);
         }
         $model->setDownloadableReadonly(true);
         $model->setGiftCardReadonly(true);
         $model->setIsDeleteable(false);
         $model->setIsDuplicable(false);
         $model->unlockAttribute('category_ids');
         foreach ($model->getCategoryCollection() as $category) {
             $path = implode("/", array_reverse($category->getPathIds()));
             if (!$this->_role->hasExclusiveCategoryAccess($path)) {
                 $model->setCategoriesReadonly(true);
                 $model->lockAttribute('category_ids');
                 break;
             }
         }
         if (!$this->_role->hasStoreAccess($model->getStoreIds())) {
             $model->setIsReadonly(true);
         }
     } else {
         /*
          * We should check here amount of websites to which admin user assigned
          * and not to those product itself. So if admin user assigned
          * only to one website we will disable ability to unassign product
          * from this one website
          */
         if (count($this->_role->getWebsiteIds()) == 1) {
             $model->setWebsitesReadonly(true);
             $model->lockAttribute('website_ids');
         }
     }
 }
开发者ID:beejhuff,项目名称:magento-1.13.0.2,代码行数:66,代码来源:Models.php

示例12: productAttribute

 /**
  * Prepare product attribute html output
  *
  * @param   Mage_Catalog_Model_Product $product
  * @param   string $attributeHtml
  * @param   string $attributeName
  * @return  string
  */
 public function productAttribute($product, $attributeHtml, $attributeName)
 {
     $attributes = $product->getAttributes();
     $attribute = isset($attributes[$attributeName]) ? $attributes[$attributeName] : null;
     if ($attribute && $attribute->getFrontendInput() != 'media_image' && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled())) {
         $attributeHtml = $this->htmlEscape($attributeHtml);
     }
     $attributeHtml = $this->process('productAttribute', $attributeHtml, array('product' => $product, 'attribute' => $attributeName));
     return $attributeHtml;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:18,代码来源:Output.php

示例13: amendAttributeTags

 /**
  * 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_value = $this->getAttributeValue($product, $key);
                     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);
                 }
             }
         }
     }
 }
开发者ID:nosto,项目名称:nosto-magento-extension,代码行数:33,代码来源:Product.php

示例14: _getAdditionalData

 /**
  * Retrieve the attributes which are visible on the checkout page
  *
  * @param Mage_Catalog_Model_Product $product
  * @return array
  */
 protected function _getAdditionalData(Mage_Catalog_Model_Product $product)
 {
     $data = array();
     $attributes = $product->getAttributes();
     foreach ($attributes as $attribute) {
         if ($attribute->getIsVisibleOnCheckout()) {
             $value = $attribute->getFrontend()->getValue($product);
             if (!$product->hasData($attribute->getAttributeCode()) || (string) $value == '') {
                 $value = '';
             } elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
                 $value = Mage::app()->getStore()->convertPrice($value, true);
             }
             if (is_string($value) && strlen($value)) {
                 $data[$attribute->getAttributeCode()] = array('label' => $attribute->getStoreLabel(), 'value' => $value, 'print_value' => $value, 'code' => $attribute->getAttributeCode());
             }
         }
     }
     return $data;
 }
开发者ID:nhp,项目名称:firegento-germansetup,代码行数:25,代码来源:Configuration.php

示例15: _unsetValues

 /**
  * Set value of not changed attributes to false to prevents from copying
  * attribute's values to current scope if user selected Current store
  * option of Save edits to setting in admin interface
  *
  * Filter out following attributes:
  * - Gallery attr (is a complex attr with it's own editor)
  * - Global (setting value of global attr to false removes it globally)
  * - Non-visible (non-visible attributes can't be edited directly)
  * - Without input field (this attributes can'be edited directly)
  *
  * Filtering rules are taken from:
  * - Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes::_prepareForm()
  * - Mage_Adminhtml_Block_Widget_Form::_setFieldset()
  *
  * @param Mage_Catalog_Model_Product $product Product
  * @param array $changed Key-based list of updated attributes
  * @param array $globalData Global values
  */
 protected function _unsetValues($product, $changed, $globalData)
 {
     foreach ($product->getAttributes() as $code => $attr) {
         if (isset($changed[$code])) {
             continue;
         }
         // We need to find out if an attribute has a per-store value that
         // is different than the global value. If so, do Not mark the
         // field as 'use default'.
         // Global default is store_id==0
         if (isset($globalData[$code])) {
             if ($globalData[$code] != $product->getData($code)) {
                 continue;
             }
         }
         $allow = $code != 'gallery' && $attr->getIsGlobal() != Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL && $attr->getIsVisible() && $attr->getFrontend()->getInputType();
         if (!$allow) {
             continue;
         }
         $product->setData($code, false)->setOrigData($code, false);
     }
 }
开发者ID:hughwilkie,项目名称:MVentory_Productivity,代码行数:41,代码来源:ProductController.php


注:本文中的Mage_Catalog_Model_Product::getAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。