0

I started by creating an install script to create and install my custom attribute...

startSetup();
$eavConfig = Mage::getSingleton('eav/config');
//JobContractUid
$data = array(
'label' => 'Job Contract Uid',
'frontend_label' => 'Job Contract Uid',
'type' => 'varchar',
'input' => 'text',
'required' => 0,
'user_defined' => 1,
'group' => 'Epicor Attributes',
'is_visible_on_front' => 1,
'is_visible' => 0,
'backend_type' => 'varchar',
'entity_model' => 'customer/attribute',
'attribute_model' => 'customer/attribute', 
'position' => 710,
'sort_order' => 600, 
);
$installer->addAttribute('customer_address', 'e_customer_jobcontractuid', $data);
$attribute = $eavConfig->getAttribute('customer_address', 'e_customer_jobcontractuid');
$attribute->setData('used_in_forms', array
(
'customer_account_create',
'customer_account_edit', 
'adminhtml_customer_address'
)
);
$attribute->save();
$attribute->setData('is_visible_on_front', 1);
$attribute->save();
$attribute->setData('is_visible', 1);
$attribute->save();
//below here had already been done when I started; I include it here for completeness
$data = array(
'type' => 'varchar',
'input' => 'text',
'label' => 'External Id',
'visible' => true,
'required' => false,
'unique' => false,
'sort_order' => 600, // Positions of the other attributes are listed in
'position' => 700, // Mage_Customer_Model_Resource_Setup
'is_user_defined' => 1,
'is_system' => 0,
'validate_rules' => array(
'max_text_length' => 255,
),
);
$installer->addAttribute('customer_address', 'epicor_external_id', $data);
$attribute = $eavConfig->getAttribute('customer_address', 'epicor_external_id');
$attribute->setData('used_in_forms', array
( 
'adminhtml_customer_address'
)
);
$attribute->save();
$attribute->setData('is_visible_on_front', 1);
$attribute->save();
$attribute->setData('is_visible', 1);
$attribute->save();

This seems to work. They both appear on the customer_address_edit area of admin.

So I added my attributes to the wsdl. (note: everything in the standard customer entity works and allows me to update or retrieve the information)

<?xml version="1.0" ?>
<definitions xmlns:typens="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="Magento" targetNamespace="urn:Magento" data-livestyle-extension="available">
<types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
        <complexType name="customerCustomerEntityToCreate">
        <all>
            <element name="e_customer_custid"  type="xsd:int" minOccurs="0"/>
            <element name="e_customer_contactid" type="xsd:int" minOccurs="0"/>
            <element name="e_customer_company" type="xsd:string" minOccurs="0"/>
            <element name="e_customer_terms" type="xsd:string" minOccurs="0"/>
            <element name="e_customer_shipto_id" type="xsd:int" minOccurs="0"/>

        </all>
    </complexType>
    <complexType name="customerAddressEntityCreate">
        <all>
            <element name="epicor_external_id" type="xsd:int" minOccurs="0" />
            <element name="e_customer_jobcontractuid" type="xsd:int" minOccurs="0" />
        </all>
    </complexType>
    <complexType name="customerAddressEntityItem">
        <all>
            <element name="epicor_external_id" type="xsd:int" minOccurs="0" />
            <element name="e_customer_jobcontractuid" type="xsd:int" minOccurs="0" />
        </all>
    </complexType>
</schema>

Now magento successfully merges these into the main wsdl. and I make my call.

$sessionId = $proxy->login($user,$password);
$p21Idents = array(
'epicor_external_id' => '5',
'e_customer_jobcontractuid' => '9'
);
$AddressUpdate = $proxy->customerAddressUpdate($sessionId,'18001',$p21Idents);

Call completes, no errors thrown on cli, nothing in system.log or exception.log. Also The admin customer_address screen is still showing both of these attributes as empty. Also using CustomerAddressList or customerAddressInfo I can't include my 2 values in the return. Obviously I am missing a piece to this puzzle, please help.

Update 1

It seems if I manually apply values in the admin I can then run an update. So this has something to with magento no wanting to recognize a null field as a valid endpoint.

0

I needed to extend the customer_address model. Unlike the Customer_customer model that smoothly loops through all of the supplied attributes the customer_address model is a little rougher. Also some of the documentation in the 1.x branch on customerAddressCreate and customerAddressUpdate is misleading. Stating that addressData is an Array of customerCustomerEntityCreate makes you think that you can pass in a multi-dimensional array into AddressData until you look at the model and you realize the documentation was attempting to tell you that customerCustomerEntityCreate is an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.