disable magento admin notification

This item was filled under [ magento ]

If you want totaly disable notifications do as follow:

1) Remove from app/design/adminhtml/default/default/layout/main.xml two lines:

<block type="adminhtml/notification_window" name="notification_window" as="notification_window" acl="system/adminnotification/show_toolbar" template="notification/window.phtml" />

and

<block type="adminhtml/notification_toolbar" name="notification_toolbar" as="notification_toolbar" acl="system/adminnotification/show_toolbar" template="notification/toolbar.phtml"></block>

2) Change following code in app/etc/modules/Mage_All.xml

<Mage_AdminNotification>
<
active>true</active>
<
codePool>core</codePool>
<
depends>
<
Mage_Core />
</
depends>
</
Mage_AdminNotification>

into

<Mage_AdminNotification>
<
active>false</active>
<
codePool>core</codePool>
<
depends>
<
Mage_Core />
</
depends>
</
Mage_AdminNotification> 阅读更多...
Bookmark and Share

快速范例入门

This item was filled under [ magento ]

Just like any new concepts, we know that without actually diving in and getting your hand dirty, you can never truly grasp what you’ve been explained in words. So here are a couple of exercises for you to get a feel for working with layouts. In order to work with this exercise, you must have the default Magento theme ready and accessible.

Exercise #1: In the category page, move the “My Cart” box from the right column to the left
  1. Turn on the Template Path Hint by going to the admin then navigating to System -> Configuration. When you’re in the configuration page, select the store you’re working in by using the top left website/store selector. Wait for the page to reload, then select the Developer tab. Select ‘Yes’ in the select box for Template Path Hints. Click on Save. Go back to the store front, and reload.
  2. When the page reloads, look at the template path of the ‘My Cart’ block- it’ll most likely say ‘frontend/default/default/template/checkout/cart/sidebar.phtml’. By looking at the path, you know this template is being introduced via the ‘checkout’ module. How do you know this? – frontend/default/default/template/checkout/cart/sidebar.phtml. It says so in the template path. The immediate directory name following ‘template’ is the name of the module through which a template is introduced.
  3. Open up layout/checkout.xml – because now we know we’re dealing with the checkout module
  4. Search for ‘checkout/cart/sidebar.phtml’ (the template name of the My Cart block) in the layout updates. You will find an area that looks like this:
    <reference name="right">
    <block type="checkout/cart_sidebar" name="cart_sidebar" before="-" template="checkout/cart/sidebar.phtml"/">
    </reference">
    Change it to say the following instead (Note that all you’re doing is changing the <reference name="right"> to <reference name="left">).
    <reference name="left">
    <block type="checkout/cart_sidebar" name="cart_sidebar" before="-" template="checkout/cart/sidebar.phtml"/">
    </reference">
  5. Reload the store front and you will now see the change reflected.
Exercise #2: Separate the SEO links at the footer area – Instead of having the link items to be one list, isolate ‘Advanced Search’ to be in the header instead.
  1. You can make a calculated assumption that the SEO links must be assigned somewhere in the layout under the footer block because it’s being pulled through ‘<?=$this->getChildHtml()?>’ of template/page/html/footer.phtml. (You will need the Template Path Hints turned on to see why this is obvious).
  2. Open up layout/page.xml and look through the list of children under the footer block in order to locate a block that calls the footer links – You will find <block name=”footer_links”>, which is what calls the SEO links. Now that you know that layout updates reference the SEO links via the name=”footer_links”, now you will do a search in all the xml files for <reference name=”footer_links”>. You will find references for the footer_links block in catalog.xml (which calls ‘Site Map’), catalogsearch.xml(which calls ‘Search Terms’ and ‘Advanced Search’) and contacts.xml (which calls ‘Contact Us’).
  3. Now that you’ve located the area of the individual SEO link items, you will now begin the steps to isolate ‘Advanced Search’ from the bunch and make it it’s own thing in the header. First go back to page.xml and create a new block <block type=”page/template_links” name=”header_links” as=”header_links” template=”page/template/links.phtml”/> and nest it inside <block name=”header”>. You’ve made the layout updates to expect this link in header.phtml. Open template/page/html/header.phtml, and type in <?=$this->getChildHtml('header_links')?> where you want the link to reside.
  4. Now I go to catalogsearch.xml, and cut this:
    <action method="addLink" translate="label title" module="catalogsearch"><label>Advanced Search</label><url helper="catalogsearch/getAdvancedSearchUrl" /><title>Advanced Search</title></action>
    out from <reference name="footer_links">.
    I create new lines to reference the new header_links block I created, and nest the cut out code inside it like so:
    <reference name="header_links">
    <action method="addLink" translate="label title" module="catalogsearch"><label>Advanced Search</label><url helper="catalogsearch/getAdvancedSearchUrl" /><title>Advanced Search</title></action>
    </reference>
  5. Now I have Advanced search in the header instead of the footer.

This marks the end of Designer’s Guide to Magento. Hopefully by now you’re armed with confidence and knowledge about how to approach designing with Magento. We hope to see some of your results up on the forum. Share with us your designs, discuss this documentation and ask lots of questions at the community forum’s ‘HTML, XHTML, CSS, Design Questions’ thread.

Bookmark and Share

magento 定制注册字段并添加到数据库

This item was filled under [ magento ]

Alright, we will be dealing with 3 files. So open each of the following up:

app/design/frontend/default/yourstore/template/customer/form/register.html – Has the HTML form
app/code/core/Mage/Customer/Model/Entity/Setup.php – Has an array full of customer attributes to use for registration
app/code/core/Mage/Customer/controllers/AccountController.php – Has a specific block of code for registration

Alright, for this little tutorial, we will do a couple of fields. The first one will be a text box asking the customer for their occupation/title.
Navigate to somewhere around line 54 of register.html – You should see this block of code:

<li>
<
div class="input-box">
<
label for="email_address"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br/>
<
input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
</
div>
</
li>

Now, we need to add our code for the occupation text box, so change that block of code to the following:

<li>
<
div class="input-box">
<
label for="email_address"><?php echo $this->__('Email Address') ?> <span class="required">*</span></label><br/>
<
input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" />
</
div>
<
div class="input-box">
<
label for="occupation"><?php echo $this->__('Occupation/Title') ?></label><br/>
<
input type="text" name="occupation" id="occupation" value="<?php echo $this->htmlEscape($this->getFormData()->getOccupation()) ?>" title="<?php echo $this->__('Occupation') ?>" class="input-text" />
</
div>
</
li>

Ok, if you refresh your create account (register) page, you will see the new field show up. Now, the fun part is getting that value into the database. Now, navigate to around line 78 in Setup.php – you should see this block of code:

'email' => array(
'type' => 'static',
'label' => 'Email',
'class' => 'validate-email',
'sort_order' => 6,
),

Now, we need to add our attribute to this file. So, change this block of code to:

'email' => array(
'type' => 'static',
'label' => 'Email',
'class' => 'validate-email',
'sort_order' => 6,
),
'occupation' => array(
'label' => 'Occupation',
'required' => false,
'sort_order' => 7,
),

Right under your occupation array, you will see the group_id one, etc. You need to increment the sort_order as they were doing before. So, since the sort_order for occupation is 7, make the one after it 8, and so on.

Now, head to line 164 of AccountController.php. You should see this block of code:

$customer = Mage::getModel('customer/customer')
->
setFirstname($this->getRequest()->getPost('firstname'))
->
setLastname($this->getRequest()->getPost('lastname'))
->
setEmail($this->getRequest()->getPost('email'))
->
setPassword($this->getRequest()->getPost('password'))
->
setConfirmation($this->getRequest()->getPost('confirmation'))
->
setId(null);

We need to add our new occupation attribute to this, so change the code to this:

$customer = Mage::getModel('customer/customer')
->
setFirstname($this->getRequest()->getPost('firstname'))
->
setLastname($this->getRequest()->getPost('lastname'))
->
setEmail($this->getRequest()->getPost('email'))
->
setOccupation($this->getRequest()->getPost('occupation')) //Add this
->setPassword($this->getRequest()->getPost('password'))
->
setConfirmation($this->getRequest()->getPost('confirmation'))
->
setId(null);

Now, our code is all set up and ready. However, we still need to add this attribute to the eav_attribute table in your mysql database. How do we do that? This block of code:

<?
$setup
= new Mage_Eav_Model_Entity_Setup('core_setup');
$attr2 = array (
'position' => 1,
'is_required'=>0 /* 0 if you want it to be a required field, 1 if not. Also, if required, add this class to the occupation input box on register.phtml class="required-entry input-text" */
);
$setup->addAttribute('1', 'occupation', $attr2);
?>

My suggestion is to add this block of code to the very top of your register.html file. You only need to load this block of code once, so add it to your register.html file, navigate to your register.html file, and then remove the block of code. If you go to your mysql database, view the eav_attribute table and do a search for occupation, you will see that your attribute has been added.

Now, go back to your create account page, fill it out, including your occupation, and bam your finished. If you need proof that it was added to the database, simply go to the customer_entity_varchar table and look for yourself smile

Also, to retrieve the customer data (as if you were in the account dashboard or something) you can call this function: getOccupation. I believe this works – if not, then hopefully someone else can provide this part of the code.

Thanks all!

Bookmark and Share