本文整理汇总了PHP中Varien_Object::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::setId方法的具体用法?PHP Varien_Object::setId怎么用?PHP Varien_Object::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::setId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTrackingReqeust
protected function setTrackingReqeust()
{
$r = new Varien_Object();
$id = $this->getConfigData('id');
$r->setId($id);
$this->_rawTrackRequest = $r;
}
示例2: testGetStoredAliasForCustomer
/**
* @loadFixture ../../../var/fixtures/aliases.yaml
*/
public function testGetStoredAliasForCustomer()
{
$reflectionClass = new ReflectionClass(get_class($this->_block));
$method = $reflectionClass->getMethod("getStoredAliasForCustomer");
$method->setAccessible(true);
$this->assertNull($method->invoke($this->_block));
$configMock = $this->getModelMock('ops/config', array('isAliasManagerEnabled'));
$configMock->expects($this->any())->method('isAliasManagerEnabled')->will($this->returnValue(true));
$this->replaceByMock('model', 'ops/config', $configMock);
$aliases = Mage::getModel('ops/alias')->getCollection()->addFieldToFilter('customer_id', 1)->addFieldToFilter('state', Netresearch_OPS_Model_Alias_State::ACTIVE)->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
$alias = $aliases->getFirstItem();
$aliasHelperMock = $this->getHelperMock('ops/alias', array('getAliasesForAddresses'));
$aliasHelperMock->expects($this->once())->method('getAliasesForAddresses')->will($this->returnValue($aliases));
$this->replaceByMock('helper', 'ops/alias', $aliasHelperMock);
$customerMock = $this->getHelperMock('customer/data', array('isLoggedIn'));
$customerMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
$this->replaceByMock('helper', 'customer/data', $customerMock);
$fakeCustomer = new Varien_Object();
$fakeCustomer->setId(1);
$fakeQuote = new Varien_Object();
$fakeQuote->setCustomer($fakeCustomer);
$blockMock = $this->getBlockMock('ops/form', array('getQuote'));
$blockMock->expects($this->once())->method('getQuote')->will($this->returnValue($fakeQuote));
$this->replaceByMock('block', 'ops/form', $blockMock);
$reflectionClass = new ReflectionClass(get_class($blockMock));
$method = $reflectionClass->getMethod("getStoredAliasForCustomer");
$method->setAccessible(true);
$this->assertEquals($alias->getData(), $method->invoke($blockMock));
}
示例3: _prepareCollection
/**
* Prepare grid collection
*/
protected function _prepareCollection()
{
$collection = new Varien_Data_Collection();
$layout = $this->getLayout();
$update = $layout->getUpdate();
$design = Mage::getSingleton('core/design_package');
$layoutXML = $update->getFileLayoutUpdatesXml('frontend', $design->getPackageName(), $design->getTheme('layout'), 0);
$xpath = $layoutXML->xpath('//action[@method="setEsi"]');
foreach ($xpath as $x) {
$esi = new Varien_Object();
$handle = $x->xpath('ancestor::node()[last()-2]');
$handleName = $handle[0]->label ? $handle[0]->label : $handle[0]->getName();
$parentBlock = $x->xpath('parent::*');
$parentBlockName = $parentBlock[0]->getAttribute('name');
$parentBlockDescription = $parentBlock[0]->getAttribute('description');
$cacheType = $x->params->cache_type ? $x->params->cache_type : "global";
$esi->setId($parentBlockName);
$esi->setHandle($handleName);
$esi->setBlockName($parentBlockName);
$esi->setDescription($parentBlockDescription);
$esi->setCacheType($cacheType);
try {
$collection->addItem($esi);
} catch (Exception $e) {
Mage::logException($e);
}
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
示例4: _prepareObject
/**
* Prepare page object
*
* @param array $data
* @return Varien_Object
*/
protected function _prepareObject(array $data)
{
$object = new Varien_Object();
$object->setId($data[$this->getIdFieldName()]);
$object->setUrl($data['url']);
return $object;
}
示例5: updateAttributes
/**
* Update attribute values for entity list per store
*
* @param array $entityIds
* @param array $attrData
* @param int $storeId
* @return Mage_Catalog_Model_Product_Action
*/
public function updateAttributes($entityIds, $attrData, $storeId)
{
$object = new Varien_Object();
$object->setIdFieldName('entity_id')->setStoreId($storeId);
$this->_getWriteAdapter()->beginTransaction();
try {
foreach ($attrData as $attrCode => $value) {
$attribute = $this->getAttribute($attrCode);
if (!$attribute->getAttributeId()) {
continue;
}
$i = 0;
foreach ($entityIds as $entityId) {
$object->setId($entityId);
// collect data for save
$this->_saveAttributeValue($object, $attribute, $value);
// save collected data every 1000 rows
if ($i % 1000 == 0) {
$this->_processAttributeValues();
}
}
}
$this->_processAttributeValues();
$this->_getWriteAdapter()->commit();
} catch (Exception $e) {
$this->_getWriteAdapter()->rollBack();
throw $e;
}
return $this;
}
示例6: _createRowObject
/**
* Converts map array to microdata Object
*
* @param array $map map array returned by the generator
* @return null|Varien_Object
*/
protected function _createRowObject($map)
{
if (empty($map['price']) || empty($map['availability']) || empty($map['title'])) {
return null;
}
$microdata = new Varien_Object();
$microdata->setName($map['title']);
$microdata->setId($map['id']);
if (!empty($map['sale_price'])) {
$price = $map['sale_price'];
} else {
$price = $map['price'];
}
$microdata->setPrice(Zend_Locale_Format::toNumber($price, array('precision' => 2, 'number_format' => '#0.00')));
$microdata->setCurrency(Mage::app()->getStore()->getCurrentCurrencyCode());
if ($map['availability'] == 'in stock') {
$microdata->setAvailability('http://schema.org/InStock');
} else {
$microdata->setAvailability('http://schema.org/OutOfStock');
}
if (array_key_exists('condition', $map)) {
if (strcasecmp('new', $map['condition']) == 0) {
$microdata->setCondition('http://schema.org/NewCondition');
} else {
if (strcasecmp('used', $map['condition']) == 0) {
$microdata->setCondition('http://schema.org/UsedCondition');
} else {
if (strcasecmp('refurbished', $map['condition']) == 0) {
$microdata->setCondition('http://schema.org/RefurbishedCondition');
}
}
}
}
return $microdata;
}
示例7: _prepareObject
protected function _prepareObject(array $data)
{
$object = new Varien_Object();
$object->setId($data['post_id']);
$object->setUrl($data['url']);
$object->setDate($data['date']);
return $object;
}
示例8: _prepareCategory
/**
* Prepare category
*
* @param array $categoryRow
* @return Varien_Object
*/
protected function _prepareCategory(array $categoryRow)
{
$category = new Varien_Object();
$category->setId($categoryRow[$this->getIdFieldName()]);
$categoryUrl = $this->getCategoryUrl($categoryRow, $category);
$category->setUrl($categoryUrl);
return $category;
}
示例9: _beforeSave
protected function _beforeSave(Varien_Object $object)
{
if (!$object->getId() && $object->getSku()) {
$object->setId($this->getIdBySku($object->getSku()));
}
if (is_array($object->getData('category_ids'))) {
$object->setData('category_ids', implode(',', $object->getData('category_ids')));
}
return parent::_beforeSave($object);
}
示例10: testGetRecommendedCategoryIds
public function testGetRecommendedCategoryIds()
{
$productType = new Varien_Object();
$productType->setId('test_id_1');
$productTypeId = 'test_id_1';
$expectedResult = array(1, 2, 3);
$selectMock = $this->_getSelectMock(array('category_id'), 'mapping_product_type_id', 'test_id_1');
$adapterMock = $this->_getAdapterMock($selectMock, $expectedResult);
$this->_mockReadAdapter($adapterMock);
$result = $this->_object->getRecommendedCategoryIds($productTypeId);
$this->assertEquals($expectedResult, $result);
}
示例11: _ToHtml
public function _ToHtml()
{
$json = array();
$data = Mage::helper('core')->jsonDecode($this->getRequest()->getPost('data'));
foreach ($data as $f) {
$row = new Varien_Object();
$row->setId($f[0]);
$row->setCronExpr($f[1]);
$status = new Wyomind_Simplegoogleshopping_Block_Adminhtml_Simplegoogleshopping_Renderer_Status();
$json[] = array("id" => $f[0], "content" => $status->render($row));
}
return Mage::helper('core')->jsonEncode($json);
}
示例12: _prepareProduct
protected function _prepareProduct(array $productRow)
{
$product = new Varien_Object();
$product->setId($productRow[$this->getIdFieldName()]);
$id = $product->getId();
$productMedia = Mage::getModel('catalog/product')->load($id)->getImage();
$product->setMedia($productMedia);
$productName = Mage::getModel('catalog/product')->load($id)->getName();
$product->setName($productName);
$productUrl = !empty($productRow['url']) ? $productRow['url'] : 'catalog/product/view/id/' . $product->getId();
$product->setUrl($productUrl);
return $product;
}
示例13: jsonProductInfoAction
public function jsonProductInfoAction()
{
$response = new Varien_Object();
$id = $this->getRequest()->getParam('id');
if (intval($id) > 0) {
$product = Mage::getModel('catalog/product')->load($id);
$response->setId($id);
$response->addData($product->getData());
$response->setError(0);
} else {
$response->setError(1);
$response->setMessage(Mage::helper('catalog')->__('Unable to get the product ID.'));
}
$this->getResponse()->setBody($response->toJSON());
}
示例14: update
/**
* Mage_Catalog_Model_Resource_Eav_Mysql4_Import_Product_Action::update()
*
* @param mixed $entityId
* @param mixed $data = array('statics' => , 'attributes' => , 'inventories' => )
* @param mixed $storeId
* @return void
*/
public function update($entityId, $data, $storeId, $obj = null)
{
$object = new Varien_Object();
$object->setIdFieldName('entity_id')->setStoreId($storeId);
$this->_getWriteAdapter()->beginTransaction();
try {
if ($obj == null) {
$obj = new Varien_Object();
}
if (!$obj->getId()) {
$this->simpleLoad($obj, $entityId);
}
//update attributes
foreach ($data['attributes'] as $attrCode => $value) {
$attribute = $this->getAttribute($attrCode);
if (!$this->__checkApply($obj, $attribute)) {
continue;
}
$object->setId($entityId);
// collect data for save
$this->_saveAttributeValue($object, $attribute, $value);
// save collected data every 1000 rows
}
//update
$this->__updateProductValues($entityId, $data['statics']);
//update inventory
if (count($data['inventories']) > 0) {
$stockItem = Mage::getSingleton('cataloginventory/stock_item');
$stockItem->setData(array());
$stockItem->loadByProduct($entityId)->setProductId($entityId);
$stockDataChanged = false;
foreach ($data['inventories'] as $k => $v) {
$stockItem->setDataUsingMethod($k, $v);
if ($stockItem->dataHasChangedFor($k)) {
$stockDataChanged = true;
}
}
if ($stockDataChanged) {
$stockItem->save();
}
}
$this->_processAttributeValues();
$this->_getWriteAdapter()->commit();
} catch (Exception $e) {
$this->_getWriteAdapter()->rollBack();
throw $e;
}
}
示例15: getCollection
public function getCollection($storeId)
{
$pages = parent::getCollection($storeId);
$select = Mage::getModel('amlanding/page')->getCollection()->addFieldToFilter('is_active', 1)->getSelect()->join(array('amlanding_page_store' => $this->getTable('amlanding/page_store')), 'main_table.page_id = amlanding_page_store.page_id', array())->where('amlanding_page_store.store_id IN (?)', array($storeId));
$query = $this->_getWriteAdapter()->query($select);
$urlSuffix = Mage::helper('catalog/category')->getCategoryUrlSuffix($storeId);
$urlSuffix = $urlSuffix ? $urlSuffix : '';
while ($row = $query->fetch()) {
$object = new Varien_Object();
$object->setId($row['page_id']);
$object->setUrl($row['identifier'] . $urlSuffix);
$object->setTitle($row['title']);
$pages[] = $object;
}
return $pages;
}