0

在我的购物网站中,我有 100 种产品。我从中选择了一种产品。如何获取该产品的用户 ID?

我仍然需要对此做更多的事情,这在卖家页面中。

我试过这段代码,但没有用。

<?php 
    $product_id = $this->getProduct()->getId();
    echo $product_id; // It's displaying Product ID
    $productowner=Mage::getModel('marketplacepartner/marketplacepartner')->isCustomerProducttemp($product_id['entity_id']);
    if($productowner['productid']!=""){
        $rowsocial=Mage::getModel('marketplaceprofile/marketplaceprofile')->getPartnerProfileById($productowner['userid']);
    }
?>

我正在使用 Magento CE 1.7.0.2

我必须获取此产品的所有者 ID

有任何想法吗 ?

4

4 回答 4

0

尝试使用此代码

<?php

require_once 'app/Mage.php';

/*
* Initialize Magento. Older versions may require Mage::app() instead.
*/
Mage::init();

/*
* Get all unique order IDs for items with a particular SKU.
*/
$orderItems = Mage::getResourceModel('sales/order_item_collection')
->addFieldToFilter('sku', 'some-product-sku')
->toArray(array('order_id'));

$orderIds = array_unique(array_map(
function($orderItem) {
    return $orderItem['order_id'];
},
$orderItems['items']
));

/*
* Now get all unique customers from the orders of these items.
*/
$orderCollection = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('entity_id',   array('in'  => $orderIds))
->addFieldToFilter('customer_id', array('neq' => 'NULL'));
$orderCollection->getSelect()->group('customer_id');

foreach ($orderCollection as $order) {
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
var_dump($customer->getData());
}

参考这个帖子获取购买过这个产品的用户 (MAGENTO)

于 2013-08-17T06:02:25.397 回答
0

您可以使用 Magento SQL 查询来获取产品的卖家 ID,如下所示:

(此查询适用于 Webkul Marketplace 扩展,但我认为您可以设法更改此查询以与任何其他类似的扩展一起使用)

/* Get the resource model */
$resource = Mage::getSingleton('core/resource');

/* Retrieve the read connection */
$readConnection = $resource->getConnection('core_read');

/* Get product id */
$productId = $this->getProduct()->getId();

/* Get table name */
$table = $resource->getTableName('marketplace/product');

/* Query for user id */
$query = 'SELECT userid FROM ' . $table . ' WHERE mageproductid = '. (int)$productId . ' LIMIT 1';

/* Execute the query and store the user id in $userid */
$userid = $readConnection->fetchOne($query);
于 2015-05-13T10:14:16.277 回答
0

如果您正在使用市场扩展,您可以试试这个

$_marketProduct=Mage::getModel('marketplace/product')->getCollection()->addFieldToFilter('adminassign',array('eq'=>1))->addFieldToFilter('mageproductid','product_id');
foreach($_marketProduct as $_mp){
            $_vendorId =$_mp->getuserid();             
            $_customerDetails = Mage::getModel('customer/customer')->load($_vendorId);
            print_r($_customerDetails);           }

并且不要忘记更改 product_id

于 2015-12-03T10:48:41.337 回答
-1

更改('marketplacepartner/marketplacepartner')('marketplace/Userprofile')('marketplaceprofile/marketplaceprofile')_('marketplace/Userprofile')

喜欢

$product_id = $this->getProduct()->getId();
//echo $product_id; // It's displaying Product ID
$productowner=Mage::getModel('marketplace/Userprofile')>isCustomerProducttemp($product_id['entity_id']);
if($productowner['userid']!=""){
  $rowsocial=Mage::getModel('marketplace/Userprofile')->getPartnerProfileById($productowner['userid']);
}
$customer=Mage::getModel('customer/customer')->load($productowner['userid']);

echo $customer->getName();
于 2015-02-25T10:54:44.597 回答