使用 magento 扩展 m2e(“magento2ebay”)可以创建“优惠”。每个报价可以包含不同数量的 magento 产品,例如应该在 ebay 上列出。但是如何以编程方式获取产品?
问问题
431 次
1 回答
2
首先,通过 ID 加载 Instance。您可以在 magento 后端的列表网格中看到 ID,例如:
$listing = Mage::getModel('M2ePro/Ebay_Listing')->loadInstance(1) // 1 is my listing-id
foreach ( $eBayListing->getProducts() as $key => $foo )
{
echo $foo->getProductId(); // for Example
}
我以为我将它发布在 stackoverflow 上,因为没有很多使用 m2e 类的示例。也许我将来会添加另一个例子......
如果您想获取所有优惠的列表,请尝试:
$all_Listings = Mage::getModel('M2ePro/Ebay_Listing')->getResourceCollection();
var_dump( $alleListings->getData() );
它将返回一个数组。数组的每个元素都包含单个列表对象的主要数据(如 id)。在我的情况下(有两个报价),返回数组如下所示:
array(2) {
[0]=> array(3) { ["listing_id"]=> string(1) "1" ["products_sold_count"]=> string(1) "0" ["items_sold_count"]=> string(1) "0" }
[1]=> array(3) { ["listing_id"]=> string(1) "2" ["products_sold_count"]=> string(1) "0" ["items_sold_count"]=> string(1) "0" }
}
要访问列表对象的主要数据(可能是标题),您必须使用以下方法:
$your_listing_instance->getParentObject()->getData()
会有标题、同步信息、产品总数等通用数据。
于 2013-07-10T11:10:55.950 回答