“It's not at all important to get it right the first time. It's vitally important to get it right the last time.” - Andrew Hunt and David Thomas
Friday, 11 July 2014
Tuesday, 8 July 2014
Magento Call Java script Function in XML Top links.
<reference name="top.links">
<action method="addLink" translate="label title" module="smartproductfinder">
<label>Smart Product Finder</label>
<title>javascript:void(0)</title>
<prepare/><aParams/>
<position>10</position>
<li/><a>data-reveal-id="myModal"</a>
</action>
</reference>
<action method="addLink" translate="label title" module="smartproductfinder">
<label>Smart Product Finder</label>
<title>javascript:void(0)</title>
<prepare/><aParams/>
<position>10</position>
<li/><a>data-reveal-id="myModal"</a>
</action>
</reference>
Magento Display Dropdown For Quntity Box
In the addtocart.phtml file find the following code(line 33)
<input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" />
Replace with this code:
This code shows the “Available Qty for Product”.
<select class="input-text qty" name="qty" id="qty">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()) ?></select>
This code shows the “Maximum Qty Allowed in Shopping Cart”.
<select class="input-text qty" name="qty" id="qty">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i ?>">
<?php echo $i ?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMaxSaleQty()) ?>
</select>
<input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" />
Replace with this code:
This code shows the “Available Qty for Product”.
<select class="input-text qty" name="qty" id="qty">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()) ?></select>
This code shows the “Maximum Qty Allowed in Shopping Cart”.
<select class="input-text qty" name="qty" id="qty">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i ?>">
<?php echo $i ?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMaxSaleQty()) ?>
</select>
Magento Add Date Filed In Admin Form
Step-1 Add the following code in app/code/local/YourNamespace/YourModule/Block/Adminhtml/Yourmodule/Edit/Tab/Form.php
$fieldset->addField('purchase_date', 'date', array(
'label' => Mage::helper('subscription')->__('Purchase Date'),
'name' => 'purchase_date',
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
));
Step-2 Now the date field with a datepicker is displayed in your admin form. To save the value into database, you need to add a line of code in saveAction() function of app/code/local/YourNamespace/YourModule/controllers/YourModuleController.php
if ($data = $this->getRequest()->getPost()) {
$data = $this->_filterDates($data, array('purchase_date', 'expiry_date'));
$model = Mage::getModel('subscription/subscription');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
Hope it helps. Thanks.
$fieldset->addField('purchase_date', 'date', array(
'label' => Mage::helper('subscription')->__('Purchase Date'),
'name' => 'purchase_date',
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
));
Step-2 Now the date field with a datepicker is displayed in your admin form. To save the value into database, you need to add a line of code in saveAction() function of app/code/local/YourNamespace/YourModule/controllers/YourModuleController.php
if ($data = $this->getRequest()->getPost()) {
$data = $this->_filterDates($data, array('purchase_date', 'expiry_date'));
$model = Mage::getModel('subscription/subscription');
$model->setData($data)
->setId($this->getRequest()->getParam('id'));
Hope it helps. Thanks.
Subscribe to:
Posts (Atom)