Changing Core data for Magento programmatically - magento

I am currently working on a live website, but the trouble is they would like to switch theme so what I would like to install the new theme and only make it viewable by my ip address.
The trouble is I do not know how to change the Magento theme and skin values programmatically.
Could any of you help me out here?

So this is not a direct answer. Best practices are going to be to back up your database, and system, and restore to a development environment files and database.
Edit the two entries for each store in the core_config_data table to change the url from the live site to the dev site url.
Then develop your new or modified theme on the dev site and deploy the files to the live server when you are ready to push your changes.
There could be an alternative way to do this. You could make a new store in on your Magento install See How to Make Multiple Stores and then copy the theme folder to your development them name directory. And finally configure the new/dev store to use your dev theme.
Both of these are viable options. Trying to trick Magento to serve one theme to your IP and another to everyone else seems like asking for trouble.

This can be done with no modifications to the Magento core.
It involves Chrome and setting your user agent as something custom.
First off, create an exception in Magento - we'll set the matched expression as dev and set the package to new-theme. This will set your package as new-theme if your user-agent matches dev (will serve the theme located in app/design/frontend/new-theme:
Then the second and final step is to open your Developer Toolbar in Chrome and set your user-agent as dev:
Take these 2 easy steps and you can programatically set your theme package only for yourself without affecting others.

You can do it with
Mage::getSingleton('core/design_package')->setTheme('default');
For the implementation just create a block that loads on all pages and add it to the constructor.
XML would be something like that:
<layout version="0.1.0">
<default>
<reference name="content">
<block type="kervin/theme" name="kervin.theme"/>
</reference>
</default>
</layout>
and theme.php, the block would be:
class My_Kervin_Block_Theme extends Mage_Core_Block_Template
{
public function __construct()
{
if ($_SERVER["REMOTE_ADDR"] == 'xxx') {
Mage::getSingleton('core/design_package')->setTheme('default');
}
}
}

Related

Static block not showing up in CMS page

I just started working on magento/admin. I am trying to show my static block in one of my CMS pages, but it is not working. I tried to find out answer in google and stack exchange but no luck! Can anyone please help.Thanks.
Below are details:
This is my static block
This is my CMS page: I am able to see the text "Yes!" though.
Final output: That blue box is my CSS. (jfyi).
If you use the latest Magento version 1.9.2.2 that includes the latest patches, then you need to add first the block to Magento white list in teh backend: System->Permissions->Block.
See this article: http://www.dudesquare.nl/blog/2015/10/31/static-block-shortcodes-not-working-1-9-2-2/
Please set different identifier in static block than CMS page. I think CMS page and block identifier same so may be block not display on CMS page.
Also select all store views in static block may be your store is wrong.
And finally remove all cache and refresh all index.
Please check following:
Whether you had editor enabled, while calling static block. If yes, please click on Show/Hide Editor button and check what code is there in text area while editor mode off.
If above does not work, then go to System >> Configuration >> Advanced (Developer) and under Log Settings, Enable Logs. Then refresh cms page in frontend.
I hope this will help you resolve your issue. Please let me know if you find any problem.
Try to add static blocks through Layout Update XML in CMS Pages use something like this code. Add this code in your CMS page design tab.
<reference name="content">
<block type="cms/block" name="block.name">
<action method="setBlockId">
<block_id>block_id</block_id>
</action>
</block>
</reference>
Solution:
Step 1)Go to admin.
Step 2)Open Top menu System->Permissions->Blocks.
Step 3)click "Add New Block".
write your "Block Name" and Is Allowed "Yes".
Note: Block Name is type of your block for example "cms/block"
after Save Block.
Step 4)Clear cache and refresh front page. Now Block is showing.
Done.

Payment fields missing from Authorize.net checkout method

This is a pretty strange issue. If I enable the Authorize.net payment method, the input fields to enter your CC details is missing from HTML. This is a pretty much out of the box installation with just some theme work having been done, and I didn't touch the opc templates.
If I enable Saved CC payment method, the fields appear correctly.
I did not make any changes to the OOTB Authorize.net files in Magneto and even tried disabling my entire theme and it doesn't have any impact.
Screenshot of code:
http://cl.ly/image/3g1n2x021N2s
After looking into this more, it looks like this line in templates/checkout/payments/method.phtml is not returning any HTML:
$this->getPaymentMethodFormHtml($_method)
I found this method and it in-turn is trying to load a child.
public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method)
{
return $this->getChildHtml('payment.method.' . $method->getCode());
}
That is about how far I have gotten.
I would try the following steps:
Check your exception log under /var/log/exception.log
Check your PHP error log
Disable your current theme by renaming your theme folder eg: /app/design/frontend/default/themename >> /app/design/frontend/default/_themename - this rules out the possibility of invalid theme/layout XML issues. Make sure it falls back to an untouched base default theme!
Disable your non-standard extensions by setting <active>false</active> in the XMLs found under /app/etc/modules one by one.
Try see if there is a difference in value $method->getCode() when saved CC is turned on & off.
If possible, update the Authorize.net extension. If not, at least check if your /app/etc/modules/Mage_Authorizenet.xml is as follows:
<config>
<modules>
<Mage_Authorizenet>
<active>true</active>
<codePool>core</codePool>
<depends>
<Mage_Paygate/>
<Mage_Sales/>
<Mage_Checkout/>
</depends>
</Mage_Authorizenet>
</modules>
</config>
This is a workaround if you don't find any solution for your problem.
You can create your own payment form for authorize.net
Authorize.net form used cc.phtml file for display Authorize.net fields so you can copy this file and set this form from xml.
Go to your checkout.xmland in <checkout_onepage_index translate="label"> tag find checkout.payment.methods which display all methods put action methods something like this
<action method="setMethodFormTemplate"><method>authorizenet</method><template>payment/form/authorizenet.phtml(which is copy of your cc.phtml)</template></action>
I have not test it.
Authorize.net use this block for display form fields so further you can look into this file
app\code\core\Mage\Paygate\Block\Authorizenet\Form\Cc.php
You can also check if Mage_Authorizenet or Mage_Paygate module are disabled in your Magento admin.
System -> ADVANCED -> Advanced
Make sure that they are enabled there.

Magento: Incorrect template design for login and register page due to Persistent Shopping Cart

I am using Magento 1.7.0.2 and my login and register page design has problem. It is not taking the template path from my custom theme. Instead, it is taking the template path from base persistent folder.
For example, the login template path is taken from
frontend/base/default/template/persistent/customer/form/login.phtml instead of
frontend/default/MY_THEME/template/customer/form/login.phtml
It’s strange how this persistent folder come into action.
I try below things also
1) Copy the persistent folder from design base directory to your custom theme directory. And then modify the design on the files you copied.
2)Disable the persistent shopping cart feature. You can do this from :
System -> Configuration -> CUSTOMERS -> Persistent Shopping Cart -> General Options -> Enable Persistence = No
3)directly disable the module by editing the file: app/etc/modules/Mage_Persistent.xml by setting active = false.
Also did Refresh my Magento cache and also browser cache!
Is there any other solution or suggestion that i have to applied other then this?
Waiting for your kind response.
Copy login.phtml from frontend/base/default/template/persistent/customer/form/ to frontend/default/MY_THEME/template/persistent/customer/form/ (You have already done this)
Clear the Magento CACHE. Even your browser cache.
If still doesn't shows up, then check the folder path. If you have placed it correctly, it should show the Theme Template path in the hints. There is no bug in Magento which causes this kinda problem.
Make sure the Theme where you have copied the persistent login.phtml is the Theme that you are using in design settings.
Copy your template from frontend/default/MY_THEME/template/customer/form/login.phtml to frontend/default/MY_THEME/template/persistent/customer/form/Login.phtml, then refresh your Cache. Now the changes you did to the Login.phtml should be loaded.
Sometimes a module can overwrite the template used for the login form. And maybe you are missing the template files. You should check for layout xml handles like:
<customer_account_login>
<reference name="customer_form_login">
<action method="setTemplate"><template>template/name.phtml</template></action>
</reference>
</customer_account_login>
Another thing you should check is if the block used for the login is the core one because again a template override may happen from a module.

Magento Multi Store themes calling same login.phtml file

I'm new to magento. Currently i'm developing two ecommerce sites using multi-store option in magento. Both the sites are 90% over, last night when i planned to customize the login page i was shocked. The reason is the changes made in first store login page also reflecting in second store also. The login page is curently calling from
frontend/default/default/template/persistent/customer/form/login.phtml
Is it possible to give any custom login page? PLz guide me magento experts......
Please update your post with your frontend/ folder structure down to each theme template folder. It might be that you don't have a copy of login.phtml in the second theme. Moreover you should follow templates best practices as:
Always create for a new shop different packaga. So not
frontend/default
but
frontend/yourcustompackage
Always have default theme left as much untouched, as possible. So in the
frontend/package/default
Should be some basic changes and rules of your package. It means for example in the putting reset.css for all of your themes. Or something like this.
As for me, each store view should have own theme. So, for example, storeview1
frontend/package/storeview1/
There you copy and change files specific for this theme. So, for example, in default you might have login.phtml. But you want storeview1 to have another login.phtml and in storeview2 it should be the same as in default. Therefore you copy the login.phtml from default to storeview1 and change it there. Don't forget to change package and theme in System->Configuration->Design. Package should be change for whole shop and theme should be specified for every store view or left untouched for default.
P.S. Magento theme fallbacks
P.P.S. Try this tutorial or google another one
P.P.P.S. I hope, you got the answer for your question.

Custom block in magento

I have added this block in checkout.xml:
<block type="checkout/cart_shipping" name="checkout.cart.shipping" as="shipping" template="checkout/cart/shipping.phtml"/>
Then, I have shown this in cart.phtml:
echo $this->getChildHtml('shipping');
Then, I have made a page as shipping.phtml file in cart folder. This is working on my local PC, but when I follow this path on the server no block is showing. There is one difference between the two environments: on local I am doing all this step in the base folder, but on the server there is a customized theme folder in the default folder.
Can anyone tell me where I am wrong?
Thanks in advance.
Check design's configuration on server, is this theme really loaded.
Make sure that you added the XML correctly (without any typos). A typo in the XML would probably cause Magento to load the default checkout.xml instead of your custom one, losing your block changes.

Resources