Cheat Sheet [abc] A single character of: a, b or c [^abc] Any single character except: a, b, or c [a-z] Any single character in the range a-z [a-zA-Z] Any single character in the range a-z or A-Z ^ Start of line $ End of line \A Start of string \z End of string . Any single character \s Any whitespace character \S Any non-whitespace character \d Any digit \D Any non-digit \w Any word character (letter, number, underscore) \W Any non-word character \b Any word boundary (...) Capture everything enclosed (a|b) a or b a? Zero or one of a a* Zero or more of a a+ One or more of a a{3} Exactly 3 of a a{3,} 3 or more of a a{3,6} Between 3 and 6 of a Options i case insensitive m treat as multi-line string s dot matches newline x ignore whitespace in regex A matches only at the start of string D matches only at the end of string U non-greedy matching by default
Search
Aug 26, 2015
Regex in string php
http://www.phpliveregex.com/
Aug 18, 2015
Set type customer ( group_id ) from register form in Magento
Step 1: Go to admin -> System -> Config (default) -> Customer Config -> Create new account options (tab) -> Enable Automatic Assignment to Customer Group ( Set = No ) -> Save
Step 2: Edit file ../../Customer/controllers/AccountController.php (from Core file or Module file)
Step 3: Create register form with name="group_id"
Step 2: Edit file ../../Customer/controllers/AccountController.php (from Core file or Module file)
public function createPostAction() { ..... $customer = $this->_getCustomer(); // Start Mod if ($this->getRequest()->getPost('group_id')){ $customer->setGroupId(intval($this->getRequest()->getPost('group_id'))); } else $customer->getGroupId(); // End Mod ...... $customer->save(); ...... }
Step 3: Create register form with name="group_id"
<div class="form-group"> <label class="radio-inline" for="group_id"> <input type="radio" name="group_id" value="3">Retailer</label> <label class="radio-inline" for="group_id"> <input type="radio" name="group_id" value="4">Designer</label> <label class="radio-inline" for="group_id"> <input type="radio" name="group_id" value="5">Hospitality</label> </div>
Aug 11, 2015
Create custom attribute in magento
Lưu ý: tên biến không được có số
app/local/customerAttribute/sql/custom_setup/mysql4-install-0.1.0.php
$installer->addAttribute("customer", "fix_state_issued_by", array( "type" => "varchar", "backend" => "", "label" => "State Issued By", "input" => "text", "source" => "", "visible" => true, "required" => false, "default" => "", "frontend" => "", "unique" => false, "note" => "" )); $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "fix_state_issued_by"); $used_in_forms=array(); $used_in_forms[]="adminhtml_customer"; $used_in_forms[]="checkout_register"; $used_in_forms[]="customer_account_create"; $used_in_forms[]="customer_account_edit"; $used_in_forms[]="adminhtml_checkout"; $attribute->setData("used_in_forms", $used_in_forms) ->setData("is_used_for_customer_segment", true) ->setData("is_system", 0) ->setData("is_user_defined", 1) ->setData("is_visible", 1) ->setData("sort_order", 100) ; $attribute->save(); $installer->addAttribute("customer", "fix_resale_expired", array( "type" => "datetime", "backend" => "eav/entity_attribute_backend_datetime", "label" => "Expiration Date", "input" => "date", "source" => "", "visible" => true, "required" => false, "default" => "", "frontend" => "", "unique" => false, "note" => "" )); $attribute = Mage::getSingleton("eav/config")->getAttribute("customer", "fix_resale_expired"); $used_in_forms=array(); $used_in_forms[]="adminhtml_customer"; $used_in_forms[]="checkout_register"; $used_in_forms[]="customer_account_create"; $used_in_forms[]="customer_account_edit"; $used_in_forms[]="adminhtml_checkout"; $attribute->setData("used_in_forms", $used_in_forms) ->setData("is_used_for_customer_segment", true) ->setData("is_system", 0) ->setData("is_user_defined", 1) ->setData("is_visible", 1) ->setData("sort_order", 100) ; $attribute->save();
Aug 10, 2015
Get Custom Attribute in Magento
<?php $_product= Mage::getSingleton('catalog/product')->load($_item->getProductId()); echo $_product->getResource()->getAttribute('attributeCode')->getFrontend()->getValue($_product); $product->getData("attributeCode"); $product->getAttributeText("attributeCode"); ?>
Aug 4, 2015
Config magento server apache2
<VirtualHost *:80> ServerAdmin admin@your-domain.com DocumentRoot /var/www/html/madegoods/ ServerName bluepheasant.com ServerAlias www.bluepheasant.com <Directory /var/www/html/madegoods/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/madegoods.com-error_log CustomLog /var/log/apache2/madegoods.com-access_log common </VirtualHost>
Subscribe to:
Posts (Atom)