I'm not sure how .NET
s SOAP API would handle this, but I'd try using the catalog_product.list
method with a SKU filter. If the resulting list/array/collection/whatever-its-serialized-as is empty, then you know the product doesn't exist.
Per the comments below, the following code should get you that list
Dim productExists As Boolean
Dim webService As MagentoService = New MagentoWS.MagentoService
Dim filters As filters = New filters()
filters.filter = {New associativeEntity() With {.key = "sku", .value = sku}}
Dim productInfo As catalogProductEntity() = webService.catalogProductList(sSessionId, filters, String.Empty)
productExists = productInfo.Count() > 0
Try this
Step1: trigger an event on basic of customer_save_before
<global>
<events>
<customer_save_before>
<observers>
<stockalert>
<type>singleton</type>
<class>magento37890/observer</class>
<method>checkDisplay</method>
</stockalert>
</observers>
</customer_save_before>
</events>
</global>
Step2:
In before event
give you can get customer id
if customer is old
,then checking current value and past value match or not
.
If not match then checking this value exit in Rest of collection
. If exit then send a flag (false)
and
throw error using throw Mage::exception
which prevent data save
.....
if($flagofmy==false){
throw Mage::exception(
'Mage_Customer', Mage::helper('customer')->__('This customer lastname already exists'),
Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS
);
}
full Logic
<?php
class Stackexchange_Magento37890_Model_Observer
{
public function checkDisplay(Varien_Event_Observer $observer){
$flagofmy=true;
//eeeeee
$customer=$observer->getEvent()->getCustomer();
Mage::log('My log entry'.$customer->getId(), null, 'Magento37890.log');
/* if customer is old customer */
if($customer->getId()){
if($customer->getOrigData('lastname')!=$customer->getData('lastname')){
Mage::log($customer->getData('lastname').'My log entry'.$customer->getId(), null, 'Magento37890.log');
$flagofmy=$this->HasLastName($customer->getData('lastname'));
if($flagofmy==false){
throw Mage::exception(
'Mage_Customer', Mage::helper('customer')->__('This customer lastname already exists'),
Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS
);
}
}else{
Mage::log($customer->getData('lastname').' Step A _1'.$customer->getId(), null, 'Magento37890.log');
}
}else{
/* New Customer */
$flagofmy=$this->NewHasLastName($customer->getData('lastname'));
throw Mage::exception(
'Mage_Customer', Mage::helper('customer')->__('This customer lastname already exists'),
Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS
);
}
}
protected function HasLastName($lastname){
$customer_check = Mage::getModel('customer/customer')
->getCollection()
->addAttributeToSelect('lastname')
->addAttributeToFilter('lastname',$lastname);
if(count($customer_check)>0){
return false;
}
return true;
}
}
Note: I have done basic of lastname field juts need to change field name to display_name
Best Answer
try this
This should work but if it doesn't just tell me so i can find an solution.