Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Bridging Magento to Other CMS packages (Typolight, specifically)
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Ok, I want to generate an increment_id while synching some outside data using queries to the Magento schema.  What do I need to know about doing this correctly?

Thanks,

Fred

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Bump!  Still looking for some help on this one.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Could you provide some more details on what you are trying to do?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Hi Moshe!  Long time (or so it seems...) wink

Well, I am going to be running a series of queries in my CMS that update Magento tables to synchronize a customer’s information with an account that is created through my CMS.  Magento and my CMS share a database.  So, I went through and (hopefully) completely mapped out all tables with data related to a magento customer, so I can run a batch of queries that synchronize those two datasets.  I’m starting with the table Customer_Entity.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Hi smile

increment_id is intended for entity ID that can be generated using custom logic, such as prefix and charset used in ID generation.
The model for the logic is specified in `eav_entity_type`.`increment_model` , and for customers it is ‘eav/entity_increment_numeric’.

I think, instead of creating a custom sql queries, duplicating Magento functionality and maintaining your code to keep up with database structure updates, it would be better to use Magento’s models or create a simple web service that would accept your queries and use Magento models.

For example you could create a new customer from your CMS like this:

<?php

require_once MAGENTO_ROOT_DIR.'/app/Mage.php';
Mage::app('base');

$customer Mage::getModel('customer/customer')->setData(array(....))->save();
$id $customer->getId();
 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

this would really REALLY help save a ton of time.  I love this idea.  so, how do I ensure that the fields I’m sending are mapping to the correct magento table fields?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

you can see the list of attribute you have for customer by running this query:

select a.* from eav_attribute a inner join eav_entity_type et using(entity_type_idwhere et.entity_type_code='customer';

data can be set by:
* $customer->setData($associatedArray);
* $customer->setData($attribute, $value);
* $customer->setCamelizedAttributeName($value);

Also take a look at public methods in Mage_Customer_Model_Customer

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

ok, so could I use attribute_code as the key and my value as the value like this? (assume the the variables have been already created)

how would i get values for created_in and store_id?

$associatedArray = array(
'default_billing' => $concatenatedBillingAddress,
'default_shipping' => $concatenatedShippingAddress,
'email' => $emailAddress,
'firstname' => $firstName,
'lastname' => $lastName,
'password_hash' => $passwordHash
);


$customer->setData($associatedArray)->save();

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Bump!

Thanks for the help so far, Moshe.  Now, let’s say that all my fields have already been prepared and are ready to basically, be directly inserted into the Magento database tables.  What would be the best way for me to map my values to the appropriate Magento attributes?  Would my associative array example as shown above work?  Assume that my password has already been MD5 hashed and that I want the password to be the same in Magento as in my CMS for the customer.

Also, what format should billing and shipping addresses be in?

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Oh, bugger. 

The magic method __autoload() is being used in both my CMS and in Magento.  I get this error when I try to run something that instantiates the Mage framework:

[03-Jan-2008 10:37:16] PHP Fatal error:  Cannot redeclare __autoload() previously declared in /<cms path>/functions.php:29) in /<magento path >/app/code/core/Mage/Core/functions.php on line 48

I don’t know if there is going to be a way around this without the future API.  Your thoughts?

Thanks,

Fred

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Ok, everyone!  Moshe came to the rescue and found a special way to handle multiple __autoload declarations using Standard PHP Library (AKA SPL).  SPL is a standard extension integrated into PHP 5.x packages.

The function that allows us to handle multiple __autoload() methods is call spl_autoload_register and more information can be found on it here:

http://us.php.net/manual/en/function.spl-autoload-register.php

I will report back with anything additional I find, including how it is being used to help me bridge these two systems together.

Thanks again to Moshe, we are in the presence of greatness! wink

Fred

 
Magento Community Magento Community
Magento Community
Magento Community
 
winans_fred
Sr. Member
 
Total Posts:  83
Joined:  2007-09-06
 

Hi Moshe,

Here is a new problem. I need to be able to specify the required path to make this error go away.  Any thoughts?

Warning: file_get_contents(/distro.xml) [function.file-get-contents]: failed to open stream: No such file or directory in /home/myonline/public_html/store/app/code/core/Mage/Core/Model/Config.php on line 180

I know where distro.xml resides, how to I correctly set the path from outside?

Thanks!

Fred

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top