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

http://www.smarttutorials.net/php-quiz-application-using-jquery-ajax-mysql-bootstrap/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+SmartTutorials+%28Smart+Tutorials%29

 
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
https://tournasdimitrios1.wordpress.com/2011/11/04/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

 
 
Follow

Get every new post delivered to your Inbox.