Magento - Product by country using IPaddress - magento

I want to add a radio button with the following option
Show product in
> United States
> International
> Both
Upon selection the product will show on the front end for the appropriate customers using IP detection
I google it and i found one plugin
http://www.magentocommerce.com/magento-connect/Vinay.N+%28+Tumkur%2CKethohalli%29/extension/2413/product-by-ipaddress
But it is not compatible with Magento ver. 1.5.0.1. Please help. Thanks

Setup two websites for your shop, where 'website' does not have to mean a different URL, just, internally for Magento it is a 'website'. For this example use codes 'usd' and 'row'.
Use GeoIP in Apache if you can install packages on your distro. If not then you can use PHP geoip plugins - again see what is recommended for your setup.
To send your customers to what Magento thinks is a website, with the site visitor not knowing they have been 'redirected'. In your index.php you will need something like:
$country=$_SERVER['GEOIP_COUNTRY_CODE'];
switch ($country)
{ case "CA":
case "MX":
case "US":
$_SERVER['MAGE_RUN_CODE'] = "usd";
$_SERVER['MAGE_RUN_TYPE'] = "website";
break;
default:
$_SERVER['MAGE_RUN_CODE'] = "row";
$_SERVER['MAGE_RUN_TYPE'] = "store";
}
Mage::run($_SERVER['MAGE_RUN_CODE'], $_SERVER['MAGE_RUN_TYPE']);
For your products, in the website tab, select the websites that you want the product to show in. Put a tick in both boxes or just one depending on how it is to show.
This will be easy to update compared to a 'hacked' solution.
Update.
The sleekest way to run GeoIP is as an apache module. Here is the link to the instructions and download:
http://www.maxmind.com/app/mod_geoip
If installing an Apache module is not possible due to shared hosting or operating system flakiness then the PHP module can be used instead. Full instructions and download for geoIP can be found here:
http://www.maxmind.com/app/php
Once installed swap out $country=$_SERVER['GEOIP_COUNTRY_CODE']; for the following:
include("geoip/geoip.inc");
// Uncomment if querying against GeoIP/Lite City.
// include("geoipcity.inc");
$gi = geoip_open("/your/path/to/geoip/GeoIP.dat",GEOIP_STANDARD);
$country=geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);
More help on GeoIP is available from the above links.

Related

CAPTCHA does not look like the way it should in my contact form in Joomla

I'm new to Joomla and recently I've tried a lot to enable captcha for my contact forms and I've done all the steps to do it. (enabling captcha in Plugins,global configuration and user manager) but after all I just see this in my form:
*Security Code(Captcha)
and the code itself and the textfield to enter the captcha code are not displayed.
what should I do??? As I said I'm new to Joomla please explain step by step. By the way my site's language is Persian(Although it is not important)
this is how my form looks like after enabling captcha:
My form after enabling CAPTCHA
After 24 hours of searching on the net finally I found the answer.
Under the site's Home directory You must go to:
public_html -> plugins -> captcha -> recaptcha
and open the file named recaptcha.php.
Search for the pieces of code mentioned bellow and make the following changes:
change
const RECAPTCHA_API_SERVER = "http://api.recaptcha.net";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
To
const RECAPTCHA_API_SERVER = "http://www.google.com/recaptcha/api";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
const RECAPTCHA_VERIFY_SERVER = "www.google.com";
and also change
$response = $this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/verify"
To
$response = $this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify"
Then save and reload your page. it's done.
Don't forget that this is needed in Joomla 2.5 where the version of RECAPTCHA is 1.0 if your Joomla is a newer version you don't need to change anything just enable RECAPTCHA.

How to properly override a core JS file in Magento2

We are attempting to override the behavior of Bundle Products in Magento2, specifically, to enable user defined quantities for Checkbox type products within the bundle.
We have written an extension, and followed instructions about how to replace a default JS component found here: http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/javascript/custom_js.html
Our requirejs-config.js within our extension's frontend (app/code/Endertech/BundleExtended/view/frontend/) view looks like:
var config = {
"map": {
"*": {
'Magento_Bundle/js/price-bundle': "Endertech_BundleExtended/js/price-bundle"
}
}
};
This is having the effect of loading BOTH the core Magento2 price-bundle.js AND our modified version... and the customization we've added to our modified version is not executing... presumably because the Magento2 core version is loading first.
We expected for this revision to PREVENT the core version from loading in favor of ours.
Perhaps we are approaching the problem from the wrong direction, or have some other misunderstanding.
We are seeking a solution to have our modified price-bundle.js be loaded in lieu of the built-in that comes in the Magento Bundle module... or at least a way to override specific methods within and is required here (vendor/magento/module-bundle/view/frontend/requirejs-config.js).
If our approach is wrong, we'd be happy to be corrected!

Magento - import - Get an error just after clic on save and continue to edit

My data was move from another server by the team who host my website ( www.whc.ca) and now when i go in the section:
system -> import/export -> CommerceExtension
when i open a import with out add any file just clicking save and continue i get this message:
Invalid POST data (please check post_max_size and upload_max_filesize settings in your php.ini file).
I don't get this from any other files in the system -> import/export
I talk with the guy how program this extension and he said that there is nothing in his program that bring this error.
The guys who doing the technical support on WHC do not know how to fix it. It was fix once when i was on the other server but there was no note about how it was fix.
some one made this for me: http://djinncomics.com/phpinfo.php
Can some one know what can cause that or where to look? true the Cpanel i already configure the limit and i modify the php file ether. nothing seem affect this error message.
I assume your import/export extension is certainly overloading some of Magento classes. I got the same error today and checked the code, here is what appear to be the problem, in file app/code/core/Mage/Adminhtml/controllers/System/Convert/ProfileController.php :
/**
* Save profile action
*/
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
...actions...
}
else {
Mage::getSingleton('adminhtml/session')->addError(
$this->__('Invalid POST data (please check post_max_size and upload_max_filesize settings in your php.ini file).')
);
$this->_redirect('*/*');
}
}
When you try to save an import/export profile and don't change any param, Magento will automatically assume that you have a problem with your server configuration, which is not the case.

Magento : How to hide the default Store View code from the url

The site has 2 languages: English and French, represented by 2 store views. French is the default one. For our SEO efforts we need to have the following urls:
French - http://www.domain.com/category/product
English - http://www.domain.com/en/category/product
System -> Configuration -> Web -> Add Store Codes to URL is the all or nothing setting. We just need to turn it off for the default store only.
I’ve done a lot of searching through the forums and wiki but there’s nothing on the subject.
Please any sugestions?
Finnaly i solved this magic probleme , i hope that's save others persone here is the details :
1- Download the zip existe in this page : https://github.com/Knectar/Magento-Store-Codes
2- unzip the file and put the folder called "Knectar" in {app/code/community/} and Knectar_Storecodes.xml file in {app/etc/modules}
3- In your backoffice go to "System > Tools > Compilation" and click the rebuild button
4- always in backoffice got to "System > Configuration > Web > URL options" and set the attribute "and default store view" to No and save the configuration
5- Clear your cach magento and enjoy your application :) .
I had the same problem and I have developed an extension for that.
It is available on GitHub: https://github.com/jreinke/magento-hide-default-store-code
I didn't find a quick solution to your problem, but I see that's possible through 2 steps :
1 / Using the advise commented by #user3154108 and trying this tip https://magento.stackexchange.com/questions/8126/store-code-in-url-for-every-store-view-except-for-default
2 / For SEO SITEMAP, it's possible to override the following file
app/code/core/Mage/Sitemap/Model/Sitemap.php
public function generateXml()
{
...
}
and replace the default store code by NULL.
For more details try to look at this post : http://alanstorm.com/generating_google_sitemaps_in_magento
I was having the same problem and I had already selected to not show store code in url in the config. I also didn't want to install an extension just to handle something this minor. Here's my EASY solution:
Copy app/code/core/Mage/Catalog/Block/Widget/Link.php to app/code/local/Mage/Catalog/Block/Widget/Link.php
Search for (line 91 in Magento 1.7.x / line 100 in Magento 1.9.x)
$this->_href = $this->_href . $symbol . "___store=" . $store->getCode();
And modify to
$this->_href = $this->_href;
Upload and save your changes and you'll now not have your widget (dynamically) inserted links getting appended with ?___store=default.
Credit: DesignHaven
Under System -> Configuration -> Web -> URL Options you
change "Add Store Code to Urls" to "NO" as on the attached screenshot

How to upload a file in joomla?

Hi i am making a simple component in joomla having name image detail and i have to upload that image how can i upload image from backend. which one is better using extension or make custom. can you please share any good article for it. i have searched many more but due to lack of idea on joomla cannot find. hope you genius guys help me.
thanks i advance
Joomla Component for the exact scenario of your requirement will be very hard to find out. So you've two options:
1. Make your own component
2. Customize other similar type of component like gallery component
For uploading file from joomla component on admin if you're making your own component:
1. Just use move_uploaded_file php function.
2. copy this code, for joomla's standard fxn :
function upload($src, $dest)
{
jimport('joomla.client.helper');
$FTPOptions = JClientHelper::getCredentials('ftp');
$ret = false;
$dest = JPath::clean($dest);
$baseDir = dirname($dest);
if (!file_exists($baseDir)) {
jimport('joomla.filesystem.folder');
JFolder::create($baseDir);
}
if ($FTPOptions['enabled'] == 1) {
jimport('joomla.client.ftp');
$ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
$dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/');
if (is_uploaded_file($src) && $ftp->store($src, $dest))
{
$ret = true;
unlink($src);
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
} else {
if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors
if (JPath::setPermissions($dest)) {
$ret = true;
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR01'));
}
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
}
return $ret;
}
If you want to use other's component and edit it according to need, download it:
http://prakashgobhaju.com.np/index.php?option=com_showcase_gallery&view=items&catid=1&Itemid=64
Remember it's a gallery component.
Uploading any file be it an image on your Joomla site is something which is so simple, and can be done using either the web based FTP and or the desktop FTP services like filezilla but only when you have saved the file you want to upload. Using the web based way, you need to log in to your host for example 000webhost, locate the file manager option, click on it and enter your domain username and password. Then go to public_html folder , create a new folder for your photos or images and click on upload. Locate your image and click on the tick link to start uploading.
Using the desktop way, you will need to unzip your file to add to joomla, open your FTP client like filezilla, locate the file on local host, input your log in details as provided by your host and once you are logged in to your account through filezilla, locate where you want to add the file and click on upload.
You can find a similar tutorial with regard here http://www.thekonsulthub.com/how-tos/how-to-upload-joomla-with-filezilla-to-your-hosting-servers-cpanel/ {entire thing}
Please please please make sure you use the filtering available in the MediaHelper. Specifically never trust uploaded images, always check first that they are valid file types, then that they are in the list of approved types of files listed in your global configuration, that the names do not contain html or javascript, and that the files themselves do not contain code. In particular I would recommend the MediaHelper::canUpload method which will check the majority of these things for you. If anything you should be checking even more strongly. Also make sure that you are checking whether the user has permission to upload. If anything you should make the checking even more restrictive. Use the APIs that joomla gives you, such as the built in media field.

Resources