I haven't created a Magento module before and after a lot of research I attempted to create a module to insert wordpress avatars into blog posts inside Magento (I am using Fishpig).
Below I will list my folder structure and what I have in my files but I can't seem to get my custom module to work!
JUST TO NOTE: I am trying to extend "Fishpig_Wordpress_Model_User"
app/code/local/Splitpixel/Avatar/Fishpig/Wordpress/Model/User.php app/code/local/Splitpixel/Avatar/etc/config.xml
app/etc/modules/Splitpixel_Avatar.xml
My Splitpixel_Avatar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Splitpixel_Avatar>
<!-- Whether our module is active: true or false -->
<active>true</active>
<!-- Which code pool to use: core, community or local -->
<codePool>local</codePool>
</Splitpixel_Avatar>
</modules>
</config>
My config.xml:
> <?xml version="1.0" encoding="UTF-8"?> <config>
> <modules>
> <Splitpixel_Avatar>
> <version>0.0.1</version>
> </Splitpixel_Avatar>
> </modules>
> <global>
> <models>
> <fishpig>
> <wordpress>
> <rewrite>
> <user>Splitpixel_Avatar_Fishpig_Wordpress_Model_User</user>
> </rewrite>
> </wordpress>
> </fishpig>
> </models>
> </global> </config>
My app/code/local/Splitpixel/Avatar/Fishpig/Wordpress/Model/User.php:
> <?php
>
> class Splitpixel_Avatar_Fishpig_Wordpress_Model_User extends
> Fishpig_Wordpress_Model_User {
> public function getUserAvatar(){
> $imageSource = “”;
> $avatarPostId = $this->getMetaValue(‘wp_user_avatar’);
> $collection = Mage::getResourceModel(‘wordpress/post_collection’)->addPostTypeFilter(‘attachment’)->addFieldToFilter(‘ID’, $avatarPostId);
> foreach($collection as $post){
> if ($post->getId() == $avatarPostId){
> $imageSource = $post->getData(‘guid’);
> return $imageSource;
> }
> }
> return $imageSource;
> } }
>
> ?>
And then finally I am trying to use the new function in "template/wordpress/post/meta.phtml" by using the following code:
> ### WORKING CODE TO GET AUTHOR NAME ###
> $post->getAuthor()->getDisplayName()
>
> ### MY CODE THAT DOESN'T WORK ###
> $post->getAuthor()->getUserAvatar()
The code pulls back nothing! Now it may be my code, but the most likely factor is that I have dome something wrong in my config.xml or folder sructure as this is all new to me!
Any help is REALLY appreciated, thanks!
EDIT: Posted same time as patch drop so got missed by most!