Magento Quote Item object - how can I load product parameters?

Although I know that I can just download the Quote Item collection of options and filter its item_id, I just can’t plunge into the fact that Magento people haven’t added any method _afterLoador _loadOptions, to easily assign options to an element, since there are already properties _options, _optionsByCode...

to provide an example of what I'm doing:

// updated (forgot to actually load object
$item = Mage::getModel('sales/quote_item')->load($itemId);
$buyRequest = $item->getBuyRequest(); // almost empty, only qty is set

I want to know if there is any method $item->loadOptions()... or another native way to load parameters into an element

UPDATE

What I want to do: I want to load an object of an object and use my own way of adding its parameters to this loaded object.

+4
source share
4

/** @var Mage_Sales_Model_Resource_Quote_Item_Option_Collection $options */
$options = Mage::getResourceModel('sales/quote_item_option_collection');
$options->addItemFilter($item->getId());
foreach ($options as $option) {
    $item->addOption($option);
}

, , , . , , - .

+8

, , , :

foreach ($item->getOptions() as $option) {
    if ($option->getCode() == 'info_buyRequest') {
        $values = unserialize($option->getValue()); // to array object
        // lookup custom option
        if ($values && array_key_exists('options', $values)) { 
            //
        }       
    }
}

, cart/quote , info_buyRequest, . .

. : $item- > getData(), .

+2

- . , getOptions , .

?

0

. , .

:

$quoteItem = someMethodToGetYourQuoteItem();
$quoteItem->getBuyRequest()->getYouroption();
0

Source: https://habr.com/ru/post/1524343/


All Articles