Magento - Adminhtml - Default website in new customer form - magento

I am developing an online store for my customer and, we only have one website in our Magento setup.
In the admin panel when I go to Add a customer screen, in the "Associate to Website" field I see "Admin" selected by default. I would like to have my website there by default.
I think one possible way would be to write some code in:
Mage_Adminhtml_Block_Customer_Edit_Tab_Account::initForm

The cleanest way to do this is the just set the default value in your database. This will require no code changes at all.
UPDATE eav_attribute
SET default_value = 1
WHERE attribute_code = 'website_id'
The sample MySQL statement above sets your default website_id to 1.

Or You can simply edit array in:
Mage_Customer_Model_Customer_Attribute_Source_Website::getAllOptions()

I took the hint from Lrrr's answer and populated the drop-down with only user added websites, that is "Please Select" and "Admin" are no more available as options there by adding the following line:
$form->getElement('website_id')->setValues(Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm());
at the end of this function:
Mage_Adminhtml_Block_Customer_Edit_Tab_Account::initForm
The ideal way would be of course to override the above function in one's own module, but in our case overriding the above class creates conflict for another extension that we have installed, so I took this way round.

Related

Joomla Get menu id from names

I am in joomla 2.5 and I try to get the id of a menu, I have the name, the alias
exemple :
menu = FAQ-> menu item =FAQ
I have try :
$app = JFactory::getApplication('site');
$params = $app->getParams();
$idfaq = $params->get('content_id_faq');
but i am a newbie so I dont even know if content_id_faq is correct
thanks
Have a look at here for more information on how to get the correct item.
There is no guarantee that either the menu item alias or the article alias must be unique within either the #__menu or #__content table, they just need to be unique within that menu-parent item branch or the category, respectively. Since you are making something custom for a specific site you could modify the queries in the other answer to reflect this; I would do that rather than assuming no one in the future is ever going to use the same aliases. Of course you could write a plugin to basically make those aliases reserved words. Also in your code I would force that to cache so you aren't constantly doing that query.

is it possible to remove zip/postal code field in magento

is it possible to remove zip/postal code field depending on country chosen in the address section of the checkout page in Magento?
e.g. when a user chooses 'Ireland' the field disappears on the fly.
thanks
Dave
In the admin panel there is an option to make zip code optional for specific countries:
System-> Configuration -> General -> Countries Options -> "Postal Code is Optional for the following countries"
Select your specific countries which you want to make optional.
If this isn't enough with a some basic modification you should be able to make the field invisible as well.
In your theme (don't modify the existing themes), copy js/opcheckout.js and modify that.
Add your observer to the zipcode fields. The best is to hide the zipcode, as the client-side validation won't fire then.
If you would like some code to get you started, I can post that in an edit.
Magento hasn't anything built-in yet. You have to wrote some javascript to do that and, of course, control this flow into Magento Core classes.
on Magento 1.7.0.2
first you have to remove 'required-entry' on zipcode field (you can use jquery to remove class)
then
go to Mage_Checkout_OnepageController
on saveBillingAction() method
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);
$result = array() // clear error message;
and then on saveShippingAction() method
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
$result = array() // clear error message;
hope works!!

Changing Views in a Module pops me into the Admin Skin

This question has probably been the most covered question in all of DotNetNuke's lifetime but I'm going to ask it here in StackOverflow because I need an answer, a really good one that doesn't make me look the other way. Thanks in advance to all DNN experts.
I've researched many ways of making this work for me and i've seen Michael Washington's solutions (Panels, MultiViews, ...) and Will's (Strohl) blog post on DotNetNuke's personalization engine through setting SkinSrc which is useful, as well as reading through Default.aspx's code which has given me more insight, however, i'm still faced with the problem that calling EditUrl()/NavigateUrl() brings me to a page with a single module in admin skin or a page with nothing respectively.
The specific version is DotNetNuke 6.0.1 (DNN). This Module has 4 other views in addition to the main view which I desire to navigate through sequentially. e.g.
Begin Checkout -> Collection of Delivery Details -> Confim Order
Have you found a solution?
I want to achieve
1) Module loads with other modules around. No module isolation
2) Views in a module that don't Preload e.g. Page_Load in each view gets called when the Module loads up
Help!
Assuming you are asking this as the module developer, the solution is to not use DNN's mechanism for specifying a control. So, you can't use EditUrl or specify the ControlKey in the NavigateURL call (which both generate "ctl=mycontrol" in the URL). Instead you need to have your module display your various controls based on the Query String parameters. So, you'll generally have a control in your module who's primary purpose is to dynamically load other controls based on the query string. So, for instance:
You will start with your control that lists items. You'll have a "Buy Now" button for each item. The hyperlink for each item can be generated by calling
NavigateURL(TabID, "", "View=BeginCheckout", "itemid=" & id, "mid=" & mid)
2.) On the page load of the handler control, it looks to see if anything is specified for the "View" Querystring parameter. If not it displays the listing control, if so, it displays the corresponding control.
Dim controlPath As String
Dim path as String = "~/DesktopModules/MyModule/Controls"
Select Case Request("View")
Case "BeginCheckout"
ControlPath = path + "BeginCheckout.ascx"
Case "DeliveryDetails"
ControlPath = path + "DeliveryDetails.ascx"
Case "ConfirmOrder"
ControlPath = path + "ConfirmOrder.ascx"
Case Else
ControlPath = path + "ItemList.aspx"
End Select
If System.IO.File.Exists(Request.MapPath(controlPath)) Then
placeholder.LoadControl(controlPath)
Else
Throw New Exception("Unable to load selected template. Please go into module settings and select a list and details template.")
End If
Most of the advanced modules for DNN do something along these lines so there's plenty of sample code out there. I would guess some of the core modules do something similar. I adapted the code above from Efficon's Articles module for DotNetNuke.

Magento saving a product option for an attribute with a dropdown type

I have written code that automatically imports products basically something like:
$product->setName('my name');
$product->save();
This is fine for free fill text boxes, but how would I go about setting say manufacturer, which is a drop down menu? Is there also a way that if the option doesnt exist, then it will automagically add it?
Thanks
This is tested in 1.5.0.1, you just need to target the correct attribute ID. As #B00MER stated, the attribute will not be created that you are targetting but if the attribute exist, this will create the options.
$eav_entity_setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$new_option['attribute_id'] = $id;
$new_option['value']['_custom_'.$value][0] = $value;
$eav_entity_setup->addAttributeOption($new_option);
Documentation about addAttributeOption can be found here.
http://freegento.com/doc/d0/d7b/_eav_2_model_2_entity_2_setup_8php-source.html#l00603
You will need to create the functionality yourself unfortunately. And by default Magento will not 'automagically' create a option if one doesn't pre-exist.
To simply set the ID of the value you want (Say Sony was ID 12) you can do:
$product->setData('mfr', '12');
However you may find a lot more insight here on steps to do what your looking for:
http://www.arscommunity.com/wiki/magento/configurable-products-creation-code

Displaying specific content to specific user in Joomla 1.5

To be short, It's a website for an investigations lab.
I need to display specific content (lab report) to specific user. Users will be given a username and a password when leaving and will be asked to login on the website to access his/her report with the credentials given to him.
So , it's a "specific content" for "specific user" - Moving to 1.6 is not an option.
I have a solution in mind but involve a lot of core hacking and will take some time ... If any one been in a similar situation or have an idea in mind I would appreciate your help.
Ok, this can be done but it's going to take a little trickery to get there. First, you are going to need a way to post the lab reports and associate them with a user. I would use K2 for this since you can add the report as an attachment to an item. You can also add extra fields to K2, which would be the next step. You'll need an extra field where you can enter a user ID number that you will use to determine if a user is allowed to view the content.
There are several steps you will need to take to now filter the content so only the associated user can see it.
You will need to get the user ID once the user is logged in:
$user =& JFactory::getUser();
$usr_id = $user->get('id');
You'll need a menu item that links to a K2 Category where all the lab reports go.
You'll need a subtemplate with a modified category_item.php for that category that only displays the associate reports:
if($this->item->extra_fields[USER_ID_EXTRA_FIELD_NAME]==$usr_id){
all the category item stuff
}
You'll need a subtemplate with a modified item.php for the category that again blocks users other than the associated user, basically the same code as #3 to either display the content or an error message.
The only other way I can think of that you can accomplish this would be to use an ACL component with a group for each user.
The K2 method with subtemplates would not require any core hacks and will work with a little work.
You can achieve what you want with Flexicontent http://www.flexicontent.org/ and Flexiaccess
Flexicontent is a K2 type component and I use them interchangeably. With Flexiaccess you can create items that are only available to certain users.
No hacks required.
Bad News: That cant be done with standard Joomla 1.5 (without hacking)
Good News: You can use one of the free or commercial Extensions for Joomla to accomplish that. I would suggest for example:
Admin-User-Access
http://extensions.joomla.org/extensions/access-a-security/backend-a-full-access-control/9040
Or you can search for yourself:
http://extensions.joomla.org/extensions/access-a-security/backend-a-full-access-control

Resources