0
朋友,我想使用id方法加載2個產品包產品。這是我該寫的代碼...無法使用magento中的id方法加載2個產品
<?php
$bundled = Mage::getModel('catalog/product');
$stdid=$bundled->getIdBySku('123457');
$compid=$bundled->getIdBySku('123458');
/*get additional options of the each products*/
$y=$bundled->load($compid);
$selectionCollection_complete = $y->getTypeInstance(true)->getSelectionsCollection(
$y->getTypeInstance(true)->getOptionsIds($y), $y);
$x=$bundled->load($stdid);
$selectionCollection_standard = $x->getTypeInstance(true)->getSelectionsCollection(
$x->getTypeInstance(true)->getOptionsIds($x), $x);
/*store the option head name to an array for future
reference*/
foreach($selectionCollection_standard as $std_opt)
{
$opt_std_hd_names.=$std_opt->getName()."<BR>";
}
foreach($selectionCollection_complete as $cmp_opt)
{
$opt_cmp_hd_names.=$cmp_opt->getName()."<BR>";
}
$display="<pre>".print_r($opt_std_hd_names."<br><br>".$opt_cmp_hd_names)."</pre>"
?>
但我的問題是$ opt_std_hd _names和$ opt_cmp_hd_names返回相同的輸出,他們是我所第一次加載產品的那些選項(在這種情況下$ y,如果我首先放置$ x代碼,那麼它顯示$ x的選項)。輸出如下所示。
output:
Preparation and Filing of Incorporation Documents
Verify Business Name Availability
Unlimited Phone/Email Support
24/7 Access to Our Online Status Center
FREE Registered Agent Service for 6 Months
BizComply (free with your Registered Agent Service)
500 Four-Color Business Cards
Business License Application Package
Palo Alto's Business Plan Pro
Preparation and Filing of Incorporation Documents
Verify Business Name Availability
Unlimited Phone/Email Support
24/7 Access to Our Online Status Center
FREE Registered Agent Service for 6 Months
BizComply (free with your Registered Agent Service)
500 Four-Color Business Cards
Business License Application Package
Palo Alto's Business Plan Pro
你可以看到輸出是相同的。爲什麼會發生這樣的事?請給出你的建議
是的,這是正確的。我已經想出了它並應用於我的應用程序中。但我真的不明白我的第一種方法是什麼問題。現在,當你解釋它時,事情變得非常清楚。非常感謝您的指導...... –