Magento if tax is not included on configurable product

Posted on Updated on

if tax are not included on configurable product, You have to check following attributes if query does not include them itself.

tax_percent
tax_class_id

$products = Mage::getResourceModel(‘catalog/product_collection’);
$products->addAttributeToFilter(‘type_id’, array(‘eq’ => ‘configurable’));
$products->addAttributeToFilter(‘status’, 1);
$products->addAttributeToFilter(‘visibility’, 4);
$products->addAttributeToSelect(‘sku’);
$products->addAttributeToSelect(‘name’);
$products->addAttributeToSelect(‘description’);
$products->addAttributeToSelect(‘short_description’);
$products->addAttributeToSelect(‘url’);
$products->addAttributeToSelect(‘image’);
$products->addAttributeToSelect(‘price’);
$products->addAttributeToSelect(‘special_price’);
$products->addAttributeToSelect(‘manufacturer’);
$products->addAttributeToSelect(‘category_ids’);
$products->addAttributeToSelect(‘gender’);
$products->addAttributeToSelect(‘tax_percent’);
$products->addAttributeToSelect(‘tax_class_id’);

foreach ($products as $product) {
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();

//Original Price with Tax
echo number_format(Mage::helper(‘tax’)->getPrice($product, $product->getPrice()),2, ‘.’, ”).$currency_code;

//Special Price with Tax
$product_data[‘sale_price’] = number_format(Mage::helper(‘tax’)->getPrice($product, $product->getSpecialPrice()),2, ‘.’, ”).$currency_code;

}

Advertisements

Remove specific folders and files from ubuntu trash

Posted on Updated on

sudo rm -r /home/username/.local/share/Trash/foldernametoremove/your folder name or file

 

Remove all in Trash

sudo rm -r /home/udana/.local/share/Trash/files/*

Create a Product Attribute and Select Options in Magento

Posted on

1. Create a Setup file in your module.

2. Add attribute and options as follows. You can remove the attribute from remove codes as follows

$installer = $this;
$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);
$installer->startSetup();

//Create Attribute
$installer->addAttribute(‘catalog_product’, ‘basic_color’, array(
‘group’             => ‘General’,
‘type’              => ‘text’,
‘backend’           => ”,
‘frontend’          => ”,
‘label’             => ‘Basic Color’,
‘input’             => ‘select’,
‘class’             => ”,
‘source’            => ”,
‘global’            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
‘visible’           => true,
‘required’          => false,
‘user_defined’      => false,
‘default’           => ”,
‘searchable’        => false,
‘filterable’        => false,
‘comparable’        => false,
‘visible_on_front’  => false,
‘unique’            => false,
‘apply_to’          => ”,
‘is_configurable’   => false,
‘used_in_product_listing’ => true,
‘sort_order’        => 500,
));

//Add initial basic color options
$initialOptions = array(‘black’,’blue’,’green’,’red’,’grey’,’white’,’rose’,’yellow’,’purple’);
$entityTypeId     = $installer->getEntityTypeId(‘catalog_product’);
$code =’basic_color’;
$attributeId = Mage::getSingleton(‘eav/config’)->getAttribute(‘catalog_product’, ‘basic_color’)->getId();
foreach($initialOptions as $k=>$v){
$installer->addAttributeOption(array(
‘attribute_id’ => $attributeId,
‘order’ => array($k),
‘value’ => array(array($v)
)
));

}

//Remove
//$setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’);
//$setup->removeAttribute( ‘catalog_product’, ‘basic_color’ );

$installer->endSetup();

Get date in Magento way

Posted on

Friday 14th of June 2013 06:29:10 PM

Following will be given the above format of date

Mage::getModel(‘core/date’)->date(‘l jS \of F Y h:i:s A’);

Get the stock status of Magento Configurable Product

Posted on Updated on

Here is a way you can get the stock status of Magento Configurable Products collection.

$products = Mage::getResourceModel(‘catalog/product_collection’);
$products->addAttributeToFilter(‘type_id’, array(‘eq’ => ‘configurable’));
$products->addAttributeToFilter(‘status’, 1);
$products->addAttributeToFilter(‘visibility’, 4);

foreach ($products as $product) {
$stockStatus = Mage::getModel(‘cataloginventory/stock_item’) ->loadByProduct($product)->getIsInStock();
print ($stockStatus);
}

Magento – How to create a your own dropdown for system configuration

Posted on Updated on

We can use our own system configurations in magento. Creating a drop down on our own manageable way of code will be benefited. Followings are the steps you could follow. This is only the way of magento. There are other methods too

1. Create your own module or use your existing module and Create a system configuration file
2. Add system configuration as follows

<sample_config_select translate=”label”>
<label>sample label</label>
<frontend_type>select</frontend_type>
<sort_order>1</sort_order>
<sort_order>100</sort_order>
<source_model>sample/select</source_model>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<tooltip>adds select</tooltip>
</sample_config_select>

3. create options. we follow the way of magento structure or use your own.

class YourPackage_Module_Model_Sample
{

public function toOptionArray()
{
return array(
array(‘value’ => 0, ‘label’ => Mage::helper(‘adminhtml’)->__(‘select option 1’)),
array(‘value’ => 1, ‘label’ => Mage::helper(‘adminhtml’)->__(select option 2′)));
}

}

4. See the Configuration in Admin

Sending Emails with Zend_Mail and Yahoo! SMTP

Posted on Updated on

When developers are trying to test emails with popular email service providers from the local server environments, it does not allow to send emails since they try to impose restrictions on spamming. Followings can be used to test email contact forms with Zend Framework and its mail function. It is tested and worked fine with yahoo SMTP settings but on zend framework. Here the trick was setting from email as same as the authenticated email address.

//values from  zend form elements
$sender = $form->getValue(‘name’);
$email = $form ->getValue(’email’);
$subject = $form ->getValue(‘subject’);
$message = $form ->getValue(‘message’);

$mail = new Zend_Mail();
$config = array(‘auth’ => ‘login’,’username’ => ‘your_e_mail@yahoo.com’,’password’ => ‘your_password’);
$transport = new Zend_Mail_Transport_Smtp(‘smtp.mail.yahoo.com’, $config);

$mail->setSubject($subject);
$mail->setFrom(‘your_e_mail@yahoo.com’, $sender); //should be the same email used for config
$mail->setReplyTo($email, $sender);
$mail->addTo(‘your_e_mail@yahoo.com ‘, ‘webmaster’);
$mail->setBodyHtml(’email body text in html’);
$mail->setBodyText(’email body text in text’);
$mail->send($transport);

——————————————————-

cheers! 🙂