• Setting up the web configuration on local.xml instead of DB in Magento

    Posted on October 13, 2012 by Nimrod Techn

    First of all, why? why setting up the web configuration on the local.xml, when Magento's default setting is DB?

    We would prefer to set up the web configuration on the local.xml, in case we use CDN / several servers that use the same DB.

    In that case, only 1 address (let it be js/css or base url) is configured, when we actually need 2-3 or more.

     

    The solution would be, to have the addresses on the local.xml of each one of the server  instances.

    How do we set this up?

    Go to app/etc/local.xml and add the following lines:

     <stores>
           <STORECODE1>
    		<web>
    			<unsecure>
    				<base_url>http://www.your-server-instance.com/</base_url>
    				<base_web_url>{{unsecure_base_url}}</base_web_url>
    				<base_link_url>{{unsecure_base_url}}</base_link_url>
    		       </unsecure>
    			<secure>
    				<base_url>https://www.your-server-instance.com/</base_url>
    				<base_web_url>{{secure_base_url}}</base_web_url>
    				<base_link_url>{{secure_base_url}}</base_link_url>
    		       </secure>
    	       </web>
            </STORECODE1>
           <STORECODE2>
    		<web>
    			<unsecure>
    				<base_url>http://www.your-server-instance.com/</base_url>
    				<base_web_url>{{unsecure_base_url}}</base_web_url>
    				<base_link_url>{{unsecure_base_url}}</base_link_url>
    		       </unsecure>
    			<secure>
    				<base_url>https://www.your-server-instance.com/</base_url>
    				<base_web_url>{{secure_base_url}}</base_web_url>
    				<base_link_url>{{secure_base_url}}</base_link_url>
    		       </secure>
    	       </web>
            </STORECODE2>
       </stores>
        <default>
            <web>
                <unsecure>
                    <base_url>http://www.your-server-instance.com/</base_url>
                    <base_web_url>{{unsecure_base_url}}</base_web_url>
                    <base_link_url>{{unsecure_base_url}}</base_link_url>
                    <base_js_url>{{unsecure_base_url}}js/</base_js_url>
                    <base_skin_url>{{unsecure_base_url}}skin/</base_skin_url>
                    <base_media_url>{{unsecure_base_url}}media/</base_media_url>
                </unsecure>
                <secure>
                    <base_url>https://www.your-server-instance.com/</base_url>
                    <base_web_url>{{secure_base_url}}</base_web_url>
                    <base_link_url>{{secure_base_url}}</base_link_url>
                    <base_js_url>{{secure_base_url}}js/</base_js_url>
                    <base_skin_url>{{secure_base_url}}skin/</base_skin_url>
                    <base_media_url>{{secure_base_url}}media/</base_media_url>
                </secure>
            </web>
        </default>
    </config>

    Replace STORECODE1 / STORECODE2 with the actual store codes you use.
    Replace  http://www.your-server-instance.com/ with your URL addresses.

    Second step, you have to remove from the DB table core_config_data everything that begins with web/secure AND web/unsecure.
    If you don't, Magento will continue taking our addresses from the DB (as always, the DB is the "strongest"). Remove the cache, and try to start your application.

     

    Bear in mind, the <stores> section isn't mandatory - if you have just one instance and wish to start the default website, you can copy only that section and everything will work out just fine.


    This post was posted in Core

  • Allowing permissions for a customized Magento extension

    Posted on October 13, 2012 by Nimrod Techn

    Assuming we have developed the following extension to Magento admin panel:

    app/code/local/Engineering/Custommodule/

    And we can actually use it in the admin panel, but when we would like to set the permissions - we go to System -> Permissions -> Users, and try to give the right permissions to our users.

    However, it doesn't seem to work, and the non-administrator users will not be able to view the extension (lack of permissions).

     

    To solve this, we would create a new adminhtml.xml file in app/code/local/Engineering/Custommodule/etc/

     

    Inside the file, we will have the following code:

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
    	<menu>
    		<cms> //change to whatever tab you want
    			<children>
    				<custommodule translate="title" module="custommodule">
    					<title>Custom Module</title>
    					<action>custommodule/adminhtml_custommodule</action>
    				</custommodule>
    			</children>
    		</cms>
    	</menu>
    	<acl>
    		<resources>
    			<admin>
    				<children>
    					<cms>
    						<children>
    							<custommodule translate="title">
    								<title>Custom Module</title>
    								<sort_order>0</sort_order>
    							</custommodule>
    						</children>
    					</cms>
    				</children>
    			</admin>
    		</resources>
    	</acl>
    </config>

    This post was posted in Writing a Magento Extension

  • Allowing/Disallowing file extensions upload in the Magento admin panel CMS editor

    Posted on October 12, 2012 by Nimrod Techn

    Basically, in order to allow certain file extensions to be uploaded via the
    CMS editor, we would need to override the normal config configuration.
    As you probably know, all the config.xml files in Magento are gathered together everytime the
    system runs, and the overriden files (local) take priority over those in the core.
    Thus, we can create an extension, or add the following lines to one of our current extensions
    config.xml file (inside the config tag):
    <adminhtml>
    <cms>
            <browser>
    	            <extensions>
                        <allowed>
                            <jpg>1</jpg>
                            <jpeg>1</jpeg>
                            <png>1</png>
                            <gif>1</gif>
    			<pdf>1</pdf>
                        </allowed>
                        <image_allowed>
                            <jpg>1</jpg>
                            <jpeg>1</jpeg>
                            <png>1</png>
                            <gif>1</gif>
    			<pdf>1</pdf>
                        </image_allowed>
    		    </extensions>
    	</browser>
    </cms>
    </adminhtml>
    This is how we define all the file extensions to be allowed.
    In case we would like to disallow jpg files from being uploaded, we would do this:
    <jpg>0</jpg>
    in both places.

    This post was posted in Core

Items 10 to 12 of 22 total

Page:
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. ...
  8. 8
Magento is a well-engineered eCommerce platform designed to help engineers develop customized eCommerce online stores. Due to lack of proper coding documentation, Engineer-ing.com was created with the sole purpose of instructing Magento developers to-be with the "how-to-do" know-how. In the event of unresolved issues, you are more than welcome to contact me for consultation. However, please do so only if you possess a Software Engineering background and you're able to specify your question.