->group(array('entity_id', 'customer_group_id', 'website_id'));
$query = $select->insertFromSelect($copTable);
$write->query($query);
$table = array('i' => $this->_getDefaultFinalPriceTable());
$select = $write->select()
public function getValues($store_id)
{
$this->getSelect()
->joinLeft(array('default_value_price'=>$this->getTable('catalog/product_option_type_price')),
'`default_value_price`.option_type_id=`main_table`.option_type_id AND '.$this->getConnection()->quoteInto('`default_value_price`.store_id=?',0),
array('default_price'=>'price','default_price_type'=>'price_type'))
->joinLeft(array('store_value_price'=>$this->getTable('catalog/product_option_type_price')),
'`store_value_price`.option_type_id=`main_table`.option_type_id AND '.$this->getConnection()->quoteInto('`store_value_price`.store_id=?', $store_id),
if ($this->_categoryAttributes[$attributeCode]['is_global'] || $category->getStoreId() == 0) {
$attributeData['store_id'] = 0;
}
$select = $this->_getWriteAdapter()->select()
->from($attributeTable)
->where('entity_type_id=?', $attributeData['entity_type_id'])
->where('attribute_id=?', $attributeData['attribute_id'])
->where('store_id=?', $attributeData['store_id'])
->where('entity_id=?', $attributeData['entity_id']);
if ($row = $this->_getWriteAdapter()->fetchRow($select)) {
$whereCond = $this->_getWriteAdapter()->quoteInto('value_id=?', $row['value_id']);
$this->_getWriteAdapter()->update($attributeTable, $attributeData, $whereCond);
}
else {
$this->_getWriteAdapter()->insert($attributeTable, $attributeData);
}
if ($attributeData['store_id'] != 0) {
$attributeData['store_id'] = 0;
$this->_prepareDataForSave($product, $productData);
try {
/**
* @todo implement full validation process with errors returning which are ignoring now
* @todo see Mage_Catalog_Model_Product::validate()
*/
if (is_array($errors = $product->validate())) {
$strErrors = array();
if (property_exists($productData, 'website_ids') && is_array($productData->website_ids)) {
$product->setWebsiteIds($productData->website_ids);
}
if (property_exists($productData, 'additional_attributes')) {
foreach ($productData->additional_attributes as $_attribute) {
$_attrCode = $_attribute->key;
$productData->$_attrCode = $_attribute->value;
public function setAttribute($attribute)
{
$this->_attribute = $attribute;
return $this;
}
/**
* Get attribute instance
*
* @return Mage_Catalog_Model_Resource_Eav_Attribute
*/
public function getAttribute()
{
return $this->_attribute;
}
/**
* Add Value Sort To Collection Select
*
* @param Mage_Eav_Model_Entity_Collection_Abstract $collection
* @param string $dir direction
* @return Mage_Eav_Model_Entity_Attribute_Source_Abstract
*/
public function addValueSortToCollection($collection, $dir = 'asc')
{
if ($this->getAttribute()->isScopeGlobal()) {
$tableName = $this->getAttribute()->getAttributeCode() . '_t';
$collection->getSelect()
->joinLeft(
array($tableName => $this->getAttribute()->getBackend()->getTable()),
"`e`.`entity_id`=`{$tableName}`.`entity_id`"
. " AND `{$tableName}`.`attribute_id`='{$this->getAttribute()->getId()}'"
. " AND `{$tableName}`.`store_id`='0'",
array());
$valueExpr = $tableName . '.value';
}
else {
$valueTable1 = $this->getAttribute()->getAttributeCode() . '_t1';
$valueTable2 = $this->getAttribute()->getAttributeCode() . '_t2';
$collection->getSelect()
->joinLeft(
array($valueTable1 => $this->getAttribute()->getBackend()->getTable()),
"`e`.`entity_id`=`{$valueTable1}`.`entity_id`"
. " AND `{$valueTable1}`.`attribute_id`='{$this->getAttribute()->getId()}'"
$links[(int)$linkedProductId][$attribute['code']] = $data[$attribute['code']];
}
}
try {
$link->getResource()->saveProductLinks($product, $links, $typeId);
} catch (Exception $e) {
$this->_fault('data_invalid', Mage::helper('catalog')->__('Link product does not exist.'));
$attributes = array(
'custom_design' => array(
'group' => 'design',
'sort' => 10
),
'custom_design_apply' => array(
'group' => 'design',
'sort' => 20
),
'custom_design_from' => array(
'group' => 'design',
'sort' => 30
),
'custom_design_to' => array(
'group' => 'design',
'sort' => 40
),
'page_layout' => array(
'group' => 'design',
'sort' => 50
),
'custom_layout_update' => array(
'group' => 'design',
if (!$_FILES) {
?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php
exit;
}
if (!empty($_FILES['io_file']['tmp_name'])) {
//$this->setData(file_get_contents($_FILES['io_file']['tmp_name']));
$uploader = new Varien_File_Uploader('io_file');
$uploader->setAllowedExtensions(array('csv','xml'));
$path = Mage::app()->getConfig()->getTempVarDir().'/import/';
$uploader->save($path);
->addRatingInfo(Mage::app()->getStore()->getId())
->load();
$this->setRatingCollection( ( $ratingCollection->getSize() ) ? $ratingCollection : false );
}
return $this->getRatingCollection();
}
/**
* Retrieve rating summary for current product
*
protected function _prepareLayout()
{
if ($headBlock = $this->getLayout()->getBlock('head')) {
$headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId()));
}
$this->setChild(
$select->group(array(
'period',
'store_id',
'order_status'
));
$select->having('orders_count > 0');
$this->_getWriteAdapter()->query($select->insertFromSelect($table, array_keys($columns)));
$select->reset();
$columns = array(
'period' => 'period',
'store_id' => new Zend_Db_Expr('0'),
'order_status' => 'order_status',
Mage_Sales_Model_Order::STATE_CANCELED),
array()
);
$filterSubSelect = $this->_getWriteAdapter()->select();
$filterSubSelect->from(array('filter_source_table' => $sourceTable), 'MAX(filter_source_table.entity_id)')
$select->group(array(
'period',
'store_id',
'order_status'
));
$select->having('orders_count > 0');
$this->_getWriteAdapter()->query($select->insertFromSelect($table, array_keys($columns)));
$select->reset();
$columns = array(
'period' => 'period',
'store_id' => new Zend_Db_Expr('0'),
'order_status' => 'order_status',
'orders_count' => 'SUM(orders_count)',
'product_id' => array('type'=>'static'),
'super_product_id' => array('type'=>'static'),
'parent_product_id' => array('type'=>'static'),
'sku' => array('type'=>'static'),
'name' => array('type'=>'static'),
'description' => array('type'=>'static'),
'weight' => array('type'=>'static'),
'free_shipping' => array('type'=>'static'),
'qty' => array('type'=>'static'),
'is_qty_decimal'=> array('type'=>'static'),
'price' => array('type'=>'static'),
'custom_price' => array('type'=>'static'),
'discount_percent' => array('type'=>'static'),
'discount_amount' => array('type'=>'static'),
'no_discount' => array('type'=>'static'),
'address_type' => array('type'=>'static'),
'customer_id' => array('type'=>'static'),
'customer_address_id' => array('type'=>'static'),
'save_in_address_book' => array('type'=>'static'),
'email' => array('type'=>'static'),
'prefix' => array('type'=>'static'),
'firstname' => array('type'=>'static'),
'middlename'=> array('type'=>'static'),
'lastname' => array('type'=>'static'),
'suffix' => array('type'=>'static'),
'company' => array('type'=>'static'),
'street' => array('type'=>'static'),
'city' => array('type'=>'static'),
'region' => array('type'=>'static'),
'region_id' => array('type'=>'static'),
'postcode' => array('type'=>'static'),
'country_id'=> array('type'=>'static'),
'telephone' => array('type'=>'static'),
'quote_item_id' => array('type'=>'int'),
'product_id' => array('type'=>'int'),
'super_product_id' => array('type'=>'int'),
'parent_product_id' => array('type'=>'int'),
'sku' => array(),
'image' => array(),
'name' => array(),
'description' => array('type'=>'text'),
'weight' => array('type'=>'decimal'),
'free_shipping' => array('type'=>'int'),
'qty' => array('type'=>'decimal'),
'is_qty_decimal'=> array('type'=>'int'),
'price' => array('type'=>'decimal'),
'discount_percent' => array('type'=>'decimal'),
'discount_amount' => array('type'=>'decimal'),
'no_discount' => array('type'=>'int'),
'tax_percent' => array('type'=>'decimal'),
'tax_amount' => array('type'=>'decimal'),
'method' => array(),
'additional_data' => array('type'=>'text'),
'po_number' => array(),
'cc_type' => array(),
'cc_number_enc' => array(),
'cc_last4' => array(),
'cc_owner' => array(),
'cc_exp_month' => array('type'=>'int'),
'cc_exp_year' => array('type'=>'int'),
'cc_cid_enc' => array(),
'cc_ss_issue' => array(),
'cc_ss_start_month' => array('type'=>'int'),
'cc_ss_start_year' => array('type'=>'int'),
),
),
'order' => array(
'entity_model' => 'sales/order',
'table'=>'sales/order',
'increment_model'=>'eav/entity_increment_numeric',
'increment_per_store'=>true,
'backend_prefix'=>'sales_entity/order_attribute_backend',
'attributes' => array(
'entity_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_attribute_backend_parent'
),
'store_id' => array('type'=>'static'),
'store_name' => array('type'=>'varchar'),
'remote_ip' => array(),
'status' => array('type'=>'varchar'),
'state' => array('type'=>'varchar'),
'hold_before_status' => array('type'=>'varchar'),
'hold_before_state' => array('type'=>'varchar'),
'relation_parent_id' => array('type'=>'varchar'),
'relation_parent_real_id' => array('type'=>'varchar'),
'relation_child_id' => array('type'=>'varchar'),
'relation_child_real_id' => array('type'=>'varchar'),
'original_increment_id' => array('type'=>'varchar'),
'edit_increment' => array('type'=>'int'),
'ext_order_id' => array('type'=>'varchar'),
'ext_customer_id' => array('type'=>'varchar'),
'quote_id' => array('type'=>'int'),
'quote_address_id' => array('type'=>'int'),
'base_subtotal' => array('type'=>'static'),
'base_grand_total' => array('type'=>'static'),
'base_total_paid' => array('type'=>'static'),
'base_total_due' => array('type'=>'decimal'),
'base_total_refunded' => array('type'=>'static'),
'base_total_qty_ordered' => array('type'=>'static'),
'base_total_canceled' => array('type'=>'static'),
'base_total_invoiced' => array('type'=>'static'),
'base_total_online_refunded' => array('type'=>'static'),
'base_total_offline_refunded'=> array('type'=>'static'),
'base_adjustment_positive' => array('type'=>'decimal'),
'base_adjustment_negative' => array('type'=>'decimal'),
'subtotal_refunded' => array('type'=>'static'),
'subtotal_canceled' => array('type'=>'static'),
'discount_refunded' => array('type'=>'static'),
'discount_canceled' => array('type'=>'static'),
'discount_invoiced' => array('type'=>'static'),
'subtotal_invoiced' => array('type'=>'static'),
'tax_refunded' => array('type'=>'static'),
'tax_canceled' => array('type'=>'static'),
'tax_invoiced' => array('type'=>'static'),
'shipping_refunded' => array('type'=>'static'),
'shipping_canceled' => array('type'=>'static'),
'shipping_invoiced' => array('type'=>'static'),
'base_subtotal_refunded' => array('type'=>'static'),
'protect_code' => array('type' => 'static'),
'customer_id' => array('type'=>'static', 'visible'=>false),
'customer_group_id' => array('type'=>'int', 'visible'=>false),
'customer_email' => array('type'=>'varchar', 'visible'=>false),
'customer_prefix' => array('type'=>'varchar', 'visible'=>false),
'customer_firstname'=> array('type'=>'varchar', 'visible'=>false),
'customer_gender' => array('type'=>'int', 'visible'=>false),
),
),
'order_address' => array(
'entity_model' => 'sales/order_address',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array('type'=>'static', 'backend'=>'sales_entity/order_attribute_backend_child'),
'quote_address_id' => array('type'=>'int'),
'row_total' => array('type'=>'decimal'),
'row_weight' => array('type'=>'decimal'),
'row_invoiced' => array('type'=>'decimal'),
'invoiced_total' => array('type'=>'decimal'),
'amount_refunded' => array('type'=>'decimal'),
'base_price' => array('type'=>'decimal'),
'base_original_price' => array('type'=>'decimal'),
'base_discount_amount' => array('type'=>'decimal'),
'base_discount_invoiced' => array('type'=>'decimal'),
'base_tax_amount' => array('type'=>'decimal'),
'base_tax_invoiced' => array('type'=>'decimal'),
'base_row_total' => array('type'=>'decimal'),
'base_row_invoiced' => array('type'=>'decimal'),
'base_invoiced_total' => array('type'=>'decimal'),
'base_amount_refunded' => array('type'=>'decimal'),
'applied_rule_ids' => array(),
'additional_data' => array('type'=>'text'),
),
),
'order_payment' => array(
'entity_model' => 'sales/order_payment',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_attribute_backend_child'
),
'quote_payment_id' => array('type'=>'int'),
'method' => array(),
'additional_data' => array('type'=>'text'),
'last_trans_id' => array(),
'po_number' => array(),
'cc_type' => array(),
'cc_number_enc' => array(),
'cc_last4' => array(),
'cc_owner' => array(),
'cc_exp_month' => array(),
'cc_exp_year' => array(),
'cc_ss_issue' => array(),
'cc_ss_start_month' => array(),
'cc_ss_start_year' => array(),
'cc_status' => array(),
'cc_status_description' => array(),
'cc_trans_id' => array(),
'cc_approval' => array(),
'cc_avs_status' => array(),
'cc_cid_status' => array(),
'cc_debug_request_body' => array(),
'cc_debug_response_body'=> array(),
'cc_debug_response_serialized' => array(),
'anet_trans_method' => array(),
'echeck_routing_number' => array(),
'echeck_bank_name' => array(),
'echeck_account_type' => array(),
'echeck_account_name' => array(),
'echeck_type' => array(),
'base_amount_refunded_online' => array('type'=>'decimal'),
'base_shipping_amount' => array('type'=>'decimal'),
'base_shipping_captured' => array('type'=>'decimal'),
'base_shipping_refunded' => array('type'=>'decimal'),
),
),
'order_status_history' => array(
'entity_model' => 'sales/order_status_history',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_attribute_backend_child'
),
'status' => array('type'=>'varchar'),
'comment' => array('type'=>'text'),
'is_customer_notified' => array('type'=>'int'),
),
),
'invoice' => array(
'entity_model' => 'sales/order_invoice',
'table' =>'sales/order_entity',
'increment_model' =>'eav/entity_increment_numeric',
'increment_per_store'=>true,
'backend_prefix' =>'sales_entity/order_attribute_backend',
'attributes' => array(
'entity_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_invoice_attribute_backend_parent'
),
'state' => array('type'=>'int'),
'is_used_for_refund' => array('type'=>'int'),
'transaction_id' => array(),
'order_id' => array(
'type'=>'int',
'backend'=>'sales_entity/order_invoice_attribute_backend_order'
),
'billing_address_id' => array('type'=>'int'),
'shipping_address_id' => array('type'=>'int'),
'global_currency_code' => array(),
'base_currency_code' => array(),
'store_currency_code' => array(),
'order_currency_code' => array(),
'store_to_base_rate' => array('type'=>'decimal'),
'store_to_order_rate' => array('type'=>'decimal'),
'base_to_global_rate' => array('type'=>'decimal'),
'base_to_order_rate' => array('type'=>'decimal'),
'subtotal' => array('type'=>'decimal'),
'discount_amount' => array('type'=>'decimal'),
'invoice_item' => array(
'entity_model' => 'sales/order_invoice_item',
//'table'=>'sales/invoice',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_invoice_attribute_backend_child'
),
'order_item_id' => array('type'=>'int'),
'product_id' => array('type'=>'int'),
'name' => array(),
'description' => array('type'=>'text'),
'sku' => array(),
'qty' => array('type'=>'decimal'),
'cost' => array('type'=>'decimal'),
'price' => array('type'=>'decimal'),
'discount_amount' => array('type'=>'decimal'),
'tax_amount' => array('type'=>'decimal'),
'row_total' => array('type'=>'decimal'),
'base_price' => array('type'=>'decimal'),
'base_discount_amount' => array('type'=>'decimal'),
'base_tax_amount' => array('type'=>'decimal'),
'base_row_total' => array('type'=>'decimal'),
'additional_data' => array('type'=>'text'),
),
),
'invoice_comment' => array(
'entity_model' => 'sales/order_invoice_comment',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_invoice_attribute_backend_child'
),
'comment' => array('type'=>'text'),
'is_customer_notified' => array('type'=>'int'),
),
),
'shipment' => array(
'entity_model' => 'sales/order_shipment',
//'table'=>'sales/shipment',
'table'=>'sales/order_entity',
'increment_model'=>'eav/entity_increment_numeric',
'shipment_item' => array(
'entity_model' => 'sales/order_shipment_item',
//'table'=>'sales/shipment',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_shipment_attribute_backend_child'
),
'order_item_id' => array('type'=>'int'),
'product_id' => array('type'=>'int'),
'name' => array(),
'description' => array('type'=>'text'),
'sku' => array(),
'qty' => array('type'=>'decimal'),
'price' => array('type'=>'decimal'),
'weight' => array('type'=>'decimal'),
'row_total' => array('type'=>'decimal'),
'additional_data' => array('type'=>'text'),
),
),
'shipment_comment' => array(
'entity_model' => 'sales/order_shipment_comment',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_shipment_attribute_backend_child'
),
'comment' => array('type'=>'text'),
'is_customer_notified' => array('type'=>'int'),
),
),
'shipment_track' => array(
'entity_model' => 'sales/order_shipment_track',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_shipment_attribute_backend_child'
),
'order_id' => array('type'=>'int'),
'number' => array('type'=>'text'),
'carrier_code' => array('type'=>'varchar'),
'title' => array('type'=>'varchar'),
'description' => array('type'=>'text'),
'qty' => array('type'=>'decimal'),
'weight' => array('type'=>'decimal'),
),
),
'creditmemo' => array(
'entity_model' => 'sales/order_creditmemo',
//'table'=>'sales/creditmemo',
'table'=>'sales/order_entity',
'increment_model'=>'eav/entity_increment_numeric',
'increment_per_store'=>true,
'backend_prefix'=>'sales_entity/order_attribute_backend',
'attributes' => array(
'entity_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_creditmemo_attribute_backend_parent'
),
'state' => array('type'=>'int'),
'invoice_id' => array('type'=>'int'),
'transaction_id'=> array(),
'order_id' => array('type'=>'int'),
'creditmemo_status' => array('type'=>'int'),
'billing_address_id' => array('type'=>'int'),
'shipping_address_id' => array('type'=>'int'),
'global_currency_code' => array(),
'base_currency_code' => array(),
'store_currency_code' => array(),
'order_currency_code' => array(),
'store_to_base_rate' => array('type'=>'decimal'),
'store_to_order_rate' => array('type'=>'decimal'),
'base_to_global_rate' => array('type'=>'decimal'),
'base_to_order_rate' => array('type'=>'decimal'),
'subtotal' => array('type'=>'decimal'),
'discount_amount' => array('type'=>'decimal'),
'tax_amount' => array('type'=>'decimal'),
'shipping_amount' => array('type'=>'decimal'),
'adjustment' => array('type'=>'decimal'),
'adjustment_positive' => array('type'=>'decimal'),
'creditmemo_item' => array(
'entity_model' => 'sales/order_creditmemo_item',
//'table'=>'sales/creditmemo',
'table'=>'sales/order_entity',
'attributes' => array(
'parent_id' => array(
'type'=>'static',
'backend'=>'sales_entity/order_creditmemo_attribute_backend_child'
),
'order_item_id' => array('type'=>'int'),
'product_id' => array('type'=>'int'),
'name' => array(),
'description' => array('type'=>'text'),
'sku' => array(),
'qty' => array('type'=>'decimal'),
'cost' => array('type'=>'decimal'),
'price' => array('type'=>'decimal'),
'discount_amount' => array('type'=>'decimal'),
'tax_amount' => array('type'=>'decimal'),
'row_total' => array('type'=>'decimal'),
$this->_totals['avgsale'] = $this->_totals['base_lifetime'] / $this->_totals['num_orders'];
}
}
return $this;
}
/**
* Print and/or log query
*
* @param boolean $printQuery
* @param boolean $logQuery
* @param mixed $sql
* @return Mage_Sales_Model_Mysql4_Sale_Collection
*/
public function printLogQuery($printQuery = false, $logQuery = false, $sql = null) {
if ($printQuery) {
if (!$order->getId()) {
$this->_fault('order_not_exists');
}
/**
* Check invoice create availability
*/
if (!$order->canInvoice()) {
$this->_fault('data_invalid', Mage::helper('sales')->__('Cannot do invoice for order.'));
if (!$order->getId()) {
$this->_fault('order_not_exists');
}
/**
* Check shipment create availability
*/
if (!$order->canShip()) {
$this->_fault('data_invalid', Mage::helper('sales')->__('Cannot do shipment for order.'));
}
/* @var $shipment Mage_Sales_Model_Order_Shipment */
$shipment = $order->prepareShipment($itemsQty);
return $pdf;
}
/**
* Create new page and assign to PDF object
*
* @param array $settings
* @return Zend_Pdf_Page
*/
public function newPage(array $settings = array())
{
/* Add new table head */
$page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
$this->_getPdf()->pages[] = $page;
$order->setTotalInvoiced($order->getTotalInvoiced() - $this->getGrandTotal());
$order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() - $this->getBaseGrandTotal());
$order->setSubtotalInvoiced($order->getSubtotalInvoiced() - $this->getSubtotal());
$order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() - $this->getBaseSubtotal());
$order->setTaxInvoiced($order->getTaxInvoiced() - $this->getTaxAmount());
$order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() - $this->getBaseTaxAmount());
$order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() - $this->getHiddenTaxAmount());
$order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() - $this->getBaseHiddenTaxAmount());
if (!Mage::helper('sales')->canSendNewShipmentEmail($this->getOrder()->getStore()->getId())) {
return $this;
}
$currentDesign = Mage::getDesign()->setAllGetOld(array(
'package' => Mage::getStoreConfig('design/package/name', $this->getStoreId()),
'store' => $this->getStoreId()
));
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
$order = $this->getOrder();
$copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
$copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStoreId());
if (!$notifyCustomer && !$copyTo) {
return $this;
}
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($order->getStore()->getId());
$mailTemplate = Mage::getModel('core/email_template');
if ($order->getCustomerIsGuest()) {
$template = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $order->getStoreId());
$customerName = $order->getBillingAddress()->getName();
} else {
$template = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $order->getStoreId());
$customerName = $order->getCustomerName();
}
if ($notifyCustomer) {
$sendTo[] = array(
'name' => $customerName,
'email' => $order->getCustomerEmail()
);
if ($copyTo && $copyMethod == 'bcc') {
$mailTemplate = Mage::getModel('core/email_template');
if ($order->getCustomerIsGuest()) {
$template = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, $order->getStoreId());
$customerName = $order->getBillingAddress()->getName();
} else {
$template = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_TEMPLATE, $order->getStoreId());
$customerName = $order->getCustomerName();
}
if ($notifyCustomer) {
$sendTo[] = array(
'name' => $customerName,
'email' => $order->getCustomerEmail()
);
if ($copyTo && $copyMethod == 'bcc') {
foreach ($copyTo as $email) {
if (!Mage::helper('sales')->canSendNewShipmentEmail($this->getOrder()->getStore()->getId())) {
return $this;
}
$currentDesign = Mage::getDesign()->setAllGetOld(array(
'package' => Mage::getStoreConfig('design/package/name', $this->getStoreId()),
'store' => $this->getStoreId()
));
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
$order = $this->getOrder();
$copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
$copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStoreId());
if (!$notifyCustomer && !$copyTo) {
return $this;
}
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($order->getStore()->getId());
$mailTemplate = Mage::getModel('core/email_template');
if ($order->getCustomerIsGuest()) {
$template = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $order->getStoreId());
$customerName = $order->getBillingAddress()->getName();
} else {
$template = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $order->getStoreId());
$customerName = $order->getCustomerName();
}
if ($notifyCustomer) {
$sendTo[] = array(
'name' => $customerName,
'email' => $order->getCustomerEmail()
);
if ($copyTo && $copyMethod == 'bcc') {
foreach ($copyTo as $email) {
if (!Mage::helper('sales')->canSendShipmentCommentEmail($this->getOrder()->getStore()->getId())) {
return $this;
}
$currentDesign = Mage::getDesign()->setAllGetOld(array(
'package' => Mage::getStoreConfig('design/package/name', $this->getStoreId()),
));
$translate = Mage::getSingleton('core/translate');
/* @var $translate Mage_Core_Model_Translate */
$translate->setTranslateInline(false);
$order = $this->getOrder();
$copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO);
$copyMethod = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, $this->getStoreId());
if (!$notifyCustomer && !$copyTo) {
return $this;
}
$mailTemplate = Mage::getModel('core/email_template');
if ($order->getCustomerIsGuest()) {
$template = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, $order->getStoreId());
$customerName = $order->getBillingAddress()->getName();
} else {
$template = Mage::getStoreConfig(self::XML_PATH_UPDATE_EMAIL_TEMPLATE, $order->getStoreId());
$customerName = $order->getCustomerName();
}
if ($notifyCustomer) {
$sendTo[] = array(
'name' => $customerName,
'email' => $order->getCustomerEmail()
);
if ($copyTo && $copyMethod == 'bcc') {
foreach ($copyTo as $email) {
public function items($filters = null)
{
//TODO: add full name logic
$billingAliasName = 'billing_o_a';
$shippingAliasName = 'shipping_o_a';
$collection = Mage::getModel("sales/order")->getCollection()
$store = $this->getInvoice()->getStore();
$orderItem = $this->getOrderItem();
$orderItemQty = $orderItem->getQtyOrdered();
$rowTotal = $orderItem->getRowTotal();
$baseRowTotal = $orderItem->getBaseRowTotal();
try {
$installer->getConnection()->beginTransaction();
foreach ($attributes as $attribute) {
$installer->run("
UPDATE {$this->getTable('sales_order')} AS o, {$this->getTable('sales_order')}_{$attribute['backend_type']} AS od
SET o.{$attribute['attribute_code']} = od.value
WHERE od.entity_id = o.entity_id
AND od.attribute_id = {$attribute['attribute_id']}
CREATE TABLE `{$installer->getTable('sales_flat_shipment')}` (
`entity_id` int(10) unsigned NOT NULL auto_increment,
`store_id` smallint(5) unsigned default NULL,
`total_weight` decimal(12,4) default NULL,
`total_qty` decimal(12,4) default NULL,
`email_sent` tinyint(1) unsigned default NULL,
`order_id` int(10) unsigned NOT NULL,
`customer_id` int(10) default NULL,
`shipping_address_id` int(10) default NULL,
`billing_address_id` int(10) default NULL,
`shipment_status` int(10) default NULL,
`increment_id` varchar(50) default NULL,
`created_at` datetime default NULL,
`updated_at` datetime default NULL,
PRIMARY KEY (`entity_id`),
KEY `IDX_STORE_ID` (`store_id`),
KEY `IDX_TOTAL_QTY` (`total_qty`),
KEY `IDX_INCREMENT_ID` (`increment_id`),
KEY `IDX_ORDER_ID` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/* Shipments Grid */
CREATE TABLE `{$installer->getTable('sales_flat_shipment_grid')}` (
$constraints = array(
'sales_flat_order' => array(
'customer' => array('customer_id', 'customer_entity', 'entity_id', 'set null'),
'store' => array('store_id', 'core_store', 'store_id', 'set null'),
),
'sales_flat_order_grid' => array(
'parent' => array('entity_id', 'sales_flat_order', 'entity_id'),
'customer' => array('customer_id', 'customer_entity', 'entity_id', 'set null'),
'store' => array('store_id', 'core_store', 'store_id', 'set null'),
),
'sales_flat_order_item' => array(
'parent' => array('order_id', 'sales_flat_order', 'entity_id'),
'store' => array('store_id', 'core_store', 'store_id', 'set null'),
),
'sales_flat_order_address' => array(
'parent' => array('parent_id', 'sales_flat_order', 'entity_id'),
),
'sales_flat_order_payment' => array(
'parent' => array('parent_id', 'sales_flat_order', 'entity_id'),
),
'sales_flat_order_status_history' => array(
'parent' => array('parent_id', 'sales_flat_order', 'entity_id'),
),
'sales_flat_shipment' => array(
'parent' => array('order_id', 'sales_flat_order', 'entity_id'),
'store' => array('store_id', 'core_store', 'store_id', 'set null')
),
'sales_flat_shipment_grid' => array(
'parent' => array('entity_id', 'sales_flat_shipment', 'entity_id'),
'store' => array('store_id', 'core_store', 'store_id', 'set null')
),
'sales_flat_shipment_track' => array(
'parent' => array('parent_id', 'sales_flat_shipment', 'entity_id'),
),
'sales_flat_shipment_item' => array(
'parent' => array('parent_id', 'sales_flat_shipment', 'entity_id'),
),
'sales_flat_shipment_comment' => array(
'parent' => array('parent_id', 'sales_flat_shipment', 'entity_id'),
),
'sales_flat_invoice' => array(
'parent' => array('order_id', 'sales_flat_order', 'entity_id'),
'store' => array('store_id', 'core_store', 'store_id', 'set null')
),
'sales_flat_invoice_grid' => array(
'parent' => array('entity_id', 'sales_flat_invoice', 'entity_id'),
'store' => array('store_id', 'core_store', 'store_id', 'set null')
),
'sales_flat_invoice_item' => array(
'parent' => array('parent_id', 'sales_flat_invoice', 'entity_id'),
),
'sales_flat_invoice_comment' => array(
'parent' => array('parent_id', 'sales_flat_invoice', 'entity_id'),
),
'sales_flat_creditmemo' => array(
->load()
->getItems();
if( count($tags) == 0 ) {
return $this;
}
$this->_maxPopularity = reset($tags)->getPopularity();
return $html;
}
protected function getShippingMethods()
{
if (!$this->hasData('shipping_methods')) {
$website = $this->getRequest()->getParam('website');
$store = $this->getRequest()->getParam('store');
$storeId = null;
if (!is_null($website)) {
$storeId = Mage::getModel('core/website')->load($website, 'code')->getDefaultGroup()->getDefaultStoreId();
} elseif (!is_null($store)) {
$storeId = Mage::getModel('core/store')->load($store, 'code')->getId();
}
$methods = array();
$carriers = Mage::getSingleton('shipping/config')->getActiveCarriers($storeId);
foreach ($carriers as $carrierCode=>$carrierModel) {
if (!$carrierModel->isActive()) {
continue;
}
$carrierMethods = $carrierModel->getAllowedMethods();
if (!$carrierMethods) {
continue;
}
$carrierTitle = Mage::getStoreConfig('carriers/'.$carrierCode.'/title', $storeId);
$this->addColumn('in_products', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_products',
'values' => $this->_getSelectedProducts(),
'align' => 'center',
'index' => 'entity_id'
));
}
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => 60,
'index' => 'entity_id'
));
$this->addColumn('name', array(
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
));
$this->addColumn('type', array(
'header' => Mage::helper('catalog')->__('Type'),
'width' => 100,
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
->load()
->toOptionHash();
$this->addColumn('set_name', array(
'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
'width' => 130,
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
));
$this->addColumn('status', array(
'header' => Mage::helper('catalog')->__('Status'),
'width' => 90,
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
$this->addColumn('visibility', array(
'header' => Mage::helper('catalog')->__('Visibility'),
'width' => 90,
'index' => 'visibility',
'type' => 'options',
$this->setDefaultSort('entity_id');
$this->setUseAjax(true);
if ($this->_getProduct()->getId()) {
$this->setDefaultFilter(array('in_products'=>1));
}
}
/**
* Retirve currently edited product model
*
* @return Mage_Catalog_Model_Product
*/
protected function _getProduct()
{
return Mage::registry('current_product');
protected function _prepareColumns()
{
if (!$this->isReadonly()) {
$this->addColumn('in_products', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_products',
'values' => $this->_getSelectedProducts(),
'align' => 'center',
'index' => 'entity_id'
));
}
$this->addColumn('entity_id', array(
'header' => Mage::helper('catalog')->__('ID'),
'sortable' => true,
'width' => 60,
'index' => 'entity_id'
));
$this->addColumn('name', array(
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
));
$this->addColumn('type', array(
'header' => Mage::helper('catalog')->__('Type'),
'width' => 100,
'index' => 'type_id',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
));
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
->load()
->toOptionHash();
$this->addColumn('set_name', array(
'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
'width' => 130,
'index' => 'attribute_set_id',
'type' => 'options',
'options' => $sets,
));
$this->addColumn('status', array(
'header' => Mage::helper('catalog')->__('Status'),
'width' => 90,
'index' => 'status',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
));
$this->addColumn('visibility', array(
'header' => Mage::helper('catalog')->__('Visibility'),
'width' => 90,
'index' => 'visibility',
'type' => 'options',
'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(),
));
$this->addColumn('sku', array(
->setPopularQueryFilter($storeIds);
$this->setCollection($this->_collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('search_query', array(
'header' => $this->__('Search Term'),
'sortable' => false,
'index' => 'query_text',
'renderer' => 'adminhtml/dashboard_searches_renderer_searchquery',
));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('name', array(
'header' => $this->__('Customer Name'),
protected function _prepareCollection()
{
$collection = Mage::getModel('salesrule/rule')->getResourceCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
/**
* Prepare columns for rules grid
*
* @return Mage_Adminhtml_Block_Widget_Grid
*/
protected function _prepareColumns()
{
$this->addColumn('rule_id', array(
'header' => Mage::helper('salesrule')->__('ID'),
'align' => 'right',
'width' => '50px',
'index' => 'rule_id',
));
$this->addColumn('name', array(
'header' => Mage::helper('salesrule')->__('Rule Name'),
'align' => 'left',
'index' => 'name',
));
$this->addColumn('coupon_code', array(
'header' => Mage::helper('salesrule')->__('Coupon Code'),
'align' => 'left',
'width' => '150px',
'index' => 'code',
));
if (!Mage::app()->isSingleStoreMode()) {
$fieldset->addField('website_ids', 'multiselect', array(
'name' => 'website_ids[]',
'label' => Mage::helper('catalogrule')->__('Websites'),
'title' => Mage::helper('catalogrule')->__('Websites'),
'required' => true,
'values' => Mage::getSingleton('adminhtml/system_config_source_website')->toOptionArray(),
$format = $this->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$html = '<div class="range"><div class="range-line date">
<span class="label">' . Mage::helper('adminhtml')->__('From').':</span>
<input type="text" name="'.$this->_getHtmlName().'[from]" id="'.$htmlId.'_from" value="'.$this->getEscapedValue('from').'" class="input-text no-changes"/>
<img src="' . Mage::getDesign()->getSkinUrl('images/grid-cal.gif') . '" alt="" class="v-middle" id="'.$htmlId.'_from_trig" title="'.$this->htmlEscape(Mage::helper('adminhtml')->__('Date selector')).'"/>
</div>';
$html.= '<div class="range-line date">
$this->setCollection($collection);
return parent::_prepareCollection();
}
/**
* Prepare grid columns
*
* TODO: fix up this mess
*
* @return Mage_Sales_Block_Adminhtml_Recurring_Profile_View_Tab_Orders
*/
protected function _prepareColumns()
{
$this->addColumn('real_order_id', array(
'header'=> Mage::helper('sales')->__('Order #'),
'width' => '80px',
'type' => 'text',
'index' => 'increment_id',
));
if (!Mage::app()->isSingleStoreMode()) {
$this->addColumn('store_id', array(
'header' => Mage::helper('sales')->__('Purchased From (Store)'),
'index' => 'store_id',
'type' => 'store',
'store_view'=> true,
'display_deleted' => true,
));
}
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Purchased On'),
'index' => 'created_at',
'type' => 'datetime',
'width' => '100px',
));
$this->addColumn('billing_name', array(
'header' => Mage::helper('sales')->__('Bill to Name'),
'index' => 'billing_name',
));
$this->addColumn('shipping_name', array(
'header' => Mage::helper('sales')->__('Ship to Name'),
'index' => 'shipping_name',
));
$this->addColumn('base_grand_total', array(
'header' => Mage::helper('sales')->__('G.T. (Base)'),
'index' => 'base_grand_total',
'type' => 'currency',
'currency' => 'base_currency_code',
));
$this->addColumn('grand_total', array(
'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
'index' => 'grand_total',
'type' => 'currency',
'currency' => 'order_currency_code',
));
public function getDefaultRecipient()
{
if(!$this->getEntity()) {
return '';
}
if($this->getEntity()->getOrder()) {
if ($this->getEntity()->getOrder()->getShippingAddress()) {
'index' => 'created_at',
'type' => 'datetime',
));
$this->addColumn('order_increment_id', array(
'header' => Mage::helper('sales')->__('Order #'),
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('user_id', array(
'header' => Mage::helper('adminhtml')->__('ID'),
'width' => 5,
'align' => 'right',
'sortable' => true,
'index' => 'user_id'
));
$this->addColumn('username', array(
'header' => Mage::helper('adminhtml')->__('User Name'),
public function getStoreSelectOptions()
{
$section = $this->getRequest()->getParam('section');
$curWebsite = $this->getRequest()->getParam('website');
$curStore = $this->getRequest()->getParam('store');
$storeModel = Mage::getSingleton('adminhtml/system_store');
/* @var $storeModel Mage_Adminhtml_Model_System_Store */
$url = Mage::getModel('adminhtml/url');
$options = array();
$options['default'] = array(
'label' => Mage::helper('adminhtml')->__('Default Config'),
'url' => $url->getUrl('*/*/*', array('section'=>$section)),
'selected' => !$curWebsite && !$curStore,
'style' => 'background:#ccc; font-weight:bold;',
);
foreach ($storeModel->getWebsiteCollection() as $website) {
$websiteShow = false;
foreach ($storeModel->getGroupCollection() as $group) {
if ($group->getWebsiteId() != $website->getId()) {
continue;
}
$groupShow = false;
foreach ($storeModel->getStoreCollection() as $store) {
if ($store->getGroupId() != $group->getId()) {
continue;
}
if (!$websiteShow) {
$websiteShow = true;
$options['website_' . $website->getCode()] = array(
'label' => $website->getName(),
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
'selected' => !$curStore && $curWebsite == $website->getCode(),
'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
);
}
if (!$groupShow) {
$groupShow = true;
$options['group_' . $group->getId() . '_open'] = array(
'is_group' => true,
'is_close' => false,
protected function _prepareColumns()
{
$this->addColumn('name', array(
'header' => $this->__('Customer Name'),
'sortable' => false,
'index' => 'name'
));
$this->addColumn('orders_count', array(
'header' => $this->__('Number of Orders'),
'width' => '100px',
'sortable' => false,
'index' => 'orders_count',
'total' => 'sum',
'type' => 'number'
));
$baseCurrencyCode = $this->getCurrentCurrencyCode();
$this->addColumn('orders_avg_amount', array(
$this->setUseAjax(false);
}
protected function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
if ($quote) {
$collection = $quote->getItemsCollection(false);
}
else {
$collection = new Varien_Data_Collection();
}
$collection->addFieldToFilter('parent_item_id', array('null' => true));
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('product_id', array(
'header' => Mage::helper('customer')->__('Product ID'),
'index' => 'product_id',
'width' => '100px',
));
$this->addColumn('name', array(
'header' => Mage::helper('customer')->__('Product Name'),
'index' => 'name',
));
$this->addColumn('sku', array(
'header' => Mage::helper('customer')->__('SKU'),
'index' => 'sku',
'width' => '100px',
));
$this->addColumn('qty', array(
'index' => 'grand_total',
'type' => 'currency',
'currency' => 'order_currency_code',
));
if (!Mage::app()->isSingleStoreMode()) {
class Mage_Adminhtml_Block_Permissions_Role_Grid_User extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setDefaultSort('role_user_id');
$this->setDefaultDir('asc');
$this->setId('roleUserGrid');
$this->setDefaultFilter(array('in_role_users'=>1));
$this->setUseAjax(true);
}
protected function _addColumnFilterToCollection($column)
{
if ($column->getId() == 'in_role_users') {
$collection = Mage::getModel('admin/roles')->getUsersCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('in_role_users', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_role_users',
'values' => $this->_getUsers(),
'align' => 'center',
'index' => 'user_id'
));
$this->addColumn('role_user_id', array(
'header' =>Mage::helper('adminhtml')->__('User ID'),
'width' =>5,
'align' =>'left',
'sortable' =>true,
'index' =>'user_id'
));
$this->addColumn('role_user_username', array(
'header' =>Mage::helper('adminhtml')->__('User Name'),
'align' =>'left',
'index' =>'username'
));
$this->addColumn('role_user_firstname', array(
'header' =>Mage::helper('adminhtml')->__('First Name'),
'align' =>'left',
'index' =>'firstname'
));
$this->addColumn('role_user_lastname', array(
'header' =>Mage::helper('adminhtml')->__('Last Name'),
'align' =>'left',
'index' =>'lastname'
));
$this->addColumn('role_user_email', array(
'header' =>Mage::helper('adminhtml')->__('Email'),
'width' =>40,
'align' =>'left',
'index' =>'email'
));
$this->addColumn('role_user_is_active', array(
'header' => Mage::helper('adminhtml')->__('Status'),
'index' => 'is_active',
'align' =>'left',
'type' => 'options',
'options' => array('1' => Mage::helper('adminhtml')->__('Active'), '0' => Mage::helper('adminhtml')->__('Inactive')),
protected function _prepareLayout()
{
$this->setChild('backButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('adminhtml')->__('Back'),
'onclick' => 'window.location.href=\''.$this->getUrl('*/*/').'\'',
'class' => 'back'
))
);
$this->setChild('resetButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('adminhtml')->__('Reset'),
'onclick' => 'window.location.reload()'
))
);
$this->setChild('saveButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('adminhtml')->__('Save Role'),
'onclick' => 'roleForm.submit();return false;',
'class' => 'save'
))
);
$this->setChild('deleteButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData(array(
'label' => Mage::helper('adminhtml')->__('Delete Role'),
'onclick' => 'deleteConfirm(\'' . Mage::helper('adminhtml')->__('Are you sure you want to do this?') . '\', \'' . $this->getUrl('*/*/delete', array('rid' => $this->getRequest()->getParam('rid'))) . '\')',
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('user_id', array(
'header' => Mage::helper('adminhtml')->__('ID'),
'width' => 5,
'align' => 'right',
'sortable' => true,
'index' => 'user_id'
));
$this->addColumn('username', array(
'header' => Mage::helper('adminhtml')->__('User Name'),
'index' => 'username'
));
$this->addColumn('firstname', array(
'header' => Mage::helper('adminhtml')->__('First Name'),
'index' => 'firstname'
));
$this->addColumn('lastname', array(
'header' => Mage::helper('adminhtml')->__('Last Name'),
'index' => 'lastname'
));
$this->addColumn('email', array(
'header' => Mage::helper('adminhtml')->__('Email'),
'width' => 40,
'align' => 'left',
'index' => 'email'
));
$this->addColumn('is_active', array(
class Mage_Adminhtml_Block_Permissions_User_Edit_Tab_Roles extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setId('permissionsUserRolesGrid');
$this->setDefaultSort('sort_order');
$this->setDefaultDir('asc');
//$this->setDefaultFilter(array('assigned_user_role'=>1));
$this->setTitle(Mage::helper('adminhtml')->__('User Roles Information'));
$collection->setRolesFilter();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('assigned_user_role', array(
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('user_');
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Account Information')));
if ($model->getUserId()) {
$fieldset->addField('user_id', 'hidden', array(
'name' => 'user_id',
));
} else {
if (! $model->hasData('is_active')) {
$model->setIsActive(1);
}
}
$fieldset->addField('username', 'text', array(
'name' => 'username',
'label' => Mage::helper('adminhtml')->__('User Name'),
'id' => 'username',
'title' => Mage::helper('adminhtml')->__('User Name'),
'required' => true,
));
$fieldset->addField('firstname', 'text', array(
'name' => 'firstname',
'label' => Mage::helper('adminhtml')->__('First Name'),
'id' => 'firstname',
'title' => Mage::helper('adminhtml')->__('First Name'),
'required' => true,
));
$fieldset->addField('lastname', 'text', array(
'name' => 'lastname',
'label' => Mage::helper('adminhtml')->__('Last Name'),
$collection = Mage::getModel("admin/roles")->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('role_id', array(
public function _beforeToHtml() {
$this->_initForm();
return parent::_beforeToHtml();
}
protected function _initForm()
{
$roleId = $this->getRequest()->getParam('rid');
$form = new Varien_Data_Form();
$fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('adminhtml')->__('Role Information')));
$fieldset->addField('role_name', 'text',
$rootArray = $this->_getNodeJson($resources->admin, 1);
$json = Mage::helper('core')->jsonEncode(isset($rootArray['children']) ? $rootArray['children'] : array());
return $json;
}
protected function _sortTree($a, $b)
{
return $a['sort_order']<$b['sort_order'] ? -1 : ($a['sort_order']>$b['sort_order'] ? 1 : 0);
}
protected function _getNodeJson($node, $level=0)
{
$item = array();
$selres = $this->getSelectedResources();
if ($level != 0) {
$item['text']= (string)$node->title;
$item['sort_order']= isset($node->sort_order) ? (string)$node->sort_order : 0;
if ($child->children) {
$menuArr['children'] = $this->_buildMenuArray($child->children, $path.$childName.'/', $level+1);
}
$parentArr[$childName] = $menuArr;
$sortOrder++;
}
uasort($parentArr, array($this, '_sortMenu'));
while (list($key, $value) = each($parentArr)) {
$frequencyDaily = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_DAILY;
$frequencyWeekly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_WEEKLY;
$frequencyMonthly = Mage_Adminhtml_Model_System_Config_Source_Cron_Frequency::CRON_MONTHLY;
$cronDayOfWeek = date('N');
$cronExprArray = array(
intval($time[1]), # Minute
intval($time[0]), # Hour
($frequncy == $frequencyMonthly) ? '1' : '*', # Day of the Month
'*', # Month of the Year
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', array('id' => $model->getId()));
return;
}
$this->_redirect('*/*/');
}
return;
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('tax')->__('This class no longer exists'));
$this->_redirect('*/*/');
return;
}
}
$this->_title($model->getId() ? $model->getClassName() : $this->__('New Class'));
$data = Mage::getSingleton('adminhtml/session')->getClassData(true);
return $this;
}
public function _initReportAction($blocks)
{
if (!is_array($blocks)) {
public function __construct()
{
parent::_construct();
$this->setModel('adminhtml/report_item');
$this->_resource = Mage::getResourceModel('sales/report')->init('sales/order', 'entity_id');
$this->setConnection($this->getResource()->getReadConnection());
}
/**
* Apply stores filter
*
* @return Mage_Sales_Model_Mysql4_Report_Order_Updatedat_Collection
*/
protected function _applyStoresFilter()
{
$nullCheck = false;
$storeIds = $this->_storesIds;
if (!is_array($storeIds)) {
$storeIds = array($storeIds);
}
$storeIds = array_unique($storeIds);
return $this;
}
protected function _saveAppliedTaxes(Mage_Sales_Model_Quote_Address $address, $applied, $amount, $baseAmount, $rate)
{
$previouslyAppliedTaxes = $address->getAppliedTaxes();
$process = count($previouslyAppliedTaxes);
foreach ($applied as $row) {
if (!isset($previouslyAppliedTaxes[$row['id']])) {
$row['process'] = $process;
$row['amount'] = 0;
$row['base_amount'] = 0;
$previouslyAppliedTaxes[$row['id']] = $row;
}
if (!is_null($row['percent'])) {
$row['percent'] = $row['percent'] ? $row['percent'] : 1;
$rate = $rate ? $rate : 1;
$appliedAmount = $amount/$rate*$row['percent'];
$baseAppliedAmount = $baseAmount/$rate*$row['percent'];
} else {
$appliedAmount = 0;
$baseAppliedAmount = 0;
foreach ($row['rates'] as $rate) {
$appliedAmount += $rate['amount'];
$baseAppliedAmount += $rate['base_amount'];
}
}
$isPriceInclTax = false;
}
if ($item->hasCustomPrice()) {
/**
* Initialize item original price before declaring custom price
*/
$item->getOriginalPrice();
$item->setCustomPrice($price);
$baseTaxPrice = $this->_calculator->round($baseTaxSubtotal/$qty);
if ($taxOnOrigPrice) {
$taxable = $origSubtotal;
$baseTaxable = $baseOrigSubtotal;
} else {
$taxable = $subtotal;
$baseTaxable = $baseSubtotal;
}
$isPriceInclTax = false;
}
if ($item->hasCustomPrice()) {
/**
* Initialize item original price before declaring custom price
*/
$item->getOriginalPrice();
$item->setCustomPrice($price);
$item->setBaseCustomPrice($basePrice);
} else {
$item->setConvertedPrice($price);
}
$item->setPrice($basePrice);
$item->setBasePrice($basePrice);
$item->setRowTotal($subtotal);
'backend_type' => $attribute->getBackendType()
);
}
$attribute = $this->_attributesCache[$attributeCode];
if (!$this->_select instanceof Zend_Db_Select) {
return false;
}
switch ($type) {
case '=':
$conditionRule = '=?';
break;
case 'in':
$conditionRule = ' IN(?)';
break;
default:
return false;
break;
}
if ($attribute['backend_type'] == 'static') {
$this->_select->where('e.' . $attributeCode . $conditionRule, $value);
}
else {
$this->_select->join(
array('t1_'.$attributeCode => $attribute['table']),
'e.entity_id=t1_'.$attributeCode.'.entity_id AND t1_'.$attributeCode.'.store_id=0',
if (isset($this->_priceBlockTypes[$productTypeId])) {
if ($this->_priceBlockTypes[$productTypeId]['block'] != '') {
$block = $this->_priceBlockTypes[$productTypeId]['block'];
}
}
$this->_priceBlock[$productTypeId] = $this->getLayout()->createBlock($block);
}
return $this->_priceBlock[$productTypeId];
}
protected function _getPriceBlockTemplate($productTypeId)
{
if (isset($this->_priceBlockTypes[$productTypeId])) {
if ($this->_priceBlockTypes[$productTypeId]['template'] != '') {
return $this->_priceBlockTypes[$productTypeId]['template'];
}
}
return $this->_priceBlockDefaultTemplate;
}
/**
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
'feed' => 35,
));
// draw SKU
$lines[0][] = array(
'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
'feed' => 255
);
// draw QTY
$lines[0][] = array(
'text' => $item->getQty()*1,
'feed' => 435
);
// draw Price
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getPrice()),
'feed' => 395,
'font' => 'bold',
'align' => 'right'
);
// draw Tax
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getTaxAmount()),
'feed' => 495,
'font' => 'bold',
'align' => 'right'
);
// draw Subtotal
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getRowTotal()),
'feed' => 565,
'font' => 'bold',
'align' => 'right'
);
// custom options
$options = $this->getItemOptions();
public function draw()
{
$order = $this->getOrder();
$item = $this->getItem();
$pdf = $this->getPdf();
$page = $this->getPage();
$lines = array();
$leftBound = 35;
$rightBound = 565;
$x = $leftBound;
// draw Product name
$lines[0] = array(array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
'feed' => $x,
));
$x += 220;
// draw SKU
$lines[0][] = array(
'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
'feed' => $x
);
$x += 100;
// draw Total (ex)
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getRowTotal()),
'feed' => $x,
'font' => 'bold',
'align' => 'right',
'width' => 50,
);
$x += 50;
// draw Discount
$lines[0][] = array(
'text' => $order->formatPriceTxt(-$item->getDiscountAmount()),
'feed' => $x,
'font' => 'bold',
'align' => 'right',
'width' => 50,
);
$x += 50;
// draw QTY
$lines[0][] = array(
'text' => $item->getQty()*1,
'feed' => $x,
'font' => 'bold',
'align' => 'center',
'width' => 30,
);
$x += 30;
// draw Tax
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getTaxAmount()),
'feed' => $x,
'font' => 'bold',
'align' => 'right',
'width' => 45,
);
$x += 45;
// draw Subtotal
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getRowTotal() + $item->getTaxAmount() - $item->getDiscountAmount()),
$installer->addAttribute('catalog_product', 'samples_title', array(
'type' => 'varchar',
'backend' => '',
'frontend' => '',
'label' => 'Samples title',
'input' => '',
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => false,
'required' => true,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'apply_to' => 'downloadable',
'is_configurable' => false
protected function _processDownload($resource, $resourceType)
{
$helper = Mage::helper('downloadable/download');
/* @var $helper Mage_Downloadable_Helper_Download */
$helper->setResource($resource, $resourceType);
$fileName = $helper->getFilename();
extends Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Default
{
/**
* Reindex all stock status data for configurable products
*
* @return Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Configurable
*/
public function reindexAll()
{
$this->useIdxTable(true);
$this->_prepareIndexTable();
return $this;
}
/**
* Reindex stock data for defined configurable product ids
*
* @param int|array $entityIds
* @return Mage_CatalogInventory_Model_Mysql4_Indexer_Stock_Configurable
*/
public function reindexEntity($entityIds)
{
$this->_updateIndex($entityIds);
return $this;
}
/**
* Get the select object for get stock status by product ids
*
* @param int|array $entityIds
* @param bool $usePrimaryTable use primary or temporary index table
* @return Varien_Db_Select
*/
protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = false)
{
$adapter = $this->_getWriteAdapter();
$idxTable = $usePrimaryTable ? $this->getMainTable() : $this->getIdxTable();
$paResStatus = $this->getAuthenticatePaResStatus();
$eciFlag = $this->getAuthenticateEciFlag();
$xid = $this->getAuthenticateXid();
$cavv = $this->getAuthenticateCavv();
$errorNo = $this->getAuthenticateErrorNo();
$signatureVerification = $this->getAuthenticateSignatureVerification();
class Mage_Centinel_Model_State_Visa extends Mage_Centinel_Model_StateAbstract
{
/**
* Analyse lookup`s results. If lookup is successful return true and false if it failure
* Result depends from flag self::getIsModeStrict()
*
* @return bool
*/
public function isLookupSuccessful()
{
if ($this->_isLookupStrictSuccessful()) {
if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '07' &&
$xid == '' && $cavv == '' && $errorNo == '1050') {
if ($this->getIsModeStrict()) {
return false;
} else {
return true;
}
}
}
//Test cases 6-10
if (!$this->getIsModeStrict() && $this->_isLookupSoftSuccessful()) {
if ($paResStatus == '' && $signatureVerification == '' && $eciFlag == '' &&
$xid == '' && $cavv == '' && $errorNo == '0') {
return true;
}
}
return false;
}
/**
* Analyse lookup`s results. If lookup is strict successful return true
*
* @return bool
*/
private function _isLookupStrictSuccessful()
{
//Test cases 1-5, 11
if ($this->getLookupEnrolled() == 'Y' &&
$this->getLookupAcsUrl() != '' &&
$this->getLookupPayload() != '' &&
$this->getLookupErrorNo() == '0') {
return true;
}
return false;
}
/**
* Analyse lookup`s results. If lookup is soft successful return true
*
* @return bool
*/
private function _isLookupSoftSuccessful()
{
$acsUrl = $this->getLookupAcsUrl();
$payload = $this->getLookupPayload();
public function getChilds($item)
{
$_itemsArray = array();
if ($item instanceof Mage_Sales_Model_Order_Invoice_Item) {
$_items = $item->getInvoice()->getAllItems();
} else if ($item instanceof Mage_Sales_Model_Order_Shipment_Item) {
$_items = $item->getShipment()->getAllItems();
public function isShipmentSeparately($item = null)
{
if ($item) {
if ($item->getOrderItem()) {
$item = $item->getOrderItem();
}
if ($parentItem = $item->getParentItem()) {
if ($options = $parentItem->getProductOptions()) {
if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
return true;
} else {
return false;
}
}
} else {
if ($options = $item->getProductOptions()) {
if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
return false;
} else {
return true;
}
}
}
}
if ($options = $this->getOrderItem()->getProductOptions()) {
if (isset($options['shipment_type']) && $options['shipment_type'] == Mage_Catalog_Model_Product_Type_Abstract::SHIPMENT_SEPARATELY) {
return true;
}
}
return false;
}
public function isChildCalculated($item = null)
{
if ($item) {
if ($item->getOrderItem()) {
$item = $item->getOrderItem();
}
if ($parentItem = $item->getParentItem()) {
if ($options = $parentItem->getProductOptions()) {
if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
return true;
} else {
return false;
}
}
} else {
if ($options = $item->getProductOptions()) {
if (isset($options['product_calculations']) && $options['product_calculations'] == Mage_Catalog_Model_Product_Type_Abstract::CALCULATE_CHILD) {
$prevGroup = $allGroups;
foreach ($prices as $price) {
if ($price['cust_group']!=$custGroup && $price['cust_group']!=$allGroups) {
// tier not for current customer group nor is for all groups
continue;
}
if ($qty < $price['price_qty']) {
// tier is higher than product qty
continue;
}
if ($price['price_qty'] < $prevQty) {
// higher tier qty already found
continue;
}
if ($price['price_qty'] == $prevQty && $prevGroup != $allGroups && $price['cust_group'] == $allGroups) {
// found tier qty is same as current tier qty but current tier group is ALL_GROUPS
continue;
}
if ($price['website_price'] < $prevPrice) {
$prevPrice = $price['website_price'];
$prevQty = $price['price_qty'];
continue;
}
$ccTypes .= '
<item' . ($_typeCode == $_ccType ? ' selected="1"' : '') . '>
<label>' . $_typeName . '</label>
<value>' . $_typeCode . '</value>
</item>';
}
$ccMonthes = '';
$_ccExpMonth = $this->getInfoData('cc_exp_month');
foreach ($this->getCcMonths() as $k => $v){
$itemXml->addChild('qty', $renderer->getQty());
$icon = $renderer->getProductThumbnail()->resize(Mage_XmlConnect_Block_Catalog_Product::PRODUCT_IMAGE_SMALL_RESIZE_PARAM);
$iconXml = $itemXml->addChild('icon', $icon);
$baseUrl = Mage::getBaseUrl('media');
$path = str_replace($baseUrl, '', $icon);
$file = Mage::getBaseDir('media') . DS . str_replace('/', DS, $path);
$iconXml->addAttribute('modification_time', filemtime($file));
/**
* Price
*/
$exclPrice = $inclPrice = 0.00;
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()){
if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()){
$exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount() + $item->getWeeeTaxDisposition();
}
else {
$exclPrice = $item->getCalculationPrice();
}
}
if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()){
$_incl = $this->helper('checkout')->getPriceInclTax($item);
if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()){
$inclPrice = $_incl + $item->getWeeeTaxAppliedAmount();
}
else {
$inclPrice = $_incl - $item->getWeeeTaxDisposition();
}
}
$exclPrice = sprintf('%01.2f', $exclPrice);
$formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
$inclPrice = sprintf('%01.2f', $inclPrice);
$formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
$priceXmlObj = $itemXml->addChild('price');
$formatedPriceXmlObj = $itemXml->addChild('formated_price');
if ($this->helper('tax')->displayCartBothPrices()) {
$priceXmlObj->addAttribute('excluding_tax', $exclPrice);
$priceXmlObj->addAttribute('including_tax', $inclPrice);
$formatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice);
$formatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice);
}
else {
if ($this->helper('tax')->displayCartPriceExclTax()) {
$priceXmlObj->addAttribute('regular', $exclPrice);
$formatedPriceXmlObj->addAttribute('regular', $formatedExclPrice);
}
if ($this->helper('tax')->displayCartPriceInclTax()) {
$priceXmlObj->addAttribute('regular', $inclPrice);
$formatedPriceXmlObj->addAttribute('regular', $formatedInclPrice);
}
}
/**
* Subtotal
*/
$exclPrice = $inclPrice = 0.00;
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()){
if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()){
$exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition();
}
else {
$exclPrice = $item->getRowTotal();
}
}
if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()){
$_incl = $this->helper('checkout')->getSubtotalInclTax($item);
if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()){
$inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount();
}
else {
$inclPrice = $_incl - $item->getWeeeTaxRowDisposition();
}
}
$exclPrice = sprintf('%01.2f', $exclPrice);
$formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
$inclPrice = sprintf('%01.2f', $inclPrice);
$formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
$subtotalPriceXmlObj = $itemXml->addChild('subtotal');
$subtotalFormatedPriceXmlObj = $itemXml->addChild('formated_subtotal');
if ($this->helper('tax')->displayCartBothPrices()) {
$subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice);
$subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice);
$subtotalFormatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice);
Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
'cache',
Mage::app()->getStore()->getId(),
$path[] = $this->getDestinationSubdir()
);
if((!empty($this->_width)) || (!empty($this->_height)))
$path[] = "{$this->_width}x{$this->_height}";
// add misk params as a hash
$miscParams = array(
($this->_keepAspectRatio ? '' : 'non') . 'proportional',
($this->_keepFrame ? '' : 'no') . 'frame',
return parent::_beforeSave($object);
}
/**
* Retrieve alert row by object parameters
*
public function addCustomerFilter($customer)
{
if (is_array($customer)) {
$condition = $this->getConnection()->quoteInto('customer_id IN(?)', $customer);
}
elseif ($customer instanceof Mage_Customer_Model_Customer) {
$condition = $this->getConnection()->quoteInto('customer_id=?', $customer->getId());
}
else {
$condition = $this->getConnection()->quoteInto('customer_id=?', $customer);
->setCustomerOrder();
}
catch (Exception $e) {
$this->_errors[] = $e->getMessage();
return $this;
}
$previousCustomer = null;
$email->setWebsite($website);
foreach ($collection as $alert) {
class Mage_Customer_Model_Attribute_Data_Date extends Mage_Customer_Model_Attribute_Data_Abstract
{
/**
* Extract data from request and return value
*
* @param Zend_Controller_Request_Http $request
* @return array|string
*/
public function extractValue(Zend_Controller_Request_Http $request)
$address->setCustomerId($customer->getId());
$valid = $address->validate();
if (is_array($valid)) {
$this->_fault('data_invalid', implode("\n", $valid));
}
try {
$address->save();
} catch (Mage_Core_Exception $e) {
$this->_fault('data_invalid', $e->getMessage());
}
return $address->getId();
}
/**
* Retrieve address data
*
* @param int $addressId
* @return array
*/
public function info($addressId)
{
$address = Mage::getModel('customer/address')
->load($addressId);
if (!$address->getId()) {
$this->_fault('not_exists');
}
$result = array();
foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) {
$result[$attributeAlias] = $address->getData($attributeCode);
}
foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) {
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'suffix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'email'),
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
$setup = $installer->getConnection();
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/prefix_show')
->where('value!=?', '0');
$showPrefix = (bool)Mage::helper('customer/address')->getConfig('prefix_show')
|| $setup->fetchOne($select) > 0;
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/middlename_show')
->where('value!=?', '0');
$showMiddlename = (bool)Mage::helper('customer/address')->getConfig('middlename_show')
|| $setup->fetchOne($select) > 0;
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/suffix_show')
->where('value!=?', '0');
$showSuffix = (bool)Mage::helper('customer/address')->getConfig('suffix_show')
|| $setup->fetchOne($select) > 0;
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/dob_show')
->where('value!=?', '0');
$showDob = (bool)Mage::helper('customer/address')->getConfig('dob_show')
|| $setup->fetchOne($select) > 0;
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/taxvat_show')
->where('value!=?', '0');
$showTaxVat = (bool)Mage::helper('customer/address')->getConfig('taxvat_show')
|| $setup->fetchOne($select) > 0;
/**
*****************************************************************************
* customer/account/create/
*****************************************************************************
*/
$setup->insert($installer->getTable('eav/form_type'), array(
'code' => 'customer_account_create',
'label' => 'customer_account_create',
'is_system' => 1,
'theme' => '',
'store_id' => 0
));
$formTypeId = $setup->lastInsertId();
$entityTypeId = $installer->getEntityTypeId('customer');
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $entityTypeId
));
$setup->insert($installer->getTable('eav/form_fieldset'), array(
'type_id' => $formTypeId,
'code' => 'general',
'sort_order' => 1
));
$fieldsetId = $setup->lastInsertId();
$setup->insert($installer->getTable('eav/form_fieldset_label'), array(
'fieldset_id' => $fieldsetId,
'store_id' => 0,
'label' => 'Personal Information'
));
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'suffix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'email'),
'sort_order' => $elementSort++
));
if ($showDob) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'dob'),
'sort_order' => $elementSort++
));
}
if ($showTaxVat) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'taxvat'),
'sort_order' => $elementSort++
));
}
/**
*****************************************************************************
* customer/account/edit/
*****************************************************************************
*/
$setup->insert($installer->getTable('eav/form_type'), array(
'code' => 'customer_account_edit',
'label' => 'customer_account_edit',
'is_system' => 1,
'theme' => '',
'store_id' => 0
));
$formTypeId = $setup->lastInsertId();
$entityTypeId = $installer->getEntityTypeId('customer');
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $entityTypeId
));
$setup->insert($installer->getTable('eav/form_fieldset'), array(
'type_id' => $formTypeId,
'code' => 'general',
'sort_order' => 1
));
$fieldsetId = $setup->lastInsertId();
$setup->insert($installer->getTable('eav/form_fieldset_label'), array(
'fieldset_id' => $fieldsetId,
'store_id' => 0,
'label' => 'Account Information'
));
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'suffix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'email'),
'sort_order' => $elementSort++
));
if ($showDob) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'dob'),
'sort_order' => $elementSort++
));
}
if ($showTaxVat) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'taxvat'),
'sort_order' => $elementSort++
));
}
/**
*****************************************************************************
* customer/address/edit
*****************************************************************************
*/
$setup->insert($installer->getTable('eav/form_type'), array(
'code' => 'customer_address_edit',
'label' => 'customer_address_edit',
'is_system' => 1,
'theme' => '',
'store_id' => 0
));
$formTypeId = $setup->lastInsertId();
$entityTypeId = $installer->getEntityTypeId('customer_address');
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $entityTypeId
));
$setup->insert($installer->getTable('eav/form_fieldset'), array(
'type_id' => $formTypeId,
'code' => 'contact',
'sort_order' => 1
));
$fieldsetId = $setup->lastInsertId();
$setup->insert($installer->getTable('eav/form_fieldset_label'), array(
'fieldset_id' => $fieldsetId,
'store_id' => 0,
'label' => 'Contact Information'
));
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'suffix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'company'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'telephone'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'fax'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_fieldset'), array(
'type_id' => $formTypeId,
'code' => 'address',
'sort_order' => 2
));
$fieldsetId = $setup->lastInsertId();
$setup->insert($installer->getTable('eav/form_fieldset_label'), array(
'fieldset_id' => $fieldsetId,
'store_id' => 0,
'label' => 'Address'
));
$elementSort = 0;
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'street'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => $fieldsetId,
'attribute_id' => $installer->getAttributeId($entityTypeId, 'city'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
if ($this->getRequest()->isPost()) {
$customer = $this->_getSession()->getCustomer();
/* @var $address Mage_Customer_Model_Address */
$address = Mage::getModel('customer/address');
$addressId = $this->getRequest()->getParam('id');
if ($addressId) {
$existsAddress = $customer->getAddressById($addressId);
if ($existsAddress->getId() && $existsAddress->getCustomerId() == $customer->getId()) {
$address->setId($existsAddress->getId());
}
}
$errors = array();
/* @var $addressForm Mage_Customer_Model_Form */
$addressForm = Mage::getModel('customer/form');
$addressForm->setFormCode('customer_address_edit')
->setEntity($address);
$addressData = $addressForm->extractData($this->getRequest());
class Mage_Admin_Model_Acl_Role_Registry extends Zend_Acl_Role_Registry
{
/**
* Add parent to the $role node
*
* @param Zend_Acl_Role_Interface|string $role
* @param array|Zend_Acl_Role_Interface|string $parents
* @return Mage_Auth_Model_Acl_Role_Registry
*/
function addParent($role, $parents)
{
try {
if ($role instanceof Zend_Acl_Role_Interface) {
$roleId = $role->getRoleId();
} else {
$regionsToIns = array(
array('RO', 'AB', 'Alba'), array('RO', 'AR', 'Arad'), array('RO', 'AG', 'Argeş'),
array('RO', 'BC', 'Bacău'), array('RO', 'BH', 'Bihor'), array('RO', 'BN', 'Bistriţa-Năsăud'),
array('RO', 'BT', 'Botoşani'), array('RO', 'BV', 'Braşov'), array('RO', 'BR', 'Brăila'),
array('RO', 'B', 'Bucureşti'), array('RO', 'BZ', 'Buzău'), array('RO', 'CS', 'Caraş-Severin'),
array('RO', 'CL', 'Călăraşi'), array('RO', 'CJ', 'Cluj'), array('RO', 'CT', 'Constanţa'),
array('RO', 'CV', 'Covasna'), array('RO', 'DB', 'Dâmboviţa'), array('RO', 'DJ', 'Dolj'),
array('RO', 'GL', 'Galaţi'), array('RO', 'GR', 'Giurgiu'), array('RO', 'GJ', 'Gorj'),
array('RO', 'HR', 'Harghita'), array('RO', 'HD', 'Hunedoara'), array('RO', 'IL', 'Ialomiţa'),
array('RO', 'IS', 'Iaşi'), array('RO', 'IF', 'Ilfov'), array('RO', 'MM', 'Maramureş'),
public function getFormatedOptionValue($optionValue)
{
$optionInfo = array();
// define input data format
if (is_array($optionValue)) {
if (isset($optionValue['option_id'])) {
$optionInfo = $optionValue;
if (isset($optionInfo['value'])) {
$optionValue = $optionInfo['value'];
}
} elseif (isset($optionValue['value'])) {
$optionValue = $optionValue['value'];
}
}
// render customized option view
if (isset($optionInfo['custom_view']) && $optionInfo['custom_view']) {
$_default = array('value' => $optionValue);
if (isset($optionInfo['option_type'])) {
try {
$group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
return array('value' => $group->getCustomizedView($optionInfo));
} catch (Exception $e) {
$installer = $this;
$installer->startSetup();
$setup = $installer->getConnection();
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/prefix_show')
->where('value!=?', '0');
$showPrefix = (bool)Mage::helper('customer/address')->getConfig('prefix_show')
|| $setup->fetchOne($select) > 0;
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/middlename_show')
->where('value!=?', '0');
$showMiddlename = (bool)Mage::helper('customer/address')->getConfig('middlename_show')
|| $setup->fetchOne($select) > 0;
$select = $setup->select()
->from($installer->getTable('core/config_data'), 'COUNT(*)')
->where('path=?', 'customer/address/suffix_show')
->where('value!=?', '0');
$showSuffix = (bool)Mage::helper('customer/address')->getConfig('suffix_show')
|| $setup->fetchOne($select) > 0;
'is_system' => 1,
'theme' => '',
'store_id' => 0
));
$formTypeId = $setup->lastInsertId();
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $customerEntityTypeId
));
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId
));
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'suffix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'company'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($customerEntityTypeId, 'email'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'street'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'city'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'region'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'postcode'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'country_id'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'telephone'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'fax'),
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId
));
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'street'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'city'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'region'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'postcode'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'is_system' => 1,
'theme' => '',
'store_id' => 0
));
$formTypeId = $setup->lastInsertId();
$setup->insert($installer->getTable('eav/form_type_entity'), array(
'type_id' => $formTypeId,
'entity_type_id' => $addressEntityTypeId
));
$elementSort = 0;
if ($showPrefix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'prefix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'firstname'),
'sort_order' => $elementSort++
));
if ($showMiddlename) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'middlename'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'lastname'),
'sort_order' => $elementSort++
));
if ($showSuffix) {
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'suffix'),
'sort_order' => $elementSort++
));
}
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'company'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'street'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'city'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'region'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'postcode'),
'sort_order' => $elementSort++
));
$setup->insert($installer->getTable('eav/form_element'), array(
'type_id' => $formTypeId,
'fieldset_id' => null,
'attribute_id' => $installer->getAttributeId($addressEntityTypeId, 'country_id'),
echo $e;
}
// if ($batch) {
// $batch->delete();
// }
$this->setExceptions($profile->getExceptions());
return $this;
}
public function _parseGuiData()
{
$nl = "\r\n";
$import = $this->getDirection()==='import';
$p = $this->getGuiData();
if ($this->getDataTransfer()==='interactive') {
// $p['file']['type'] = 'file';
// $p['file']['filename'] = $p['interactive']['filename'];
// $p['file']['path'] = 'var/export';
$interactiveXml = '<action type="dataflow/convert_adapter_http" method="'.($import?'load':'save').'">'.$nl;
#$interactiveXml .= ' <var name="filename"><![CDATA['.$p['interactive']['filename'].']]></var>'.$nl;
$interactiveXml .= '</action>';
$fileXml = '';
} else {
$interactiveXml = '';
$parseDataXml .= ' <var name="url_field"><![CDATA['.$p['export']['add_url_field'].']]></var>'.$nl;
}
$parseDataXml .= '</action>'.$nl.$nl;
}
$adapters = array(
$fileXml = '<action type="dataflow/convert_adapter_io" method="'.($import?'load':'save').'">'.$nl;
$fileXml .= ' <var name="type">'.$p['file']['type'].'</var>'.$nl;
$fileXml .= ' <var name="path">'.$p['file']['path'].'</var>'.$nl;
$fileXml .= ' <var name="filename"><![CDATA['.$p['file']['filename'].']]></var>'.$nl;
if ($p['file']['type']==='ftp') {
$hostArr = explode(':', $p['file']['host']);
$mapXml .= '<action type="dataflow/convert_mapper_column" method="map">'.$nl;
$map = $p['map'][$this->getEntityType()];
if (sizeof($map['db'])>0) {
$from = $map[$import?'file':'db'];
$to = $map[$import?'db':'file'];
foreach ($from as $i=>$f) {
$mapXml .= ' <var name="'.$f.'"><![CDATA['.$to[$i].']]></var>'.$nl;
}
}
if ($p['map']['only_specified']) {
$mapXml .= ' <var name="_only_specified">'.$p['map']['only_specified'].'</var>'.$nl;
}
$mapXml .= '</action>'.$nl.$nl;
$parsers = array(
'product'=>'catalog/convert_parser_product',
'customer'=>'customer/convert_parser_customer',
);
if ($import) {
$parseDataXml = '<action type="'.$parsers[$this->getEntityType()].'" method="parse">'.$nl;
$parseDataXml .= ' <var name="store"><![CDATA['.$this->getStoreId().']]></var>'.$nl;
$parseDataXml .= '</action>'.$nl.$nl;
} else {
$parseDataXml = '<action type="'.$parsers[$this->getEntityType()].'" method="unparse">'.$nl;
$parseDataXml .= ' <var name="store"><![CDATA['.$this->getStoreId().']]></var>'.$nl;
$parseDataXml .= '</action>'.$nl.$nl;
}
$adapters = array(
'product'=>'catalog/convert_adapter_product',
'customer'=>'customer/convert_adapter_customer',
);
if ($import) {
$entityXml = '<action type="'.$adapters[$this->getEntityType()].'" method="save">'.$nl;
$entityXml .= ' <var name="store"><![CDATA['.$this->getStoreId().']]></var>'.$nl;
$entityXml .= '</action>'.$nl.$nl;
} else {
$entityXml = '<action type="'.$adapters[$this->getEntityType()].'" method="load">'.$nl;
$entityXml .= ' <var name="store"><![CDATA['.$this->getStoreId().']]></var>'.$nl;
foreach ($p[$this->getEntityType()]['filter'] as $f=>$v) {
if (empty($v)) {
public function skinDirective($construction)
{
$params = $this->_getIncludeParameters($construction[2]);
$params['_absolute'] = $this->_useAbsoluteLinks;
$url = Mage::getDesign()->getSkinUrl($params['url'], $params);
return $url;
}
/**
* Retrieve media file URL directive
*
* @param array $construction
* @return string
* @see Mage_Core_Model_Email_Template_Filter::mediaDirective() method has been copypasted
*/
public function mediaDirective($construction)
{
$params = $this->_getIncludeParameters($construction[2]);
return Mage::getBaseUrl('media') . $params['url'];
}
/**
* Retrieve store URL directive
* Support url and direct_url properties
*
* @param array $construction
* @return string
* @see Mage_Core_Model_Email_Template_Filter::storeDirective() method has been copypasted
*/
public function storeDirective($construction)
{
$params = $this->_getIncludeParameters($construction[2]);
if (!isset($params['_query'])) {
$params['_query'] = array();
public function authorize(Varien_Object $payment, $amount)
{
return $this->_placeOrder($payment, $amount);
}
/**
* Void payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @return Mage_Paypal_Model_Method_Agreement
*/
public function void(Varien_Object $payment)
{
$this->_pro->void($payment);
return $this;
}
/**
* Capture payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return Mage_Paypal_Model_Method_Agreement
*/
public function capture(Varien_Object $payment, $amount)
{
if (false === $this->_pro->capture($payment, $amount)) {
$this->_placeOrder($payment, $amount);
}
return $this;
}
/**
* Refund capture
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return Mage_Paypal_Model_Method_Agreement
*/
public function refund(Varien_Object $payment, $amount)
{
$this->_pro->refund($payment, $amount);
return $this;
}
/**
* Cancel payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @return Mage_Paypal_Model_Method_Agreement
public function __construct($params = array())
{
$proInstance = array_shift($params);
if ($proInstance && ($proInstance instanceof Mage_Paypal_Model_Pro)) {
$this->_pro = $proInstance;
} else {
$this->_pro = Mage::getModel($this->_proType);
}
$this->_pro->setMethod($this->_code);
public function authorize(Varien_Object $payment, $amount)
{
return $this->_placeOrder($payment, $amount);
}
/**
* Void payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @return Mage_Paypal_Model_Method_Agreement
*/
public function void(Varien_Object $payment)
{
$this->_pro->void($payment);
return $this;
}
/**
* Capture payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return Mage_Paypal_Model_Method_Agreement
*/
public function capture(Varien_Object $payment, $amount)
{
if (false === $this->_pro->capture($payment, $amount)) {
$this->_placeOrder($payment, $amount);
}
return $this;
}
/**
* Refund capture
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return Mage_Paypal_Model_Method_Agreement
*/
public function refund(Varien_Object $payment, $amount)
{
$this->_pro->refund($payment, $amount);
return $this;
}
/**
* Cancel payment
*
* @param Mage_Sales_Model_Order_Payment $payment
* @return Mage_Paypal_Model_Method_Agreement