tag:blogger.com,1999:blog-20424082265193129632024-02-22T09:37:49.237-08:00PHP CoderMagento, OpenCart, Joomla, wordpress, PHPBB, Core PHP, jQuery, Javascript professional elancer.PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.comBlogger303125tag:blogger.com,1999:blog-2042408226519312963.post-81445236684934897002017-11-04T05:56:00.004-07:002017-11-04T05:56:49.797-07:00How to Rewrite / Override block in magento<div dir="ltr" style="text-align: left;" trbidi="on">
How to Rewrite / Override block in magento<br />
<br />
Here we are Overriding / Rewriting magento block of Mage_Catalog_Block_Product_View with custom module named Chand_Software.<br />
<br />
(1) Create module file in app/etc/modules/Chand_Software.xml<br />
<br />
<?xml version="1.0"?><br />
<config><br />
<modules><br />
<Chand_Software><br />
<active>true</active><br />
<codePool>local</codePool><br />
</Chand_Software><br />
</modules><br />
</config><br />
<br />
(2) Create module config file in app/code/local/Chand/Software/etc/config.xml<br />
<br />
<?xml version="1.0"?><br />
<config><br />
<modules><br />
<Chand_Software><br />
<version>1.0.0</version><br />
</Chand_Software><br />
</modules><br />
<global><br />
<blocks><br />
<catalog> // This is the block identifier which we want rewrite<br />
<rewrite><br />
<product_view>Chand_Software_Block_Product_View</product_view><br />
</rewrite><br />
</catalog><br />
</blocks><br />
</global><br />
</config><br />
<br />
(3) Now Create block file of our custom module in app/code/local/Chand/Software/Block/Product/View.php<br />
<br />
class Chand_Software_Block_Product_View extends Mage_Catalog_Block_Product_View<br />
{<br />
/**<br />
* Put your logic here<br />
*<br />
*/<br />
}</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com1tag:blogger.com,1999:blog-2042408226519312963.post-21643673580142274132017-11-04T05:56:00.000-07:002017-11-04T05:56:06.359-07:00How to add css in only product type simple in magento<div dir="ltr" style="text-align: left;" trbidi="on">
How to add css in only product type simple in magento<br />
<br />
First
to create local.xml file at this path
app/design/frontend/yourpackage/default/layout/local.xml and paste below
code in local.xml<br />
<br />
<?xml version="1.0"?><br />
<br />
<layout version="0.1.0"><br />
<br />
<PRODUCT_TYPE_simple><br />
<br />
<reference name="head"><br />
<br />
<action method="addCss"><stylesheet>css/your_simple.css</stylesheet></action><br />
<br />
</reference><br />
<br />
</PRODUCT_TYPE_simple><br />
<br />
</layout><br />
<br />
Handle of different product types :<br />
<br />
<PRODUCT_TYPE_simple><br />
<PRODUCT_TYPE_configurable><br />
<PRODUCT_TYPE_grouped><br />
<PRODUCT_TYPE_virtual><br />
<PRODUCT_TYPE_downloadable><br />
<PRODUCT_TYPE_bundle></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-20045735793924854112017-11-04T05:54:00.002-07:002017-11-04T05:54:24.369-07:00How to make timer that not reset when page refresh javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<form name="counter"><br />
<input type="text" size="8" name="jimmy" id="counter"><br />
</form><br />
<br />
<script type="text/javascript"><br />
function getCookie(cname) {<br />
var name = cname + "=";<br />
var decodedCookie = decodeURIComponent(document.cookie);<br />
var ca = decodedCookie.split(';');<br />
for(var i = 0; i <ca.length; i++) {<br />
var c = ca[i];<br />
while (c.charAt(0) == ' ') {<br />
c = c.substring(1);<br />
}<br />
if (c.indexOf(name) == 0) {<br />
return c.substring(name.length, c.length);<br />
}<br />
}<br />
return "";<br />
}<br />
<br />
var cnt = 60;<br />
function counter(){<br />
if(getCookie("cnt") > 0){<br />
cnt = getCookie("cnt");<br />
}<br />
cnt -= 1;<br />
document.cookie = "cnt="+ cnt;<br />
jQuery("#counter").val(getCookie("cnt"));<br />
<br />
if(cnt>0){<br />
setTimeout(counter,1000);<br />
}<br />
<br />
}<br />
<br />
counter();<br />
</script><br />
<br /></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-66269933777546672752017-11-04T05:51:00.003-07:002017-11-04T05:51:30.541-07:00How to add css and js file in head section opencart<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Include Css file code:<br />
<br />
$this->document->addStyle('catalog/view/theme/themename/stylesheet/product.css');<br />
<br />
<br />
Include Js file code:<br />
<br />
$this->document->addScript('catalog/view/theme/themename/js/product.js');</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-91667269684434524132017-11-04T05:49:00.002-07:002017-11-04T05:49:58.334-07:00How to append GET parameters in url PHP<div dir="ltr" style="text-align: left;" trbidi="on">
First make one function like below<br />
<br />
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";<br />
<br />
$param = GET;<br />
<br />
function filter_url($url,$param){<br />
<br />
$parsed = parse_url($url);<br />
$query = str_replace("&amp;","&",$parsed['query']);<br />
parse_str($query,$params);<br />
unset($params[$param]);<br />
$new_query = http_build_query($params);<br />
$newUrl = $parsed['scheme']."://".$parsed['host'].$parsed['path'];<br />
if($new_query){ <br />
$newUrl .= "?".$new_query;<br />
}<br />
return $newUrl;<br />
<br />
}</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-23213655923955922442017-11-04T05:47:00.002-07:002017-11-04T05:47:15.642-07:00How do i reverse parse_url in PHP<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
$parsed = parse_url($url);<br />
<br />
You can reverse back parse url like below<br />
<br />
$newUrl = $parsed['scheme']."://".$parsed['host'].$parsed['path'];<br />
$new_query = http_build_query($params);<br />
if($new_query){ <br />
$newUrl .= "?".$new_query;<br />
}</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-75940083791463683842017-02-10T23:09:00.003-08:002017-02-10T23:09:46.042-08:00How to add css and js file in head section opencart<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
How to add css and js file in head section opencart<br />
<br />
Include Css file code:<br />
<br />
$this->document->addStyle('catalog/view/theme/themename/stylesheet/product.css');<br />
<br />
<br />
Include Js file code:<br />
<br />
$this->document->addScript('catalog/view/theme/themename/js/product.js');</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-29298757654979291412017-01-28T05:14:00.000-08:002017-01-28T05:14:29.203-08:00How to make counter not reset on page refresh javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
How to make counter not reset on page refresh javascript<br />
<br />
<form name="counter"><br />
<input type="text" size="8" name="chandresh" id="counter"><br />
</form><br />
<br />
<script type="text/javascript"><br />
function getCookie(cname) {<br />
var name = cname + "=";<br />
var decodedCookie = decodeURIComponent(document.cookie);<br />
var ca = decodedCookie.split(';');<br />
for(var i = 0; i <ca.length; i++) {<br />
var c = ca[i];<br />
while (c.charAt(0) == ' ') {<br />
c = c.substring(1);<br />
}<br />
if (c.indexOf(name) == 0) {<br />
return c.substring(name.length, c.length);<br />
}<br />
}<br />
return "";<br />
}<br />
<br />
var cnt = 60;<br />
function counter(){<br />
if(getCookie("cnt") > 0){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cnt = getCookie("cnt");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>cnt -= 1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>document.cookie = "cnt="+ cnt;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>jQuery("#counter").val(getCookie("cnt"));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(cnt>0){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>setTimeout(counter,1000);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />
<br />
counter();<br />
</script></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com4tag:blogger.com,1999:blog-2042408226519312963.post-83580374084046462992016-12-12T01:34:00.001-08:002016-12-12T01:34:32.789-08:00How to add sku column in sales order grid magento admin<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
How to add sku column in sales order grid magento admin<br />
<br />
Note: For not to override magento core functionality, You can create your own module and use the below code in Grid.php<br />
<br />
Open app\code\core\Mage\Adminhtml\Block\Sales\Order\Grid.php<br />
<br />
Replace the below function<br />
<br />
protected function _prepareCollection()<br />
{<br />
$collection = Mage::getResourceModel($this->_getCollectionClass());<br />
$collection->getSelect()->joinLeft(<br />
'sales_flat_order_item',<br />
'`sales_flat_order_item`.order_id=`main_table`.entity_id',<br />
array('skus' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.sku SEPARATOR ",")'))<br />
);<br />
$collection->getSelect()->group('entity_id');<br />
<br />
$this->setCollection($collection);<br />
return parent::_prepareCollection();<br />
}<br />
<br />
Now put the below code in _prepareColumns() function<br />
<br />
$this->addColumn('sku', array(<br />
'header' => Mage::helper('sales')->__('SKU'),<br />
'index' => 'skus',<br />
'type' => 'text',<br />
'width' => '100px',<br />
'filter' => false,<br />
));</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-44770213097713311322016-12-09T22:36:00.001-08:002016-12-09T22:36:14.447-08:00Swap variable values in php<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Swap variable values in php<br />
<br />
<?php<br />
$a = 40;<br />
$b = 50;<br />
<br />
$temp = $a;<br />
$a = $b;<br />
$b = $temp;<br />
<br />
echo $a;<br />
echo $b;<br />
<br />
OR<br />
<br />
Swap values without third variable<br />
<br />
$a = 40;<br />
$b = 50;<br />
<br />
$a = $a+$b;<br />
$b = $a - $b;<br />
$a = $a - $b;<br />
<br />
echo $a;<br />
echo $b;<br />
<br />
?></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-32929111232093530482016-12-09T22:22:00.000-08:002016-12-09T22:22:43.925-08:00Star pattern programs with for loop in php<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Star pattern programs with for loop in php<br />
<br />
Script for following pattern<br />
<br />
*<br />
**<br />
***<br />
****<br />
*****<br />
******<br />
*******<br />
********<br />
<br />
<?php<br />
for($i=1;$i<=8;$i++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo str_repeat('*',$i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo "<br/>";<br />
}<br />
<br />
OR<br />
<br />
for($i=1;$i<=8;$i++){<br />
<br />
for($j=1;$j<$i;$j++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '*';<br />
}<br />
echo '<br/>';<br />
}<br />
<br />
?><br />
<br />
<br />
Script for following pattern<br />
<br />
****<br />
****<br />
****<br />
****<br />
****<br />
****<br />
<br />
<?php<br />
for ($i=1;$i<=6;$i++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for($j=1;$j<5;$j++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '*';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '<br/>';<br />
}<br />
?><br />
<br />
<br />
Script for following pattern<br />
<br />
*****<br />
****<br />
***<br />
**<br />
*<br />
<br />
<?php<br />
for($i=6;$i>0;$i--){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for($j=1;$j<$i;$j++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '*';<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '<br/>';<br />
}<br />
?><br />
<br />
Script for Triangle of Stars in PHP<br />
<br />
*<br />
**<br />
***<br />
****<br />
*****<br />
****** <br />
<br />
<?php<br />
$l = 1;<br />
for($i=8;$i>1;$i--){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for($j=1;$j<$i;$j++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '&nbsp;';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for($k=1;$k<$l;$k++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '*';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$l++;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '<br/>';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
}<br />
<br />
OR<br />
<br />
$l = 1;<br />
for($i=8;$i>1;$i--){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo str_repeat('&nbsp;',$i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo str_repeat('*',$l++);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo '<br/>';<br />
}<br />
<br />
?></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-86097859343344494212016-11-30T04:21:00.003-08:002016-11-30T04:21:36.918-08:00How to enable paypal payment standard in magento 1.9.2.1<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
How to enable paypal payment standard in magento 1.9.2.1<br />
<br />
In magento 1.9.2.1 Paypal Payment Standard method not exist. If you want use paypal, you have to select Website Payments Standard (Includes Express Checkout). Here i have used small trick to reuse the old method.<br />
<br />
Run the following query in your database and check in admin panel in payment method section<br />
<br />
update core_config_data set value = '1' where path = 'payment/paypal_standard/active';</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-16936758177617275262016-11-14T03:42:00.002-08:002016-11-14T03:42:33.600-08:00Radio button validation in javascript check or uncheck<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Radio button validation in javascript check or uncheck<br />
<br />
<form action="" method="post" name="register_form" id="register_form" enctype="multipart/form-data"><br />
<br />
<div class="text-input"><br />
<label>Gender: </label><br />
<input class="form-control" type="radio" name="gender" id="male" value="male" /><br />
<label for="male">Male</label><br />
<input class="form-control" type="radio" name="gender" id="female" value="female" /><br />
<label for="female">Female</label><br />
</div><br />
<div class="text-input" align="center"><br />
<input type="submit" name="register" value="Submit" onclick="return radioValidation();" /><br />
</div><br />
<br />
</form><br />
<br />
<script type="text/javascript"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>function radioValidation(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var gender = document.getElementsByName('gender');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var genValue = false;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(var i=0; i<gender.length;i++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(gender[i].checked == true){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>genValue = true;<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(!genValue){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>alert("Please Choose the gender");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return false;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
</script></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-86236296643581205712016-11-09T21:29:00.000-08:002016-11-09T21:29:01.605-08:00PayPal gateway has rejected request. Currency is not supported paypal Express error magento<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-family: "times new roman"; margin: 0px;">
<br />
PayPal gateway has rejected request. Currency is not supported paypal Express error magento</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Generally
People face this type error becoz of Paypal does not support requested
currency. For Example : If you are trying to checkout with Indian Rupee ,
You would get this type of error due to paypal does not support Indian
Rupee. In this condition you have to switch the your base currency to
paypal supported currency. But with this solution your store price will
be changed. so that here i came with small hack.</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
I have used small trick to rid this error. It is not good solution but sometime it is useful.</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Go to app\code\core\Mage\Paypal\Model\Express\Checkout.php. Find the public function start and find below code</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
$this->_api->setAmount($this->_quote->getBaseGrandTotal())</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setCurrencyCode($this->_quote->getBaseCurrencyCode())</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setInvNum($this->_quote->getReservedOrderId())</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setReturnUrl($returnUrl)</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setCancelUrl($cancelUrl)</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setSolutionType($solutionType)</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setPaymentAction($this->_config->paymentAction);</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Just replace the below code</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
$this->_api->setAmount($this->_quote->getBaseGrandTotal())</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setCurrencyCode('USD')</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setInvNum($this->_quote->getReservedOrderId())</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setReturnUrl($returnUrl)</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setCancelUrl($cancelUrl)</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setSolutionType($solutionType)</div>
<div style="font-family: "times new roman"; margin: 0px;">
->setPaymentAction($this->_config->paymentAction);</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
<b>With this trick now you will go to paypal without any error. But you have to convert the price from Base Currency to USD.</b></div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
<b>Note: This solution is only for Paypal Express Users.</b></div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
That's it. Enjoy Chandresh Rana's Coding...</div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com1tag:blogger.com,1999:blog-2042408226519312963.post-47244222049334599712016-11-09T21:27:00.000-08:002017-01-05T05:20:38.053-08:00How to make custom mini shopping cart in header magento<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="font-family: "times new roman"; margin: 0px;">
How to make custom mini shopping cart in header magento</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Kindly Copy the below code and paste it into your header.phtml file.</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="shopping_cart active"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span><?php $cart = Mage::getModel('checkout/cart')->getQuote(); ?></div>
<div style="font-family: "times new roman"; margin: 0px;">
<?php $cnt = Mage::helper('checkout/cart')->getSummaryCount(); ?></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="icon"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<i class="shopping-bag-icon v-middle"></i></div>
<div style="font-family: "times new roman"; margin: 0px;">
<span class="count-number"><?php if($cnt > 0){echo $cnt;}else{echo "0";} ?></span></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<span class="block-cart hidden-xs hidden-sm"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<b class="hidden-xs hidden-sm m-l-sm">MY BAG</b></div>
<div style="font-family: "times new roman"; margin: 0px;">
<p>item(s)</p></div>
<div style="font-family: "times new roman"; margin: 0px;">
</span></div>
<div style="font-family: "times new roman"; margin: 0px;">
<?php if($cnt > 0): ?></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="cart_block cart-block exclusive"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="block_content"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<p class="cart-subtitle">Recently added item(s)</p></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="cart_block_list"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="products"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<?php foreach ($cart->getAllVisibleItems() as $item): ?></div>
<div style="font-family: "times new roman"; margin: 0px;">
<?php $_product =
Mage::getModel('catalog/product')->load($item->getProduct()->getId());
?></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="product-item-list"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<a href="<?php echo $_product->getProductUrl() ?>" class="cart-images"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<img src="<?php echo
$this->helper('catalog/image')->init($_product,
'small_image')->keepFrame(false)->resize(72, 99); ?>"
class="img-responsive"></a></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="cart-info"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="product-name"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<a href="<?php echo
$_product->getProductUrl() ?>"
class="cart_block_product_name"><?php echo
$_product->getName(); ?></a></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<span><?php echo $item->getQty(); ?> x </span></div>
<div style="font-family: "times new roman"; margin: 0px;">
<span
class="price"><?php echo
Mage::helper('core')->currency($_product->getFinalPrice(), 2);
?> </span></div>
<div style="margin: 0px;">
<div style="font-family: "times new roman";">
</div></div>
<span style="font-family: times new roman;"> <span class="remove_link"></span><br />
<span style="font-family: times new roman;"> <a href="<?php echo $this->getUrl('checkout/cart/delete',array('id'=>$item->getId(),Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl())); ?>" rel="nofollow" title="remove this product from my cart"><i class="delet-item"></i></span><br />
<span style="font-family: times new roman;"> </a></span><br />
<span style="font-family: times new roman;"> </span></span></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<?php endforeach; ?> </div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="clearfix"></div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="buttons m-t-sm"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="row"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="col-xs-6 p-r-xs"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<button onclick="setLocation('<?php echo
$this->getUrl('checkout/cart'); ?>')" type="button" title="View
Bag" class="btn btn-theme btn-block"><span>VIEW
BAG</span> </button></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<div class="col-xs-6 p-l-xs"></div>
<div style="font-family: "times new roman"; margin: 0px;">
<button onclick="setLocation('<?php echo
$this->getUrl('onepagecheckout'); ?>')" class="btn brown-btn
btn-block" title="Checkout"
type="button"><span>CHECKOUT</span> </button></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div> </div>
<div style="font-family: "times new roman"; margin: 0px;">
</div> </div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
<?php endif; ?></div>
<div style="font-family: "times new roman"; margin: 0px;">
</div></div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-88258969743616715062016-11-08T21:49:00.002-08:002016-11-08T21:51:06.279-08:00How to set validation on checkout with minimum qty purchase magento<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-family: "times new roman"; margin: 0px;">
<br />
How to set validation on checkout with minimum qty magento</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Put below code in your module/any module config.xml file after <models> block</div>
<div style="font-family: "times new roman"; margin: 0px;">
<global></div>
<div style="font-family: "times new roman"; margin: 0px;">
<events></div>
<div style="font-family: "times new roman"; margin: 0px;">
<controller_action_predispatch_checkout_onepage_index></div>
<div style="font-family: "times new roman"; margin: 0px;">
<observers></div>
<div style="font-family: "times new roman"; margin: 0px;">
<spirit_cms_validate_checkout></div>
<div style="font-family: "times new roman"; margin: 0px;">
<class>Setblue_Banner_Model_Observer</class></div>
<div style="font-family: "times new roman"; margin: 0px;">
<method>validateCheckout</method></div>
<div style="font-family: "times new roman"; margin: 0px;">
</spirit_cms_validate_checkout></div>
<div style="font-family: "times new roman"; margin: 0px;">
</observers></div>
<div style="font-family: "times new roman"; margin: 0px;">
</controller_action_predispatch_checkout_onepage_index></div>
<div style="font-family: "times new roman"; margin: 0px;">
</events></div>
<div style="font-family: "times new roman"; margin: 0px;">
</global></div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Next
we need to create observer file to read this code. Create Observer.php
in /yourmodule/Model/Observer.php and put the below code :</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
public function validateCheckout($observer)</div>
<div style="font-family: "times new roman"; margin: 0px;">
{</div>
<div style="font-family: "times new roman"; margin: 0px;">
// Ensure we only observe once. $oObserver</div>
<div style="font-family: "times new roman"; margin: 0px;">
if( Mage::registry( 'restrict_checkout_flag' ) )</div>
<div style="font-family: "times new roman"; margin: 0px;">
{</div>
<div style="font-family: "times new roman"; margin: 0px;">
return $this;</div>
<div style="font-family: "times new roman"; margin: 0px;">
}</div>
<div style="font-family: "times new roman"; margin: 0px;">
else</div>
<div style="font-family: "times new roman"; margin: 0px;">
{</div>
<div style="font-family: "times new roman"; margin: 0px;">
$oQuote = Mage::getSingleton( 'checkout/cart' )->getQuote();</div>
<div style="font-family: "times new roman"; margin: 0px;">
$oCartItems = $oQuote->getAllItems();</div>
<div style="font-family: "times new roman"; margin: 0px;">
$iTotalAmount = $oQuote->getGrandTotal();</div>
<div style="font-family: "times new roman"; margin: 0px;">
$iGroupId = $oQuote->getCustomerGroupId();</div>
<div style="font-family: "times new roman"; margin: 0px;">
$iTotalQty = 0;</div>
<div style="font-family: "times new roman"; margin: 0px;">
foreach( $oCartItems as $oCartItem )</div>
<div style="font-family: "times new roman"; margin: 0px;">
{</div>
<div style="font-family: "times new roman"; margin: 0px;">
$iTotalQty = $iTotalQty + $oCartItem->getQty();</div>
<div style="font-family: "times new roman"; margin: 0px;">
}</div>
<div style="font-family: "times new roman"; margin: 0px;">
if($iGroupId == '2'){</div>
<div style="font-family: "times new roman"; margin: 0px;">
if( $iTotalQty < 15 )</div>
<div style="font-family: "times new roman"; margin: 0px;">
{</div>
<div style="font-family: "times new roman"; margin: 0px;">
$oSession = Mage::getSingleton( 'checkout/session' );</div>
<div style="font-family: "times new roman"; margin: 0px;">
$oSession->addError( 'Please add at least 15 items to your cart.' );</div>
<div style="font-family: "times new roman"; margin: 0px;">
Mage::app()->getResponse()->setRedirect( Mage::getUrl( 'checkout/cart' ) );</div>
<div style="font-family: "times new roman"; margin: 0px;">
}</div>
<div style="font-family: "times new roman"; margin: 0px;">
Mage::register( 'restrict_checkout_flag', 1, TRUE );</div>
<div style="font-family: "times new roman"; margin: 0px;">
}</div>
<div style="font-family: "times new roman"; margin: 0px;">
</div>
<div style="font-family: "times new roman"; margin: 0px;">
}</div>
<div style="font-family: "times new roman"; margin: 0px;">
}</div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-60344366481613688552016-11-07T21:21:00.002-08:002016-11-07T21:21:49.499-08:00How to Remove "What is PayPal?" from PayPal payment method on checkout magento<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="font-family: "times new roman"; margin: 0px;">
<br />
How to Remove "What is PayPal?" from PayPal payment method on checkout magento</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
In
magento by default paypal payment method provide Paypal logo and and
"What is Paypal?" text with title. Here i will given you exact file
where you remove logo and "What is Paypal?" text.</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Just open <b>/app/design/frontend/base/default/template/paypal/payment/mark.phtml</b> file. In this file you can easily find paypal logo and "What is paypal?" text.. Just remove it or comment it out.</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<br />
<div style="font-family: "times new roman";">
</div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: "Times New Roman"; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal; letter-spacing: normal; margin: 0px; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
Thats it enjoy chandresh rana coding.... :)</div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-30189045230273930222016-11-07T03:36:00.002-08:002016-11-07T03:36:24.104-08:00How to get the joomla base url<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
Here is the joomla base url/site url</div>
<div style="font-family: "times new roman"; margin: 0px;">
<br /></div>
<div style="font-family: "times new roman"; margin: 0px;">
<b><?php echo JURI::base(); ?></b></div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-10091867494555269302016-10-17T05:13:00.002-07:002016-10-17T05:13:39.607-07:00Register Customer approve by admin for wholesale user group magento<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Register Customer approve by admin for wholesale user group magento<br />
<br />
To Enable the Require Emails Confirmation, Go to system->configuration->Customer configuration open Create New Account Options section<br />
<br />
<br />
Open register.phtml and put the below line before the submit button for assign wholesale group.<br />
<br />
<input type="hidden" name="group_id" id="group_id" value="2" /><br />
<br />
Now open \app\code\core\Mage\Customer\controllers\AccountController.php<br />
<br />
Change $message variable like below in loginPostAction() function<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$message = $this->_getHelper('customer')->__('This account is not approved. You will receive an email with confirmation once your account is approved by admin.');<br />
<br />
Change in createPostAction() function<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Find $errUrl = $this->_getUrl('*/*/login', array('_secure' => true));<br />
<br />
and replace as below<br />
<br />
if($this->getRequest()->getPost('group_id') == 2){<br />
$errUrl = $this->_getUrl('*/*/create?register=wholesale', array('_secure' => true));<br />
}else{<br />
$errUrl = $this->_getUrl('*/*/login', array('_secure' => true));<br />
}<br />
<br />
Now Replace _successProcessRegistration() function as below <br />
<br />
protected function _successProcessRegistration(Mage_Customer_Model_Customer $customer)<br />
{<br />
$session = $this->_getSession();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Code By Chand */<br />
if ($customer->isConfirmationRequired() && $this->getRequest()->getPost('group_id') == 2) {<br />
/** @var $app Mage_Core_Model_App */<br />
$app = $this->_getApp();<br />
/** @var $store Mage_Core_Model_Store*/<br />
$store = $app->getStore();<br />
$customer->sendNewAccountEmail(<br />
'confirmation',<br />
$session->getBeforeAuthUrl(),<br />
$store->getId()<br />
);<br />
$customerHelper = $this->_getHelper('customer');<br />
$session->addSuccess($this->__('Thank you for registering with us. Your account is under moderation and will be approved by admin soon.',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/* End Code By Chand */<span class="Apple-tab-span" style="white-space: pre;"> </span> <br />
$customerHelper->getEmailConfirmationUrl($customer->getEmail())));<br />
$url = $this->_getUrl('*/*/index', array('_secure' => true));<br />
} else {<br />
$session->setCustomerAsLoggedIn($customer);<br />
$url = $this->_welcomeCustomer($customer);<br />
}<br />
$this->_redirectSuccess($url);<br />
return $this;<br />
}<br />
<br />
In _getCustomer() function replace line $customer->getGroupId(); as below<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if($this->getRequest()->getPost('group_id')){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $customer->setGroupId($this->getRequest()->getPost('group_id'));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}else{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$customer->getGroupId();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<br />
Now open \app\code\core\Mage\Customer\Model\Customer.php and replace isConfirmationRequired() function as below<br />
<br />
public function isConfirmationRequired()<br />
{<br />
if ($this->canSkipConfirmation()) {<br />
return false;<br />
}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Code By Chand */<br />
if (self::$_isConfirmationRequired === null && $this->getGroupId() == 2) {<br />
$storeId = $this->getStoreId() ? $this->getStoreId() : null;<br />
self::$_isConfirmationRequired = (bool)Mage::getStoreConfig(self::XML_PATH_IS_CONFIRM, $storeId);<br />
}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/* End Code By Chand */<br />
return self::$_isConfirmationRequired;<br />
}<br />
<br />
<br />
Go to magento admin panel open transactional Emails in system. Open New account confirmation key template and paste below code:<br />
<br />
{{template config_path="design/email/header"}}<br />
{{inlinecss file="email-inline.css"}}<br />
<br />
<table cellpadding="0" cellspacing="0" border="0"><br />
<tr><br />
<td><br />
<table cellpadding="0" cellspacing="0" border="0"><br />
<tr><br />
<td class="action-content"><br />
<h1>{{htmlescape var=$customer.name}},</h1><br />
<p>Thank you for registering with us. Your account is under moderation and will be approved by admin soon.</p><br />
<p class="highlighted-text"><br />
Use the following values when prompted to log in:<br/><br />
<strong>Email:</strong> {{var customer.email}}<br/><br />
<strong>Password:</strong> {{htmlescape var=$customer.password}}<br />
</p><br />
<p><br />
If you have any questions, please feel free to contact us at<br />
<a href="mailto:{{var store_email}}">{{var store_email}}</a><br />
{{depend store_phone}} or by phone at <a href="tel:{{var phone}}">{{var store_phone}}</a>{{/depend}}.<br />
</p><br />
</td><br />
</tr><br />
</table><br />
</td><br />
</tr><br />
</table><br />
<br />
{{template config_path="design/email/footer"}}<br />
<br />
<br />
Open New account confirmed template and paste below code:<br />
<br />
{{template config_path="design/email/header"}}<br />
{{inlinecss file="email-inline.css"}}<br />
<br />
<table cellpadding="0" cellspacing="0" border="0"><br />
<tr><br />
<td class="action-content"><br />
<h1>{{htmlescape var=$customer.name}},</h1><br />
<p>Congratulations. Your account has been approved. Now you can access our wholesale catalog price.</p><br />
<p>To log in when visiting our site just click <a href="{{store url="customer/account/"}}">Login</a> or <a href="{{store url="customer/account/"}}">My Account</a> at the top of every page, and then enter your email address and password.</p><br />
<p>When you log in to your account, you will be able to do the following:</p><br />
<ul><br />
<li>Proceed through checkout faster when making a purchase</li><br />
<li>Check the status of orders</li><br />
<li>View past orders</li><br />
<li>Make changes to your account information</li><br />
<li>Change your password</li><br />
<li>Store alternative addresses (for shipping to multiple family members and friends!)</li><br />
</ul><br />
<p><br />
If you have any questions, please feel free to contact us at<br />
<a href="mailto:{{var store_email}}">{{var store_email}}</a><br />
{{depend store_phone}} or by phone at <a href="tel:{{var phone}}">{{var store_phone}}</a>{{/depend}}.<br />
</p><br />
</td><br />
</tr><br />
</table><br />
<br />
{{template config_path="design/email/footer"}}<br />
<br />
Assigned both template from Customer configuration in magento admin panel.<br />
<div>
<br /></div>
<br /></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-36405892109303493182016-09-29T03:06:00.004-07:002016-09-29T03:06:56.737-07:00Sales report shows wrong invoiced amount in magento<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Sales report shows wrong invoiced amount in magento<br />
<br />
Most of people have this issue.<br />
<br />
The solution is that refresh the lifetime statistic instead of the daily statistic refresh.<br />
<br />
Moreover refer the below picture for more information about the current report.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhBIPX0yCH0nwUJ9UqlvZGRaWCDZTcgN58X5lzGLuQnQWGIWmhW-sdP1nSycAR1d_7LeLI_Nw34qJd-Pw2TNk6HibmPS_C7NEsdMkJIhJ5yDLZXXU2tIG_0rraFmhg3PrpBif6rfLIZ8_O/s1600/report.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhBIPX0yCH0nwUJ9UqlvZGRaWCDZTcgN58X5lzGLuQnQWGIWmhW-sdP1nSycAR1d_7LeLI_Nw34qJd-Pw2TNk6HibmPS_C7NEsdMkJIhJ5yDLZXXU2tIG_0rraFmhg3PrpBif6rfLIZ8_O/s320/report.png" width="320" /></a></div>
<br /></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-78357690218897555762016-09-26T04:51:00.001-07:002016-09-26T04:51:54.889-07:00Change contact email template plain text to HTML format magento<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Change contact email template plain text to HTML format magento<br />
<br />
Open app/code/core/Mage/Contacts/etc/config.xml<br />
<br />
Note: You can create your own module and override the contact module config.xml file.<br />
<br />
<email><br />
<contacts_email_email_template translate="label" module="contacts"><br />
<label>Contact Form</label><br />
<file>contact_form.html</file><br />
<type>text</type><br />
</contacts_email_email_template><br />
</email><br />
<br />
Replace to<br />
<br />
<email><br />
<contacts_email_email_template translate="label" module="contacts"><br />
<label>Contact Form</label><br />
<file>contact_form.html</file><br />
<type>html</type><br />
</contacts_email_email_template><br />
</email></div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-43704334068917275132016-09-06T23:04:00.000-07:002016-09-06T23:04:49.373-07:00Insert product in magento through Soap API with media images<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Insert product in magento through Soap API with media images<br />
<br />
<?php<br />
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");<br />
header("Cache-Control: post-check=0, pre-check=0", false);<br />
header("Pragma: no-cache");<br />
error_reporting(E_ALL);<br />
ini_set('display_errors', 1);<br />
<br />
//create soap object<br />
$mage_url = 'http://cohodeals.com/index.php/api/soap?wsdl';<br />
$mage_user = 'chandresh';<br />
$mage_api_key = '12345678';<br />
// Initialize the SOAP client<br />
$soap = new SoapClient($mage_url);<br />
<br />
// Login to Magento<br />
$session_id = $soap->login($mage_user, $mage_api_key);<br />
$productData = array(<br />
'name' => $_REQUEST['name'], //'Test product'<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'categories' => array($_REQUEST['cat']),<br />
'websites' => array(1),<br />
'short_description' => $_REQUEST['desc'],<br />
'description' => $_REQUEST['desc'],<br />
'price' => $_REQUEST['price'],<br />
'status' => 1,<br />
'tax_class_id' => 0,<br />
'url_key' => $_REQUEST['url'],<br />
'visibility' => '4',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'stock_data' => array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'qty' => $_REQUEST['qty'],<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'is_in_stock' => 1<br />
)<br />
);<br />
$sku = $_REQUEST['sku'];<br />
$storeView = 1;<br />
$attributeSetId = 4; // you can get this id from admin area<br />
$productType = 'simple';<br />
try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$product_exist = null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $product_exist = $soap->call($session_id, 'product.info', $sku);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> catch(exception $e){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> //nothing to do<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if($product_exist==null or $product_exist==""){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$result = $soap->call($session_id, 'catalog_product.create', array($productType, $attributeSetId, $sku, $productData, $storeView));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Image Upload area start */<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Get the file<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$url = $_REQUEST['image'];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$content = file_get_contents($url);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//Store in media.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$imageInfo = pathinfo($url);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$imageName = $imageInfo['basename'];<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$fp = fopen("../media/import/".$imageName, "w");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>fwrite($fp, $content);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>fclose($fp);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//attach image with database<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>require_once '../app/Mage.php';<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Mage::app();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$path = Mage::getBaseDir('media') . DS . 'import' . DS . $imageName;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$type = pathinfo($path, PATHINFO_EXTENSION);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$data = file_get_contents($path);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$base64 = base64_encode($data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$productId = $result;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$file = array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'content' => $base64,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'mime' => 'image/jpeg'<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$result = $soap->call(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$session_id,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>'catalog_product_attribute_media.create',<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>array(<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$productId,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>array('file'=>$file, 'label'=>'Label', 'position'=>'1', 'types'=>array('thumbnail','small_image','image'), 'exclude'=>0)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Image Upload area end */<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> //$result = $soap->call($session_id, 'catalog_product.delete', $sku);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> $result = $soap->call($session_id, 'catalog_product.update', array($sku,$productData));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>echo 'Product Uploaded Successfully';<br />
} catch (SoapFault $e) {<br />
echo "Error in inserting product with sku $sku : " . $e->getMessage();<br />
}<br />
<div>
<br /></div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-11474864472608866362016-08-28T22:40:00.001-07:002016-08-28T22:40:05.483-07:00How to fetch all files name from folder in PHP<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Fetch all files name from folder in PHP<br />
<br />
if ($handle = opendir("C:\wamp\www\yoursite/download/")) {<br />
<br />
while (false !== ($entry = readdir($handle))) {<br />
if ($entry != "." && $entry != "..") {<br />
<br />
echo "<b>".preg_replace('/\\.[^.\\s]{3,4}$/', '', $entry)."</b>";<br />
<br />
}<br />
}<br />
<br />
closedir($handle);<br />
}<br />
<br />
Thats it.... Enjoy Chandresh rana's Coding... :)<br />
<div>
<br /></div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com1tag:blogger.com,1999:blog-2042408226519312963.post-19007820656830834112016-08-25T03:10:00.001-07:002016-08-25T03:10:20.199-07:00Programatically get all currency of store in opencart<div dir="ltr" style="text-align: left;" trbidi="on">
Programatically get all currency of store in opencart<br />
<br />
<?php<br />
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency ORDER BY title ASC");<br />
if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {<br />
$connection = 'SSL';<br />
} else {<br />
$connection = 'NONSSL';<br />
}<br />
<br />
$action = $this->url->link('module/currency', '', $connection);<br />
?><br />
<br />
<form action="<?php echo $action; ?>" method="post" name="currency_form" enctype="multipart/form-data"><br />
<ul><br />
<?php foreach ($query->rows as $result) { ?><br />
<li><a onclick="$('input[name=\'currency_code\']').attr('value', '<?php echo $result['code']; ?>'); document.currency_form.submit();"><?php echo $result['code']; ?></a></li><br />
<?php } ?><br />
</ul><br />
<input type="hidden" name="currency_code" value="" /><br />
</form><br />
<br />
Thats it.... Enjoy Chandresh rana's Coding... :)</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com0tag:blogger.com,1999:blog-2042408226519312963.post-13309995937245804642016-08-21T22:40:00.002-07:002016-08-21T22:40:41.611-07:00Display image column in manage category grid magento admin<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br class="Apple-interchange-newline" />Display image column in manage category grid magento admin</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
Here i will show you how to create image column in admin mangage category grid magento.</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
First open app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php file.</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
You can copy this file in your local folder so that magento core functionality will not be override.</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
Put the below code in _prepareColumns() function to create image column in grid.</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
$this->addColumn('image', array(</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
'header' => Mage::helper('catalog')->__('Image'),</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
'align' => 'left',</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
'index' => 'image',</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
'width' => '100',</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
'renderer' => 'adminhtml/Catalog_Category_Grid_Render_Image',</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
));</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
You can check in code we have created renderer to fetch product image. Now as per renderer create the Grid folder then Render folder and then Image.php file in app/code/core/Mage/Adminhtml/Block/Catalog/Category/ folder</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
Copy and paste the below code in Image.php file</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
class Mage_Adminhtml_Block_Catalog_Category_Grid_Render_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
{</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
public function render(Varien_Object $row)</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>$products = Mage::getModel('catalog/product')->load($row->getEntityId());</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>try{</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> $imgSrc = Mage::helper('catalog/image')->init($products, 'small_image')->resize(100);</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>catch(Exception $e) {</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span> $imgSrc = Mage::getDesign()->getSkinUrl('images/catalog/product/placeholder/image.jpg',array('_area'=>'frontend'));</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>return '<img src="'.$imgSrc.'" alt="'.$strBannerTitle.'" title="'.$strBannerTitle.'" width="100px">';</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
}</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
}</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
Now you can check in admin panel image shows in image column like below:</div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
<br /></div>
<div class="separator" style="clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpSD1cwNtFGqxbFNOCNKfRwvEbZhinKth8v-9rvwd76HC6Gnr6syp0oevy8ydCVtMRsvhmjBG85I-iA9MMn1twkfbbnpAhpo4wNsLg_-nlf3BlK2TPbhWreO-bV6yqdDXxkBECvNeX1iY/s1600/image_column.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpSD1cwNtFGqxbFNOCNKfRwvEbZhinKth8v-9rvwd76HC6Gnr6syp0oevy8ydCVtMRsvhmjBG85I-iA9MMn1twkfbbnpAhpo4wNsLg_-nlf3BlK2TPbhWreO-bV6yqdDXxkBECvNeX1iY/s320/image_column.png" style="cursor: move;" width="320" /></a></div>
</div>
PHP Coderhttp://www.blogger.com/profile/01065666669148575183noreply@blogger.com1