Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron error "Requested country is not available." #58

Closed
mikehenze opened this issue Aug 4, 2017 · 21 comments · Fixed by #174
Closed

Cron error "Requested country is not available." #58

mikehenze opened this issue Aug 4, 2017 · 21 comments · Fixed by #174
Assignees
Milestone

Comments

@mikehenze
Copy link

Cron ebizmarts_ecommerce outputs error:
Requested country is not available.

Version: 1.0.22
Magento: 2.1.7
Multiple storefronts (languages) and multiple Mailchimp Stores (1 list for each language).

@mamreezaa
Copy link

mamreezaa commented Aug 10, 2017

i have the same issue. when i run the cron.

[Magento\Framework\Exception\NoSuchEntityException] Requested country is not available.

in my case these are the country ids where this error occurred.

  1. /var/www/magento/vendor/magento/module-directory/Model/CountryInformationAcquirer.php:103: string(2) "GB"

  2. /var/www/magento/vendor/magento/module-directory/Model/CountryInformationAcquirer.php:103: NULL
    i think the problem is
    'vendor/mailchimp/mc-magento2/Model/Api/Customer.php:184'
    where mailchimp tried to get data from locale using store Id.

actually mailchimp module call this function
'vendor/magento/module-directory/Model/CountryInformationAcquirer.php:90'
which is using storeId to get the values.

After debugging this issue i did the following changes to make it work. This is a working solution, but i feel this is little slow.

Solution.
` public function __construct(
\Magento\Directory\Model\CountryFactory $countryFactory
) {
$this->_countryFactory = $countryFactory;
}

protected function _buildCustomerData(\Magento\Customer\Model\Customer $customer)
{
  ....
 if ($address->getCountry()) {
           $country = $this->_countryFactory->create()->loadByCode($address->getCountryId());
            $customerAddress["country"] = $country->getName();
            $customerAddress["country_code"] = $address->getCountryId();
        }
 .....
}`

@gonzaloebiz
Copy link
Collaborator

Thanks for the feedback.
Please see the associated commit.

Best

@mikehenze
Copy link
Author

mikehenze commented Aug 11, 2017

Hi, this does not fix the "Requested country is not available".
Maybe it should also be changed in:
mc-magento2\Model\Api\Subscriber.php

@gonzaloebiz
Copy link
Collaborator

Hi @mikehenze

if you have any ->getCountry() call in mc-magento2\Model\Api\Subscriber.php you must update the extension, because no calls to getCountry() in this file
Let me know

@gonzaloebiz gonzaloebiz reopened this Aug 11, 2017
@mikehenze
Copy link
Author

I see its all commented

// "country" => $address->getCountry() ? Mage::getModel('directory/country')->loadByCode($address->getCountry())->getName() : ""

@mamreezaa
Copy link

Hi @ALL

I think still the problem exist. i am looking into this now. :)

@mamreezaa
Copy link

@mikehenze did you try my solution ?
i did the same fix in Model/Api/Cart.php, Customer.php, Order.php
Now i don't see the issue.

Thanks.

@mikehenze
Copy link
Author

@mamreezaa
I am having trouble implementing your fix.
Do I need to edit:

  • vendor/mailchimp/mc-magento2/Model/Api/Customer.php
  • vendor/mailchimp/mc-magento2/Model/Api/Cart.php
  • vendor/mailchimp/mc-magento2/Model/Api/Order.php

And add:
\Magento\Directory\Model\CountryFactory $countryFactory
) {
$this->_countryFactory = $countryFactory;
}

to public function __construct
and add:
if ($address->getCountry()) {
$country = $this->_countryFactory->create()->loadByCode($address->getCountryId());
$customerAddress["country"] = $country->getName();
$customerAddress["country_code"] = $address->getCountryId();
}

to protected function _buildCustomerData ?

Maybe you can attach your versions ?

@mikehenze
Copy link
Author

@gonzaloebiz Please fix this issue because we need this extension to work soon.
Thanks

@mikehenze
Copy link
Author

After implementing commit "Add store id" everything works now.

@mikehenze
Copy link
Author

Magento 2.2.1
Mailchimp 1.0.25

Still getting issue "Requested country is not available."

Please tell me what to do.

@mikehenze mikehenze reopened this Dec 5, 2017
@gonzaloebiz
Copy link
Collaborator

Enable all the associated countries to customer, orders, etc.
If you have any problem, please open other issue

Best

@mikehenze
Copy link
Author

Yes that fixed it.
Can I disable the countries we have stopped shipping to after the sync has completed?

@gonzaloebiz
Copy link
Collaborator

I think

@tonytrinh206
Copy link

@mikehenze I got the same issue. Could you please show me how to fix it? I got Magento 2.1

@gonzaloebiz
Copy link
Collaborator

@tonytrinh206 look 4 comments above

@tonytrinh206
Copy link

Hi @gonzaloebiz, thank you for your response. Do you mean I have to allow all countries to my shipping and billing address during the first sync? I went through all of my orders and customers and they have the same US country which has already allowed on our shopping cart.

@mikehenze
Copy link
Author

Setting the sync date to after the date that you disabled certain countries does not fix it.
It will only sync with all countries enabled that have orders.
This is a problem.

@joshdavenport
Copy link

Yes, we disable countries because we no longer ship there or support those countries to any extent. Now for a sync we have to turn them on? This just confuses users, they'll think we now ship to that country again, but we don't.

@Tantuss
Copy link

Tantuss commented Jan 11, 2018

Ticket is closed, but issue is not solved.

Solution is written in comment by:
mamreezaa commented on 10 Aug 2017

Please apply this fix to the sources to get it working if you have disabled some countries where you was sending before to and now not anymore.

@robgt
Copy link

robgt commented May 4, 2018

I am still encountering this same error in Magento 2.1.6 with MC-Magento plugin version 1.0.27.

ebizmarts_ecommerce | error | Requested country is not available

Any thoughts as to how this can be fully resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants