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


PHP Varien_Data_Collection_Db::addExpressionAttributeToSelect方法代码示例

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


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

示例1: addCustomAttributes

 /**
  * Add custom attributes selected by magento admin to query
  *
  * @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
  * @param string $customAttribs Comma separated list of attribute codes
  * @param array $fieldMap Reference to fieldmap where attribute codes should also be added
  */
 protected function addCustomAttributes($collection, $customAttribs, &$fieldMap)
 {
     // Log
     Mage::helper('mybuys')->log("Adding custom attributes include in query: {$customAttribs}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
     // Check if we have any custom attribs
     if (strlen(trim($customAttribs)) > 0) {
         // Iterate custom attribs
         foreach (explode(',', $customAttribs) as $curAttrib) {
             // Trim attribute code
             $curAttrib = trim($curAttrib);
             // Check if attribute exists
             $_attribute = $collection->getAttribute($curAttrib);
             if ($_attribute === false) {
                 // Attribute not found
                 Mage::throwException("Attribte not found: {$curAttrib}");
             }
             // Log
             Mage::helper('mybuys')->log("Adding attribute to query: {$curAttrib}", Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
             if ($_attribute->getFrontendInput() == "select" || $_attribute->getFrontendInput() == "multiselect") {
                 // attribute is a select of multi-select input and attribute id to value translation is needed
                 // Log
                 Mage::helper('mybuys')->log("Note - Attribute needs translation", Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
                 $this->_optionValueMap['custom_' . $curAttrib] = true;
             }
             // Add attribute to select
             $collection->addExpressionAttributeToSelect('custom_' . $curAttrib, "{{" . $curAttrib . "}}", $curAttrib)->addAttributeToSelect($curAttrib);
             // Add attribute to map
             $fieldMap['custom_' . $curAttrib] = 'custom_' . $curAttrib;
         }
     }
     // Return the original collection object
     return $collection;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:40,代码来源:Base.php


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