3

I am trying to create a custom page that will show in the customers My Dashboard area. The page will be similar to the My Orders page however it will show different information. On the website we list and sell items on other peoples behalf so I want this page to show which of their items are for sale. This is not a marketplace website as such. My thoughts were that if I added an attribute to each product that had a customer id entered into it I could pull all of the product info into this page based on the customer id.

I have basic skills in modifying Magento to the way I need it however this is more technical than anything I have attempted before. I am not sure where to start and was hoping some of the experts on here could point me in the right direction or even if what I am trying to achieve is possible.

4

Give this a try:

local.xml - sits in your layout folder:

<?xml version="1.0"?>
<layout version="0.1.0">
<!--Add a link to navigation-->
<customer_account>
    <reference name="customer_account_navigation" >
        <action method="addLink"><name>plink</name><path>customer/plink</path><label>plink</label></action>
    </reference>
</customer_account>
<!--Add a link to navigation-->
<!--controller action-->
<customer_plink_index translate="label">
    <label>Customer Plink Dashboard</label>
    <update handle="customer_account"/>
    <reference name="root">
        <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
    </reference>
    <reference name="my.account.wrapper">
        <block type="customer/account_dashboard" name="customer_account_dashboard" template="customer/account/dashboard.phtml">
            <block type="customer/account/dashboard_plink" name="plink" template="customer/account/dashboard/plink.phtml"/>
        </block>
    </reference>
</customer_plink_index>


Create a controller, e.g. app/code/local/Mage/Customer/controllers/PlinkController.php:

<?php
class Mage_Customer_PlinkController extends    Mage_Core_Controller_Front_Action
{
    public function indexAction()
{
    $this->loadLayout();
    $this->_initLayoutMessages('customer/session');
    $this->_initLayoutMessages('catalog/session');

    $this->getLayout()->getBlock('content')->append(
        $this->getLayout()->createBlock('dashboard_plink')
    );
    $this->getLayout()->getBlock('head')->setTitle($this->__('plink'));
    $this->renderLayout();
}


}    

Create a template, e.g. plink.phtml in frontend\base\theme\package\customer\account\dashboard\plink.phtml:

<div class="welcome-msg">
<?php echo Mage::getSingleton('customer/session')->getCustomerId();?>
<?php echo Mage::helper('customer')->getCustomerName(); ?>

/*put your logic here*/

</div>

Put the code below into the dashboard template - app\design\theme\package\default\template\customer\account\dashboard.phtml, inside the wrapper with class="box-account box-info":

<?php echo $this->getChildHtml('plink') ?>

Screenshot of custom tab

  • if you need further help let me know.. – Pawan Oct 3 '16 at 10:01
  • Hi @pawan kumar parmar and Robbie, thank you so much for the guidance. I have managed to add the link and show the page. I had to put the xml code into customer.xml, I think this was due to the template I am using. Now I need to pull the information into the page. I have a background in MS Access and am wondering whether I can create a query using the database tables to put this information together, is this possible? – Mage17 Oct 6 '16 at 9:49
  • What I want to do is add an attribute to each product that contains the customer id. When a customer goes to the "plink" page it will show all of the products that have their id as an attribute. Is this possible? – Mage17 Oct 6 '16 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.