How to View Single Product URL Product ID via in Magento?

Hi below code for single product url. When you pass the query string in your url. You can use below code for single product url. Or you can put product id also here working fine.
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper(‘catalog/output’);

//Jai Write Below Code for Product id via getting Product URL Start

//redirect to old Product
if(isset($_GET[‘product_id’])){
$product_id = $_GET[‘product_id’];

$cProduct = Mage::getModel(“catalog/product”);
$cProduct->load($product_id);
//echo $cProduct->getImageUrl().”<br />”;
$currentProductURL = $cProduct->getProductUrl();
//echo $currentProductURL.”<br />”;

echo “<script type=’text/javascript’ language=’javascript’>window. location='”.$currentProductURL.”‘;</script>”;

}
//Jai Write Below Code for Product id via getting Product URL Start
?>

I have small knowledge in magento. So, I more then 3 hours spent for this code getting. If anyone find this post. This is useful for you.

thanks.

How to View Magneto SKU Number in Cart & Page View?

1. You Want cart page to view the SKU number :
You can use below code in your : app/design/frontend/youtheme/yourtheme/template/checkout/cart.phtml
<?php echo $this->__(‘SKU Number’) ?>

And add item section this : app/design/frontend/youtheme/yourtheme/template/checkout/cart/item/default.phtml
<?php echo $_item->getSku() ?>

2. You want to view the Page View :

app/design/frontend/youtheme/yourtheme/template/catalog/product/view.phtml
<!– Write SKU –>
<?php echo $this->__(‘SKU Number :’); ?> <?php
$sku = Mage::getModel(‘catalog/product’)->load($_product->getId())->getSku();
echo $sku; ?>
<!– Sku End –>

its is working for my side.

How to get Current Page URL in via PHP?

<?php
function curPageURL() {
$pageURL = ‘http’;
if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER[“SERVER_PORT”] != “80”) {
$pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”];
} else {
$pageURL .= $_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI”];
}
return $pageURL;
}

$url =  curPageURL();

//print_r(parse_url($url));

$URLpath = parse_url($url, PHP_URL_PATH);

$langPathAraay = explode(“/”, $URLpath);
$langPath = $langPathAraay[1];
//echo $langPath;

if($langPath == ‘agd_nl’){
//echo “here”;
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(108)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agd_be”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(98)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agd_befr”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(98)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agb_de”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(105)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agb_fr”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(106)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agb_gb”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(107)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else{
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(108)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
?>

How to Reduce Magento Resize Product Image Size?

<?php
$_helper = $this->helper('catalog/output');
$productId = $this->getProduct_id();
$_product = Mage::getModel('catalog/product')->load($productId);  //load the product
$_img = '<a id="a_image" href="'.$_product->getProductUrl().'" title="">
<img id="image".src="'.$this->helper('catalog/image')->
init($_product, 'image')->constrainOnly(TRUE)->
keepAspectRatio(TRUE)->resize(176,251).'" alt="'.$this->
htmlEscape($this->getImageLabel()).'" title="'.
$this->htmlEscape($this->getImageLabel()).'"/></a>';
echo $_helper->productAttribute($_product, $_img, 'image');
?>

How to view Particular Category List in Home Page from Magento?

Go to Magento Cms Page Inside, Put Blow Code then view in your page :
{{block type=”catalog/product_list” category_id=”98″ template=”catalog/product/list.phtml”}}

(OR)

Open in your Magento theme page layout, There you can past below code

<?php     echo $this->getLayout()->createBlock(‘catalog/product_list’)->setCategoryId(98)->setTemplate(‘catalog/product/list.phtml’)->toHtml()     ?>

(OR)

Open Magento Static Block, Create Magento New Static Block, Then Past Below Code :

{{block type=”catalog/product_list” category_id=”98″ template=”catalog/product/list.phtml”}}

Once you placed above code in Magento Staic block inside, You can write below code in your Magento .phtml file inside,

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId(IDENTIFIER)->toHtml() ?>

Here you change "IDENTIFIER" in your Magento Static Block identified number.
Now you refresh your site will show your custom Magento Style Theme.

Thanks,
J.
echo $this->getLayout()->createBlock('catalog/product_list')->setCategoryId(10)->setTemplate('catalog/product/list.phtml')->toHtml()
© 2020 Spirituality