Cu ajutorul lui Daniel am activat CNP-ul. Iata indicatiile lui:
SQL
UPDATE `eav_attribute`, `eav_entity_type` SET `eav_attribute`.`is_visible`=1 WHERE `eav_attribute`.`attribute_code`="pfpj_cnp" AND (`eav_entity_type`.`entity_type_code`="customer_address" OR `eav_entity_type`.`entity_type_code`="order_address") AND `eav_attribute`.`entity_type_id`=`eav_entity_type`.`entity_type_id`;
app/code/community/PfpjRom/CustomerRom/etc/config.xml (atasat)
linia 134:
<pfpj_cnp> <legality> <show>1</show> <required>1</required> </legality> <!-- Daca CNP trebuie sa apara la ambele optiuni: <natural> <show>1</show> <required>1</required> </natural> --> </pfpj_cnp>
161:
{{if pfpj_tip_pers == 2}}Cod Numeric Personal (CNP): {{var pfpj_cnp}}{{/if}}
190:
{{if pfpj_tip_pers == 2}}Cod Numeric Personal (CNP): {{var pfpj_cnp}}{{/if}}<br />
211:
{{if pfpj_tip_pers == 2}}Cod Numeric Personal (CNP): {{var pfpj_cnp}}|{{/if}}
Nota
Copiati app/code/community/PfpjRom/CustomerRom/etc/config.xml pe app/code/local/PfpjRom/CustomerRom/etc/config.xml sa nu-l modificati la fiecare update (local “suprascrie” restul, inclusiv core).
sorry for posting in English here, but the Pfpjrom extension is the only one I could find for handling different types of customers with different data sets. and only here I could find a related discussion
My question is whether it’s possible to add more customer types (like educational institutions)? I’ve tried in the config,
Warning: constant() [function.constant]: Couldn’t find constant PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers::EDUCATIONAL in /var/www/test.webshop/app/code/community/PfpjRom/CustomerRom/Model/Address/Config.php on line 98
I understand you want to add a third option, if not just rename an old one.
Yes first thing you should declare in that class `PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers` another constant named `EDUCATIONAL` with a value = 3 is ok.
You should modify PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers, especially method:
Before it gets more complex you should try yo add the third option in database.
Field named `pfpj_tip_pers` is a combination of radio inputs (in Magento uses renderer lib/Varien/Data/Form/Element/Radios.php - actually CustomerRom/Block/Address/Renderer/Tippers.php). What i’m trying to say, options have almost same implementation as dropdown fields.
In table `eav_attribute_option` and `eav_attribute_option_value` add the third option. To do this first you need `attribute_id` from table `eav_attribute`:
SELECT * FROM `eav_attribute` WHERE `attribute_code` LIKE 'pfpj_tip_pers'
`entity_id` == 2 is for customer address entity and `entity_id` == 12 is for order address entity (because customer address is quoted in order at checkout time).
Now check on frontend at MyAccount -> Edit Address if you got the third option.
If didn’t worked look in CustomerRom/sql/customerrom_setup/mysql4-install-0.1.0.php and SalesRom/sql/salesrom_setup/mysql4-install-0.1.0.php.
Next, i think you will need your own fields instead of `pfpj_cui`, `pfpj_reg_com`, `pfpj_banca`, `pfpj_iban`, `pfpj_cnp` and `pfpj_serienr_buletin`. You also could rename the labels to reuse a part of them. To add a new field in database just duplicate, for example, `pfpj_cui` in `eav_attribute` table ( don’t forget to put your own attribute_code). The fields above are input text fields. To add other types you should study yourself to have more insight on Magento’s EAV attribute implementation. But for now just keep it simple.
In CustomerRom/etc/config.xml declare also which fields should apear on a selected option:
<educational> <show>1</show> <!-- show(==1) the field when Educational Insititution is selected --> <required>1</required> <!-- required 1 or 0(if not)--> </educational> </company>
<!-- an example of possible new field:---> <pfpj_school> <natural> <show>0</show> <!-- show is 0 anyway by default --> </natural>
<legality> <!-- not mandatory if show is 0 --> <show>0</show> </legality>
b) the 4 <formats> - The address is formated for text/html/pdf/online pices of strings; you can see one of them at checkout on the progress sidebar. For this feature only, you should edit the columns of table `sales_flat_quote_address`. There are already pfpjrom columns added.
2. SalesRom/etc/config.xml:
a) Modify <global> <fieldsets> part, depending on your fields.
3. check again all config.xml for pfpj_ fields, i might missed here something.
Before seeing some results, you still to add/modify in templates the html for your input fields.
First look through app/frontend/yourpachage/yourtheme/template/customerrom/address/edit.phtml.
Test it, see if it saves and loads addresses correctly.
Than modify app/frontend/yourpachage/yourtheme/template/checkoutrom/checkoutrom/onepage/billing.phtml and shipping.phtml templates.
Admin should go smoothly. All javascripts used by this extension should work well too, becouse it implements some degree of generalisation.
Post your progress if you got stuck.
Let me know if it worked.
PS: this post should work with the version 0.1.4 of the extension. Future releases will implement custom behaviour that depends of billing and shipping on MyAccount -> Edit Address page. Also it will have some configuration in admin for fields.
Pentru ca am fost intrebat cum se dezinstaleaza extensia:
Dupa ce ati dat uninstall din ‘magento connect’, raman totusi niste inregistrari in baza de date.
Query de uninstall:
DELETE * FROM `eav_attribute` WHERE `attribute_code` LIKE 'pfpj_%';
ALTER TABLE `sales_flat_quote_address` DROP `pfpj_tip_pers`, DROP `pfpj_cui`, DROP `pfpj_reg_com`, DROP `pfpj_banca`, DROP `pfpj_iban`, DROP `pfpj_cnp`, DROP `pfpj_serienr_buletin`, DROP `pfpj_for_billing`, DROP `pfpj_for_shipping`;
Engine-ul la db este InnoDb,
asa ca vor fi sterse si celelalte inregistrari din tabele relationate cu foreign key (folosite de extensie).
In caz ca extensia a instalat si judetele Romaniei si se vor si ele a fi sterse,
puteti gasi inregistrarile in tabelele:
In caz ca va razganditi si doriti sa reinstalati pe viitor extensia:
DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'checkoutrom_setup' LIMIT 1; DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'customerrom_setup' LIMIT 1; DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'directoryrom_setup' LIMIT 1; DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'romanianregions_setup' LIMIT 1; DELETE FROM `core_resource` WHERE `core_resource`.`code` = 'salesrom_setup' LIMIT 1;
Toate modulele sunt pastrate in `core_resource` impreuna cu versiunea lor.Se pastreaza un fel de versioning la versiunea deja instalata odata. Asa nu apar inregistrari duplicate in tabele la reinstall.
Toate insert-urile de la instalarea extensiei sunt generate in app/code/community/PfpjRom/NumeModulRom/sql/.../mysql4-install(sau upgrade)-*.php
Tin sa mentionez ca extensia functioneaza bine pe Magento 1.3.2.4 (ultima versiune de 1.3.x).