RSS

Magento: How to get attribute name and value?

/**
* get attribute collection
*/
$attribute = $_product->getResource()->getAttribute(‘my_attribute’);
/**
* get attribute type
*/
$attribute->getAttributeType();
/**
* get attribute Label
*/
$attribute->getFrontendLabel();
/**
* get attribute default value
*/
$attribute->getDefaultValue();
/**
* check if the attribute is visible
*/
$attribute->getIsVisible();
/**
* check if the attribute is required
*/
$attribute->getIsRequired();
/**
* get attribute value
*/
$attributeValue = Mage::getModel(‘catalog/product’)->load($_product->getId())->getMyAttribute();

 

Get value from a select box attribute

The attribute code is supposed to be ‘my_attribute

Load any particular attribute by attribute code

Get all option value list for the particular attribute

You can see above that I got attribute information by attribute code. My attribute information is stored as $attributeInfo. See code above.

Here is the code to get all option values for my attribute $attributeInfo.

Get all options of any attribute

Getting all options of attribute with attribute-code “color“.

Get attribute’s option information by option id

I have my attribute as $attributeInfo.
I have my attribute’s option value array as $attributeOptions.
See code above.

Suppose, I want to get detail information of any option listed in strong>$attributeOptions array. Here is the code to do so:-

Get attribute of particular entity type

Here, I am going to get information about ‘order_id‘ attribute of ‘invoice‘ entity type.

Get attribute options of Configurable product

Hope this helps. Thanks.

soruce From:http://blog.chapagain.com.np/magento-how-to-get-attribute-name-and-value/

 
Leave a comment

Posted by on July 2, 2015 in magento

 

Disable HTML Right-click, Copy & Paste using Javascript

//below javascript is used for Disabling right-click on HTML page
document.oncontextmenu=new Function(“return false”);//Disabling right-click

//below javascript is used for Disabling text selection in web page
document.onselectstart=new Function (“return false”); //Disabling text selection in web page
if (window.sidebar){
document.onmousedown=new Function(“return false”);
document.onclick=new Function(“return true”) ;

//Disable Cut into HTML form using Javascript
document.oncut=new Function(“return false”);

//Disable Copy into HTML form using Javascript
document.oncopy=new Function(“return false”);

//Disable Paste into HTML form using Javascript
document.onpaste=new Function(“return false”);
}

http://teqsnacks.com/2014/01/27/disable-html-copy-paste-javascript/
http://www.ondeweb.in/disable-right-click-and-copy-paste-using-javascript/

 
Leave a comment

Posted by on July 2, 2015 in Javascript

 

PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap

PHP Quiz Application Using jQuery Ajax MySQL and Bootstrap

 
Leave a comment

Posted by on January 2, 2015 in PHP

 

Create api categories and sub categories

<?php
//http://www.brenelz.com/blog/how-to-create-a-simple-api-with-php-and-mysql/
//isc_shopping_comparison_categories
//Create Database connection
header(‘Content-Type: application/json’);
include’conn.php’;

$sql = mysql_query(“select * from isc_categories where catparentid=0”);
// parent categories node
$categories = array(“Categories” => array());

//print_r($categories);

while ($row = mysql_fetch_array($sql,MYSQL_ASSOC)) {
$cat_id = $row[‘categoryid’];
//print_r($row);
$ssql = mysql_query(“select * from isc_categories where catparentid=’$cat_id'”);

// single category node
$category = array(); // temp array
$category[“categoryid”] = $row[“categoryid”];
$category[“name”] = $row[“catname”];
$category[“sub_categories”] = array(); // subcategories again an array

while ($srow=mysql_fetch_array($ssql,MYSQL_ASSOC)) {
$subcat = array(); // temp array
$subcat[“categoryid”] = $srow[‘categoryid’];
$subcat[“name”] = $srow[‘catname’];
// pushing sub category into subcategories node
array_push($category[“sub_categories”], $subcat);
}

array_push($categories[“Categories”], $category);

//print_r($category);

}echo ((isset($_GET[‘callback’])) ? $_GET[‘callback’] : “”) . ‘(‘ . json_encode($categories) . ‘)’;

?>

 

3rd leval categories

 

<?php

header(‘Content-Type: application/json’);
include’conn.php’;

$sql = mysql_query(“select * from isc_categories where catparentid=0 and catvisible=’1′”);
// parent categories node
$categories = array(“Categories” => array());

//print_r($categories);

while ($row = mysql_fetch_array($sql,MYSQL_ASSOC)) {
$cat_id = $row[‘categoryid’];
//print_r($row);
$ssql = mysql_query(“select * from isc_categories where catparentid=’$cat_id'”);

// single category node
$category = array(); // temp array
$category[“categoryid”] = $row[“categoryid”];
$category[“name”] = $row[“catname”];
$category[“sub_categories”] = array(); // subcategories again an array

while ($srow=mysql_fetch_array($ssql,MYSQL_ASSOC)) {
$subcat = array(); // temp array

$sid=$srow[‘categoryid’];
$subcat[“categoryid”] = $srow[‘categoryid’];
$subcat[“name”] = $srow[‘catname’];

$subcat[“sub_categories_3rd”] = array();
// $subcat[“sub_categories_3rd”] = array(‘Front’, ‘Rear’ );
$ssql12 = mysql_query(“select * from isc_categories where catparentid=’$sid'”);
while ($srow1=mysql_fetch_array($ssql12,MYSQL_ASSOC)) {
$subcat_3rd = array(); // temp array
$subcat_3rd[“categoryid”] = $srow1[‘categoryid’];
$subcat_3rd[“name”] = $srow1[‘catname’];
array_push( $subcat[“sub_categories_3rd”], $subcat_3rd);

}

/*$tssql = mysql_query(“select * from isc_categories where catparentid='”.$srow[‘categoryid’].”‘”);

while ($tsrow=mysql_fetch_array($tssql,MYSQL_ASSOC)) {
$thirdsub = array(); // temp array
$thirdsub[“status”] = $tsrow[‘catname’];

} array_push( $subcat, $thirdsub);
*/

// pushing sub category into subcategories node
array_push($category[“sub_categories”], $subcat);
}

array_push($categories[“Categories”], $category);

//print_r($category);

}echo ((isset($_GET[‘callback’])) ? $_GET[‘callback’] : “”) . ‘(‘ . json_encode($categories) . ‘)’;

?>

 

 

 

http://www.9lessons.info/2012/07/ecommerce-menu-design-with-json-data.html

http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

 
Leave a comment

Posted by on November 24, 2014 in Javascript

 

How to create JSON using data from MySQL database

http://www.techrecite.com/how-to-create-json-using-data-from-mysql-database/

http://www.techrecite.com/how-to-create-json-using-data-from-mysql-database/
http://www.thesoftwareguy.in/read-and-write-json-file-with-php-and-mysql/
http://jacksiva.blogspot.in/2011/08/create-json-file-using-php-from-mysql.html
http://krasimirtsonev.com/blog/article/MySQL-vs-JSON-file-data-storing-benchmark-results

How To Generate JSON With PHP from Mysql and Parse It With JQuery

 

 
Leave a comment

Posted by on November 21, 2014 in json

 

convert year or month into days, PHP

$lastdate=Authlite::instance()->get_user()->define_dat;

$currentDate = date(‘Y-m-d H:i:s’);

$ct = strtotime($currentDate);
$ct2 = strtotime(‘0 days’, $ct);
echo $ccurrentDate = date(‘r’, $ct2) . PHP_EOL;

$dateString = $lastdate;
$t = strtotime($dateString);
$t2 = strtotime(‘+365 days’, $t);
$endDate = date(‘r’, $t2) . PHP_EOL;
echo “Package will be exired on : “. date(‘r’, $t2) . PHP_EOL;

if($endDate >= $ccurrentDate) {
echo”
“;
echo”Hello”;
} else {
echo”Bye”;
}

 

http://stackoverflow.com/questions/13821427/convert-year-or-month-into-days-php

http://stackoverflow.com/questions/2191573/php-convert-timestamp-to-months-and-days

http://stackoverflow.com/questions/18269556/php-date-add-1-year-to-current-date

 
Leave a comment

Posted by on November 18, 2014 in PHP

 

JQUERY FRACTION SLIDER

http://jacksbox.de/stuff/jquery-fractionslider/

 
Leave a comment

Posted by on November 13, 2014 in slider

 

Magento database maintenance

Log cleaning

Magento maintains several tables for logging. These tables log things such as customer accesses and frequently-compared products. Magento has a mechanism for cleaning these logs regularly, but unfortunately, this feature is disabled by default and most customers do not enable it. There are three ways to clean out these tables: via log cleaning in the Magento Admin, via log.php in the ../shell directory, and manually via phpMyAdmin or MySQL client.

The following tables are managed by Magento’s log cleaning function:

log_customer

log_visitor log_visitor_info
log_url log_url_info
log_quote
report_viewed_product_index
report_compared_product_index
report_event catalog_compare_item
Log cleaning via administrator interface
  • From the Magento administrator interface, go to System > Configuration.
  • In the left menu under Advanced, click System.
  • Under Log Cleaning, change Enable Log Cleaning to Yes and configure the Save Log for 15 days:
log_cleaning01
  • Click Save Config

 

Manual cleaning via phpMyAdmin

This is the most efficient way to clean the logs for those more comfortable working with databases. It is faster than the built-in Magento tools and it allows you to clean other tables not included in those tools. This procedure will consolidate the data inside those tables, often decreasing database size by as much as 95% and greatly reducing query times.

  1. Open the database in phpMyAdmin via the SiteWorx control panel.
  2. In the right frame, select the check box for the following tables:
dataflow_batch_export
dataflow_batch_import
log_customer
log_quote log_summary
log_summary_type
log_url log_url_info
log_visitor log_visitor_info
log_visitor_online
report_viewed_product_index
report_compared_product_index
report_event
log_cleaning02
  • At the bottom of the page, click the drop-down box With Selected and select Empty.
  • A confirmation screen will appear. Click Yes. This will truncate all of the selected tables.
  • Click the Structure tab at the top of the page.
  • Select the same tables as you did in step 2, then under the With Selected drop-down menu, select Optimize.

Regular maintenance

It is not unusual to see 2GB+ databases decrease their size by 75% after cleaning the logs. It is therefore critical to regularly perform this sort of maintenance, particularly if your time-to-first-byte latency begins increasing and you have already implemented the other performance tweaks.

http://eaccelerator.net/

 
Leave a comment

Posted by on November 11, 2014 in magento

 

5 Star Rating plugin in PHP Script with Ajax

5 Star Rating plugin in PHP Script with Ajax

 
Leave a comment

Posted by on November 3, 2014 in Javascript

 

Fade In and Fade Out Effect Using css On main div

<style>
.main:hover .imgclass,.main:hover .left,.main:hover .right
{

opacity: 1.0;
transition: opacity .5s ease-in-out;
-moz-transition: opacity .5s ease-in-out;
-webkit-transition: opacity .5s ease-in-out;

}

.right
{
width:180px;
float:left;

opacity: 0.70;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-webkit-transition: opacity 1s ease-in-out;
margin: 0px 0px 0px 10px;
/* right: 1000; */
text-align: right;}

.left
{
width:200px;
float:left;
opacity: 0.70;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-webkit-transition: opacity 1s ease-in-out;
margin: 0 0 0 10px;}

.imgclass
{

opacity: 0.70;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-webkit-transition: opacity 1s ease-in-out;
}

/*img {
opacity: 0.6;
transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-webkit-transition: opacity 1s ease-in-out;
}
img:hover {
opacity: 1.0;
transition: opacity .55s ease-in-out;
-moz-transition: opacity .55s ease-in-out;
-webkit-transition: opacity .55s ease-in-out;
}*/

.main
{
width:430px;
}

</style>
<div class=”main”>

<a href=”#”><img class=”imgclass” src=”http://www.adworldsmedia.com/wp-content/themes/adworldmedia/img/p1.png&#8221; />
<div style=”border:2px solid #C5BDBE;width:430px;float:left;”>
<div class=”left”><h2>Test Here</h2></div> <div class=”right”><h2>right text Here</h2></div>
</div>
</a>

</div>

 
Leave a comment

Posted by on October 29, 2014 in css