CloudSwift Solutions - Web Development Company in Vadodara
If you are searching for the professional web development, app development company in Vadodara then Cloudswift Solutions is the name on which you can trust. Visit our website for more information.
Sunday, 25 November 2012
Friday, 23 November 2012
Using php to display visitor / user information such as their IP address
$ip = $_SERVER['REMOTE_ADDR'];
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER['HTTP_USER_AGENT'];
$referred = $_SERVER['HTTP_REFERER']; // a quirky spelling mistake that stuck in php
print "Display IP address:
\n";
print "$ip
\n";
print "More detailed host address:
\n";
print "$hostaddress
\n";
print "Display browser info:
\n";
print "$browser
\n";
print "Where you came from (if you clicked on a link to get here:
\n";
if ($referred == "") {
print "Page was directly requested";
}
else {
print "$referred";
}
$hostaddress = gethostbyaddr($ip);
$browser = $_SERVER['HTTP_USER_AGENT'];
$referred = $_SERVER['HTTP_REFERER']; // a quirky spelling mistake that stuck in php
print "Display IP address:
\n";
print "$ip
\n";
print "More detailed host address:
\n";
print "$hostaddress
\n";
print "Display browser info:
\n";
print "$browser
\n";
print "Where you came from (if you clicked on a link to get here:
\n";
if ($referred == "") {
print "Page was directly requested";
}
else {
print "$referred";
}
Most Important Tables in magento are: eav_attribute and eav_entity_type
PRODUCT
Main Table: catalog_product_entity
catalog_product_entity_datetime
catalog_product_entity_decimal
catalog_product_entity_gallery
catalog_product_entity_int
catalog_product_entity_media_gallery
catalog_product_entity_media_gallery_value
catalog_product_entity_text
catalog_product_entity_tier_price
catalog_product_entity_varchar
CATEGORY
Main Table: catalog_category_entity
catalog_category_entity_datetime
catalog_category_entity_decimal
catalog_category_entity_int
catalog_category_entity_text
catalog_category_entity_varchar
catalog_category_product
PARTY
Main Table: customer_entity and customer_address_entity
customer_entity_datetime
customer_entity_decimal
customer_entity_int
customer_entity_text
customer_entity_varchar
customer_group
customer_address_entity_datetime
customer_address_entity_decimal
customer_address_entity_int
customer_address_entity_text
customer_address_entity_varchar
ORDER
Main Table: sales_flat_order
sales_flat_order_address
sales_flat_order_grid
sales_flat_order_item
sales_flat_order_payment
sales_flat_order_status_history
Thursday, 22 November 2012
Wednesday, 21 November 2012
my paypal details
my paypal details :
Login : mayank.patel@live.in
Seller Account : mayank_1354093144_biz@live.in / mayank_seller
Buyer Account : mayank_1354092969_per@live.in / mayank_buyer
Login : mayank.patel@live.in
Seller Account : mayank_1354093144_biz@live.in / mayank_seller
Buyer Account : mayank_1354092969_per@live.in / mayank_buyer
Clean Magento database
TRUNCATE TABLE `dataflow_batch_export`;
TRUNCATE TABLE `dataflow_batch_import`;
TRUNCATE TABLE `log_customer`;
TRUNCATE TABLE `log_quote`;
TRUNCATE TABLE `log_summary`;
TRUNCATE TABLE `log_summary_type`;
TRUNCATE TABLE `log_url`;
TRUNCATE TABLE `log_url_info`;
TRUNCATE TABLE `log_visitor`;
TRUNCATE TABLE `log_visitor_info`;
TRUNCATE TABLE `log_visitor_online`;
TRUNCATE TABLE `report_viewed_product_index`;
TRUNCATE TABLE `report_compared_product_index`;
TRUNCATE TABLE `report_event`;
magento: insert query for a custom table
$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->beginTransaction();
$sql = 'INSERT INTO tableName (`field1`, `field2`) VALUES (?, ?)';
$bind = array('value1', 'value2');
$connection->query($sql, $bind);
$connection->commit();
Show subcategory in a category page
If you're comfortable editing your theme, this code snippet will bring you a list of all sub-categories of the current category (from the session, so this should work anywhere in your theme). I typically use this in app/design/frontend/default/*theme_name*/template/catalog/category/view.phtml
<?php
$_category = $this->getCurrentCategory();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');
?>
<ul>
<?foreach ($collection as $cat):?>
<?php if($_category->getIsActive()):?>
<?php
$cur_category = Mage::getModel('catalog/category')->load($cat->getId());
$_img = $cur_category->getImageUrl();
?>
<li>
<a href="<?php echo $helper->getCategoryUrl($cat);?>">
<img src="<?php echo $_img?>" title="$cat->getName()"/>
<cite><?php echo $cat->getName();?></cite>
</a>
</li>
<?php endif?>
<?php endforeach;?>
</ul>
how do i change the price filter attributes price range with text
You can configure step of price ranges via admin panel. Log in into admin panel and go to System->Configuration->Catalog->Catalog->Layered Navigation. There select "Manual" in dropdown Price Navigation Step Calculation and enter prefered value into next input field.
Magento – Show Quantity Box in Products List
Find the following line on list.phtml file
Replace with:
<?php if($_product->isSaleable()): ?>
<button onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?<')">>span>
<?php echo $this->__('Add to Cart') ?></span></button>Replace with:
<form action="
<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId(); ?>">
<input name="qty" type="text" id="qty" maxlength="12" value="
<?php echo $this->getMinimalQty($_product) ?>" />
<button" onclick="productAddToCartForm_
<?php echo $_product->getId(); ?>.submit()"><span>
<?php echo $this->__('Add to Cart') ?></span></button>
</form>
<script type="text/javascript">
var productAddToCartForm_
<?php echo $_product->getId(); ?> = new VarienForm('product_addtocart_form_
<?php echo $_product->getId(); ?>');
productAddToCartForm_
<?php echo $_product->getId(); ?>.submit = function(){
if (this.validator.validate()) {
this.form.submit();
}
}.bind(productAddToCartForm_<?php echo $_product->getId(); ?>);
</script>Javascript – get Url
window.location.href - get entire url
window.location.protocol - get protocol: "http" / "https"
window.location.host - get hostname, e.g: "www.g31zone.com"
window.location.pathname - get script name, e.g: "example/index.html"
Tuesday, 20 November 2012
Moving Magento From One Host To Another
1. take buckup of your database
2. take backup of your files.
3. create new database on your new host
4. save your database and password of your database
5. open local.xml in magento folder on path app\etc change infomation of previous database with new.
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[username]]></username>
<password><![CDATA[password]]></password>
<dbname><![CDATA[databasename]]></dbname>
<active>1</active>
</connection>
6. upload all your files to you new host.
7. go to you new host database open table `core_config_data` change the value of your old host name with new host name
example:
Before Changing Host
config_id scope scope_id path value
Edit Delete 2 default 0 web/unsecure/base_url http://localhost/oldhost/
Edit Delete 3 default 0 web/secure/base_url http://localhost/oldhost/
After Changing Host
config_id scope scope_id path value
Edit Delete 2 default 0 web/unsecure/base_url http://localhost/newhost/
Edit Delete 3 default 0 web/secure/base_url http://localhost/newhost/
2. take backup of your files.
3. create new database on your new host
4. save your database and password of your database
5. open local.xml in magento folder on path app\etc change infomation of previous database with new.
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[username]]></username>
<password><![CDATA[password]]></password>
<dbname><![CDATA[databasename]]></dbname>
<active>1</active>
</connection>
6. upload all your files to you new host.
7. go to you new host database open table `core_config_data` change the value of your old host name with new host name
example:
Before Changing Host
config_id scope scope_id path value
Edit Delete 2 default 0 web/unsecure/base_url http://localhost/oldhost/
Edit Delete 3 default 0 web/secure/base_url http://localhost/oldhost/
After Changing Host
config_id scope scope_id path value
Edit Delete 2 default 0 web/unsecure/base_url http://localhost/newhost/
Edit Delete 3 default 0 web/secure/base_url http://localhost/newhost/
Running script out side Magento Folder and Updating Project Database
Place this script 'image.php' out side magento folder and run this with http://yoursite/image.php, this will update all product images if there is no small or thumbnail image.
It will make first image as thumb and small image.
An example to run script out side magento folder.
<?php
require 'app/Mage.php';
Mage::app();
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product) {
if (!$product->hasImage()) continue;
if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());
$product->save();
}
It will make first image as thumb and small image.
An example to run script out side magento folder.
<?php
require 'app/Mage.php';
Mage::app();
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
foreach ($products as $product) {
if (!$product->hasImage()) continue;
if (!$product->hasSmallImage()) $product->setSmallImage($product->getImage());
if (!$product->hasThumbnail()) $product->setThumbnail($product->getImage());
$product->save();
}
Get productID from specific order in Magento
$order = Mage::getModel('sales/order')->load($order_id);$items = $order->getAllItems();$itemcount=count($items);$name=array();$unitPrice=array();$sku=array();$ids=array();$qty=array();foreach ($items as $itemId => $item){ $name[] = $item->getName(); $unitPrice[]=$item->getPrice(); $sku[]=$item->getSku(); $ids[]=$item->getProductId(); $qty[]=$item->getQtyToInvoice();}Magento addAttributeToFilter
Get all product collection with the below code:
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');Add different types of filters on collection. example shown below
// Equal To (eq)
$collection->addAttributeToFilter('status', array('eq' => 1));
// Not Equal To (neq)
$collection->addAttributeToFilter('visibility', array('neq' => 1));
// Greater Than (gt)
$collection->addAttributeToFilter('price', array('gt' => 3.99));
// Less Than (lt)
$collection->addAttributeToFilter('price', array('lt' => 3.99));
// Greater Than or Equal To (gteq)
$collection->addAttributeToFilter('price', array('gteq' => 4.99));
// Less Than or Equal To (lteq)
$collection->addAttributeToFilter('price', array('lteq' => 4.99));
// Contains (like) - also uses % wildcards
$collection->addAttributeToFilter('sku', array('like' => 'DVD%'));
// Does Not Contain (nlike) - also uses % wildcards
$collection->addAttributeToFilter('sku', array('nlike' => 'ABC%'));
// In Array (in)
$collection->addAttributeToFilter('id', array('in' => array(1,3,12)));
// Not In Array (nin)
$collection->addAttributeToFilter('id', array('nin' => array(1,2,12)));
// Is NULL (null)
$collection->addAttributeToFilter('description', 'null');
// Is Not NULL (notnull)
$collection->addAttributeToFilter('description', 'notnull');
display product in magento with sql in list.phtml file
Place this following code in your phtml file where you want to display particular category products this will return array of products and you can use this array to display product of particular category.
$sql = “SELECT product_id FROM catalog_category_product WHERE category_id=57″;
$data = Mage::getSingleton(‘core/resource’) ->getConnection(‘core_read’)->fetchAll($sql);
Display All Product Attribute in Mageto Shopping Cart
Open the location given below
note: path can differ according to templete
app\design\frontend\base\default\template\checkout\cart\item\default.phtml
use the Code below in default.phtml.
<?php
$product = Mage::getModel(‘catalog/product’)->load($this->getProduct()->getId());
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined()) {
$value = $attribute->getFrontend()->getValue($product);
if (strlen($value) && $product->hasData($attribute->getAttributeCode())) {
$data[$attribute->getAttributeCode()] = array(
‘label’ => $attribute->getFrontend()->getLabel(),
‘value’ => $value //$product->getData($attribute->getAttributeCode())
);
?>
<span style=”font-weight:bold;”><?php echo $data[$attribute->getAttributeCode()]['label']; ?></span>: <span><?php echo $data[$attribute->getAttributeCode()]['value']; ?></span>
<?php
}
}
}
?>
note: path can differ according to templete
app\design\frontend\base\default\template\checkout\cart\item\default.phtml
use the Code below in default.phtml.
<?php
$product = Mage::getModel(‘catalog/product’)->load($this->getProduct()->getId());
$attributes = $product->getAttributes();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined()) {
$value = $attribute->getFrontend()->getValue($product);
if (strlen($value) && $product->hasData($attribute->getAttributeCode())) {
$data[$attribute->getAttributeCode()] = array(
‘label’ => $attribute->getFrontend()->getLabel(),
‘value’ => $value //$product->getData($attribute->getAttributeCode())
);
?>
<span style=”font-weight:bold;”><?php echo $data[$attribute->getAttributeCode()]['label']; ?></span>: <span><?php echo $data[$attribute->getAttributeCode()]['value']; ?></span>
<?php
}
}
}
?>
Magento Image Switcher On MouseOver
Step1. open file on location given below
app/design/frontend/default/default/template/catalog/product/view/media.phtml
Step2. Search the code in media.phtml file
<a onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" href="#"> <!--nested img tag stays the same--></a>
Step 3. Replace searched code with code below.
<a title="<?php echo $_product->getName();?>" onmouseover="$('image').src = this.href; return false;" href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>"> <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" width="56" height="56" /></a>
app/design/frontend/default/default/template/catalog/product/view/media.phtml
Step2. Search the code in media.phtml file
<a onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" href="#"> <!--nested img tag stays the same--></a>
Step 3. Replace searched code with code below.
<a title="<?php echo $_product->getName();?>" onmouseover="$('image').src = this.href; return false;" href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>"> <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" width="56" height="56" /></a>
Subscribe to:
Posts (Atom)