News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Magento E-commerce - SMF forums bridge files and code

Started by Andre N, December 06, 2009, 02:12:44 PM

Previous topic - Next topic

magentobridge

never met you in yim

Only do not want to expose first and lastname public on forum from all customers.
So i searched a way to specifiable or generating a nickname on signup in magento.
There are two more fields editable, prefix and suffix.
prefix is only able to be optional by default. But suffix field is able to set as required.
since this field is unused by me i could easily rename it to nickname instead of suffix. noone cares.

but than comes the part of your code. thought it should be such as easy to use suffix instead of first and lastname for creating the user nickname in smf.


line 51 AccountController.php

            /* Begin magento bridge code here */
            //set the smf username to be first_last name
    (string)$username = $customer->firstname.'_'.$customer->lastname;

would like change it to something like :

(string)$username = $customer->suffix;

but i don't know if and where the suffix is stored at this point.
isn't it already in the array of $customer?

not about to read all the signup process with this lots of includes :s
:-\

magentobridge

This should be very easy to be done, so if you know the correct variable at this part. please let me know. ;D

Andre N

#22
In Magento, registration requires an email which is used for login purposes instead of a username. For this reason I put the users first and last name together with the underscore to use as a username to register them in SMF under. So if their name is Jake Speed then they will be registered in SMF as Jake_Speed. The user can change this of course. So if I understand you, you want to use something else to not expose the users name right? Using suffix won't work because it is optional. You could take the email address and strip everything after the '@' and use that... so [email protected] would create a username of jakespeed69lol. This code should work but I have not tried it:

/* Begin magento bridge code here */
            //set the smf username to be first_last name
          (string)$username = $customer->email;
          $username = substr($username, 0, strpos($username, '@'));


Or did you just want to use the surname? Change the code you quoted to be:

/* Begin magento bridge code here */
            //set the smf username to be first_last name
          (string)$username = $customer->lastname;


Is that what you're looking for? :)

Edit: It is important to create a unique username to register them into SMF otherwise the registration will fail. Using a surname like 'Dr' or 'Jr' to the name so you have 'TomJr' or 'JonesSr' is going to net you a username that is already in use sooner rather than later. If you REALLY want to find what the surname variable is, replace that code above with this for testing and register a new account (using a suffix of course):

/* Begin magento bridge code here */
           Zend_debug::dump($customer);
          die('<br/>Look at the output for the suffix variable name');


You could rename suffix to be nickname, it sounds like a lot of work though. :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

#23
Quote from: ike turner on May 31, 2010, 12:37:56 PM
The user can change this of course. So if I understand you, you want to use something else to not expose the users name right?

Yes, Jake_Speed may not want to get exposed he is buying there :)





Quote from: ike turner on May 31, 2010, 12:37:56 PM

Using suffix won't work because it is optional. You could take the email address and strip everything after the '@' and use that... so [email protected] would create a username of jakespeed69lol.Using suffix won't work because it is optional.


Thought about this method first, but he might use address [email protected]. His Forum nick will expose his real name again.



attached you Screenshot showing that making suffix requiered field is possible

thank you for the Zend_debug::dump($customer); was using print_r($); before always

if i found working solution finally i will share here




edit:

            /* Begin magento bridge code here */
           
                       Zend_debug::dump($customer);
          die('<br/>Look at the output for the suffix variable name');
            //set the smf username to be first_last name
    (string)$username = $customer->firstname.'_'.$customer->lastname;



does stop to signup the user.. because the script dies but i never see the output :( shouldn't it be simple to just dump the $customer array ?

magentobridge

    protected function _welcomeCustomer(Mage_Customer_Model_Customer $customer, $isJustConfirmed = false)
    {

print_r($customer);

object(Magentobridge_Customerinfo_Model_Customer)#66 (16) {
  ["_eventPrefix:protected"] => string(8) "customer"
  ["_eventObject:protected"] => string(8) "customer"
  ["_addresses:protected"] => array(0) {
  }
  ["_errors:protected"] => array(0) {
  }
  ["_attributes:protected"] => NULL
  ["_isDeleteable:protected"] => bool(true)
  ["_isReadonly:protected"] => bool(false)
  ["_resourceName:protected"] => string(17) "customer/customer"
  ["_resource:protected"] => NULL
  ["_resourceCollectionName:protected"] => string(28) "customer/customer_collection"
  ["_cacheTag:protected"] => bool(false)
  ["_dataSaveAllowed:protected"] => bool(true)
  ["_data:protected"] => array(21) {
    ["entity_id"] => string(1) "5"
    ["firstname"] => string(5) "First"
    ["lastname"] => string(4) "Last"
    ["suffix"] => string(6) "Suffix"
    ["email"] => string(33) "[email protected]"
    ["password"] => string(9) "Password "
    ["confirmation"] => NULL
    ["dob"] => NULL
    ["group_id"] => string(1) "1"
    ["store_id"] => string(1) "1"
    ["entity_type_id"] => int(1)
    ["parent_id"] => int(0)
    ["created_at"] => string(19) "2010-06-02 02:01:51"
    ["updated_at"] => string(19) "2010-06-02 02:01:52"
    ["increment_id"] => string(9) "000000005"
    ["created_in"] => string(18) "Default Store View"
    ["website_id"] => string(1) "1"
    ["allowed"] => string(1) "1"
    ["dob_is_formated"] => bool(true)
    ["password_hash"] => string(35) "ea4035a0d58452d4c6276a181423216c:aB"
    ["is_just_confirmed"] => bool(true)
  }
  ["_origData:protected"] => NULL
  ["_idFieldName:protected"] => string(9) "entity_id"
  ["_isDeleted:protected"] => bool(false)
}


Look at the output for the suffix variable name

Andre N

$customer->suffix
but I'm sure you got that already :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

that was the first i did on the day i found your code
I am still where i have started at :(

sadly it does not work on the part of your code

echo $customer->firstname.'_'.$customer->lastname;
echo $customer->suffix;


shows me :

john_smith
nickname

for example so it is just $customer->suffix but why this isn't at the part of the user generation in your code if the array is there too and $customer->firstname works :o don't get it

works in  \htdocs\app\code\core\Mage\Customer\controllers\AccountController.php

but not working at

\htdocs\app\code\local\Magentobridge\Smfaccounts\controllers\AccountController.php

magentobridge


Andre N

There are some tutorials on the magento forums about adding custom customer registration fields. There is at least one purchaseable module I know of, I think the developer name is amnasty or something sililar. I have used it and it is great.

Or you could disable registration from magento and redirect magento registration attempts to smf, so you can be sure the username is created that doesn't include their name.
Or you could generate a random username for them... Take the first name and add some random digits. When you send the welcome email let them know what their smf username is and link to the profile edit area so they can change it.
I think the best way would be to add the new field for username during magento registration. If you google magento custom registration field you should find ways to do it. I would give you a link or 2 but I'm on my phone and won't be home for a while. Does the integration work for you otherwise, on 1.4?
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

Andre N

Also, what do you get when you dump $customer ? I'm sure surname is in there... :)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

/*Save array in file:
PHP Code:*/
file_put_contents('array.txt', serialize($array));
/*Read into another script:
PHP Code:*/
$array = unserialize(file_get_contents('array.txt'));

magentobridge

Quote from: ike turner on May 25, 2010, 03:04:02 PM
It *should* work for 1.4 too. I believe I had it working for one site, but the theme I had purchased didn't work so I installed 1.3.2.4 instead. I don't think the api changed enough to break it, but ok.

What code info would you like? Post it here so anyone else who is interested can reference :)

I would love to use 1.4 because PayPal updates
Magento ver. 1.4.1.0
SMS 1.1.11
But gives me following for fresh install and your tutorial:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in 'http://localhost/api/v2_soap/?wsdl'; in /var/www/htdocs/forum/magentoBridge.php:102 Stack trace: #0 /var/www/htdocs/forum/magentoBridge.php(102): SoapClient->SoapClient('http://localhos...') #1 /var/www/htdocs/forum/index.php(59): require_once('/var/www/htdocs...') #2 {main} thrown in /var/www/htdocs/forum/magentoBridge.php on line 102

Andre N

#32
Hi,
Try something like this to get the suffix out:

$customerInfo = Mage::getModel('customer/customer')->load($customer_id); //you need customer ID
$suffix = $customerInfo->getData('suffix');

or since you already have the customer model maybe just
$suffix = $customer->getData('suffix');


For the SOAP error... do you have SOAP v2?
When you navigate to http://www.yourdomain.com/magento/api/v2_soap/?wsdl in your browser you should see an xml page like this:
http://www.xtremelean.us/shop/api/v2_soap/?wsdl
It looks like the error is being thrown up because SOAP can't find your these definitions...

The php code in line 102 is:

$proxy = new SoapClient('http://www.yourdomain.com/magento/api/v2_soap/?wsdl');

Make sure you've got the right path there to the definitions page

Edit:
Also, make sure you turn off error reporting in the api and magentobridge scripts when you are done testing.
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

this soap wasnt working for 1.4.0.1 because it's broken ...

QuoteThe solution is,
Open file /app/code/core/Mage/Api/Model/Server/Adapter/Soap.php

find the line 133, 134

} else {
$this->fault('0', 'Unable to load Soap extension on the server');

and replce this part of code with

} else {
$this->fault('0', 'Unable to load Soap extension on the server');
}

The developers forgot to close the bracket

didn't checked this yet because installed mage like 15 times now and it was working before
will post more later


Andre N

installed 15 times!? Install with ssh and it will be the cleanest ever ;)
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

magentobridge

#35
yes yes yes!  8)  ;D

$suffix = $customer->getData('suffix');
thats it! your the best :P
thank you
wow, i was beginnnig to hate mage.
by the way i like the box on store page with the forum stats :)

should be ssi_boardStats();




if anyone else wants to use suffix field for nickname in the forum replace accountcontroller.php from the bridgefolder to following
find  /* Begin magento bridge code here */

replace this:


(string)$username = $customer->firstname.'_'.$customer->lastname;


with:
           
            $username = $customer->getData('suffix');;



very nice



Quote from: ike turner on June 17, 2010, 02:51:27 PM
installed 15 times!? Install with ssh and it will be the cleanest ever ;)

hehe, did
for trying different versions 1.4/1.3 smf 1.1.11/2.0rc and so on
would be much more disturbing if done manually  8)


ok, here it is:

SMF 1.1.11
Magento ver. 1.4.1.0

CONFIRMEND WORING


(if you fix the soap error, which is mage fault)

Andre N

"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

maran_lz

Running Mage 1.4
got it all working and seemed to be fine, however once someone created and account through SMF, i cant access any customer details through magento admin panel.....
Any ideas? all i get is a blank screen now

zymex

Quote from: maran_lz on September 09, 2010, 11:43:19 PM
Running Mage 1.4
got it all working and seemed to be fine, however once someone created and account through SMF, i cant access any customer details through magento admin panel.....
Any ideas? all i get is a blank screen now

I had edit the register link, to ../customer/account/create/
So ppl, who wants to sign up, have to do it in the shop.
then i'm sure nothing mess up =)
i edited in /Themes/THEME NAME/index.template.php

I run smf 1.1.11 and magento 1.4.1 and anything work so far...
but havent open my forum yet.


Btw. is there any way to make smf class/group sync with magento class/groups. ?
so VIP in forum will get VIP status both in magento custumer class and smf rank?

maran_lz

Had a glitch in the software to do with the store ID, Got it fixed and now running fine on the test server thats awaiting for roll out.
SMF 1.1.11
MAGE 1.4.0.1

Happy times!

Advertisement: