2

i want to show custom url parameter in page created via module

what is did i created a module to show page with custom page

issue is how to pass and show parameter in url like product id of parent product

With my module i am able to open url with dummy content: like below

abc.com/related

i want to pass and show parameters like

abc.com/releted/productid/11

Below is code of my module MY_Related

1: app\code\local\MY\Related\Block\Index.php

<?php 
class MY_Related_Block_Index extends Mage_Core_Block_Template{ 
}

2: app\code\local\MY\Related\controllers\IndexController.php

<?php
class MY_Related_IndexController extends Mage_Core_Controller_Front_Action{
 public function IndexAction() {
 $this->loadLayout(); 
 $this->getLayout()->getBlock("head")->setTitle($this->__("Titlename"));
 $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
 $breadcrumbs->addCrumb("home", array(
 "label" => $this->__("Home Page"),
 "title" => $this->__("Home Page"),
 "link" => Mage::getBaseUrl()
 ));
 $breadcrumbs->addCrumb("titlename", array(
 "label" => $this->__("Titlename"),
 "title" => $this->__("Titlename")
 ));
 $this->renderLayout(); 
 }
}

3: app\code\local\MY\Related\etc\config.xml

<?xml version="1.0"?>
<config>
 <modules>
 <MY_Related>
 <version>0.1.0</version>
 </MY_Related>
 </modules>
 <frontend>
 <routers>
 <related>
 <use>standard</use>
 <args>
 <module>MY_Related</module>
 <frontName>related</frontName>
 </args>
 </related>
 </routers>
 <layout>
 <updates>
 <related>
 <file>related.xml</file>
 </related>
 </updates>
 </layout>
 </frontend>
 <global>
 <helpers>
 <related>
 <class>MY_Related_Helper</class>
 </related>
 </helpers>
 <blocks>
 <related>
 <class>MY_Related_Block</class>
 </related>
 </blocks>
 </global>
</config> 

4: app\code\local\MY\Related\Helper\Data.php

<?php
class MY_Related_Helper_Data extends Mage_Core_Helper_Abstract
{
}
asked Jun 14, 2016 at 12:19

2 Answers 2

4

try related/index/index/product/11. Then you should be able to read the product param like this:

$product = Mage::app()->getRequest()->getParam('product');
answered Jun 14, 2016 at 12:41
3
  • what to do if i do not need double index/index Commented Jun 14, 2016 at 12:42
  • then you need to create a custom router. take a look at this and try to adapt the answer to your needs. Commented Jun 14, 2016 at 12:44
  • can you help how can it be fixed using router Commented Jun 14, 2016 at 12:47
1

To get all the parameters from the url related/index/index/product/11/id/4 then you can use this:

$product = Mage::app()->getRequest()->getParams();
sv3n
11.7k7 gold badges44 silver badges75 bronze badges
answered Aug 31, 2017 at 6:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.