cancel
Showing results for 
Search instead for 
Did you mean: 

Create view page for my custom customet module

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Create view page for my custom customet module

<?php
function getcustomers() {
	/* Magento's Mage.php path 
	 * Mage Enabler users may skip these lines
	 */
	require_once ("app/Mage.php");
	umask(0);
	Mage::app("default");
	/* Magento's Mage.php path */
	
	
	
	if ( isset( $_GET['sub'] ) )  // check form submit or not
 { 
	$company =  ucwords($_GET['company']);
	$title =  ucwords($_GET['title']);
	$locaton =  ucwords($_GET['location']);
	$industry =  ucwords($_GET['industry']);
	$name =  ucwords($_GET['name']);

	
 
}
	
   //$variableFirstName = "Guangxi" ;	
   
	/* Get customer model, run a query */
	$collection = Mage::getModel('customer/customer')
				  ->getCollection()
				  ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
                ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
                ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
                ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
                ->joinAttribute('billing_fax', 'customer_address/fax', 'default_billing', null, 'left')
                ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
                ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')

                ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
                ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
                ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
                ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
                ->joinAttribute('shipping_fax', 'customer_address/fax', 'default_shipping', null, 'left')
                ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
                ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left')
                		->addAttributeToSelect('firstname','billing_country_code','billing_city','billing_telephone','entity_id')
				->addAttributeToFilter('firstname', array('like' => '%'.$company.'%')) 
				->addAttributeToFilter('billing_country_code', array('like' => '%'.$locaton.'%')) 
				->addAttributeToFilter('billing_city', array('like' => '%'.$industry.'%')); 
				  
			
	
	$result = array();
	foreach ($collection as $customer) {
		$result[] = $customer->toArray();
	}
	
	return $result;
}
?>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>

<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">

<!-- jQuery library -->


<!-- Latest compiled JavaScript -->

<title>Company Directory</title>
</head>
<body>

<div> 
<?php  //echo
$this->getLayout()->createBlock('catalogsearch/advanced_form')->setTemplate('catalogsearch/advanced/form.phtml')->toHtml() 
?>
</div>

<div class="table-responsive">
 <div class="col-lg-12">  
	<br>
	<form class="form-inline" action="" method="get" role="search">
		<div class="form-group form-group-lg">
		<input type="text" name="company" class="form-control" placeholder="Search for the company...." value="<?php echo $_GET['company'] ?>">
		</div>
				
		<div class="form-group form-group-lg">
		<input type="text" name="location" class="form-control" placeholder="Search for the country code...." value="<?php echo $_GET['location'] ?>">
		</div>
		
		<div class="form-group form-group-lg">		
		<input type="text" name="industry" class="form-control" placeholder="Search for the city...." value="<?php echo $_GET['industry'] ?>">
		</div>
		
		
				<div class="form-group form-group-lg">		
				<input type="submit" name="sub" class="form-control" value="search">
</div>

			
	</form>
</div>
<div style="clear:both;margin-bottom: 35px;"></div>
 <div class="container">
    <div class="row">
        
        <div id="no-more-tables">
            <table class="col-md-12 table-bordered table-striped table-condensed cf">
        		<thead class="cf">
        			<tr>
					<td>Comapny Name</td>
					<td>Telephone</td>
					<td>Country</td>
					<td>City</td>
					<td>Details</td>
				    </tr>
        		</thead>
<tbody>
<?php
$result = getcustomers();

//print_r($result);

//if(count($result) > 0){
if ( isset( $_GET['sub'] ) ) {
	foreach($result as $key => $value){
		echo "<tr>";
			echo "<td>".$value['firstname']."</td>";
			echo "<td>".$value['billing_telephone']."</td>";
			echo "<td>".$value['shipping_country_code']."</td>";
			echo "<td>".$value['billing_city']."</td>"; 
			echo "<td><a href='costomar_details.phtml?id=".$value['entity_id']."'>Show</a></td>";



		echo "</tr>";
	}
}else{
	echo "<tr><td colspan=\"7\">No records found</td></tr>";
}
?>
<tbody>
</table>
<?php echo $this->getPagerHtml(); ?>
<nav>
  <ul class="pagination">
    <li>
      <a href="#" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    <li><a href="#">1</a></li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">4</a></li>
    <li><a href="#">5</a></li>
	<li><a href="#">....</a></li>
	<li><a href="#">50125</a></li>
    <li>
      <a href="#" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>
</nav>
</div>
</div>

</div> 

<style>
.custom{
    -webkit-border-radius: 0px !important;
    -moz-border-radius: 0px !important;
    border-radius: 0px !important;
}
<style>
@media only screen and (max-width: 800px) {
    
    /* Force table to not be like tables anymore */
	#no-more-tables table, 
	#no-more-tables thead, 
	#no-more-tables tbody, 
	#no-more-tables th, 
	#no-more-tables td, 
	#no-more-tables tr { 
		display: block; 
	}
 
	/* Hide table headers (but not display: none;, for accessibility) */
	#no-more-tables thead tr { 
		position: absolute;
		top: -9999px;
		left: -9999px;
	}
 
	#no-more-tables tr { border: 1px solid #ccc; }
 
	#no-more-tables td { 
		/* Behave  like a "row" */
		border: none;
		border-bottom: 1px solid #eee; 
		position: relative;
		padding-left: 50%; 
		white-space: normal;
		text-align:left;
	}
 
	#no-more-tables td:before { 
		/* Now like a table header */
		position: absolute;
		/* Top/left values mimic padding */
		top: 6px;
		left: 6px;
		width: 45%; 
		padding-right: 10px; 
		white-space: nowrap;
		text-align:left;
		font-weight: bold;
	}
 
	/*
	Label the data
	*/
	#no-more-tables td:before { content: attr(data-title); }
	
	
}
thead.cf {
    background: #41a52b;
    color: #fff;
    font-size: 16px;
}
ul { margin-bottom:0;}



</style>
</body>
</html>
echo "<td><a href='costomar_details.phtml?id=".$value['entity_id']."'>Show</a></td>";


Here getting the error 404 how to create the view page ... Please its urgent... 

5 REPLIES 5

Re: Create view page for my custom customet module

Hi @uttamgoigi

 

Can you specify what exactly you are looking? And what exactly the problem you are having? What do you mean by custom view page?

If you can elaborate, I can help you better.

Was my answer helpful? You can accept it as a solution.
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer

Re: Create view page for my custom customet module

Hi,

Thanks for your replay .

 

Here is the page I created  for customer search module but when I create the details view page its showing error 404.

 

http://dietaryglobal.com/index.php/directory/?company=Deep&location=&industry=&sub=search

 

I want a page where details customer details show.

 

You can check my total code previous post.

 

Thanks

 

 

Re: Create view page for my custom customet module

Hi,

Please check the issue its urgent.

 

And I have add pagination like product advanced search in this module ..

 

 

Thanks

Re: Create view page for my custom customet module

hello Httamgoigi,

 

 

you can not directly write phtml name in href like

<a href='costomar_details.phtml?id=".$value['entity_id']."'>Show</a>

insted of that given controller name/actioname then it's working for you.

for ex. echo <a href='<?php echo $this->getUrl('custommodulename/searchactionaname')>id=".$value['entity_id']."'>Show</a>

 

 

 

Re: Create view page for my custom customet module

You will need to give the proper URL path from which the file "costomar_details.phtml" is called. Means you get this path from the XML file. Just pass that path and parameter. Generally the path format is something like this : extensionname/controllername/actionname

Was my answer helpful? You can accept it as a solution.
200+ Premium Magento 2 Extensions Need help? Hire Magento Developer