久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Magento:如何加載產品及其在管理中使用的所有數據

Magento: how to load product along its all data as it is used in admin(Magento:如何加載產品及其在管理中使用的所有數據)
本文介紹了Magento:如何加載產品及其在管理中使用的所有數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試獲取捆綁選項數據.使用它: $product->getBundleOptionsData 我需要使用它,因為我試圖以編程方式更改數據,并且我希望以與 admin 中使用的方式一樣接近的方式進行.

I'm trying to get bundle options data. using this : $product->getBundleOptionsData I need to use this, as I'm trying to change data programmatically and I would like to do it in a way that's as close as used in admin .

但是,當我對上述函數的結果進行 var_dump 時,我得到 NULL 而在捆綁模型產品類型的管理端,我得到了正確的數據.

However, when I var_dump the result of the above function I get NULL while in admin side in bundle model product type I get correctly the data.

當我在自己的文件中 var_dump $product 時,我得到的數據比在捆綁模型產品類型保存功能中 var_dump 時短得多.

When I var_dump $product in my own file I get much shorter data than when I var_dump in bundle model product type save function.

我需要做什么來加載產品的所有數據,以便我可以使用getBundleOptionsData.我查看了幾個文件并用谷歌搜索,但找不到答案.

what do I need to do to load all data of the product, so I can use getBundleOptionsData. I looked in several files and googled, but can't find an answer.

推薦答案

最后,我成功地獲取了捆綁選項數據,以便我可以對其進行操作.我在magento的模型包觀察者類duplicateProduct函數中找到了主要代碼:但是我需要添加option_id(小心不要忘記)

Finally I made it work to get bundle options data so I can manipulate it. I found the main code in magento's model bundle observer class duplicateProduct function: I needed however to add option_id (careful not to forget that)

這是最后階段的代碼.

$product->getTypeInstance(true)->setStoreFilter($product->getStoreId(), $product);
$optionCollection = $product->getTypeInstance(true)->getOptionsCollection($product);
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
    $product->getTypeInstance(true)->getOptionsIds($product),
    $product
);
$optionCollection->appendSelections($selectionCollection);

$optionRawData = array();
$selectionRawData = array();

$i = 0;
foreach ($optionCollection as $option) {
    $optionRawData[$i] = array(
            'option_id' => $option->getOptionId(), //my addition. important otherwise, options going to be duplicated
            'required' => $option->getData('required'),
            'position' => $option->getData('position'),
            'type' => $option->getData('type'),
            'title' => $option->getData('title')?$option->getData('title'):$option->getData('default_title'),
            'delete' => ''
        );
    foreach ($option->getSelections() as $selection) {
        $selectionRawData[$i][] = array(
            'product_id' => $selection->getProductId(),
            'position' => $selection->getPosition(),
            'is_default' => $selection->getIsDefault(),
            'selection_price_type' => $selection->getSelectionPriceType(),
            'selection_price_value' => $selection->getSelectionPriceValue(),
            'selection_qty' => $selection->getSelectionQty(),
            'selection_can_change_qty' => $selection->getSelectionCanChangeQty(),
            'delete' => ''
        );
    }
    $i++;
}

$product->setBundleOptionsData($optionRawData);   //changed it to $product
$product->setBundleSelectionsData($selectionRawData);  //changed it to $product

您現在可以更改 optionsrawdata 中的原始數據.或 getBundleOptionsData.另一個也一樣.

you can either now change on the raw data in optionsrawdata. or getBundleOptionsData. and same for the other one.

這篇關于Magento:如何加載產品及其在管理中使用的所有數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 狠狠av| 成人国产精品久久久 | 国产色网 | 久久国产免费看 | 黄色大片视频 | 二区av | 中文字幕1区2区3区 亚洲国产成人精品女人久久久 | 狠狠操婷婷 | 国产日韩欧美 | 中日韩欧美一级片 | 国产欧美日韩在线播放 | 欧美一区二区三区大片 | 国产精品一区二区在线播放 | 中文字幕在线网 | 青春草在线 | www.av在线| 81精品国产乱码久久久久久 | 91av视频在线观看 | 在线色网| 国产在线中文 | 日本天天色 | 欧美日韩专区 | 午夜成人免费视频 | 国产精品日韩在线观看一区二区 | 国产精品一区二区视频 | 国产2区| 亚洲精品黄 | 精品精品| av一级毛片 | 91看片官网 | 欧美一级二级三级视频 | 北条麻妃99精品青青久久主播 | 精品美女久久久久久免费 | 亚洲三级免费看 | 国产高清在线精品 | 日日干日日射 | 黄色网址在线免费观看 | 免费一区二区三区在线视频 | 狠狠操狠狠操 | 超碰人人爱 | 国产综合精品 |