Magento – Delete System Attribute

If you want to delete an attribute. But there is no delete option while you edit the attribute. This means that the attribute is system attribute. System attributes cannot be deleted. Only user defined attributes can be deleted.

To delete the attribute, you have to make it user defined. Follow the below instructions :

– Go to phpmyadmin
– Select magento database
– Go to eav_attribute table
– Browse table with attribute_code ‘YOUR_ATTRIBUTE_CODE’ OR browse the table with the attribute_id of your attribute (‘your attribute’ means the attribute which you want to remove as system attribute)
– Edit the table row of your attribute
– Find the field ‘is_user_defined’
– Set it to 1

Now your attribute no longer remains System Attribute
Now you can delete it from Attribute manager

Magento – Delete System Attribute

delete system attribute, magento system attribute

Magento – Show Inventory Levels on Product Pages

One of our client needed to display their actual quantity on hand inventory, rather that the normal ‘Availability-In Stock’. on product detail page. For this you need to look on this file.

app/design/frontend/YOURTEMPLATE/default/template/catalog/product/view/type/default.phtml

If you do not have the above in the directory then you should copy that from the base folder and put in custom template. Approach the below code :

<?php if ($_product->isAvailable()): ?>
<?php $quantity1 = intval(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()); ?>
<div class=”add-to-box”>
<?php if($quantity1 > 0) { ?>
<p class=”availability in-stock”>
<?php echo $this->__(‘Qty on Hand:’) ?>
<?php echo $quantity1;?>
</span>
</p>
<?php } elseif($quantity1 == 0) { ?>
<p class=”availability in-stock”>
<?php echo $this->__(‘Qty on Hand:’) ?><br/><br/><span>
<?php foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
$stock = intval(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($simple)->getQty());
echo $simple->getName().” “.$simple->getSize().” have a stock of $stock”;
echo ‘<br/>’;
} ?></span>
</p>
<?php } ?>
</div>
<?php else: ?>
<p class=”availability out-of-stock”><?php echo $this->__(‘Availability:’) ?> <span><?php echo $this->__(‘Out of stock’) ?>

Fatal Error Declaration Of Zend Pdf FileParserDataSource File __construct in magento

If you will get this issue on magento while printing invoice pdf

Fatal Error: ‘Declaration of Zend_Pdf_FileParserDatasource_File::__contruct() must be compatible with Zend_Pdf_FileParderDatasource::__construct() in /…/lib/Zend/Pdf/FileParserDataSource/File.php

Then here is the simple solution.

Replace

abstract public function __construct();

to

abstract public function __construct($filePath);

in /lib/Zend/Pdf/FileParserDataSource.php

How to check home using php in magento

How to check home using php in magento.

<?php $is_homepage = Mage::getBlockSingleton(‘page/html_header’)—>getIsHomePage();
if($is_homepage) { ?>

You are in home page!!

<?php } ?>

Display product list on home page in magento

Use below code in CMS — > Home page content area

For all products

{{block type=”catalog/product_list” template=”catalog/product/list.phtml”}}

For New products

{{block type=”catalog/product_new” name=”home.catalog.product.new” alias=”product_homepage” template=”catalog/product/new.phtml”}}

All Products from one Category

{{block type=”catalog/product_list” category_id=”5″ template=”catalog/product/list.phtml”}}

htaccess for magento in subdirectory

htaccess for magento in subdirectory

Steps
1. Install Magento to /public_html/magento/ normally. Do not change Base URL during installation.
2. Copy /public_html/magento/.htaccess to /public_html/.htaccess
3. Copy /public_html/magento/index.php to /public_html/index.php
4. Edit /public_html/index.php line 32 to read:
$mageFilename = ‘magento/app/Mage.php’;
5. Log into Magento Admin. Go to System > Configuration > Web
6. Under Unsecure change Base Link URL to http://domain.com/

Now you finished!! But if you unable to load magento connect
system->magento connect->magento connect manager

then you need to add your ‘subfolder’ after ‘YourDomain.com’ in the address bar, after you select Magento Connect Manager from the dashboard.

http://www.YOURDOMAIN.COM/SUBFOLDER/downloader/

How To Show Page for Particular User Group In Magento

Show Page for Particular User Group In Magento

<?php
////Check if User is Logged In
$login = Mage::getSingleton(‘customer/session’)->isLoggedIn();
if($login){
//Get Customers Group ID
$groupId = Mage::getSingleton(‘customer/session’)->getCustomerGroupId();
//My wholesale customer id was 2
if($groupId == 2){
echo “wholesale Customer”;
}else{
echo “Not a wholesale Customer”;
}
}
?>

Get current category ID on category page in magento

Get current category ID and name on category page in magento.

We used this code :

<?php echo Mage::getModel(‘catalog/layer’)->getCurrentCategory()->getName(); ?>
<?php echo Mage::getModel(‘catalog/layer’)->getCurrentCategory()->getId(); ?>

Get create account url in magento

If you want to add create “Register” or “Create an account” link in top navigation section then simply open customer.xml file in layout folder and you have to put below code in <customer_logged_out> area

<action method=”addLink” translate=”label title” module=”customer”><label>Creat an acoount</label><url helper=”customer/getRegisterUrl”/><title>Creat an acoount</title><prepare/><urlParams/><position>9</position><liParams/><aParams>id=”register”</aParams></action>

Remove Price Display from Customs Options on Single Products in the Product View in Magento

To sort out this problem simply do below:

1) Open app/design/frontend/default/your theme/template/catalog/product/view/price_clone.phtml

2) Comment out the below code:

<?php echo $this->getPriceHtml($_product, false, ‘_clone’) ?>

like this

<? /* php echo $this->getPriceHtml($_product, false, ‘_clone’) */ ?>