1. Get Second Maximum Salary In mysql.
SELECT * FROM `employee` WHERE salary = ( SELECT MAX( salary ) FROM employee WHERE salary < (SELECT MAX(salary) FROM employee)
1. Get Second Maximum Salary In mysql.
SELECT * FROM `employee` WHERE salary = ( SELECT MAX( salary ) FROM employee WHERE salary < (SELECT MAX(salary) FROM employee)
Java Script
<script>
function selected(obj){
var lilist = document.getElementById(‘menu’);
var alist = lilist.getElementsByTagName(‘a’);
for (i=0; i<alist.length; i++ )
{
alist[i].className=””;
}
obj.className=”red”;
}
</script>
Style
<style>
.red {
color:red;
background:#F39;
width:150px;
}
HTML
<ul id=”menu”>
<li><a href=”#” onClick=”selected(this)”>Home</a></li>
<li><a href=”#” onClick=”selected(this)”>About Us</a></li>
<li><a href=”#” onClick=”selected(this)”>Our Products</a></li>
<li><a href=”#” onClick=”selected(this)”>Trade Offers</a></li>
<li><a href=”#” onClick=”selected(this)”>Contact Us</a></li>
</ul>
Jquery Include
<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>
2. Thumbnail Image
<?php the_post_thumbnail();?>
<?php the_post_thumbnail(‘thumbnail’); ?>
<?php the_post_thumbnail(‘medium’); ?>
<?php the_post_thumbnail(‘large’); ?>
<?php the_post_thumbnail(‘full’);?>
<?php the_post_thumbnail( array(100,100) );?>
3. Get Template Url
<?php get_template_directory(); ?>
<?php get_template_directory_uri(); ?>
<?php
$all_categories = get_categories( ‘taxonomy=product_cat&hide_empty=0&hierarchical=1’ );
foreach ($all_categories as $cat) {
//print_r($cat);
if($cat->category_parent == 13) {
$category_id = $cat->term_id;
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, ‘thumbnail_id’, true );
$image = wp_get_attachment_url( $thumbnail_id );
/*echo ‘<a href=”‘. get_term_link($cat->slug, ‘product_cat’) .'”><div>’. “Read more” .'</div></a>’;*/
?>
<li style=”width: 183px;”>
<div>
<h3><?php echo $cat->name; ?></h3>
<div><img src=”<?php echo $image; ?>” alt=”<?php $cat->name; ?>” width=”120″ height=”120″ /></div>
<p><?php echo $cat->description;?></p>
<?php echo ‘<a title=”Edit Product” href=”‘.get_term_link($cat->slug, ‘product_cat’).'”>Read More</a>’; ?>
</div>
</li>
<?php
}
}?>
app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php
find line
$method->setPrice($shippingPrice);
and put following code above that line
$session = Mage::getSingleton(‘checkout/session’);
$quote_id = $session->getQuoteId();
$item_quote = Mage::getModel(‘sales/quote’)->load($quote_id);
$shippingPrice = $item_quote->getSubtotal()*($this->getConfigData(‘price’)/100);
Put the code in place of where add to cart is now:
<?php echo $this->helper(‘checkout’)->formatPrice($_product->getFinalPrice()) ?>
<form action=”<?php echo Mage::getBaseUrl(); ?>checkout/cart/add/” method=”post” style=”display:block; clear:both;”>
<?php
$product = Mage::getModel(‘catalog/product’);
$product->load($_product->getId());
//print_r($product);
//exit();
$xml = “”;
$hasAtts = 0;
// configurable products
$productType = $product->getTypeId();
if($productType == “configurable”) {
// configurable products
$attValConfig = $product->getTypeInstance()->getConfigurableAttributesAsArray();
if(sizeof($attValConfig)) {
$hasAtts++;
foreach($attValConfig as $attValConfigSingle) {
$xml .= “<div class=’floatoption1′>”.$attValConfigSingle[‘frontend_label’].”: “;
$xml .= “<select style=’display:block; clear:both; margin-bottom:10px;’ name=’super_attribute[“.$attValConfigSingle[‘attribute_id’].”]’><option selected=’selected’>Choose an option</option>”;
foreach($attValConfigSingle[‘values’] as $attValConfigSingleVal) {
$baseprice = $this->getPriceHtml($product, true);
$strippedprice = str_replace(“£”, “”, $baseprice);
$numprice = strip_tags($strippedprice);
$numpricea = (float)$numprice;
$optionprice = $attValConfigSingleVal[‘pricing_value’];
$numpriceb = (float)$optionprice;
$catprice = $numpricea + $numpriceb;
$catpricea = number_format($catprice,2);
if (is_numeric($numpriceb)) {
$xml .= “<option value='”.$attValConfigSingleVal[‘value_index’].”‘>”.$attValConfigSingleVal[‘label’].” £”.$catpricea.”</option>”;
} else { $xml .= “<option value='”.$attValConfigSingleVal[‘value_index’].”‘>Not Mumeric</option>”; }
}
$xml .= “</select></div>”;
}
}
}
// end configurable products
$attVal = $product->getOptions();
if(sizeof($attVal)) {
$hasAtts++;
foreach($attVal as $optionVal) {
$xml .= “<div class=’floatoption1′>Size:<select style=’display:block; clear:both; margin-bottom:10px;’ name=’options[“.$optionVal->getId().”]’><option selected=’selected’>Choose an option</option>”;
foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
$xml .= “<option value='”.$valuesVal->getId().”‘>”.$valuesVal->getTitle().” +”.Mage::helper(‘core’)->currency($valuesVal->getPrice()).”</option>”;
}
$xml .= “</select></div>”;
}
}
$xml .= “<div class=’floatoption2′>Qty: <input style=’display:block; clear:both; margin-bottom:20px;’ id=’qty’ class=’input-text qty’ type=’text’ value=’1′ maxlength=’12’ name=’qty’/></div>”;
echo($xml);
?>
<input type=”hidden” name=”product” value=”<?php echo($_product->getId()); ?>” />
<div>
<button type=”submit”><span><span><?php echo $this->__(‘Add to Cart’) ?></span></span></button></div>
</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>
UPDATE `eav_attribute` SET `default_value` = ‘container1′ WHERE `eav_attribute`.`attribute_code`=’options_container’;
UPDATE `eav_attribute` SET `default_value` = ‘1’ WHERE `eav_attribute`.`attribute_code`=’is_active’;
UPDATE `eav_attribute` SET `default_value` = ‘1’ WHERE `eav_attribute`.`attribute_code`=’is_anchor’;
UPDATE `eav_attribute` SET `default_value` = ‘1’ WHERE `eav_attribute`.`attribute_code`=’status’;
UPDATE `eav_attribute` SET `default_value` = ‘0’ WHERE `eav_attribute`.`attribute_code`=’weight’;
UPDATE `eav_attribute` SET `default_value` = ‘2’ WHERE `eav_attribute`.`attribute_code`=’tax_class_id’;
insert into core_config_data values ( null, ‘default’, 0, ‘cataloginventory/item_options/is_in_stock’, 1 );
insert into core_config_data values ( null, ‘default’, 0, ‘cataloginventory/item_options/qty’, 10 );
Pre-populate the incremented new SKU to the SKU field by JavaScript.
Open /app/design/adminhtml/default/default/template/catalog/product/edit.phtml and add the following code to the bottom of the file:
<?php
$dbread = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);
$sql = $dbread->query(“SELECT * FROM catalog_product_entity ORDER BY created_at DESC LIMIT 1″);
$res = $sql->fetch();
?>
<script type=”text/javascript”>
if(document.getElementById(‘sku’).value == “”){
document.getElementById(‘sku’).value = <?php echo (int)$res[“sku”] + 1; ?>;
}
</script>
Note:Read the SKU (must be an integer) of the last added product.
Increment the SKU by 1.
<?php
Mage::app();
Mage::getSingleton(‘core/session’, array(
‘name’ => ‘frontend’
));
$_productCollection = Mage::getResourceModel(‘catalogsearch/advanced_collection’)-> addAttributeToSelect(Mage::getSingleton(‘catalog/config’)-> getProductAttributes())->addMinimalPrice()->setPageSize(1)->addStoreFilter();
Mage::getSingleton(‘catalog/product_status’)->addVisibleFilterToCollection ($_productCollection);
Mage::getSingleton(‘catalog/product_visibility’)->addVisibleInSearchFilterToCollection ($_productCollection);
$todayDate = date(‘m/d/y’);
$tomorrow = mktime(0, 0, 0, date(‘m’), date(‘d’) + 1, date(‘y’));
$tomorrowDate = date(‘m/d/y’, $tomorrow);
$_productCollection->addAttributeToFilter(‘special_from_date’, array(
‘date’ => true,
‘to’ => $todayDate
))->addAttributeToFilter(‘special_to_date’, array(
‘or’ => array(
0 => array(
‘date’ => true,
‘from’ => $tomorrowDate
),
1 => array(
‘is’ => new Zend_Db_Expr(‘null’)
)
)
), ‘left’)->addAttributeToSort(‘special_from_date’, ‘desc’);
?>
<?php
$i = 0;
if ($i++ % 3 == 0)
?>
<ul>
<?php
$x = 2;
?>
<?php
foreach ($_productCollection as $_product) {
if ($_product->getData(‘special_price’) != null) {
?>
<li>
<h2><?php
if ($locale == en_US) {
echo $this->__(‘Special Offers’);
} else if ($locale == el_GR) {
echo $this->__(‘Προσφορές’);
} else {
echo $this->__(‘Special Offers’);
}
?></h2>
<img src=”<?php
echo $this->helper(‘catalog/image’)->init($_product, ‘thumbnail’)->resize(135);
?>” alt=”<?php
echo $_product->getName();
?>” width=”135″ height=”135″ />
<?php
$specialPrice = $_product->getData(‘special_price’);
$orignalPrice = $_product->getData(‘price’);
?>
<?php
}
}
?>