如何在magento中获取当前产品卖家ID。如果我可以获得ID,我可以显示他们的地址国家/地区。有没有人可以帮我这个?
我按属性
获取卖家名称<?php echo $_product->getAttributeText('creator_id');?>
答案 0 :(得分:0)
从产品ID中,您可以获得其卖家名称,下面是代码示例(magento 1.9)
$ProductID = 1000; ///$_product->getProductId(); you can get it like this
$allSellers= Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid',array('eq'=> $ProductID ));
$sellerID = 0;
foreach ($allSellers as $seller) {
$sellerID= $seller->getUserid(); // here you have seller ID
$sellerName = Mage::getModel('customer/customer')->load($sellerID)->getName(); // here you have seller name
}
答案 1 :(得分:0)
如果您使用Marketplace扩展,则可以使用此代码。
假设产品ID为10。
$prodID = 10;
$collection_prod = Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('mageproductid', array('eq'=>$prodID));
$sellerID = '';
foreach($collection_prod as $collection){
$sellerID = $collection->getUserid(); //get the seller ID
}
$sellerAddress_Collection = Mage::getModel('customer/address')->getCollection()->addFieldToFilter('parent_id', array('eq'=>$sellerID));
foreach($sellerAddress_Collection as $sellerAddress_Collections){
$addressID = $sellerAddress_Collections->getEntityId(); //get the address ID of the seller
$seller_collection_address = Mage::getModel('customer/address')->load($addressID); // load the address ID of the seller
$zipcode = $seller_collection_address->getPostcode(); //zipcode
$country_id = $seller_collection_address->getCountryId(); //country id
$city = $seller_collection_address->getCity(); // City
$street1 = $seller_collection_address->getStreet(1); //street 1
$street2 = $seller_collection_address->getStreet(2); //street 2
$tel = $seller_collection_address->getTelephone(); //Telephone
}