magento开发-magento提取产品

通过清心醉

magento开发-magento提取产品

网站的二次开发,基于商城的莫过于是提取产品了.magento开发也一样,今天对magento进行二次开发,对magento提取产品的大概细节进行了编写.以下为实际编写代码.

$_products = $this->getProductCollection(); //获取产品信息
var_dump($_products->getItems()); die(“数据提取完毕”);
//getItems()方法里已经获取了所有的产品信息参数,但这里获取的产品的URL只是域名后半部分
//所以

foreach($_products->getItems() as $product) //二维数组foreach循环提取
{
echo “</br>产品的URL为:”.$product->getProductUrl(); //输出独里的URL
//应该是在这里面为URL进行了拼接
//如果改成var_dump($product); 就能看到$product其实就是一个对象:数据格式为:
/*
object(Mage_Catalog_Model_Product)#271 (32)
{
[“_cacheTag”:protected]=> string(15) “catalog_product”
[“_eventPrefix”:protected]=> string(15) “catalog_product”
[“_eventObject”:protected]=> string(7) “product”
[“_canAffectOptions”:protected]=> bool(false)
[“_typeInstance”:protected]=> NULL
[“_typeInstanceSingleton”:protected]=> NULL
[“_linkInstance”:protected]=> NULL
[“_customOptions”:protected]=> array(0) { }
[“_urlModel”:protected]=> NULL
[“_errors”:protected]=> array(0) { }
[“_optionInstance”:protected]=> NULL
[“_options”:protected]=> array(0) { }
[“_reservedAttributes”:protected]=> NULL
[“_isDuplicable”:protected]=> bool(true)
[“_calculatePrice”:protected]=> bool(true)
[“_defaultValues”:protected]=> array(0) { }
[“_storeValuesFlags”:protected]=> array(0) { }
[“_lockedAttributes”:protected]=> array(0) { }
[“_isDeleteable”:protected]=> bool(true)
[“_isReadonly”:protected]=> bool(false)
[“_resourceName”:protected]=> string(15) “catalog/product”
[“_resource”:protected]=> NULL
[“_resourceCollectionName”:protected]=> string(26) “catalog/product_collection”
[“_dataSaveAllowed”:protected]=> bool(true)
[“_isObjectNew”:protected]=> NULL
[“_data”:protected]=> array(35)
{
[“entity_id”]=> string(1) “7”
[“entity_type_id”]=> string(1) “4”
[“attribute_set_id”]=> string(1) “4”
[“type_id”]=> string(6) “simple”
[“sku”]=> string(1) “7”
[“has_options”]=> string(1) “0”
[“required_options”]=> string(1) “0”
[“created_at”]=> string(19) “2013-03-12 00:48:01”
[“updated_at”]=> string(19) “2013-03-12 00:49:26”
[“cat_index_position”]=> string(1) “0”
[“price”]=> string(8) “885.0000”
[“tax_class_id”]=> string(1) “0”
[“final_price”]=> string(8) “885.0000”
[“minimal_price”]=> string(8) “885.0000”
[“min_price”]=> string(8) “885.0000”
[“max_price”]=> string(8) “885.0000”
[“tier_price”]=> NULL
[“news_from_date”]=> string(19) “2013-03-11 00:00:00”
[“news_to_date”]=> string(19) “2019-03-11 00:00:00”
[“name”]=> string(13) “cba的产品3”
[“url_key”]=> string(5) “cba-3”
[“msrp_enabled”]=> string(1) “2”
[“msrp_display_actual_price_type”]=> string(1) “4”
[“small_image”]=> string(12) “no_selection”
[“thumbnail”]=> string(12) “no_selection”
[“short_description”]=> string(13) “cba的产品3”
[“special_price”]=> NULL
[“msrp”]=> NULL
[“special_from_date”]=> NULL
[“special_to_date”]=> NULL
[“status”]=> string(1) “1”
[“do_not_use_category_id”]=> bool(true)
[“request_path”]=> string(10) “cba-3.html”
[“is_salable”]=> string(1) “1”
[“stock_item”]=> object(Varien_Object)#281 (7)
{
[“_data”:protected]=> array(1)
{
[“is_in_stock”]=> string(1) “1”
}
[“_hasDataChanges”:protected]=> bool(false)
[“_origData”:protected]=> NULL
[“_idFieldName”:protected]=> NULL
[“_isDeleted”:protected]=> bool(false)
[“_oldFieldsMap”:protected]=> array(0) { }
[“_syncFieldsMap”:protected]=> array(0) { }
}
}
[“_hasDataChanges”:protected]=> bool(true)
[“_origData”:protected]=> NULL
[“_idFieldName”:protected]=> string(9) “entity_id”
[“_isDeleted”:protected]=> bool(false)
[“_oldFieldsMap”:protected]=> array(0) { }
[“_syncFieldsMap”:protected]=> array(0) { }
}
*/
}

关于作者

清心醉 administrator

发表评论

如果喜欢作者的文章,您可以打赏给作者:

TRC20(虚拟货币):


ERC20(虚拟货币):


Bitcoin(BTC):