/** * Adds all texts belonging to an product item. * * @param MW_Container_Content_Interface $contentItem Content item * @param MShop_Product_Item_Interface $item product item object * @param string $langid Language id */ protected function _addItem(MW_Container_Content_Interface $contentItem, MShop_Product_Item_Interface $item, $langid) { $listTypes = array(); foreach ($item->getListItems('text') as $listItem) { $listTypes[$listItem->getRefId()] = $listItem->getType(); } foreach ($this->_getTextTypes('product') as $textTypeItem) { $textItems = $item->getRefItems('text', $textTypeItem->getCode()); if (!empty($textItems)) { foreach ($textItems as $textItem) { $listType = isset($listTypes[$textItem->getId()]) ? $listTypes[$textItem->getId()] : ''; $items = array($langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', ''); // use language of the text item because it may be null if (($textItem->getLanguageId() == $langid || is_null($textItem->getLanguageId())) && $textItem->getTypeId() == $textTypeItem->getId()) { $items[0] = $textItem->getLanguageId(); $items[5] = $textItem->getId(); $items[6] = $textItem->getContent(); } $contentItem->add($items); } } else { $items = array($langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', ''); $contentItem->add($items); } } }
/** * Copys all data from a given product item. * * @param MShop_Product_Item_Interface $product Product item to copy from */ public function copyFrom(MShop_Product_Item_Interface $product) { $this->setName($product->getName()); $this->setType($product->getType()); $this->setSupplierCode($product->getSupplierCode()); $this->setProductCode($product->getCode()); $this->setProductId($product->getId()); $items = $product->getRefItems('media', 'default', 'default'); if (($item = reset($items)) !== false) { $this->setMediaUrl($item->getUrl()); } $this->setModified(); }
/** * Create new product item object initialized with given parameters. * * @param MShop_Product_Item_Interface $item Product item object * @return array Associative list of key/value pairs suitable for product item constructor */ protected function _createArray(MShop_Product_Item_Interface $item) { return array('id' => $item->getId(), 'typeid' => $item->getTypeId(), 'type' => $item->getType(), 'status' => $item->getStatus(), 'label' => $item->getLabel(), 'start' => $item->getDateStart(), 'end' => $item->getDateEnd(), 'code' => $item->getCode(), 'suppliercode' => $item->getSupplierCode(), 'ctime' => $item->getTimeCreated(), 'mtime' => $item->getTimeModified(), 'editor' => $item->getEditor()); }