Ric*_*ins 2 wordpress magento fishpig
我有Magento和Fishpig_Wordpress模块.我为帖子创建了一些新的postmeta数据,这些数据保存在postmeta表中.我刚看到Fishpig在/Model/Mysql4/Post.php中有一个自定义加载SQL方法..
protected function _getLoadSelect($field, $value, $object)
{
$select = $this->_getReadAdapter()->select()
->from(array('e' => $this->getMainTable()))
->where("e.{$field}=?", $value);
if (Mage::getDesign()->getArea() == 'frontend') {
if (Mage::helper('wordpress/plugin_allInOneSeo')->isEnabled()) {
foreach(Mage::helper('wordpress/plugin_allInOneSeo')->getMetaFields() as $field) {
$table = 'aioseop_'.$field;
$select->joinLeft(
array($table => Mage::helper('wordpress/db')->getTableName('postmeta')),
"{$table}.post_id = e.ID AND ".$this->_getReadAdapter()->quoteInto("{$table}.meta_key=?", "_aioseop_{$field}"),
array('meta_'.$field => 'meta_value')
);
}
}
}
$select->limit(1);
return $select;
}
Run Code Online (Sandbox Code Playgroud)
它在joinLeft方法中使用Mage :: helper('wordpress/db') - > getTableName('postmeta').但我不知道如何使用_getLoadSelect保护方法或创建另一个类来调用postmeta表.
所以,问题是: 有没有办法从Fishmeix模块的postmeta表中获取数据,或者我需要为此创建一个新类?
对于现在阅读此内容的任何人,您可以使用以下代码检索postmeta值:
<?php echo $post->getMetaValue('your_meta_key') ?>
Run Code Online (Sandbox Code Playgroud)
这个方法可以用于任何具有元表的帖子(帖子,页面,评论,用户等)的WordPress实体
| 归档时间: |
|
| 查看次数: |
4161 次 |
| 最近记录: |