本文整理汇总了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;
}